summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-15 04:08:51 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-15 04:08:51 +0000
commit5a9e4767704cdfea576cb6b934c3d0400beb738f (patch)
tree812bdc1723c784edb4807d53d04c4127da8fc104 /chrome/browser
parentd061e9bd1a883172db01c644d83c1a1ae45efc90 (diff)
downloadchromium_src-5a9e4767704cdfea576cb6b934c3d0400beb738f.zip
chromium_src-5a9e4767704cdfea576cb6b934c3d0400beb738f.tar.gz
chromium_src-5a9e4767704cdfea576cb6b934c3d0400beb738f.tar.bz2
Make the content::DOMStorageContext methods callable on the main thread and hide the threading details from the embedder.
Review URL: https://chromiumcodereview.appspot.com/9704048 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@126835 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/browsing_data_local_storage_helper.cc33
-rw-r--r--chrome/browser/browsing_data_local_storage_helper.h11
-rw-r--r--chrome/browser/browsing_data_remover.cc14
-rw-r--r--chrome/browser/browsing_data_remover.h4
-rw-r--r--chrome/browser/extensions/extension_data_deleter.cc15
-rw-r--r--chrome/browser/extensions/extension_data_deleter.h5
6 files changed, 26 insertions, 56 deletions
diff --git a/chrome/browser/browsing_data_local_storage_helper.cc b/chrome/browser/browsing_data_local_storage_helper.cc
index ff66398..05b31c1 100644
--- a/chrome/browser/browsing_data_local_storage_helper.cc
+++ b/chrome/browser/browsing_data_local_storage_helper.cc
@@ -52,7 +52,7 @@ BrowsingDataLocalStorageHelper::BrowsingDataLocalStorageHelper(
Profile* profile)
: dom_storage_context_(BrowserContext::GetDOMStorageContext(profile)),
is_fetching_(false) {
- DCHECK(dom_storage_context_.get());
+ DCHECK(dom_storage_context_);
}
BrowsingDataLocalStorageHelper::~BrowsingDataLocalStorageHelper() {
@@ -66,11 +66,9 @@ void BrowsingDataLocalStorageHelper::StartFetching(
is_fetching_ = true;
completion_callback_ = callback;
- dom_storage_context_->task_runner()->PostTask(
- FROM_HERE,
+ dom_storage_context_->GetAllStorageFiles(
base::Bind(
- &BrowsingDataLocalStorageHelper::FetchLocalStorageInfoHelper,
- this));
+ &BrowsingDataLocalStorageHelper::GetAllStorageFilesCallback, this));
}
void BrowsingDataLocalStorageHelper::CancelNotification() {
@@ -81,16 +79,23 @@ void BrowsingDataLocalStorageHelper::CancelNotification() {
void BrowsingDataLocalStorageHelper::DeleteLocalStorageFile(
const FilePath& file_path) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- dom_storage_context_->task_runner()->PostTask(
+ dom_storage_context_->DeleteLocalStorageFile(file_path);
+}
+
+void BrowsingDataLocalStorageHelper::GetAllStorageFilesCallback(
+ const std::vector<FilePath>& files) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ BrowserThread::PostTask(
+ BrowserThread::FILE,
FROM_HERE,
base::Bind(
- &BrowsingDataLocalStorageHelper::DeleteLocalStorageFileHelper,
- this, file_path));
+ &BrowsingDataLocalStorageHelper::FetchLocalStorageInfo,
+ this, files));
}
-void BrowsingDataLocalStorageHelper::FetchLocalStorageInfoHelper() {
- DCHECK(dom_storage_context_->task_runner()->RunsTasksOnCurrentThread());
- std::vector<FilePath> files = dom_storage_context_->GetAllStorageFiles();
+void BrowsingDataLocalStorageHelper::FetchLocalStorageInfo(
+ const std::vector<FilePath>& files) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
for (size_t i = 0; i < files.size(); ++i) {
FilePath file_path = files[i];
WebSecurityOrigin web_security_origin =
@@ -132,12 +137,6 @@ void BrowsingDataLocalStorageHelper::NotifyInUIThread() {
is_fetching_ = false;
}
-void BrowsingDataLocalStorageHelper::DeleteLocalStorageFileHelper(
- const FilePath& file_path) {
- DCHECK(dom_storage_context_->task_runner()->RunsTasksOnCurrentThread());
- dom_storage_context_->DeleteLocalStorageFile(file_path);
-}
-
//---------------------------------------------------------
CannedBrowsingDataLocalStorageHelper::CannedBrowsingDataLocalStorageHelper(
diff --git a/chrome/browser/browsing_data_local_storage_helper.h b/chrome/browser/browsing_data_local_storage_helper.h
index a2c79fe..7f88985 100644
--- a/chrome/browser/browsing_data_local_storage_helper.h
+++ b/chrome/browser/browsing_data_local_storage_helper.h
@@ -84,7 +84,8 @@ class BrowsingDataLocalStorageHelper
// Notifies the completion callback in the UI thread.
void NotifyInUIThread();
- scoped_refptr<content::DOMStorageContext> dom_storage_context_;
+ // Owned by the profile
+ content::DOMStorageContext* dom_storage_context_;
// This only mutates on the UI thread.
base::Callback<void(const std::list<LocalStorageInfo>&)> completion_callback_;
@@ -99,10 +100,10 @@ class BrowsingDataLocalStorageHelper
std::list<LocalStorageInfo> local_storage_info_;
private:
- // Enumerates all local storage files in a sequenced task.
- void FetchLocalStorageInfoHelper();
- // Delete a single local storage file in a sequenced task.
- void DeleteLocalStorageFileHelper(const FilePath& file_path);
+ // Called back with the all the local storage files.
+ void GetAllStorageFilesCallback(const std::vector<FilePath>& files);
+ // Get the file info on the file thread.
+ void FetchLocalStorageInfo(const std::vector<FilePath>& files);
DISALLOW_COPY_AND_ASSIGN(BrowsingDataLocalStorageHelper);
};
diff --git a/chrome/browser/browsing_data_remover.cc b/chrome/browser/browsing_data_remover.cc
index 0612dde..446dd18 100644
--- a/chrome/browser/browsing_data_remover.cc
+++ b/chrome/browser/browsing_data_remover.cc
@@ -303,11 +303,8 @@ void BrowsingDataRemover::RemoveImpl(int remove_mask,
}
if (remove_mask & REMOVE_LOCAL_STORAGE) {
- DOMStorageContext* context = BrowserContext::GetDOMStorageContext(profile_);
- context->task_runner()->PostTask(
- FROM_HERE,
- base::Bind(&BrowsingDataRemover::ClearDOMStorageInSequencedTask,
- base::Unretained(this), make_scoped_refptr(context)));
+ BrowserContext::GetDOMStorageContext(profile_)->DeleteDataModifiedSince(
+ delete_begin_);
}
if (remove_mask & REMOVE_INDEXEDDB || remove_mask & REMOVE_WEBSQL ||
@@ -436,13 +433,6 @@ base::Time BrowsingDataRemover::CalculateBeginDeleteTime(
return delete_begin_time - diff;
}
-void BrowsingDataRemover::ClearDOMStorageInSequencedTask(
- DOMStorageContext* dom_storage_context) {
- // We assume the end time is now.
- DCHECK(dom_storage_context->task_runner()->RunsTasksOnCurrentThread());
- dom_storage_context->DeleteDataModifiedSince(delete_begin_);
-}
-
void BrowsingDataRemover::Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
diff --git a/chrome/browser/browsing_data_remover.h b/chrome/browser/browsing_data_remover.h
index a2459d1c..d474624 100644
--- a/chrome/browser/browsing_data_remover.h
+++ b/chrome/browser/browsing_data_remover.h
@@ -246,10 +246,6 @@ class BrowsingDataRemover : public content::NotificationObserver,
// Calculate the begin time for the deletion range specified by |time_period|.
base::Time CalculateBeginDeleteTime(TimePeriod time_period);
- // Invoked in a background task to clear local storage.
- void ClearDOMStorageInSequencedTask(
- content::DOMStorageContext* dom_storage_context);
-
// Returns true if we're all done.
bool all_done() {
return registrar_.IsEmpty() && !waiting_for_clear_cache_ &&
diff --git a/chrome/browser/extensions/extension_data_deleter.cc b/chrome/browser/extensions/extension_data_deleter.cc
index ab92bae..7ab0f59 100644
--- a/chrome/browser/extensions/extension_data_deleter.cc
+++ b/chrome/browser/extensions/extension_data_deleter.cc
@@ -48,13 +48,8 @@ void ExtensionDataDeleter::StartDeleting(
base::Bind(
&ExtensionDataDeleter::DeleteCookiesOnIOThread, deleter));
- scoped_refptr<DOMStorageContext> dom_storage_context =
- BrowserContext::GetDOMStorageContext(profile);
- dom_storage_context->task_runner()->PostTask(
- FROM_HERE,
- base::Bind(
- &ExtensionDataDeleter::DeleteLocalStorageInSequencedTask, deleter,
- dom_storage_context));
+ BrowserContext::GetDOMStorageContext(profile)->DeleteForOrigin(
+ deleter->origin_id_);
BrowserThread::PostTask(
BrowserThread::WEBKIT_DEPRECATED, FROM_HERE,
@@ -127,12 +122,6 @@ void ExtensionDataDeleter::DeleteDatabaseOnFileThread() {
DCHECK(rv == net::OK || rv == net::ERR_IO_PENDING);
}
-void ExtensionDataDeleter::DeleteLocalStorageInSequencedTask(
- DOMStorageContext* dom_storage_context) {
- DCHECK(dom_storage_context->task_runner()->RunsTasksOnCurrentThread());
- dom_storage_context->DeleteForOrigin(origin_id_);
-}
-
void ExtensionDataDeleter::DeleteIndexedDBOnWebkitThread(
scoped_refptr<IndexedDBContext> indexed_db_context) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED));
diff --git a/chrome/browser/extensions/extension_data_deleter.h b/chrome/browser/extensions/extension_data_deleter.h
index c3ab6ce..41c781b 100644
--- a/chrome/browser/extensions/extension_data_deleter.h
+++ b/chrome/browser/extensions/extension_data_deleter.h
@@ -70,11 +70,6 @@ class ExtensionDataDeleter
// thread.
void DeleteDatabaseOnFileThread();
- // Deletes local storage for the extension. May only be called in a
- // DOMStorageContext sequenced task.
- void DeleteLocalStorageInSequencedTask(
- content::DOMStorageContext* dom_storage_context);
-
// Deletes indexed db files for the extension. May only be called on the
// webkit thread.
void DeleteIndexedDBOnWebkitThread(