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

Unified Diff: content/public/test/test_file_error_injector.cc

Issue 11028131: Shift passage of FileStream in downloads system to be by scoped_ptr<>. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Incorporated Al's comments. Created 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/public/browser/resource_dispatcher_host.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/test/test_file_error_injector.cc
diff --git a/content/public/test/test_file_error_injector.cc b/content/public/test/test_file_error_injector.cc
index dd53d14c6a83f1d1ce1994d18c49979bff682684..eabbbd72b3e8ed9016c17513d36b236313b45d81 100644
--- a/content/public/test/test_file_error_injector.cc
+++ b/content/public/test/test_file_error_injector.cc
@@ -39,12 +39,14 @@ class DownloadFileWithErrors: public DownloadFileImpl {
typedef base::Callback<void(const GURL& url)> DestructionCallback;
DownloadFileWithErrors(
- const DownloadCreateInfo* info,
+ scoped_ptr<DownloadCreateInfo> info,
scoped_ptr<content::ByteStreamReader> stream,
- DownloadRequestHandleInterface* request_handle,
+ scoped_ptr<DownloadRequestHandleInterface> request_handle,
content::DownloadManager* download_manager,
bool calculate_hash,
const net::BoundNetLog& bound_net_log,
+ content::DownloadId download_id,
+ const GURL& source_url,
const content::TestFileErrorInjector::FileErrorInfo& error_info,
const ConstructionCallback& ctor_callback,
const DestructionCallback& dtor_callback);
@@ -102,26 +104,28 @@ static void RenameErrorCallback(
DownloadFileWithErrors::DownloadFileWithErrors(
- const DownloadCreateInfo* info,
+ scoped_ptr<DownloadCreateInfo> info,
scoped_ptr<content::ByteStreamReader> stream,
- DownloadRequestHandleInterface* request_handle,
+ scoped_ptr<DownloadRequestHandleInterface> request_handle,
content::DownloadManager* download_manager,
bool calculate_hash,
const net::BoundNetLog& bound_net_log,
+ content::DownloadId download_id,
+ const GURL& source_url,
const content::TestFileErrorInjector::FileErrorInfo& error_info,
const ConstructionCallback& ctor_callback,
const DestructionCallback& dtor_callback)
- : DownloadFileImpl(info,
- stream.Pass(),
- request_handle,
- download_manager,
- calculate_hash,
- scoped_ptr<content::PowerSaveBlocker>(NULL).Pass(),
- bound_net_log),
- source_url_(info->url()),
- error_info_(error_info),
- destruction_callback_(dtor_callback) {
- ctor_callback.Run(source_url_, info->download_id);
+ : DownloadFileImpl(info.Pass(),
+ stream.Pass(),
+ request_handle.Pass(),
+ download_manager,
+ calculate_hash,
+ scoped_ptr<content::PowerSaveBlocker>(),
+ bound_net_log),
+ source_url_(source_url),
+ error_info_(error_info),
+ destruction_callback_(dtor_callback) {
+ ctor_callback.Run(source_url_, download_id);
}
DownloadFileWithErrors::~DownloadFileWithErrors() {
@@ -198,7 +202,7 @@ class DownloadFileWithErrorsFactory : public content::DownloadFileFactory {
// DownloadFileFactory interface.
virtual DownloadFile* CreateFile(
- DownloadCreateInfo* info,
+ scoped_ptr<DownloadCreateInfo> info,
scoped_ptr<content::ByteStreamReader> stream,
content::DownloadManager* download_manager,
bool calculate_hash,
@@ -229,32 +233,38 @@ DownloadFileWithErrorsFactory::~DownloadFileWithErrorsFactory() {
}
content::DownloadFile* DownloadFileWithErrorsFactory::CreateFile(
- DownloadCreateInfo* info,
+ scoped_ptr<DownloadCreateInfo> info,
scoped_ptr<content::ByteStreamReader> stream,
content::DownloadManager* download_manager,
bool calculate_hash,
const net::BoundNetLog& bound_net_log) {
- std::string url = info->url().spec();
+ GURL url = info->url();
- if (injected_errors_.find(url) == injected_errors_.end()) {
+ if (injected_errors_.find(url.spec()) == injected_errors_.end()) {
// Have to create entry, because FileErrorInfo is not a POD type.
TestFileErrorInjector::FileErrorInfo err_info = {
- url,
+ url.spec(),
TestFileErrorInjector::FILE_OPERATION_INITIALIZE,
-1,
content::DOWNLOAD_INTERRUPT_REASON_NONE
};
- injected_errors_[url] = err_info;
+ injected_errors_[url.spec()] = err_info;
}
+ scoped_ptr<DownloadRequestHandleInterface> request_handle(
+ new DownloadRequestHandle(info->request_handle));
+ DownloadId download_id(info->download_id);
+
return new DownloadFileWithErrors(
- info,
+ info.Pass(),
stream.Pass(),
- new DownloadRequestHandle(info->request_handle),
+ request_handle.Pass(),
download_manager,
calculate_hash,
bound_net_log,
- injected_errors_[url],
+ download_id,
+ url,
+ injected_errors_[url.spec()],
construction_callback_,
destruction_callback_);
}
« no previous file with comments | « content/public/browser/resource_dispatcher_host.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698