Chromium Code Reviews
[email protected] (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(256)

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

Issue 10919307: Move IndexedDBContext into the StoragePartition and ensure isolation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: stupid lowercasing 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 | 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 "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 12 matching lines...) Expand all
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.
90 content::StoragePartition* storage_partition =
91 BrowserContext::GetDefaultStoragePartition(profile);
Charlie Reis 2012/09/15 00:55:58 nit: wrong indent
awong 2012/09/15 01:19:37 Done.
91 if (storage_origin.SchemeIs(chrome::kExtensionScheme)) { 92 if (storage_origin.SchemeIs(chrome::kExtensionScheme)) {
92 extension_request_context_ = profile->GetRequestContextForExtensions(); 93 extension_request_context_ = profile->GetRequestContextForExtensions();
93 } else if (is_storage_isolated) { 94 } else if (is_storage_isolated) {
94 extension_request_context_ = 95 extension_request_context_ =
95 profile->GetRequestContextForIsolatedApp(extension_id); 96 profile->GetRequestContextForIsolatedApp(extension_id);
96 isolated_app_path_ = profile->GetPath(). 97 isolated_app_path_ = profile->GetPath().
97 Append(content::kStoragePartitionDirname).AppendASCII(extension_id); 98 Append(content::kStoragePartitionDirname).AppendASCII(extension_id);
98 } else { 99 } else {
99 extension_request_context_ = profile->GetRequestContext(); 100 extension_request_context_ = profile->GetRequestContext();
100 } 101 }
102
101 file_system_context_ = BrowserContext::GetFileSystemContext(profile); 103 file_system_context_ = BrowserContext::GetFileSystemContext(profile);
104 indexed_db_context_ = storage_partition->GetIndexedDBContext();
105
102 storage_origin_ = storage_origin; 106 storage_origin_ = storage_origin;
103 origin_id_ = 107 origin_id_ =
104 webkit_database::DatabaseUtil::GetOriginIdentifier(storage_origin_); 108 webkit_database::DatabaseUtil::GetOriginIdentifier(storage_origin_);
105 } 109 }
106 110
107 DataDeleter::~DataDeleter() { 111 DataDeleter::~DataDeleter() {
108 } 112 }
109 113
110 void DataDeleter::DeleteCookiesOnIOThread() { 114 void DataDeleter::DeleteCookiesOnIOThread() {
111 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 115 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
112 net::CookieMonster* cookie_monster = 116 net::CookieMonster* cookie_monster =
113 extension_request_context_->GetURLRequestContext()->cookie_store()-> 117 extension_request_context_->GetURLRequestContext()->cookie_store()->
114 GetCookieMonster(); 118 GetCookieMonster();
115 if (cookie_monster) 119 if (cookie_monster)
116 cookie_monster->DeleteAllForHostAsync( 120 cookie_monster->DeleteAllForHostAsync(
117 storage_origin_, net::CookieMonster::DeleteCallback()); 121 storage_origin_, net::CookieMonster::DeleteCallback());
118 } 122 }
119 123
120 void DataDeleter::DeleteDatabaseOnFileThread() { 124 void DataDeleter::DeleteDatabaseOnFileThread() {
121 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 125 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
122 int rv = database_tracker_->DeleteDataForOrigin( 126 int rv = database_tracker_->DeleteDataForOrigin(
123 origin_id_, net::CompletionCallback()); 127 origin_id_, net::CompletionCallback());
124 DCHECK(rv == net::OK || rv == net::ERR_IO_PENDING); 128 DCHECK(rv == net::OK || rv == net::ERR_IO_PENDING);
125 } 129 }
126 130
127 void DataDeleter::DeleteIndexedDBOnWebkitThread( 131 void DataDeleter::DeleteIndexedDBOnWebkitThread() {
128 scoped_refptr<IndexedDBContext> indexed_db_context) {
129 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); 132 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED));
130 indexed_db_context->DeleteForOrigin(storage_origin_); 133 indexed_db_context_->DeleteForOrigin(storage_origin_);
131 } 134 }
132 135
133 void DataDeleter::DeleteFileSystemOnFileThread() { 136 void DataDeleter::DeleteFileSystemOnFileThread() {
134 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 137 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
135 file_system_context_->DeleteDataForOriginOnFileThread(storage_origin_); 138 file_system_context_->DeleteDataForOriginOnFileThread(storage_origin_);
136 139
137 // TODO(creis): The following call fails because the request context is still 140 // TODO(creis): The following call fails because the request context is still
138 // around, and holding open file handles in this directory. 141 // around, and holding open file handles in this directory.
139 // See http://crbug.com/85127 142 // See http://crbug.com/85127
140 if (!isolated_app_path_.empty()) 143 if (!isolated_app_path_.empty())
141 file_util::Delete(isolated_app_path_, true); 144 file_util::Delete(isolated_app_path_, true);
142 } 145 }
143 146
144 void DataDeleter::DeleteAppcachesOnIOThread( 147 void DataDeleter::DeleteAppcachesOnIOThread(
145 appcache::AppCacheService* appcache_service) { 148 appcache::AppCacheService* appcache_service) {
146 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 149 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
147 appcache_service->DeleteAppCachesForOrigin(storage_origin_, 150 appcache_service->DeleteAppCachesForOrigin(storage_origin_,
148 net::CompletionCallback()); 151 net::CompletionCallback());
149 } 152 }
150 153
151 } // namespace extensions 154 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698