| 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 #if !defined(OS_IOS) |
| 7 #include "content/browser/appcache/chrome_appcache_service.h" | 8 #include "content/browser/appcache/chrome_appcache_service.h" |
| 8 #include "webkit/database/database_tracker.h" | 9 #include "webkit/database/database_tracker.h" |
| 9 #include "content/browser/dom_storage/dom_storage_context_impl.h" | 10 #include "content/browser/dom_storage/dom_storage_context_impl.h" |
| 10 #include "content/browser/download/download_file_manager.h" | 11 #include "content/browser/download/download_file_manager.h" |
| 11 #include "content/browser/download/download_manager_impl.h" | 12 #include "content/browser/download/download_manager_impl.h" |
| 12 #include "content/browser/in_process_webkit/indexed_db_context_impl.h" | 13 #include "content/browser/in_process_webkit/indexed_db_context_impl.h" |
| 13 #include "content/browser/renderer_host/resource_dispatcher_host_impl.h" | 14 #include "content/browser/renderer_host/resource_dispatcher_host_impl.h" |
| 14 #include "content/public/browser/resource_context.h" | 15 #include "content/public/browser/resource_context.h" |
| 15 #include "content/public/browser/site_instance.h" | 16 #include "content/public/browser/site_instance.h" |
| 16 #include "content/browser/storage_partition_impl.h" | 17 #include "content/browser/storage_partition_impl.h" |
| 17 #include "content/browser/storage_partition_impl_map.h" | 18 #include "content/browser/storage_partition_impl_map.h" |
| 18 #include "content/common/child_process_host_impl.h" | 19 #include "content/common/child_process_host_impl.h" |
| 19 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
| 20 #include "content/public/browser/content_browser_client.h" | 21 #include "content/public/browser/content_browser_client.h" |
| 21 #include "net/base/server_bound_cert_service.h" | 22 #include "net/base/server_bound_cert_service.h" |
| 22 #include "net/base/server_bound_cert_store.h" | 23 #include "net/base/server_bound_cert_store.h" |
| 23 #include "net/cookies/cookie_monster.h" | 24 #include "net/cookies/cookie_monster.h" |
| 24 #include "net/cookies/cookie_store.h" | 25 #include "net/cookies/cookie_store.h" |
| 25 #include "net/url_request/url_request_context.h" | 26 #include "net/url_request/url_request_context.h" |
| 26 #include "net/url_request/url_request_context_getter.h" | 27 #include "net/url_request/url_request_context_getter.h" |
| 28 #endif // !OS_IOS |
| 27 | 29 |
| 28 using base::UserDataAdapter; | 30 using base::UserDataAdapter; |
| 29 | 31 |
| 30 // Key names on BrowserContext. | |
| 31 static const char* kDownloadManagerKeyName = "download_manager"; | |
| 32 static const char* kStorageParitionMapKeyName = "content_storage_partition_map"; | |
| 33 | |
| 34 namespace content { | 32 namespace content { |
| 35 | 33 |
| 34 // Only ~BrowserContext() is needed on iOS. |
| 35 #if !defined(OS_IOS) |
| 36 namespace { | 36 namespace { |
| 37 | 37 |
| 38 // Key names on BrowserContext. |
| 39 const char* kDownloadManagerKeyName = "download_manager"; |
| 40 const char* kStorageParitionMapKeyName = "content_storage_partition_map"; |
| 41 |
| 38 StoragePartition* GetStoragePartitionByPartitionId( | 42 StoragePartition* GetStoragePartitionByPartitionId( |
| 39 BrowserContext* browser_context, | 43 BrowserContext* browser_context, |
| 40 const std::string& partition_id) { | 44 const std::string& partition_id) { |
| 41 StoragePartitionImplMap* partition_map = | 45 StoragePartitionImplMap* partition_map = |
| 42 static_cast<StoragePartitionImplMap*>( | 46 static_cast<StoragePartitionImplMap*>( |
| 43 browser_context->GetUserData(kStorageParitionMapKeyName)); | 47 browser_context->GetUserData(kStorageParitionMapKeyName)); |
| 44 if (!partition_map) { | 48 if (!partition_map) { |
| 45 partition_map = new StoragePartitionImplMap(browser_context); | 49 partition_map = new StoragePartitionImplMap(browser_context); |
| 46 browser_context->SetUserData(kStorageParitionMapKeyName, partition_map); | 50 browser_context->SetUserData(kStorageParitionMapKeyName, partition_map); |
| 47 } | 51 } |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 BrowserThread::IO, FROM_HERE, | 216 BrowserThread::IO, FROM_HERE, |
| 213 base::Bind( | 217 base::Bind( |
| 214 &PurgeMemoryOnIOThread, | 218 &PurgeMemoryOnIOThread, |
| 215 BrowserContext::GetDefaultStoragePartition(browser_context)-> | 219 BrowserContext::GetDefaultStoragePartition(browser_context)-> |
| 216 GetAppCacheService())); | 220 GetAppCacheService())); |
| 217 } | 221 } |
| 218 | 222 |
| 219 ForEachStoragePartition(browser_context, | 223 ForEachStoragePartition(browser_context, |
| 220 base::Bind(&PurgeDOMStorageContextInPartition)); | 224 base::Bind(&PurgeDOMStorageContextInPartition)); |
| 221 } | 225 } |
| 226 #endif // !OS_IOS |
| 222 | 227 |
| 223 BrowserContext::~BrowserContext() { | 228 BrowserContext::~BrowserContext() { |
| 229 #if !defined(OS_IOS) |
| 224 if (GetUserData(kDownloadManagerKeyName)) | 230 if (GetUserData(kDownloadManagerKeyName)) |
| 225 GetDownloadManager(this)->Shutdown(); | 231 GetDownloadManager(this)->Shutdown(); |
| 232 #endif |
| 226 } | 233 } |
| 227 | 234 |
| 228 } // namespace content | 235 } // namespace content |
| OLD | NEW |