1// Copyright (c) 2012 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_NET_LOG_PARAMETERS_H_
6#define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_NET_LOG_PARAMETERS_H_
7
8#include <string>
9
10#include "content/public/browser/download_item.h"
11#include "net/base/net_errors.h"
12#include "net/base/net_log.h"
13
14class GURL;
15
16namespace base {
17class FilePath;
18}
19
20namespace content {
21
22enum DownloadType {
23  SRC_ACTIVE_DOWNLOAD,
24  SRC_HISTORY_IMPORT,
25  SRC_SAVE_PAGE_AS
26};
27
28// Returns NetLog parameters when a DownloadItem is activated.
29base::Value* ItemActivatedNetLogCallback(
30    const DownloadItem* download_item,
31    DownloadType download_type,
32    const std::string* file_name,
33    net::NetLog::LogLevel log_level);
34
35// Returns NetLog parameters when a DownloadItem is checked for danger.
36base::Value* ItemCheckedNetLogCallback(
37    DownloadDangerType danger_type,
38    net::NetLog::LogLevel log_level);
39
40// Returns NetLog parameters when a DownloadItem is renamed.
41base::Value* ItemRenamedNetLogCallback(const base::FilePath* old_filename,
42                                       const base::FilePath* new_filename,
43                                       net::NetLog::LogLevel log_level);
44
45// Returns NetLog parameters when a DownloadItem is interrupted.
46base::Value* ItemInterruptedNetLogCallback(DownloadInterruptReason reason,
47                                           int64 bytes_so_far,
48                                           const std::string* hash_state,
49                                           net::NetLog::LogLevel log_level);
50
51// Returns NetLog parameters when a DownloadItem is resumed.
52base::Value* ItemResumingNetLogCallback(bool user_initiated,
53                                        DownloadInterruptReason reason,
54                                        int64 bytes_so_far,
55                                        const std::string* hash_state,
56                                        net::NetLog::LogLevel log_level);
57
58// Returns NetLog parameters when a DownloadItem is completing.
59base::Value* ItemCompletingNetLogCallback(int64 bytes_so_far,
60                                          const std::string* final_hash,
61                                          net::NetLog::LogLevel log_level);
62
63// Returns NetLog parameters when a DownloadItem is finished.
64base::Value* ItemFinishedNetLogCallback(bool auto_opened,
65                                        net::NetLog::LogLevel log_level);
66
67// Returns NetLog parameters when a DownloadItem is canceled.
68base::Value* ItemCanceledNetLogCallback(int64 bytes_so_far,
69                                        const std::string* hash_state,
70                                        net::NetLog::LogLevel log_level);
71
72// Returns NetLog parameters when a DownloadFile is opened.
73base::Value* FileOpenedNetLogCallback(const base::FilePath* file_name,
74                                      int64 start_offset,
75                                      net::NetLog::LogLevel log_level);
76
77// Returns NetLog parameters when a DownloadFile is opened.
78base::Value* FileStreamDrainedNetLogCallback(size_t stream_size,
79                                             size_t num_buffers,
80                                             net::NetLog::LogLevel log_level);
81
82// Returns NetLog parameters when a DownloadFile is renamed.
83base::Value* FileRenamedNetLogCallback(const base::FilePath* old_filename,
84                                       const base::FilePath* new_filename,
85                                       net::NetLog::LogLevel log_level);
86
87// Returns NetLog parameters when a File has an error.
88base::Value* FileErrorNetLogCallback(const char* operation,
89                                     net::Error net_error,
90                                     net::NetLog::LogLevel log_level);
91
92// Returns NetLog parameters for a download interruption.
93base::Value* FileInterruptedNetLogCallback(const char* operation,
94                                           int os_error,
95                                           DownloadInterruptReason reason,
96                                           net::NetLog::LogLevel log_level);
97
98}  // namespace content
99
100#endif  // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_NET_LOG_PARAMETERS_H_
101