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

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

Issue 9704048: Make the content::DOMStorageContext methods callable on the main thread and hide the threading deta… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 9 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/extension_data_deleter.h" 5 #include "chrome/browser/extensions/extension_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/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/extensions/extension_service.h" 10 #include "chrome/browser/extensions/extension_service.h"
(...skipping 30 matching lines...) Expand all
41 DCHECK(profile); 41 DCHECK(profile);
42 scoped_refptr<ExtensionDataDeleter> deleter = 42 scoped_refptr<ExtensionDataDeleter> deleter =
43 new ExtensionDataDeleter( 43 new ExtensionDataDeleter(
44 profile, extension_id, storage_origin, is_storage_isolated); 44 profile, extension_id, storage_origin, is_storage_isolated);
45 45
46 BrowserThread::PostTask( 46 BrowserThread::PostTask(
47 BrowserThread::IO, FROM_HERE, 47 BrowserThread::IO, FROM_HERE,
48 base::Bind( 48 base::Bind(
49 &ExtensionDataDeleter::DeleteCookiesOnIOThread, deleter)); 49 &ExtensionDataDeleter::DeleteCookiesOnIOThread, deleter));
50 50
51 scoped_refptr<DOMStorageContext> dom_storage_context = 51 BrowserContext::GetDOMStorageContext(profile)->DeleteForOrigin(
52 BrowserContext::GetDOMStorageContext(profile); 52 deleter->origin_id_);
53 dom_storage_context->task_runner()->PostTask(
54 FROM_HERE,
55 base::Bind(
56 &ExtensionDataDeleter::DeleteLocalStorageInSequencedTask, deleter,
57 dom_storage_context));
58 53
59 BrowserThread::PostTask( 54 BrowserThread::PostTask(
60 BrowserThread::WEBKIT_DEPRECATED, FROM_HERE, 55 BrowserThread::WEBKIT_DEPRECATED, FROM_HERE,
61 base::Bind( 56 base::Bind(
62 &ExtensionDataDeleter::DeleteIndexedDBOnWebkitThread, deleter, 57 &ExtensionDataDeleter::DeleteIndexedDBOnWebkitThread, deleter,
63 make_scoped_refptr(BrowserContext::GetIndexedDBContext(profile)))); 58 make_scoped_refptr(BrowserContext::GetIndexedDBContext(profile))));
64 59
65 BrowserThread::PostTask( 60 BrowserThread::PostTask(
66 BrowserThread::FILE, FROM_HERE, 61 BrowserThread::FILE, FROM_HERE,
67 base::Bind( 62 base::Bind(
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 storage_origin_, net::CookieMonster::DeleteCallback()); 115 storage_origin_, net::CookieMonster::DeleteCallback());
121 } 116 }
122 117
123 void ExtensionDataDeleter::DeleteDatabaseOnFileThread() { 118 void ExtensionDataDeleter::DeleteDatabaseOnFileThread() {
124 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 119 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
125 int rv = database_tracker_->DeleteDataForOrigin( 120 int rv = database_tracker_->DeleteDataForOrigin(
126 origin_id_, net::CompletionCallback()); 121 origin_id_, net::CompletionCallback());
127 DCHECK(rv == net::OK || rv == net::ERR_IO_PENDING); 122 DCHECK(rv == net::OK || rv == net::ERR_IO_PENDING);
128 } 123 }
129 124
130 void ExtensionDataDeleter::DeleteLocalStorageInSequencedTask(
131 DOMStorageContext* dom_storage_context) {
132 DCHECK(dom_storage_context->task_runner()->RunsTasksOnCurrentThread());
133 dom_storage_context->DeleteForOrigin(origin_id_);
134 }
135
136 void ExtensionDataDeleter::DeleteIndexedDBOnWebkitThread( 125 void ExtensionDataDeleter::DeleteIndexedDBOnWebkitThread(
137 scoped_refptr<IndexedDBContext> indexed_db_context) { 126 scoped_refptr<IndexedDBContext> indexed_db_context) {
138 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); 127 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED));
139 indexed_db_context->DeleteForOrigin(storage_origin_); 128 indexed_db_context->DeleteForOrigin(storage_origin_);
140 } 129 }
141 130
142 void ExtensionDataDeleter::DeleteFileSystemOnFileThread() { 131 void ExtensionDataDeleter::DeleteFileSystemOnFileThread() {
143 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 132 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
144 file_system_context_->DeleteDataForOriginOnFileThread(storage_origin_); 133 file_system_context_->DeleteDataForOriginOnFileThread(storage_origin_);
145 134
146 // TODO(creis): The following call fails because the request context is still 135 // TODO(creis): The following call fails because the request context is still
147 // around, and holding open file handles in this directory. 136 // around, and holding open file handles in this directory.
148 // See http://crbug.com/85127 137 // See http://crbug.com/85127
149 if (!isolated_app_path_.empty()) 138 if (!isolated_app_path_.empty())
150 file_util::Delete(isolated_app_path_, true); 139 file_util::Delete(isolated_app_path_, true);
151 } 140 }
152 141
153 void ExtensionDataDeleter::DeleteAppcachesOnIOThread(ResourceContext* context) { 142 void ExtensionDataDeleter::DeleteAppcachesOnIOThread(ResourceContext* context) {
154 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 143 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
155 ResourceContext::GetAppCacheService(context)->DeleteAppCachesForOrigin( 144 ResourceContext::GetAppCacheService(context)->DeleteAppCachesForOrigin(
156 storage_origin_, net::CompletionCallback()); 145 storage_origin_, net::CompletionCallback());
157 } 146 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698