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(kDownloadManagerKeyName, download_manager); |
| 100 } |
| 101 |
94 } // namespace | 102 } // namespace |
95 | 103 |
96 // static | 104 // static |
97 void BrowserContext::AsyncObliterateStoragePartition( | 105 void BrowserContext::AsyncObliterateStoragePartition( |
98 BrowserContext* browser_context, | 106 BrowserContext* browser_context, |
99 const GURL& site, | 107 const GURL& site, |
100 const base::Closure& on_gc_required) { | 108 const base::Closure& on_gc_required) { |
101 GetStoragePartitionMap(browser_context)->AsyncObliterate(site, | 109 GetStoragePartitionMap(browser_context)->AsyncObliterate(site, |
102 on_gc_required); | 110 on_gc_required); |
103 } | 111 } |
(...skipping 10 matching lines...) Expand all Loading... |
114 DownloadManager* BrowserContext::GetDownloadManager( | 122 DownloadManager* BrowserContext::GetDownloadManager( |
115 BrowserContext* context) { | 123 BrowserContext* context) { |
116 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 124 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
117 if (!context->GetUserData(kDownloadManagerKeyName)) { | 125 if (!context->GetUserData(kDownloadManagerKeyName)) { |
118 ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get(); | 126 ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get(); |
119 DCHECK(rdh); | 127 DCHECK(rdh); |
120 DownloadManager* download_manager = | 128 DownloadManager* download_manager = |
121 new DownloadManagerImpl( | 129 new DownloadManagerImpl( |
122 GetContentClient()->browser()->GetNetLog(), context); | 130 GetContentClient()->browser()->GetNetLog(), context); |
123 | 131 |
124 context->SetUserData( | 132 SetDownloadManager(context, download_manager); |
125 kDownloadManagerKeyName, | |
126 download_manager); | |
127 download_manager->SetDelegate(context->GetDownloadManagerDelegate()); | 133 download_manager->SetDelegate(context->GetDownloadManagerDelegate()); |
128 } | 134 } |
129 | 135 |
130 return static_cast<DownloadManager*>( | 136 return static_cast<DownloadManager*>( |
131 context->GetUserData(kDownloadManagerKeyName)); | 137 context->GetUserData(kDownloadManagerKeyName)); |
132 } | 138 } |
133 | 139 |
134 // static | 140 // static |
135 storage::ExternalMountPoints* BrowserContext::GetMountPoints( | 141 storage::ExternalMountPoints* BrowserContext::GetMountPoints( |
136 BrowserContext* context) { | 142 BrowserContext* context) { |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 storage_partition->GetIndexedDBContext()); | 306 storage_partition->GetIndexedDBContext()); |
301 // No task runner in unit tests. | 307 // No task runner in unit tests. |
302 if (indexed_db_context_impl->TaskRunner()) { | 308 if (indexed_db_context_impl->TaskRunner()) { |
303 indexed_db_context_impl->TaskRunner()->PostTask( | 309 indexed_db_context_impl->TaskRunner()->PostTask( |
304 FROM_HERE, | 310 FROM_HERE, |
305 base::Bind(&SaveSessionStateOnIndexedDBThread, | 311 base::Bind(&SaveSessionStateOnIndexedDBThread, |
306 make_scoped_refptr(indexed_db_context_impl))); | 312 make_scoped_refptr(indexed_db_context_impl))); |
307 } | 313 } |
308 } | 314 } |
309 | 315 |
| 316 void BrowserContext::SetDownloadManagerForTesting( |
| 317 BrowserContext* browser_context, |
| 318 DownloadManager* download_manager) { |
| 319 SetDownloadManager(browser_context, download_manager); |
| 320 } |
| 321 |
310 #endif // !OS_IOS | 322 #endif // !OS_IOS |
311 | 323 |
312 BrowserContext::~BrowserContext() { | 324 BrowserContext::~BrowserContext() { |
313 #if !defined(OS_IOS) | 325 #if !defined(OS_IOS) |
314 if (GetUserData(kDownloadManagerKeyName)) | 326 if (GetUserData(kDownloadManagerKeyName)) |
315 GetDownloadManager(this)->Shutdown(); | 327 GetDownloadManager(this)->Shutdown(); |
316 #endif | 328 #endif |
317 } | 329 } |
318 | 330 |
319 } // namespace content | 331 } // namespace content |
OLD | NEW |