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

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

Issue 1544293002: Convert Pass()→std::move() in //content (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 <vector> 8 #include <vector>
8 9
9 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
10 #include "base/logging.h" 11 #include "base/logging.h"
11 #include "content/browser/download/download_file_factory.h" 12 #include "content/browser/download/download_file_factory.h"
12 #include "content/browser/download/download_file_impl.h" 13 #include "content/browser/download/download_file_impl.h"
13 #include "content/browser/download/download_interrupt_reasons_impl.h" 14 #include "content/browser/download/download_interrupt_reasons_impl.h"
14 #include "content/browser/download/download_manager_impl.h" 15 #include "content/browser/download/download_manager_impl.h"
15 #include "content/browser/loader/resource_dispatcher_host_impl.h" 16 #include "content/browser/loader/resource_dispatcher_host_impl.h"
16 #include "content/public/browser/browser_thread.h" 17 #include "content/public/browser/browser_thread.h"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 const base::FilePath& default_download_directory, 105 const base::FilePath& default_download_directory,
105 const GURL& url, 106 const GURL& url,
106 const GURL& referrer_url, 107 const GURL& referrer_url,
107 bool calculate_hash, 108 bool calculate_hash,
108 scoped_ptr<ByteStreamReader> stream, 109 scoped_ptr<ByteStreamReader> stream,
109 const net::BoundNetLog& bound_net_log, 110 const net::BoundNetLog& bound_net_log,
110 base::WeakPtr<DownloadDestinationObserver> observer, 111 base::WeakPtr<DownloadDestinationObserver> observer,
111 const TestFileErrorInjector::FileErrorInfo& error_info, 112 const TestFileErrorInjector::FileErrorInfo& error_info,
112 const ConstructionCallback& ctor_callback, 113 const ConstructionCallback& ctor_callback,
113 const DestructionCallback& dtor_callback) 114 const DestructionCallback& dtor_callback)
114 : DownloadFileImpl( 115 : DownloadFileImpl(std::move(save_info),
115 save_info.Pass(), default_download_directory, url, referrer_url, 116 default_download_directory,
116 calculate_hash, stream.Pass(), bound_net_log, observer), 117 url,
117 source_url_(url), 118 referrer_url,
118 error_info_(error_info), 119 calculate_hash,
119 destruction_callback_(dtor_callback) { 120 std::move(stream),
121 bound_net_log,
122 observer),
123 source_url_(url),
124 error_info_(error_info),
125 destruction_callback_(dtor_callback) {
120 // DownloadFiles are created on the UI thread and are destroyed on the FILE 126 // DownloadFiles are created on the UI thread and are destroyed on the FILE
121 // thread. Schedule the ConstructionCallback on the FILE thread so that if a 127 // thread. Schedule the ConstructionCallback on the FILE thread so that if a
122 // DownloadItem schedules a DownloadFile to be destroyed and creates another 128 // DownloadItem schedules a DownloadFile to be destroyed and creates another
123 // one (as happens during download resumption), then the DestructionCallback 129 // one (as happens during download resumption), then the DestructionCallback
124 // for the old DownloadFile is run before the ConstructionCallback for the 130 // for the old DownloadFile is run before the ConstructionCallback for the
125 // next DownloadFile. 131 // next DownloadFile.
126 BrowserThread::PostTask( 132 BrowserThread::PostTask(
127 BrowserThread::FILE, 133 BrowserThread::FILE,
128 FROM_HERE, 134 FROM_HERE,
129 base::Bind(ctor_callback, source_url_)); 135 base::Bind(ctor_callback, source_url_));
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 TestFileErrorInjector::FileErrorInfo err_info = { 309 TestFileErrorInjector::FileErrorInfo err_info = {
304 url.spec(), 310 url.spec(),
305 TestFileErrorInjector::FILE_OPERATION_INITIALIZE, 311 TestFileErrorInjector::FILE_OPERATION_INITIALIZE,
306 -1, 312 -1,
307 DOWNLOAD_INTERRUPT_REASON_NONE 313 DOWNLOAD_INTERRUPT_REASON_NONE
308 }; 314 };
309 injected_errors_[url.spec()] = err_info; 315 injected_errors_[url.spec()] = err_info;
310 } 316 }
311 317
312 return new DownloadFileWithErrors( 318 return new DownloadFileWithErrors(
313 save_info.Pass(), 319 std::move(save_info), default_download_directory, url, referrer_url,
314 default_download_directory, 320 calculate_hash, std::move(stream), bound_net_log, observer,
315 url, 321 injected_errors_[url.spec()], construction_callback_,
316 referrer_url,
317 calculate_hash,
318 stream.Pass(),
319 bound_net_log,
320 observer,
321 injected_errors_[url.spec()],
322 construction_callback_,
323 destruction_callback_); 322 destruction_callback_);
324 } 323 }
325 324
326 bool DownloadFileWithErrorsFactory::AddError( 325 bool DownloadFileWithErrorsFactory::AddError(
327 const TestFileErrorInjector::FileErrorInfo& error_info) { 326 const TestFileErrorInjector::FileErrorInfo& error_info) {
328 // Creates an empty entry if necessary. Duplicate entries overwrite. 327 // Creates an empty entry if necessary. Duplicate entries overwrite.
329 injected_errors_[error_info.url] = error_info; 328 injected_errors_[error_info.url] = error_info;
330 329
331 return true; 330 return true;
332 } 331 }
(...skipping 14 matching lines...) Expand all
347 base::Bind(&TestFileErrorInjector::RecordDownloadFileConstruction, 346 base::Bind(&TestFileErrorInjector::RecordDownloadFileConstruction,
348 this), 347 this),
349 base::Bind(&TestFileErrorInjector::RecordDownloadFileDestruction, 348 base::Bind(&TestFileErrorInjector::RecordDownloadFileDestruction,
350 this)); 349 this));
351 350
352 // We will transfer ownership of the factory to the download manager. 351 // We will transfer ownership of the factory to the download manager.
353 scoped_ptr<DownloadFileFactory> download_file_factory( 352 scoped_ptr<DownloadFileFactory> download_file_factory(
354 created_factory_); 353 created_factory_);
355 354
356 download_manager_->SetDownloadFileFactoryForTesting( 355 download_manager_->SetDownloadFileFactoryForTesting(
357 download_file_factory.Pass()); 356 std::move(download_file_factory));
358 } 357 }
359 358
360 TestFileErrorInjector::~TestFileErrorInjector() { 359 TestFileErrorInjector::~TestFileErrorInjector() {
361 } 360 }
362 361
363 bool TestFileErrorInjector::AddError(const FileErrorInfo& error_info) { 362 bool TestFileErrorInjector::AddError(const FileErrorInfo& error_info) {
364 DCHECK_CURRENTLY_ON(BrowserThread::UI); 363 DCHECK_CURRENTLY_ON(BrowserThread::UI);
365 DCHECK_LE(0, error_info.operation_instance); 364 DCHECK_LE(0, error_info.operation_instance);
366 DCHECK(injected_errors_.find(error_info.url) == injected_errors_.end()); 365 DCHECK(injected_errors_.find(error_info.url) == injected_errors_.end());
367 366
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 case FILE_OPERATION_RENAME_ANNOTATE: 465 case FILE_OPERATION_RENAME_ANNOTATE:
467 return "RENAME_ANNOTATE"; 466 return "RENAME_ANNOTATE";
468 default: 467 default:
469 break; 468 break;
470 } 469 }
471 470
472 return "Unknown"; 471 return "Unknown";
473 } 472 }
474 473
475 } // namespace content 474 } // namespace content
OLDNEW
« no previous file with comments | « content/public/test/test_download_request_handler.cc ('k') | content/public/test/test_file_system_backend.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698