summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/browsing_data_local_storage_helper.cc37
-rw-r--r--chrome/browser/browsing_data_local_storage_helper.h14
-rw-r--r--chrome/browser/browsing_data_remover.cc14
-rw-r--r--chrome/browser/browsing_data_remover.h6
-rw-r--r--chrome/browser/extensions/extension_data_deleter.cc16
-rw-r--r--chrome/browser/extensions/extension_data_deleter.h8
-rw-r--r--content/browser/in_process_webkit/dom_storage_context_impl.cc9
-rw-r--r--content/browser/in_process_webkit/dom_storage_context_impl.h7
-rw-r--r--content/public/browser/dom_storage_context.h7
9 files changed, 67 insertions, 51 deletions
diff --git a/chrome/browser/browsing_data_local_storage_helper.cc b/chrome/browser/browsing_data_local_storage_helper.cc
index 57305d8..ff66398 100644
--- a/chrome/browser/browsing_data_local_storage_helper.cc
+++ b/chrome/browser/browsing_data_local_storage_helper.cc
@@ -66,10 +66,10 @@ void BrowsingDataLocalStorageHelper::StartFetching(
is_fetching_ = true;
completion_callback_ = callback;
- BrowserThread::PostTask(
- BrowserThread::WEBKIT_DEPRECATED, FROM_HERE,
+ dom_storage_context_->task_runner()->PostTask(
+ FROM_HERE,
base::Bind(
- &BrowsingDataLocalStorageHelper::FetchLocalStorageInfoInWebKitThread,
+ &BrowsingDataLocalStorageHelper::FetchLocalStorageInfoHelper,
this));
}
@@ -81,15 +81,15 @@ void BrowsingDataLocalStorageHelper::CancelNotification() {
void BrowsingDataLocalStorageHelper::DeleteLocalStorageFile(
const FilePath& file_path) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- BrowserThread::PostTask(
- BrowserThread::WEBKIT_DEPRECATED, FROM_HERE,
+ dom_storage_context_->task_runner()->PostTask(
+ FROM_HERE,
base::Bind(
- &BrowsingDataLocalStorageHelper::DeleteLocalStorageFileInWebKitThread,
+ &BrowsingDataLocalStorageHelper::DeleteLocalStorageFileHelper,
this, file_path));
}
-void BrowsingDataLocalStorageHelper::FetchLocalStorageInfoInWebKitThread() {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED));
+void BrowsingDataLocalStorageHelper::FetchLocalStorageInfoHelper() {
+ DCHECK(dom_storage_context_->task_runner()->RunsTasksOnCurrentThread());
std::vector<FilePath> files = dom_storage_context_->GetAllStorageFiles();
for (size_t i = 0; i < files.size(); ++i) {
FilePath file_path = files[i];
@@ -132,12 +132,14 @@ void BrowsingDataLocalStorageHelper::NotifyInUIThread() {
is_fetching_ = false;
}
-void BrowsingDataLocalStorageHelper::DeleteLocalStorageFileInWebKitThread(
+void BrowsingDataLocalStorageHelper::DeleteLocalStorageFileHelper(
const FilePath& file_path) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED));
+ DCHECK(dom_storage_context_->task_runner()->RunsTasksOnCurrentThread());
dom_storage_context_->DeleteLocalStorageFile(file_path);
}
+//---------------------------------------------------------
+
CannedBrowsingDataLocalStorageHelper::CannedBrowsingDataLocalStorageHelper(
Profile* profile)
: BrowsingDataLocalStorageHelper(profile),
@@ -150,7 +152,6 @@ CannedBrowsingDataLocalStorageHelper::Clone() {
CannedBrowsingDataLocalStorageHelper* clone =
new CannedBrowsingDataLocalStorageHelper(profile_);
- base::AutoLock auto_lock(lock_);
clone->pending_local_storage_info_ = pending_local_storage_info_;
clone->local_storage_info_ = local_storage_info_;
return clone;
@@ -158,18 +159,15 @@ CannedBrowsingDataLocalStorageHelper::Clone() {
void CannedBrowsingDataLocalStorageHelper::AddLocalStorage(
const GURL& origin) {
- base::AutoLock auto_lock(lock_);
pending_local_storage_info_.insert(origin);
}
void CannedBrowsingDataLocalStorageHelper::Reset() {
- base::AutoLock auto_lock(lock_);
local_storage_info_.clear();
pending_local_storage_info_.clear();
}
bool CannedBrowsingDataLocalStorageHelper::empty() const {
- base::AutoLock auto_lock(lock_);
return local_storage_info_.empty() && pending_local_storage_info_.empty();
}
@@ -181,16 +179,17 @@ void CannedBrowsingDataLocalStorageHelper::StartFetching(
is_fetching_ = true;
completion_callback_ = callback;
- BrowserThread::PostTask(
- BrowserThread::WEBKIT_DEPRECATED, FROM_HERE,
+
+ // We post a task to emulate async fetching behavior.
+ MessageLoop::current()->PostTask(
+ FROM_HERE,
base::Bind(&CannedBrowsingDataLocalStorageHelper::
- ConvertPendingInfoInWebKitThread, this));
+ ConvertPendingInfo, this));
}
CannedBrowsingDataLocalStorageHelper::~CannedBrowsingDataLocalStorageHelper() {}
-void CannedBrowsingDataLocalStorageHelper::ConvertPendingInfoInWebKitThread() {
- base::AutoLock auto_lock(lock_);
+void CannedBrowsingDataLocalStorageHelper::ConvertPendingInfo() {
for (std::set<GURL>::iterator info = pending_local_storage_info_.begin();
info != pending_local_storage_info_.end(); ++info) {
WebSecurityOrigin web_security_origin =
diff --git a/chrome/browser/browsing_data_local_storage_helper.h b/chrome/browser/browsing_data_local_storage_helper.h
index 4cb8880..a2c79fe 100644
--- a/chrome/browser/browsing_data_local_storage_helper.h
+++ b/chrome/browser/browsing_data_local_storage_helper.h
@@ -99,10 +99,10 @@ class BrowsingDataLocalStorageHelper
std::list<LocalStorageInfo> local_storage_info_;
private:
- // Enumerates all local storage files in the WEBKIT thread.
- void FetchLocalStorageInfoInWebKitThread();
- // Delete a single local storage file in the WEBKIT thread.
- void DeleteLocalStorageFileInWebKitThread(const FilePath& file_path);
+ // 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);
DISALLOW_COPY_AND_ASSIGN(BrowsingDataLocalStorageHelper);
};
@@ -140,12 +140,8 @@ class CannedBrowsingDataLocalStorageHelper
virtual ~CannedBrowsingDataLocalStorageHelper();
// Convert the pending local storage info to local storage info objects.
- void ConvertPendingInfoInWebKitThread();
+ void ConvertPendingInfo();
- // Used to protect access to pending_local_storage_info_.
- mutable base::Lock lock_;
-
- // May mutate on WEBKIT and UI threads.
std::set<GURL> pending_local_storage_info_;
Profile* profile_;
diff --git a/chrome/browser/browsing_data_remover.cc b/chrome/browser/browsing_data_remover.cc
index d78154c..0612dde 100644
--- a/chrome/browser/browsing_data_remover.cc
+++ b/chrome/browser/browsing_data_remover.cc
@@ -302,12 +302,11 @@ void BrowsingDataRemover::RemoveImpl(int remove_mask,
}
}
- if (remove_mask & REMOVE_LOCAL_STORAGE &&
- BrowserThread::IsMessageLoopValid(BrowserThread::WEBKIT_DEPRECATED)) {
+ if (remove_mask & REMOVE_LOCAL_STORAGE) {
DOMStorageContext* context = BrowserContext::GetDOMStorageContext(profile_);
- BrowserThread::PostTask(
- BrowserThread::WEBKIT_DEPRECATED, FROM_HERE,
- base::Bind(&BrowsingDataRemover::ClearDOMStorageOnWebKitThread,
+ context->task_runner()->PostTask(
+ FROM_HERE,
+ base::Bind(&BrowsingDataRemover::ClearDOMStorageInSequencedTask,
base::Unretained(this), make_scoped_refptr(context)));
}
@@ -437,9 +436,10 @@ base::Time BrowsingDataRemover::CalculateBeginDeleteTime(
return delete_begin_time - diff;
}
-void BrowsingDataRemover::ClearDOMStorageOnWebKitThread(
- scoped_refptr<DOMStorageContext> dom_storage_context) {
+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_);
}
diff --git a/chrome/browser/browsing_data_remover.h b/chrome/browser/browsing_data_remover.h
index b54ef03..a2459d1c 100644
--- a/chrome/browser/browsing_data_remover.h
+++ b/chrome/browser/browsing_data_remover.h
@@ -246,9 +246,9 @@ class BrowsingDataRemover : public content::NotificationObserver,
// Calculate the begin time for the deletion range specified by |time_period|.
base::Time CalculateBeginDeleteTime(TimePeriod time_period);
- // Invoked on the WEBKIT thread to clear local storage.
- void ClearDOMStorageOnWebKitThread(
- scoped_refptr<content::DOMStorageContext> dom_storage_context);
+ // 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() {
diff --git a/chrome/browser/extensions/extension_data_deleter.cc b/chrome/browser/extensions/extension_data_deleter.cc
index 3cae231..ab92bae 100644
--- a/chrome/browser/extensions/extension_data_deleter.cc
+++ b/chrome/browser/extensions/extension_data_deleter.cc
@@ -48,11 +48,13 @@ void ExtensionDataDeleter::StartDeleting(
base::Bind(
&ExtensionDataDeleter::DeleteCookiesOnIOThread, deleter));
- BrowserThread::PostTask(
- BrowserThread::WEBKIT_DEPRECATED, FROM_HERE,
+ scoped_refptr<DOMStorageContext> dom_storage_context =
+ BrowserContext::GetDOMStorageContext(profile);
+ dom_storage_context->task_runner()->PostTask(
+ FROM_HERE,
base::Bind(
- &ExtensionDataDeleter::DeleteLocalStorageOnWebkitThread, deleter,
- make_scoped_refptr(BrowserContext::GetDOMStorageContext(profile))));
+ &ExtensionDataDeleter::DeleteLocalStorageInSequencedTask, deleter,
+ dom_storage_context));
BrowserThread::PostTask(
BrowserThread::WEBKIT_DEPRECATED, FROM_HERE,
@@ -125,9 +127,9 @@ void ExtensionDataDeleter::DeleteDatabaseOnFileThread() {
DCHECK(rv == net::OK || rv == net::ERR_IO_PENDING);
}
-void ExtensionDataDeleter::DeleteLocalStorageOnWebkitThread(
- scoped_refptr<DOMStorageContext> dom_storage_context) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED));
+void ExtensionDataDeleter::DeleteLocalStorageInSequencedTask(
+ DOMStorageContext* dom_storage_context) {
+ DCHECK(dom_storage_context->task_runner()->RunsTasksOnCurrentThread());
dom_storage_context->DeleteForOrigin(origin_id_);
}
diff --git a/chrome/browser/extensions/extension_data_deleter.h b/chrome/browser/extensions/extension_data_deleter.h
index 6732445..c3ab6ce 100644
--- a/chrome/browser/extensions/extension_data_deleter.h
+++ b/chrome/browser/extensions/extension_data_deleter.h
@@ -70,10 +70,10 @@ class ExtensionDataDeleter
// thread.
void DeleteDatabaseOnFileThread();
- // Deletes local storage for the extension. May only be called on the webkit
- // thread.
- void DeleteLocalStorageOnWebkitThread(
- scoped_refptr<content::DOMStorageContext> dom_storage_context);
+ // 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.
diff --git a/content/browser/in_process_webkit/dom_storage_context_impl.cc b/content/browser/in_process_webkit/dom_storage_context_impl.cc
index b4d3bf6..1be7c3f 100644
--- a/content/browser/in_process_webkit/dom_storage_context_impl.cc
+++ b/content/browser/in_process_webkit/dom_storage_context_impl.cc
@@ -64,7 +64,10 @@ DOMStorageContextImpl::DOMStorageContextImpl(
last_session_storage_namespace_id_on_io_thread_(kLocalStorageNamespaceId),
clear_local_state_on_exit_(false),
save_session_state_(false),
- special_storage_policy_(special_storage_policy) {
+ special_storage_policy_(special_storage_policy),
+ webkit_message_loop_(
+ BrowserThread::GetMessageLoopProxyForThread(
+ BrowserThread::WEBKIT_DEPRECATED)) {
data_path_ = data_path;
}
@@ -292,6 +295,10 @@ void DOMStorageContextImpl::CompleteCloningSessionStorage(
RegisterStorageNamespace(existing_namespace->Copy(clone_id));
}
+base::SequencedTaskRunner* DOMStorageContextImpl::task_runner() const {
+ return webkit_message_loop_;
+}
+
std::vector<FilePath> DOMStorageContextImpl::GetAllStorageFiles() {
std::vector<FilePath> files;
file_util::FileEnumerator file_enumerator(
diff --git a/content/browser/in_process_webkit/dom_storage_context_impl.h b/content/browser/in_process_webkit/dom_storage_context_impl.h
index 701b68a..2cd84f5 100644
--- a/content/browser/in_process_webkit/dom_storage_context_impl.h
+++ b/content/browser/in_process_webkit/dom_storage_context_impl.h
@@ -19,6 +19,11 @@ class DOMStorageArea;
class DOMStorageMessageFilter;
class DOMStorageNamespace;
+namespace base {
+class MessageLoopProxy;
+class SequencedTaskRunner;
+}
+
namespace quota {
class SpecialStoragePolicy;
}
@@ -37,6 +42,7 @@ class CONTENT_EXPORT DOMStorageContextImpl :
virtual ~DOMStorageContextImpl();
// DOMStorageContext implementation:
+ virtual base::SequencedTaskRunner* task_runner() const OVERRIDE;
virtual std::vector<FilePath> GetAllStorageFiles() OVERRIDE;
virtual FilePath GetFilePath(const string16& origin_id) const OVERRIDE;
virtual void DeleteForOrigin(const string16& origin_id) OVERRIDE;
@@ -156,6 +162,7 @@ class CONTENT_EXPORT DOMStorageContextImpl :
StorageNamespaceMap storage_namespace_map_;
scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_;
+ scoped_refptr<base::MessageLoopProxy> webkit_message_loop_;
DISALLOW_IMPLICIT_CONSTRUCTORS(DOMStorageContextImpl);
};
diff --git a/content/public/browser/dom_storage_context.h b/content/public/browser/dom_storage_context.h
index 68415f1..9d21ebb 100644
--- a/content/public/browser/dom_storage_context.h
+++ b/content/public/browser/dom_storage_context.h
@@ -15,6 +15,7 @@
class FilePath;
namespace base {
+class SequencedTaskRunner;
class Time;
}
@@ -23,11 +24,15 @@ namespace content {
class BrowserContext;
// Represents the per-BrowserContext Local Storage data.
-// Call these methods only on the WebKit thread.
+// Call these methods only on tasks scheduled via it's task_runner().
class DOMStorageContext : public base::RefCountedThreadSafe<DOMStorageContext> {
public:
virtual ~DOMStorageContext() {}
+ // Returns a task runner which should be used to schedule tasks
+ // which can invoke the other methods of this interface.
+ virtual base::SequencedTaskRunner* task_runner() const = 0;
+
// Returns all the file paths of local storage files.
virtual std::vector<FilePath> GetAllStorageFiles() = 0;