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

Unified Diff: content/browser/browser_context.cc

Issue 10535026: Move creation and ownership of DownloadManager from the embedder to content. This matches all the o… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix cros compile Created 8 years, 6 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
Index: content/browser/browser_context.cc
===================================================================
--- content/browser/browser_context.cc (revision 140592)
+++ content/browser/browser_context.cc (working copy)
@@ -6,10 +6,12 @@
#include "content/browser/appcache/chrome_appcache_service.h"
#include "content/browser/dom_storage/dom_storage_context_impl.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/resource_context_impl.h"
#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/content_browser_client.h"
#include "content/public/common/content_constants.h"
#include "net/base/server_bound_cert_service.h"
#include "net/base/server_bound_cert_store.h"
@@ -30,6 +32,7 @@
static const char* kAppCacheServicKeyName = "content_appcache_service_tracker";
static const char* kDatabaseTrackerKeyName = "content_database_tracker";
static const char* kDOMStorageContextKeyName = "content_dom_storage_context";
+static const char* kDownloadManagerKeyName = "download_manager";
static const char* kFileSystemContextKeyName = "content_file_system_context";
static const char* kIndexedDBContextKeyName = "content_indexed_db_context";
static const char* kQuotaManagerKeyName = "content_quota_manager";
@@ -136,6 +139,22 @@
} // namespace
+DownloadManager* BrowserContext::GetDownloadManager(
+ BrowserContext* context) {
+ if(!context->GetUserData(kDownloadManagerKeyName)) {
Avi (use Gerrit) 2012/06/06 14:49:45 style nit: space between if (
+ scoped_refptr<DownloadManager> download_manager = new DownloadManagerImpl(
+ GetContentClient()->browser()->GetNetLog());
+ context->SetUserData(
+ kDownloadManagerKeyName,
+ new UserDataAdapter<DownloadManager>(download_manager));
+ download_manager->SetDelegate(context->GetDownloadManagerDelegate());
+ download_manager->Init(context);
+ }
+
+ return UserDataAdapter<DownloadManager>::Get(
+ context, kDownloadManagerKeyName);
+}
+
QuotaManager* BrowserContext::GetQuotaManager(BrowserContext* context) {
CreateQuotaManagerAndClients(context);
return UserDataAdapter<QuotaManager>::Get(context, kQuotaManagerKeyName);
@@ -229,6 +248,9 @@
if (GetUserData(kDOMStorageContextKeyName))
GetDOMStorageContextImpl(this)->Shutdown();
+
+ if (GetUserData(kDownloadManagerKeyName))
+ GetDownloadManager(this)->Shutdown();
}
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698