Rewrite download manager unit to be actual unit tests.
Note that this isn't intended to be complete coverage; it's an attempt to preserve coverage from the old tests while making these "real" unit tests, i.e. with every class except for the main one being tested mocked. Thorough unit tests are intended for the future after we're more completely done with refactoring.
BUG=107264
BUG=105200
BUG=110886
Review URL: https://chromiumcodereview.appspot.com/10344024
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@141674 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/content/browser/browser_context.cc b/content/browser/browser_context.cc
index 17e60d96..522ccd1 100644
--- a/content/browser/browser_context.cc
+++ b/content/browser/browser_context.cc
@@ -6,9 +6,11 @@
#include "content/browser/appcache/chrome_appcache_service.h"
#include "content/browser/dom_storage/dom_storage_context_impl.h"
+#include "content/browser/download/download_file_manager.h"
#include "content/browser/download/download_manager_impl.h"
#include "content/browser/fileapi/browser_file_system_helper.h"
#include "content/browser/in_process_webkit/indexed_db_context_impl.h"
+#include "content/browser/renderer_host/resource_dispatcher_host_impl.h"
#include "content/browser/resource_context_impl.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/content_browser_client.h"
@@ -75,7 +77,7 @@
context->GetPath(), context->IsOffTheRecord(),
context->GetSpecialStoragePolicy(), quota_manager->proxy(),
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE));
- context->SetUserData(kDatabaseTrackerKeyName,
+ context->SetUserData(kDatabaseTrackerKeyName,
new UserDataAdapter<DatabaseTracker>(db_tracker));
FilePath path = context->IsOffTheRecord() ? FilePath() : context->GetPath();
@@ -142,8 +144,16 @@
DownloadManager* BrowserContext::GetDownloadManager(
BrowserContext* context) {
if (!context->GetUserData(kDownloadManagerKeyName)) {
- scoped_refptr<DownloadManager> download_manager = new DownloadManagerImpl(
- GetContentClient()->browser()->GetNetLog());
+ ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get();
+ DCHECK(rdh);
+ DownloadFileManager* file_manager = rdh->download_file_manager();
+ DCHECK(file_manager);
+ scoped_refptr<DownloadManager> download_manager =
+ new DownloadManagerImpl(
+ file_manager,
+ scoped_ptr<DownloadItemFactory>(),
+ GetContentClient()->browser()->GetNetLog());
+
context->SetUserData(
kDownloadManagerKeyName,
new UserDataAdapter<DownloadManager>(download_manager));