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

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

Issue 11362268: Implement the ability to obliterate a storage partition from disk. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Correctly delete all data. Created 8 years, 1 month 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 | Annotate | Revision Log
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/appcache/chrome_appcache_service.h" 8 #include "content/browser/appcache/chrome_appcache_service.h"
9 #include "content/browser/dom_storage/dom_storage_context_impl.h" 9 #include "content/browser/dom_storage/dom_storage_context_impl.h"
10 #include "content/browser/download/download_manager_impl.h" 10 #include "content/browser/download/download_manager_impl.h"
(...skipping 19 matching lines...) Expand all
30 namespace content { 30 namespace content {
31 31
32 // Only ~BrowserContext() is needed on iOS. 32 // Only ~BrowserContext() is needed on iOS.
33 #if !defined(OS_IOS) 33 #if !defined(OS_IOS)
34 namespace { 34 namespace {
35 35
36 // Key names on BrowserContext. 36 // Key names on BrowserContext.
37 const char* kDownloadManagerKeyName = "download_manager"; 37 const char* kDownloadManagerKeyName = "download_manager";
38 const char* kStorageParitionMapKeyName = "content_storage_partition_map"; 38 const char* kStorageParitionMapKeyName = "content_storage_partition_map";
39 39
40 StoragePartition* GetStoragePartitionFromConfig( 40 StoragePartitionImplMap* GetStoragePartitionMap(
41 BrowserContext* browser_context, 41 BrowserContext* browser_context) {
42 const std::string& partition_domain,
43 const std::string& partition_name,
44 bool in_memory) {
45 StoragePartitionImplMap* partition_map = 42 StoragePartitionImplMap* partition_map =
46 static_cast<StoragePartitionImplMap*>( 43 static_cast<StoragePartitionImplMap*>(
47 browser_context->GetUserData(kStorageParitionMapKeyName)); 44 browser_context->GetUserData(kStorageParitionMapKeyName));
48 if (!partition_map) { 45 if (!partition_map) {
49 partition_map = new StoragePartitionImplMap(browser_context); 46 partition_map = new StoragePartitionImplMap(browser_context);
50 browser_context->SetUserData(kStorageParitionMapKeyName, partition_map); 47 browser_context->SetUserData(kStorageParitionMapKeyName, partition_map);
51 } 48 }
49 return partition_map;
50 }
51
52 StoragePartition* GetStoragePartitionFromConfig(
53 BrowserContext* browser_context,
54 const std::string& partition_domain,
55 const std::string& partition_name,
56 bool in_memory) {
57 StoragePartitionImplMap* partition_map =
58 GetStoragePartitionMap(browser_context);
52 59
53 if (browser_context->IsOffTheRecord()) 60 if (browser_context->IsOffTheRecord())
54 in_memory = true; 61 in_memory = true;
55 62
56 return partition_map->Get(partition_domain, partition_name, in_memory); 63 return partition_map->Get(partition_domain, partition_name, in_memory);
57 } 64 }
58 65
59 // Run |callback| on each DOMStorageContextImpl in |browser_context|. 66 // Run |callback| on each DOMStorageContextImpl in |browser_context|.
60 void PurgeDOMStorageContextInPartition(StoragePartition* storage_partition) { 67 void PurgeDOMStorageContextInPartition(StoragePartition* storage_partition) {
61 static_cast<StoragePartitionImpl*>(storage_partition)-> 68 static_cast<StoragePartitionImpl*>(storage_partition)->
(...skipping 15 matching lines...) Expand all
77 scoped_refptr<IndexedDBContextImpl> indexed_db_context) { 84 scoped_refptr<IndexedDBContextImpl> indexed_db_context) {
78 indexed_db_context->SetForceKeepSessionState(); 85 indexed_db_context->SetForceKeepSessionState();
79 } 86 }
80 87
81 void PurgeMemoryOnIOThread(appcache::AppCacheService* appcache_service) { 88 void PurgeMemoryOnIOThread(appcache::AppCacheService* appcache_service) {
82 appcache_service->PurgeMemory(); 89 appcache_service->PurgeMemory();
83 } 90 }
84 91
85 } // namespace 92 } // namespace
86 93
94 // static
95 void BrowserContext::AsyncObliterateStoragePartition(
96 BrowserContext* browser_context,
97 const GURL& site) {
98 GetStoragePartitionMap(browser_context)->AsyncObliterate(site);
99 }
100
87 DownloadManager* BrowserContext::GetDownloadManager( 101 DownloadManager* BrowserContext::GetDownloadManager(
88 BrowserContext* context) { 102 BrowserContext* context) {
89 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 103 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
90 if (!context->GetUserData(kDownloadManagerKeyName)) { 104 if (!context->GetUserData(kDownloadManagerKeyName)) {
91 ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get(); 105 ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get();
92 DCHECK(rdh); 106 DCHECK(rdh);
93 scoped_refptr<DownloadManager> download_manager = 107 scoped_refptr<DownloadManager> download_manager =
94 new DownloadManagerImpl( 108 new DownloadManagerImpl(
95 GetContentClient()->browser()->GetNetLog()); 109 GetContentClient()->browser()->GetNetLog());
96 110
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 #endif // !OS_IOS 227 #endif // !OS_IOS
214 228
215 BrowserContext::~BrowserContext() { 229 BrowserContext::~BrowserContext() {
216 #if !defined(OS_IOS) 230 #if !defined(OS_IOS)
217 if (GetUserData(kDownloadManagerKeyName)) 231 if (GetUserData(kDownloadManagerKeyName))
218 GetDownloadManager(this)->Shutdown(); 232 GetDownloadManager(this)->Shutdown();
219 #endif 233 #endif
220 } 234 }
221 235
222 } // namespace content 236 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698