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( | |
| 143 BrowserContext* context) { | |
| 144 if(!context->GetUserData(kDownloadManagerKeyName)) { | |
|
Avi (use Gerrit)
2012/06/06 14:49:45
style nit: space between if (
| |
| 145 scoped_refptr<DownloadManager> download_manager = new DownloadManagerImpl( | |
| 146 GetContentClient()->browser()->GetNetLog()); | |
| 147 context->SetUserData( | |
| 148 kDownloadManagerKeyName, | |
| 149 new UserDataAdapter<DownloadManager>(download_manager)); | |
| 150 download_manager->SetDelegate(context->GetDownloadManagerDelegate()); | |
| 151 download_manager->Init(context); | |
| 152 } | |
| 153 | |
| 154 return UserDataAdapter<DownloadManager>::Get( | |
| 155 context, kDownloadManagerKeyName); | |
| 156 } | |
| 157 | |
| 139 QuotaManager* BrowserContext::GetQuotaManager(BrowserContext* context) { | 158 QuotaManager* BrowserContext::GetQuotaManager(BrowserContext* context) { |
| 140 CreateQuotaManagerAndClients(context); | 159 CreateQuotaManagerAndClients(context); |
| 141 return UserDataAdapter<QuotaManager>::Get(context, kQuotaManagerKeyName); | 160 return UserDataAdapter<QuotaManager>::Get(context, kQuotaManagerKeyName); |
| 142 } | 161 } |
| 143 | 162 |
| 144 DOMStorageContext* BrowserContext::GetDOMStorageContext( | 163 DOMStorageContext* BrowserContext::GetDOMStorageContext( |
| 145 BrowserContext* context) { | 164 BrowserContext* context) { |
| 146 CreateQuotaManagerAndClients(context); | 165 CreateQuotaManagerAndClients(context); |
| 147 return UserDataAdapter<DOMStorageContextImpl>::Get( | 166 return UserDataAdapter<DOMStorageContextImpl>::Get( |
| 148 context, kDOMStorageContextKeyName); | 167 context, kDOMStorageContextKeyName); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 222 if (GetUserData(kDatabaseTrackerKeyName) && | 241 if (GetUserData(kDatabaseTrackerKeyName) && |
| 223 BrowserThread::IsMessageLoopValid(BrowserThread::FILE)) { | 242 BrowserThread::IsMessageLoopValid(BrowserThread::FILE)) { |
| 224 BrowserThread::PostTask( | 243 BrowserThread::PostTask( |
| 225 BrowserThread::FILE, FROM_HERE, | 244 BrowserThread::FILE, FROM_HERE, |
| 226 base::Bind(&webkit_database::DatabaseTracker::Shutdown, | 245 base::Bind(&webkit_database::DatabaseTracker::Shutdown, |
| 227 GetDatabaseTracker(this))); | 246 GetDatabaseTracker(this))); |
| 228 } | 247 } |
| 229 | 248 |
| 230 if (GetUserData(kDOMStorageContextKeyName)) | 249 if (GetUserData(kDOMStorageContextKeyName)) |
| 231 GetDOMStorageContextImpl(this)->Shutdown(); | 250 GetDOMStorageContextImpl(this)->Shutdown(); |
| 251 | |
| 252 if (GetUserData(kDownloadManagerKeyName)) | |
| 253 GetDownloadManager(this)->Shutdown(); | |
| 232 } | 254 } |
| 233 | 255 |
| 234 } // namespace content | 256 } // namespace content |
| OLD | NEW |