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

Side by Side Diff: chrome/browser/extensions/data_deleter.cc

Issue 10836216: Add SiteInstance parameters to IndexedDBContext calls (Closed) Base URL: http://git.chromium.org/chromium/src.git@isolated-storage
Patch Set: Candidate patch Created 8 years, 3 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 "chrome/browser/extensions/data_deleter.h" 5 #include "chrome/browser/extensions/data_deleter.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "chrome/browser/extensions/extension_service.h" 9 #include "chrome/browser/extensions/extension_service.h"
10 #include "chrome/browser/extensions/settings/settings_frontend.h" 10 #include "chrome/browser/extensions/settings/settings_frontend.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 BrowserThread::IO, FROM_HERE, 47 BrowserThread::IO, FROM_HERE,
48 base::Bind(&DataDeleter::DeleteCookiesOnIOThread, deleter)); 48 base::Bind(&DataDeleter::DeleteCookiesOnIOThread, deleter));
49 49
50 content::BrowserContext::GetDefaultStoragePartition(profile)-> 50 content::BrowserContext::GetDefaultStoragePartition(profile)->
51 GetDOMStorageContext()->DeleteOrigin(storage_origin); 51 GetDOMStorageContext()->DeleteOrigin(storage_origin);
52 52
53 BrowserThread::PostTask( 53 BrowserThread::PostTask(
54 BrowserThread::WEBKIT_DEPRECATED, FROM_HERE, 54 BrowserThread::WEBKIT_DEPRECATED, FROM_HERE,
55 base::Bind( 55 base::Bind(
56 &DataDeleter::DeleteIndexedDBOnWebkitThread, 56 &DataDeleter::DeleteIndexedDBOnWebkitThread,
57 deleter, 57 deleter));
58 make_scoped_refptr(BrowserContext::GetIndexedDBContext(profile))));
59 58
60 BrowserThread::PostTask( 59 BrowserThread::PostTask(
61 BrowserThread::FILE, FROM_HERE, 60 BrowserThread::FILE, FROM_HERE,
62 base::Bind(&DataDeleter::DeleteDatabaseOnFileThread, deleter)); 61 base::Bind(&DataDeleter::DeleteDatabaseOnFileThread, deleter));
63 62
64 BrowserThread::PostTask( 63 BrowserThread::PostTask(
65 BrowserThread::FILE, FROM_HERE, 64 BrowserThread::FILE, FROM_HERE,
66 base::Bind(&DataDeleter::DeleteFileSystemOnFileThread, deleter)); 65 base::Bind(&DataDeleter::DeleteFileSystemOnFileThread, deleter));
67 66
68 BrowserThread::PostTask( 67 BrowserThread::PostTask(
(...skipping 11 matching lines...) Expand all
80 Profile* profile, 79 Profile* profile,
81 const std::string& extension_id, 80 const std::string& extension_id,
82 const GURL& storage_origin, 81 const GURL& storage_origin,
83 bool is_storage_isolated) 82 bool is_storage_isolated)
84 : extension_id_(extension_id) { 83 : extension_id_(extension_id) {
85 // TODO(michaeln): Delete from the right StoragePartition. 84 // TODO(michaeln): Delete from the right StoragePartition.
86 // http://crbug.com/85127 85 // http://crbug.com/85127
87 database_tracker_ = BrowserContext::GetDefaultStoragePartition(profile)-> 86 database_tracker_ = BrowserContext::GetDefaultStoragePartition(profile)->
88 GetDatabaseTracker(); 87 GetDatabaseTracker();
89 // Pick the right request context depending on whether it's an extension, 88 // Pick the right request context depending on whether it's an extension,
90 // isolated app, or regular app. 89 // isolated app, or regular app.
awong 2012/09/10 21:55:21 I think for right now, just use GetDefaultStorageP
alecflett 2012/09/10 23:14:55 Heh, that seems very sad. But ok...it vastly simpl
awong 2012/09/10 23:17:53 Yeah it's sad...there's an outstanding bug to fix
90 content::StoragePartition* storage_partition;
awong 2012/09/10 21:55:21 Initialize to NULL?
alecflett 2012/09/10 23:14:55 I specifically didn't so clang would complain if I
91 if (storage_origin.SchemeIs(chrome::kExtensionScheme)) { 91 if (storage_origin.SchemeIs(chrome::kExtensionScheme)) {
92 extension_request_context_ = profile->GetRequestContextForExtensions(); 92 extension_request_context_ = profile->GetRequestContextForExtensions();
93 storage_partition = BrowserContext::GetDefaultStoragePartition(profile);
93 } else if (is_storage_isolated) { 94 } else if (is_storage_isolated) {
95 GURL extension_url =
96 extensions::Extension::GetBaseURLFromExtensionId(extension_id);
97 ExtensionProcessManager* manager = profile->GetExtensionProcessManager();
98 content::SiteInstance* site_instance =
99 manager->GetSiteInstanceForURL(extension_url);
100 storage_partition =
101 BrowserContext::GetStoragePartition(profile, site_instance);
94 extension_request_context_ = 102 extension_request_context_ =
95 profile->GetRequestContextForIsolatedApp(extension_id); 103 profile->GetRequestContextForIsolatedApp(extension_id);
96 isolated_app_path_ = profile->GetPath(). 104 isolated_app_path_ = profile->GetPath().
97 Append(content::kStoragePartitionDirname).AppendASCII(extension_id); 105 Append(content::kStoragePartitionDirname).AppendASCII(extension_id);
98 } else { 106 } else {
99 extension_request_context_ = profile->GetRequestContext(); 107 extension_request_context_ = profile->GetRequestContext();
108 storage_partition = BrowserContext::GetDefaultStoragePartition(profile);
100 } 109 }
110
101 file_system_context_ = BrowserContext::GetFileSystemContext(profile); 111 file_system_context_ = BrowserContext::GetFileSystemContext(profile);
112 indexed_db_context_ = storage_partition->GetIndexedDBContext();
113
102 storage_origin_ = storage_origin; 114 storage_origin_ = storage_origin;
103 origin_id_ = 115 origin_id_ =
104 webkit_database::DatabaseUtil::GetOriginIdentifier(storage_origin_); 116 webkit_database::DatabaseUtil::GetOriginIdentifier(storage_origin_);
105 } 117 }
106 118
107 DataDeleter::~DataDeleter() { 119 DataDeleter::~DataDeleter() {
108 } 120 }
109 121
110 void DataDeleter::DeleteCookiesOnIOThread() { 122 void DataDeleter::DeleteCookiesOnIOThread() {
111 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 123 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
112 net::CookieMonster* cookie_monster = 124 net::CookieMonster* cookie_monster =
113 extension_request_context_->GetURLRequestContext()->cookie_store()-> 125 extension_request_context_->GetURLRequestContext()->cookie_store()->
114 GetCookieMonster(); 126 GetCookieMonster();
115 if (cookie_monster) 127 if (cookie_monster)
116 cookie_monster->DeleteAllForHostAsync( 128 cookie_monster->DeleteAllForHostAsync(
117 storage_origin_, net::CookieMonster::DeleteCallback()); 129 storage_origin_, net::CookieMonster::DeleteCallback());
118 } 130 }
119 131
120 void DataDeleter::DeleteDatabaseOnFileThread() { 132 void DataDeleter::DeleteDatabaseOnFileThread() {
121 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 133 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
122 int rv = database_tracker_->DeleteDataForOrigin( 134 int rv = database_tracker_->DeleteDataForOrigin(
123 origin_id_, net::CompletionCallback()); 135 origin_id_, net::CompletionCallback());
124 DCHECK(rv == net::OK || rv == net::ERR_IO_PENDING); 136 DCHECK(rv == net::OK || rv == net::ERR_IO_PENDING);
125 } 137 }
126 138
127 void DataDeleter::DeleteIndexedDBOnWebkitThread( 139 void DataDeleter::DeleteIndexedDBOnWebkitThread() {
128 scoped_refptr<IndexedDBContext> indexed_db_context) {
129 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); 140 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED));
130 indexed_db_context->DeleteForOrigin(storage_origin_); 141 indexed_db_context_->DeleteForOrigin(storage_origin_);
131 } 142 }
132 143
133 void DataDeleter::DeleteFileSystemOnFileThread() { 144 void DataDeleter::DeleteFileSystemOnFileThread() {
134 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 145 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
135 file_system_context_->DeleteDataForOriginOnFileThread(storage_origin_); 146 file_system_context_->DeleteDataForOriginOnFileThread(storage_origin_);
136 147
137 // TODO(creis): The following call fails because the request context is still 148 // TODO(creis): The following call fails because the request context is still
138 // around, and holding open file handles in this directory. 149 // around, and holding open file handles in this directory.
139 // See http://crbug.com/85127 150 // See http://crbug.com/85127
140 if (!isolated_app_path_.empty()) 151 if (!isolated_app_path_.empty())
141 file_util::Delete(isolated_app_path_, true); 152 file_util::Delete(isolated_app_path_, true);
142 } 153 }
143 154
144 void DataDeleter::DeleteAppcachesOnIOThread( 155 void DataDeleter::DeleteAppcachesOnIOThread(
145 appcache::AppCacheService* appcache_service) { 156 appcache::AppCacheService* appcache_service) {
146 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 157 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
147 appcache_service->DeleteAppCachesForOrigin(storage_origin_, 158 appcache_service->DeleteAppCachesForOrigin(storage_origin_,
148 net::CompletionCallback()); 159 net::CompletionCallback());
149 } 160 }
150 161
151 } // namespace extensions 162 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698