Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(71)

Side by Side Diff: content/browser/browser_context.cc

Issue 1251243003: Support restricting browsing data removal for downloads by origin. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Remove unneeded DCHECK; Initialize and clear download URLs along test fixture life cycle. Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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(download_manager);
98 context->SetUserData(kDownloadManagerKeyName, download_manager);
99 }
100
94 } // namespace 101 } // namespace
95 102
96 // static 103 // static
97 void BrowserContext::AsyncObliterateStoragePartition( 104 void BrowserContext::AsyncObliterateStoragePartition(
98 BrowserContext* browser_context, 105 BrowserContext* browser_context,
99 const GURL& site, 106 const GURL& site,
100 const base::Closure& on_gc_required) { 107 const base::Closure& on_gc_required) {
101 GetStoragePartitionMap(browser_context)->AsyncObliterate(site, 108 GetStoragePartitionMap(browser_context)->AsyncObliterate(site,
102 on_gc_required); 109 on_gc_required);
103 } 110 }
(...skipping 10 matching lines...) Expand all
114 DownloadManager* BrowserContext::GetDownloadManager( 121 DownloadManager* BrowserContext::GetDownloadManager(
115 BrowserContext* context) { 122 BrowserContext* context) {
116 DCHECK_CURRENTLY_ON(BrowserThread::UI); 123 DCHECK_CURRENTLY_ON(BrowserThread::UI);
117 if (!context->GetUserData(kDownloadManagerKeyName)) { 124 if (!context->GetUserData(kDownloadManagerKeyName)) {
118 ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get(); 125 ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get();
119 DCHECK(rdh); 126 DCHECK(rdh);
120 DownloadManager* download_manager = 127 DownloadManager* download_manager =
121 new DownloadManagerImpl( 128 new DownloadManagerImpl(
122 GetContentClient()->browser()->GetNetLog(), context); 129 GetContentClient()->browser()->GetNetLog(), context);
123 130
124 context->SetUserData( 131 SetDownloadManager(context, download_manager);
125 kDownloadManagerKeyName,
126 download_manager);
127 download_manager->SetDelegate(context->GetDownloadManagerDelegate()); 132 download_manager->SetDelegate(context->GetDownloadManagerDelegate());
128 } 133 }
129 134
130 return static_cast<DownloadManager*>( 135 return static_cast<DownloadManager*>(
131 context->GetUserData(kDownloadManagerKeyName)); 136 context->GetUserData(kDownloadManagerKeyName));
132 } 137 }
133 138
134 // static 139 // static
135 storage::ExternalMountPoints* BrowserContext::GetMountPoints( 140 storage::ExternalMountPoints* BrowserContext::GetMountPoints(
136 BrowserContext* context) { 141 BrowserContext* context) {
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 storage_partition->GetIndexedDBContext()); 305 storage_partition->GetIndexedDBContext());
301 // No task runner in unit tests. 306 // No task runner in unit tests.
302 if (indexed_db_context_impl->TaskRunner()) { 307 if (indexed_db_context_impl->TaskRunner()) {
303 indexed_db_context_impl->TaskRunner()->PostTask( 308 indexed_db_context_impl->TaskRunner()->PostTask(
304 FROM_HERE, 309 FROM_HERE,
305 base::Bind(&SaveSessionStateOnIndexedDBThread, 310 base::Bind(&SaveSessionStateOnIndexedDBThread,
306 make_scoped_refptr(indexed_db_context_impl))); 311 make_scoped_refptr(indexed_db_context_impl)));
307 } 312 }
308 } 313 }
309 314
315 void BrowserContext::SetDownloadManagerForTesting(
316 BrowserContext* browser_context,
317 DownloadManager* download_manager) {
318 SetDownloadManager(browser_context, download_manager);
319 }
320
310 #endif // !OS_IOS 321 #endif // !OS_IOS
311 322
312 BrowserContext::~BrowserContext() { 323 BrowserContext::~BrowserContext() {
313 #if !defined(OS_IOS) 324 #if !defined(OS_IOS)
314 if (GetUserData(kDownloadManagerKeyName)) 325 if (GetUserData(kDownloadManagerKeyName))
315 GetDownloadManager(this)->Shutdown(); 326 GetDownloadManager(this)->Shutdown();
316 #endif 327 #endif
317 } 328 }
318 329
319 } // namespace content 330 } // namespace content
OLDNEW
« no previous file with comments | « chrome/browser/browsing_data/browsing_data_remover_unittest.cc ('k') | content/browser/download/download_manager_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698