Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/browser/browser_context.h" | 5 #include "content/public/browser/browser_context.h" |
| 6 | 6 |
| 7 #include "content/browser/appcache/chrome_appcache_service.h" | 7 #include "content/browser/appcache/chrome_appcache_service.h" |
| 8 #include "content/browser/dom_storage/dom_storage_context_impl.h" | 8 #include "content/browser/dom_storage/dom_storage_context_impl.h" |
| 9 #include "content/browser/download/download_manager_impl.h" | |
| 9 #include "content/browser/fileapi/browser_file_system_helper.h" | 10 #include "content/browser/fileapi/browser_file_system_helper.h" |
| 10 #include "content/browser/in_process_webkit/indexed_db_context_impl.h" | 11 #include "content/browser/in_process_webkit/indexed_db_context_impl.h" |
| 11 #include "content/browser/resource_context_impl.h" | 12 #include "content/browser/resource_context_impl.h" |
| 12 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
| 14 #include "content/public/browser/content_browser_client.h" | |
| 13 #include "content/public/common/content_constants.h" | 15 #include "content/public/common/content_constants.h" |
| 14 #include "net/base/server_bound_cert_service.h" | 16 #include "net/base/server_bound_cert_service.h" |
| 15 #include "net/base/server_bound_cert_store.h" | 17 #include "net/base/server_bound_cert_store.h" |
| 16 #include "net/cookies/cookie_monster.h" | 18 #include "net/cookies/cookie_monster.h" |
| 17 #include "net/cookies/cookie_store.h" | 19 #include "net/cookies/cookie_store.h" |
| 18 #include "net/url_request/url_request_context.h" | 20 #include "net/url_request/url_request_context.h" |
| 19 #include "webkit/database/database_tracker.h" | 21 #include "webkit/database/database_tracker.h" |
| 20 #include "webkit/quota/quota_manager.h" | 22 #include "webkit/quota/quota_manager.h" |
| 21 | 23 |
| 22 using appcache::AppCacheService; | 24 using appcache::AppCacheService; |
| 23 using base::UserDataAdapter; | 25 using base::UserDataAdapter; |
| 24 using content::BrowserThread; | 26 using content::BrowserThread; |
| 25 using fileapi::FileSystemContext; | 27 using fileapi::FileSystemContext; |
| 26 using quota::QuotaManager; | 28 using quota::QuotaManager; |
| 27 using webkit_database::DatabaseTracker; | 29 using webkit_database::DatabaseTracker; |
| 28 | 30 |
| 29 // Key names on BrowserContext. | 31 // Key names on BrowserContext. |
| 30 static const char* kAppCacheServicKeyName = "content_appcache_service_tracker"; | 32 static const char* kAppCacheServicKeyName = "content_appcache_service_tracker"; |
| 31 static const char* kDatabaseTrackerKeyName = "content_database_tracker"; | 33 static const char* kDatabaseTrackerKeyName = "content_database_tracker"; |
| 32 static const char* kDOMStorageContextKeyName = "content_dom_storage_context"; | 34 static const char* kDOMStorageContextKeyName = "content_dom_storage_context"; |
| 35 static const char* kDownloadManagerKeyName = "download_manager"; | |
| 33 static const char* kFileSystemContextKeyName = "content_file_system_context"; | 36 static const char* kFileSystemContextKeyName = "content_file_system_context"; |
| 34 static const char* kIndexedDBContextKeyName = "content_indexed_db_context"; | 37 static const char* kIndexedDBContextKeyName = "content_indexed_db_context"; |
| 35 static const char* kQuotaManagerKeyName = "content_quota_manager"; | 38 static const char* kQuotaManagerKeyName = "content_quota_manager"; |
| 36 | 39 |
| 37 namespace content { | 40 namespace content { |
| 38 | 41 |
| 39 namespace { | 42 namespace { |
| 40 | 43 |
| 41 void CreateQuotaManagerAndClients(BrowserContext* context) { | 44 void CreateQuotaManagerAndClients(BrowserContext* context) { |
| 42 if (context->GetUserData(kQuotaManagerKeyName)) { | 45 if (context->GetUserData(kQuotaManagerKeyName)) { |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 129 ResourceContext::GetAppCacheService(resource_context)->PurgeMemory(); | 132 ResourceContext::GetAppCacheService(resource_context)->PurgeMemory(); |
| 130 } | 133 } |
| 131 | 134 |
| 132 DOMStorageContextImpl* GetDOMStorageContextImpl(BrowserContext* context) { | 135 DOMStorageContextImpl* GetDOMStorageContextImpl(BrowserContext* context) { |
| 133 return static_cast<DOMStorageContextImpl*>( | 136 return static_cast<DOMStorageContextImpl*>( |
| 134 BrowserContext::GetDOMStorageContext(context)); | 137 BrowserContext::GetDOMStorageContext(context)); |
| 135 } | 138 } |
| 136 | 139 |
| 137 } // namespace | 140 } // namespace |
| 138 | 141 |
| 142 DownloadManager* BrowserContext::GetDownloadManager( | |
|
Avi (use Gerrit)
2012/06/05 23:34:41
This DCHECKs if you call it more than once? Don't
jam
2012/06/05 23:47:16
I hadn't tested it yet (was parallelizing review+t
| |
| 143 BrowserContext* context) { | |
| 144 DCHECK(!context->GetUserData(kDownloadManagerKeyName)); | |
| 145 scoped_refptr<DownloadManager> download_manager = new DownloadManagerImpl( | |
| 146 GetContentClient()->browser()->GetNetLog()); | |
| 147 download_manager->Init(context); | |
| 148 context->SetUserData(kDownloadManagerKeyName, | |
| 149 new UserDataAdapter<DownloadManager>(download_manager)); | |
| 150 return download_manager; | |
| 151 } | |
| 152 | |
| 139 QuotaManager* BrowserContext::GetQuotaManager(BrowserContext* context) { | 153 QuotaManager* BrowserContext::GetQuotaManager(BrowserContext* context) { |
| 140 CreateQuotaManagerAndClients(context); | 154 CreateQuotaManagerAndClients(context); |
| 141 return UserDataAdapter<QuotaManager>::Get(context, kQuotaManagerKeyName); | 155 return UserDataAdapter<QuotaManager>::Get(context, kQuotaManagerKeyName); |
| 142 } | 156 } |
| 143 | 157 |
| 144 DOMStorageContext* BrowserContext::GetDOMStorageContext( | 158 DOMStorageContext* BrowserContext::GetDOMStorageContext( |
| 145 BrowserContext* context) { | 159 BrowserContext* context) { |
| 146 CreateQuotaManagerAndClients(context); | 160 CreateQuotaManagerAndClients(context); |
| 147 return UserDataAdapter<DOMStorageContextImpl>::Get( | 161 return UserDataAdapter<DOMStorageContextImpl>::Get( |
| 148 context, kDOMStorageContextKeyName); | 162 context, kDOMStorageContextKeyName); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 225 BrowserThread::FILE, FROM_HERE, | 239 BrowserThread::FILE, FROM_HERE, |
| 226 base::Bind(&webkit_database::DatabaseTracker::Shutdown, | 240 base::Bind(&webkit_database::DatabaseTracker::Shutdown, |
| 227 GetDatabaseTracker(this))); | 241 GetDatabaseTracker(this))); |
| 228 } | 242 } |
| 229 | 243 |
| 230 if (GetUserData(kDOMStorageContextKeyName)) | 244 if (GetUserData(kDOMStorageContextKeyName)) |
| 231 GetDOMStorageContextImpl(this)->Shutdown(); | 245 GetDOMStorageContextImpl(this)->Shutdown(); |
| 232 } | 246 } |
| 233 | 247 |
| 234 } // namespace content | 248 } // namespace content |
| OLD | NEW |