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

Side by Side Diff: content/public/test/test_file_error_injector.cc

Issue 2351513002: net: rename BoundNetLog to NetLogWithSource (Closed)
Patch Set: one more fix, content bound_net_log_ Created 4 years, 2 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
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 #include "content/public/test/test_file_error_injector.h" 5 #include "content/public/test/test_file_error_injector.h"
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 11 matching lines...) Expand all
22 class ByteStreamReader; 22 class ByteStreamReader;
23 23
24 namespace { 24 namespace {
25 25
26 // A class that performs file operations and injects errors. 26 // A class that performs file operations and injects errors.
27 class DownloadFileWithError: public DownloadFileImpl { 27 class DownloadFileWithError: public DownloadFileImpl {
28 public: 28 public:
29 DownloadFileWithError(std::unique_ptr<DownloadSaveInfo> save_info, 29 DownloadFileWithError(std::unique_ptr<DownloadSaveInfo> save_info,
30 const base::FilePath& default_download_directory, 30 const base::FilePath& default_download_directory,
31 std::unique_ptr<ByteStreamReader> byte_stream, 31 std::unique_ptr<ByteStreamReader> byte_stream,
32 const net::BoundNetLog& bound_net_log, 32 const net::NetLogWithSource& net_log,
33 base::WeakPtr<DownloadDestinationObserver> observer, 33 base::WeakPtr<DownloadDestinationObserver> observer,
34 const TestFileErrorInjector::FileErrorInfo& error_info, 34 const TestFileErrorInjector::FileErrorInfo& error_info,
35 const base::Closure& ctor_callback, 35 const base::Closure& ctor_callback,
36 const base::Closure& dtor_callback); 36 const base::Closure& dtor_callback);
37 37
38 ~DownloadFileWithError() override; 38 ~DownloadFileWithError() override;
39 39
40 void Initialize(const InitializeCallback& callback) override; 40 void Initialize(const InitializeCallback& callback) override;
41 41
42 // DownloadFile interface. 42 // DownloadFile interface.
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 original_callback.Run( 91 original_callback.Run(
92 overwrite_error, 92 overwrite_error,
93 overwrite_error == DOWNLOAD_INTERRUPT_REASON_NONE ? 93 overwrite_error == DOWNLOAD_INTERRUPT_REASON_NONE ?
94 path_result : base::FilePath()); 94 path_result : base::FilePath());
95 } 95 }
96 96
97 DownloadFileWithError::DownloadFileWithError( 97 DownloadFileWithError::DownloadFileWithError(
98 std::unique_ptr<DownloadSaveInfo> save_info, 98 std::unique_ptr<DownloadSaveInfo> save_info,
99 const base::FilePath& default_download_directory, 99 const base::FilePath& default_download_directory,
100 std::unique_ptr<ByteStreamReader> byte_stream, 100 std::unique_ptr<ByteStreamReader> byte_stream,
101 const net::BoundNetLog& bound_net_log, 101 const net::NetLogWithSource& net_log,
102 base::WeakPtr<DownloadDestinationObserver> observer, 102 base::WeakPtr<DownloadDestinationObserver> observer,
103 const TestFileErrorInjector::FileErrorInfo& error_info, 103 const TestFileErrorInjector::FileErrorInfo& error_info,
104 const base::Closure& ctor_callback, 104 const base::Closure& ctor_callback,
105 const base::Closure& dtor_callback) 105 const base::Closure& dtor_callback)
106 : DownloadFileImpl(std::move(save_info), 106 : DownloadFileImpl(std::move(save_info),
107 default_download_directory, 107 default_download_directory,
108 std::move(byte_stream), 108 std::move(byte_stream),
109 bound_net_log, 109 net_log,
110 observer), 110 observer),
111 error_info_(error_info), 111 error_info_(error_info),
112 destruction_callback_(dtor_callback) { 112 destruction_callback_(dtor_callback) {
113 // DownloadFiles are created on the UI thread and are destroyed on the FILE 113 // DownloadFiles are created on the UI thread and are destroyed on the FILE
114 // thread. Schedule the ConstructionCallback on the FILE thread so that if a 114 // thread. Schedule the ConstructionCallback on the FILE thread so that if a
115 // DownloadItem schedules a DownloadFile to be destroyed and creates another 115 // DownloadItem schedules a DownloadFile to be destroyed and creates another
116 // one (as happens during download resumption), then the DestructionCallback 116 // one (as happens during download resumption), then the DestructionCallback
117 // for the old DownloadFile is run before the ConstructionCallback for the 117 // for the old DownloadFile is run before the ConstructionCallback for the
118 // next DownloadFile. 118 // next DownloadFile.
119 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, ctor_callback); 119 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, ctor_callback);
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 public: 245 public:
246 DownloadFileWithErrorFactory(const base::Closure& ctor_callback, 246 DownloadFileWithErrorFactory(const base::Closure& ctor_callback,
247 const base::Closure& dtor_callback); 247 const base::Closure& dtor_callback);
248 ~DownloadFileWithErrorFactory() override; 248 ~DownloadFileWithErrorFactory() override;
249 249
250 // DownloadFileFactory interface. 250 // DownloadFileFactory interface.
251 DownloadFile* CreateFile( 251 DownloadFile* CreateFile(
252 std::unique_ptr<DownloadSaveInfo> save_info, 252 std::unique_ptr<DownloadSaveInfo> save_info,
253 const base::FilePath& default_download_directory, 253 const base::FilePath& default_download_directory,
254 std::unique_ptr<ByteStreamReader> byte_stream, 254 std::unique_ptr<ByteStreamReader> byte_stream,
255 const net::BoundNetLog& bound_net_log, 255 const net::NetLogWithSource& net_log,
256 base::WeakPtr<DownloadDestinationObserver> observer) override; 256 base::WeakPtr<DownloadDestinationObserver> observer) override;
257 257
258 bool SetError(TestFileErrorInjector::FileErrorInfo error); 258 bool SetError(TestFileErrorInjector::FileErrorInfo error);
259 259
260 private: 260 private:
261 // Our injected error. 261 // Our injected error.
262 TestFileErrorInjector::FileErrorInfo injected_error_; 262 TestFileErrorInjector::FileErrorInfo injected_error_;
263 263
264 // Callback for creation and destruction. 264 // Callback for creation and destruction.
265 base::Closure construction_callback_; 265 base::Closure construction_callback_;
266 base::Closure destruction_callback_; 266 base::Closure destruction_callback_;
267 }; 267 };
268 268
269 DownloadFileWithErrorFactory::DownloadFileWithErrorFactory( 269 DownloadFileWithErrorFactory::DownloadFileWithErrorFactory(
270 const base::Closure& ctor_callback, 270 const base::Closure& ctor_callback,
271 const base::Closure& dtor_callback) 271 const base::Closure& dtor_callback)
272 : construction_callback_(ctor_callback), 272 : construction_callback_(ctor_callback),
273 destruction_callback_(dtor_callback) { 273 destruction_callback_(dtor_callback) {
274 injected_error_.code = TestFileErrorInjector::FILE_OPERATION_INITIALIZE; 274 injected_error_.code = TestFileErrorInjector::FILE_OPERATION_INITIALIZE;
275 injected_error_.error = DOWNLOAD_INTERRUPT_REASON_NONE; 275 injected_error_.error = DOWNLOAD_INTERRUPT_REASON_NONE;
276 injected_error_.operation_instance = -1; 276 injected_error_.operation_instance = -1;
277 } 277 }
278 278
279 DownloadFileWithErrorFactory::~DownloadFileWithErrorFactory() {} 279 DownloadFileWithErrorFactory::~DownloadFileWithErrorFactory() {}
280 280
281 DownloadFile* DownloadFileWithErrorFactory::CreateFile( 281 DownloadFile* DownloadFileWithErrorFactory::CreateFile(
282 std::unique_ptr<DownloadSaveInfo> save_info, 282 std::unique_ptr<DownloadSaveInfo> save_info,
283 const base::FilePath& default_download_directory, 283 const base::FilePath& default_download_directory,
284 std::unique_ptr<ByteStreamReader> byte_stream, 284 std::unique_ptr<ByteStreamReader> byte_stream,
285 const net::BoundNetLog& bound_net_log, 285 const net::NetLogWithSource& net_log,
286 base::WeakPtr<DownloadDestinationObserver> observer) { 286 base::WeakPtr<DownloadDestinationObserver> observer) {
287 return new DownloadFileWithError(std::move(save_info), 287 return new DownloadFileWithError(std::move(save_info),
288 default_download_directory, 288 default_download_directory,
289 std::move(byte_stream), 289 std::move(byte_stream),
290 bound_net_log, 290 net_log,
291 observer, 291 observer,
292 injected_error_, 292 injected_error_,
293 construction_callback_, 293 construction_callback_,
294 destruction_callback_); 294 destruction_callback_);
295 } 295 }
296 296
297 bool DownloadFileWithErrorFactory::SetError( 297 bool DownloadFileWithErrorFactory::SetError(
298 TestFileErrorInjector::FileErrorInfo error) { 298 TestFileErrorInjector::FileErrorInfo error) {
299 injected_error_ = std::move(error); 299 injected_error_ = std::move(error);
300 return true; 300 return true;
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 case FILE_OPERATION_RENAME_ANNOTATE: 399 case FILE_OPERATION_RENAME_ANNOTATE:
400 return "RENAME_ANNOTATE"; 400 return "RENAME_ANNOTATE";
401 default: 401 default:
402 break; 402 break;
403 } 403 }
404 404
405 return "Unknown"; 405 return "Unknown";
406 } 406 }
407 407
408 } // namespace content 408 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698