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

Unified Diff: content/browser/download/download_file_manager.cc

Issue 8770024: Added a download file factory to the download file manager, for testing. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Merged with trunk Created 9 years 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
Index: content/browser/download/download_file_manager.cc
diff --git a/content/browser/download/download_file_manager.cc b/content/browser/download/download_file_manager.cc
index 0a5f5e964ae664342d0333c816ddeebdd391cd73..e9794b76568e5f7c53a73f22f8a4c649f7f20a4a 100644
--- a/content/browser/download/download_file_manager.cc
+++ b/content/browser/download/download_file_manager.cc
@@ -34,10 +34,32 @@ namespace {
// cause it to become unresponsive (in milliseconds).
const int kUpdatePeriodMs = 500;
+class DownloadFileFactoryImpl
+ : public DownloadFileManager::DownloadFileFactory {
+ public:
+ DownloadFileFactoryImpl() {}
+
+ virtual DownloadFile* CreateFile(DownloadCreateInfo* info,
+ const DownloadRequestHandle& request_handle,
+ DownloadManager* download_manager) OVERRIDE;
+};
+
+DownloadFile* DownloadFileFactoryImpl::CreateFile(
+ DownloadCreateInfo* info,
+ const DownloadRequestHandle& request_handle,
+ DownloadManager* download_manager) {
+ return new DownloadFileImpl(info,
+ new DownloadRequestHandle(request_handle),
+ download_manager);
+}
+
} // namespace
-DownloadFileManager::DownloadFileManager(ResourceDispatcherHost* rdh)
- : resource_dispatcher_host_(rdh) {
+DownloadFileManager::DownloadFileManager(ResourceDispatcherHost* rdh,
+ DownloadFileFactory* factory)
+ : resource_dispatcher_host_(rdh), download_file_factory_(factory) {
+ if (download_file_factory_ == NULL)
+ download_file_factory_.reset(new DownloadFileFactoryImpl);
}
DownloadFileManager::~DownloadFileManager() {
@@ -67,10 +89,8 @@ void DownloadFileManager::CreateDownloadFile(
// Life of |info| ends here. No more references to it after this method.
scoped_ptr<DownloadCreateInfo> infop(info);
- scoped_ptr<DownloadFile> download_file(
- new DownloadFileImpl(info,
- new DownloadRequestHandle(request_handle),
- download_manager));
+ scoped_ptr<DownloadFile> download_file(download_file_factory_->CreateFile(
+ info, request_handle, download_manager));
if (net::OK != download_file->Initialize(get_hash)) {
request_handle.CancelRequest();
return;

Powered by Google App Engine
This is Rietveld 408576698