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 #if !defined(OS_IOS) | 7 #if !defined(OS_IOS) |
| 8 #include "content/browser/download/download_manager_impl.h" | 8 #include "content/browser/download/download_manager_impl.h" |
| 9 #include "content/browser/fileapi/chrome_blob_storage_context.h" | 9 #include "content/browser/fileapi/chrome_blob_storage_context.h" |
| 10 #include "content/browser/indexed_db/indexed_db_context_impl.h" | 10 #include "content/browser/indexed_db/indexed_db_context_impl.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 84 indexed_db_context->SetForceKeepSessionState(); | 84 indexed_db_context->SetForceKeepSessionState(); |
| 85 } | 85 } |
| 86 | 86 |
| 87 void ShutdownServiceWorkerContext(StoragePartition* partition) { | 87 void ShutdownServiceWorkerContext(StoragePartition* partition) { |
| 88 ServiceWorkerContextWrapper* wrapper = | 88 ServiceWorkerContextWrapper* wrapper = |
| 89 static_cast<ServiceWorkerContextWrapper*>( | 89 static_cast<ServiceWorkerContextWrapper*>( |
| 90 partition->GetServiceWorkerContext()); | 90 partition->GetServiceWorkerContext()); |
| 91 wrapper->process_manager()->Shutdown(); | 91 wrapper->process_manager()->Shutdown(); |
| 92 } | 92 } |
| 93 | 93 |
| 94 void SetDownloadManager(BrowserContext* context, | |
| 95 content::DownloadManager* download_manager) { | |
| 96 DCHECK_CURRENTLY_ON(BrowserThread::UI); | |
| 97 DCHECK(context); | |
| 98 DCHECK(download_manager); | |
| 99 context->SetUserData( | |
| 100 kDownloadManagerKeyName, | |
| 101 download_manager); | |
|
Charlie Reis
2015/08/03 18:33:19
style nit: This should all fit on one line.
| |
| 102 } | |
| 103 | |
| 94 } // namespace | 104 } // namespace |
| 95 | 105 |
| 96 // static | 106 // static |
| 97 void BrowserContext::AsyncObliterateStoragePartition( | 107 void BrowserContext::AsyncObliterateStoragePartition( |
| 98 BrowserContext* browser_context, | 108 BrowserContext* browser_context, |
| 99 const GURL& site, | 109 const GURL& site, |
| 100 const base::Closure& on_gc_required) { | 110 const base::Closure& on_gc_required) { |
| 101 GetStoragePartitionMap(browser_context)->AsyncObliterate(site, | 111 GetStoragePartitionMap(browser_context)->AsyncObliterate(site, |
| 102 on_gc_required); | 112 on_gc_required); |
| 103 } | 113 } |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 114 DownloadManager* BrowserContext::GetDownloadManager( | 124 DownloadManager* BrowserContext::GetDownloadManager( |
| 115 BrowserContext* context) { | 125 BrowserContext* context) { |
| 116 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 126 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 117 if (!context->GetUserData(kDownloadManagerKeyName)) { | 127 if (!context->GetUserData(kDownloadManagerKeyName)) { |
| 118 ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get(); | 128 ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get(); |
| 119 DCHECK(rdh); | 129 DCHECK(rdh); |
| 120 DownloadManager* download_manager = | 130 DownloadManager* download_manager = |
| 121 new DownloadManagerImpl( | 131 new DownloadManagerImpl( |
| 122 GetContentClient()->browser()->GetNetLog(), context); | 132 GetContentClient()->browser()->GetNetLog(), context); |
| 123 | 133 |
| 124 context->SetUserData( | 134 SetDownloadManager(context, download_manager); |
| 125 kDownloadManagerKeyName, | |
| 126 download_manager); | |
| 127 download_manager->SetDelegate(context->GetDownloadManagerDelegate()); | 135 download_manager->SetDelegate(context->GetDownloadManagerDelegate()); |
| 128 } | 136 } |
| 129 | 137 |
| 130 return static_cast<DownloadManager*>( | 138 return static_cast<DownloadManager*>( |
| 131 context->GetUserData(kDownloadManagerKeyName)); | 139 context->GetUserData(kDownloadManagerKeyName)); |
| 132 } | 140 } |
| 133 | 141 |
| 134 // static | 142 // static |
| 135 storage::ExternalMountPoints* BrowserContext::GetMountPoints( | 143 storage::ExternalMountPoints* BrowserContext::GetMountPoints( |
| 136 BrowserContext* context) { | 144 BrowserContext* context) { |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 300 storage_partition->GetIndexedDBContext()); | 308 storage_partition->GetIndexedDBContext()); |
| 301 // No task runner in unit tests. | 309 // No task runner in unit tests. |
| 302 if (indexed_db_context_impl->TaskRunner()) { | 310 if (indexed_db_context_impl->TaskRunner()) { |
| 303 indexed_db_context_impl->TaskRunner()->PostTask( | 311 indexed_db_context_impl->TaskRunner()->PostTask( |
| 304 FROM_HERE, | 312 FROM_HERE, |
| 305 base::Bind(&SaveSessionStateOnIndexedDBThread, | 313 base::Bind(&SaveSessionStateOnIndexedDBThread, |
| 306 make_scoped_refptr(indexed_db_context_impl))); | 314 make_scoped_refptr(indexed_db_context_impl))); |
| 307 } | 315 } |
| 308 } | 316 } |
| 309 | 317 |
| 318 void BrowserContext::SetDownloadManagerForTesting( | |
| 319 BrowserContext* browser_context, DownloadManager* download_manager) { | |
|
Charlie Reis
2015/08/03 18:33:19
Style nit: "For function declarations and definiti
| |
| 320 SetDownloadManager(browser_context, download_manager); | |
| 321 } | |
| 322 | |
| 310 #endif // !OS_IOS | 323 #endif // !OS_IOS |
| 311 | 324 |
| 312 BrowserContext::~BrowserContext() { | 325 BrowserContext::~BrowserContext() { |
| 313 #if !defined(OS_IOS) | 326 #if !defined(OS_IOS) |
| 314 if (GetUserData(kDownloadManagerKeyName)) | 327 if (GetUserData(kDownloadManagerKeyName)) |
| 315 GetDownloadManager(this)->Shutdown(); | 328 GetDownloadManager(this)->Shutdown(); |
| 316 #endif | 329 #endif |
| 317 } | 330 } |
| 318 | 331 |
| 319 } // namespace content | 332 } // namespace content |
| OLD | NEW |