Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: content/browser/download/download_net_log_parameters.h

Issue 10542153: NetLogEventParameter to Callback refactoring 11. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Response to comments Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_NET_LOG_PARAMETERS_H_ 5 #ifndef CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_NET_LOG_PARAMETERS_H_
6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_NET_LOG_PARAMETERS_H_ 6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_NET_LOG_PARAMETERS_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "content/public/browser/download_item.h" 11 #include "content/public/browser/download_item.h"
12 #include "net/base/net_errors.h" 12 #include "net/base/net_errors.h"
13 #include "net/base/net_log.h" 13 #include "net/base/net_log.h"
14 14
15 class FilePath;
16 class GURL;
17
15 namespace download_net_logs { 18 namespace download_net_logs {
16 19
17 enum DownloadType { 20 enum DownloadType {
18 SRC_NEW_DOWNLOAD, 21 SRC_NEW_DOWNLOAD,
19 SRC_HISTORY_IMPORT, 22 SRC_HISTORY_IMPORT,
20 SRC_SAVE_PAGE_AS 23 SRC_SAVE_PAGE_AS
21 }; 24 };
22 25
23 // NetLog parameters when a DownloadItem is activated. 26 // Returns NetLog parameters when a DownloadItem is activated.
24 class ItemActivatedParameters : public net::NetLog::EventParameters { 27 base::Value* ItemActivatedCallback(
25 public: 28 const content::DownloadItem* download_item,
26 ItemActivatedParameters(DownloadType download_type, 29 DownloadType download_type,
27 int64 id, 30 const std::string* file_name,
28 const std::string& original_url, 31 net::NetLog::LogLevel log_level);
29 const std::string& final_url,
30 const std::string& file_name,
31 content::DownloadDangerType danger_type,
32 content::DownloadItem::SafetyState safety_state,
33 int64 start_offset);
34 virtual base::Value* ToValue() const OVERRIDE;
35 32
36 protected: 33 // Returns NetLog parameters when a DownloadItem is checked for danger.
37 virtual ~ItemActivatedParameters(); 34 base::Value* ItemCheckedCallback(
35 content::DownloadDangerType danger_type,
36 content::DownloadItem::SafetyState safety_state,
37 net::NetLog::LogLevel log_level);
38 38
39 private: 39 // Returns NetLog parameters when a DownloadItem is renamed.
40 const DownloadType type_; 40 base::Value* ItemRenamedCallback(const FilePath* old_filename,
41 const int64 id_; 41 const FilePath* new_filename,
42 const std::string original_url_; 42 net::NetLog::LogLevel log_level);
43 const std::string final_url_;
44 const std::string file_name_;
45 const content::DownloadDangerType danger_type_;
46 const content::DownloadItem::SafetyState safety_state_;
47 const int64 start_offset_;
48 43
49 DISALLOW_COPY_AND_ASSIGN(ItemActivatedParameters); 44 // Returns NetLog parameters when a DownloadItem is interrupted.
50 }; 45 base::Value* ItemInterruptedCallback(content::DownloadInterruptReason reason,
46 int64 bytes_so_far,
47 const std::string* hash_state,
48 net::NetLog::LogLevel log_level);
51 49
52 // NetLog parameters when a DownloadItem is checked for danger. 50 // Returns NetLog parameters when a DownloadItem is finished.
53 class ItemCheckedParameters : public net::NetLog::EventParameters { 51 base::Value* ItemFinishedCallback(int64 bytes_so_far,
54 public: 52 const std::string* final_hash,
55 ItemCheckedParameters(content::DownloadDangerType danger_type, 53 net::NetLog::LogLevel log_level);
56 content::DownloadItem::SafetyState safety_state);
57 virtual base::Value* ToValue() const OVERRIDE;
58 54
59 protected: 55 // Returns NetLog parameters when a DownloadItem is canceled.
60 virtual ~ItemCheckedParameters(); 56 base::Value* ItemCanceledCallback(int64 bytes_so_far,
57 const std::string* hash_state,
58 net::NetLog::LogLevel log_level);
61 59
62 private: 60 // Returns NetLog parameters when a DownloadFile is opened.
63 const content::DownloadDangerType danger_type_; 61 base::Value* FileOpenedCallback(const FilePath* file_name,
64 const content::DownloadItem::SafetyState safety_state_; 62 int64 start_offset,
63 net::NetLog::LogLevel log_level);
65 64
66 DISALLOW_COPY_AND_ASSIGN(ItemCheckedParameters); 65 // Returns NetLog parameters when a DownloadFile is opened.
67 }; 66 base::Value* FileStreamDrainedCallback(size_t stream_size,
67 size_t num_buffers,
68 net::NetLog::LogLevel log_level);
68 69
69 // NetLog parameters when a DownloadItem is added to the history database. 70 // Returns NetLog parameters when a DownloadFile is renamed.
70 class ItemInHistoryParameters : public net::NetLog::EventParameters { 71 base::Value* FileRenamedCallback(const FilePath* old_filename,
71 public: 72 const FilePath* new_filename,
72 ItemInHistoryParameters(int64 handle); 73 net::NetLog::LogLevel log_level);
73 virtual base::Value* ToValue() const OVERRIDE;
74 74
75 protected: 75 // Returns NetLog parameters when a File has an error.
76 virtual ~ItemInHistoryParameters(); 76 base::Value* FileErrorCallback(const char* operation,
77 77 net::Error net_error,
78 private: 78 net::NetLog::LogLevel log_level);
79 const int64 db_handle_;
80
81 DISALLOW_COPY_AND_ASSIGN(ItemInHistoryParameters);
82 };
83
84 // NetLog parameters when a DownloadItem is updated.
85 class ItemUpdatedParameters : public net::NetLog::EventParameters {
86 public:
87 ItemUpdatedParameters(int64 bytes_so_far);
88 virtual base::Value* ToValue() const OVERRIDE;
89
90 protected:
91 virtual ~ItemUpdatedParameters();
92
93 private:
94 const int64 bytes_so_far_;
95
96 DISALLOW_COPY_AND_ASSIGN(ItemUpdatedParameters);
97 };
98
99 // NetLog parameters when a DownloadItem is renamed.
100 class ItemRenamedParameters : public net::NetLog::EventParameters {
101 public:
102 ItemRenamedParameters(
103 const std::string& old_filename, const std::string& new_filename);
104 virtual base::Value* ToValue() const OVERRIDE;
105
106 protected:
107 virtual ~ItemRenamedParameters();
108
109 private:
110 const std::string old_filename_;
111 const std::string new_filename_;
112
113 DISALLOW_COPY_AND_ASSIGN(ItemRenamedParameters);
114 };
115
116 // NetLog parameters when a DownloadItem is interrupted.
117 class ItemInterruptedParameters : public net::NetLog::EventParameters {
118 public:
119 ItemInterruptedParameters(content::DownloadInterruptReason reason,
120 int64 bytes_so_far,
121 const std::string& hash_state);
122 virtual base::Value* ToValue() const OVERRIDE;
123
124 protected:
125 virtual ~ItemInterruptedParameters();
126
127 private:
128 const content::DownloadInterruptReason reason_;
129 const int64 bytes_so_far_;
130 const std::string hash_state_;
131
132 DISALLOW_COPY_AND_ASSIGN(ItemInterruptedParameters);
133 };
134
135 // NetLog parameters when a DownloadItem is finished.
136 class ItemFinishedParameters : public net::NetLog::EventParameters {
137 public:
138 ItemFinishedParameters(int64 bytes_so_far, const std::string& final_hash);
139 virtual base::Value* ToValue() const OVERRIDE;
140
141 protected:
142 virtual ~ItemFinishedParameters();
143
144 private:
145 const int64 bytes_so_far_;
146 const std::string final_hash_;
147
148 DISALLOW_COPY_AND_ASSIGN(ItemFinishedParameters);
149 };
150
151 // NetLog parameters when a DownloadItem is canceled.
152 class ItemCanceledParameters : public net::NetLog::EventParameters {
153 public:
154 ItemCanceledParameters(int64 bytes_so_far, const std::string& hash_state);
155 virtual base::Value* ToValue() const OVERRIDE;
156
157 protected:
158 virtual ~ItemCanceledParameters();
159
160 private:
161 const int64 bytes_so_far_;
162 const std::string hash_state_;
163
164 DISALLOW_COPY_AND_ASSIGN(ItemCanceledParameters);
165 };
166
167 // NetLog parameters when a DownloadFile is opened.
168 class FileOpenedParameters : public net::NetLog::EventParameters {
169 public:
170 FileOpenedParameters(const std::string& file_name,
171 int64 start_offset);
172 virtual base::Value* ToValue() const OVERRIDE;
173
174 protected:
175 virtual ~FileOpenedParameters();
176
177 private:
178 const std::string file_name_;
179 const int64 start_offset_;
180
181 DISALLOW_COPY_AND_ASSIGN(FileOpenedParameters);
182 };
183
184 // NetLog parameters when a DownloadFile is opened.
185 class FileStreamDrainedParameters : public net::NetLog::EventParameters {
186 public:
187 FileStreamDrainedParameters(size_t stream_size,
188 size_t num_buffers);
189 virtual base::Value* ToValue() const OVERRIDE;
190
191 protected:
192 virtual ~FileStreamDrainedParameters();
193
194 private:
195 const size_t stream_size_;
196 const size_t num_buffers_;
197
198 DISALLOW_COPY_AND_ASSIGN(FileStreamDrainedParameters);
199 };
200
201 // NetLog parameters when a DownloadFile is renamed.
202 class FileRenamedParameters : public net::NetLog::EventParameters {
203 public:
204 FileRenamedParameters(
205 const std::string& old_filename, const std::string& new_filename);
206 virtual base::Value* ToValue() const OVERRIDE;
207
208 protected:
209 virtual ~FileRenamedParameters();
210
211 private:
212 const std::string old_filename_;
213 const std::string new_filename_;
214
215 DISALLOW_COPY_AND_ASSIGN(FileRenamedParameters);
216 };
217
218 // NetLog parameters when a File has an error.
219 class FileErrorParameters : public net::NetLog::EventParameters {
220 public:
221 FileErrorParameters(const std::string& operation, net::Error net_error);
222 virtual base::Value* ToValue() const OVERRIDE;
223
224 protected:
225 virtual ~FileErrorParameters();
226
227 private:
228 const std::string operation_;
229 const net::Error net_error_;
230
231 DISALLOW_COPY_AND_ASSIGN(FileErrorParameters);
232 };
233 79
234 } // namespace download_net_logs 80 } // namespace download_net_logs
235 81
236 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_NET_LOG_PARAMETERS_H_ 82 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_NET_LOG_PARAMETERS_H_
OLDNEW
« no previous file with comments | « content/browser/download/download_item_impl.cc ('k') | content/browser/download/download_net_log_parameters.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698