summaryrefslogtreecommitdiffstats
path: root/chrome/browser/in_process_webkit/webkit_context.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/in_process_webkit/webkit_context.cc')
-rw-r--r--chrome/browser/in_process_webkit/webkit_context.cc45
1 files changed, 27 insertions, 18 deletions
diff --git a/chrome/browser/in_process_webkit/webkit_context.cc b/chrome/browser/in_process_webkit/webkit_context.cc
index 5fdb358..783f7a6 100644
--- a/chrome/browser/in_process_webkit/webkit_context.cc
+++ b/chrome/browser/in_process_webkit/webkit_context.cc
@@ -15,7 +15,8 @@ WebKitContext::WebKitContext(const FilePath& data_path, bool is_incognito)
WebKitContext::~WebKitContext() {
// If the WebKit thread was ever spun up, delete the object there. The task
- // will just get deleted if the WebKit thread isn't created.
+ // will just get deleted if the WebKit thread isn't created (which only
+ // happens during testing).
DOMStorageContext* dom_storage_context = dom_storage_context_.release();
if (!ChromeThread::DeleteSoon(
ChromeThread::WEBKIT, FROM_HERE, dom_storage_context)) {
@@ -26,33 +27,41 @@ WebKitContext::~WebKitContext() {
}
void WebKitContext::PurgeMemory() {
- // DOMStorageContext::PurgeMemory() should only be called on the WebKit
- // thread.
- //
- // Note that if there is no WebKit thread, then there's nothing in
- // LocalStorage and it's OK to no-op here.
- if (ChromeThread::CurrentlyOn(ChromeThread::WEBKIT)) {
- dom_storage_context_->PurgeMemory();
- } else {
- // Since we're not on the WebKit thread, proxy the call over to it. We
- // can't post a task to call DOMStorageContext::PurgeMemory() directly
- // because that class is not refcounted.
- ChromeThread::PostTask(
+ if (!ChromeThread::CurrentlyOn(ChromeThread::WEBKIT)) {
+ bool result = ChromeThread::PostTask(
ChromeThread::WEBKIT, FROM_HERE,
NewRunnableMethod(this, &WebKitContext::PurgeMemory));
+ DCHECK(result);
+ return;
}
+
+ dom_storage_context_->PurgeMemory();
}
void WebKitContext::DeleteDataModifiedSince(const base::Time& cutoff) {
- // DOMStorageContext::DeleteDataModifiedSince() should only be called on the
- // WebKit thread.
- if (ChromeThread::CurrentlyOn(ChromeThread::WEBKIT)) {
- dom_storage_context_->DeleteDataModifiedSince(cutoff);
- } else {
+ if (!ChromeThread::CurrentlyOn(ChromeThread::WEBKIT)) {
bool result = ChromeThread::PostTask(
ChromeThread::WEBKIT, FROM_HERE,
NewRunnableMethod(this, &WebKitContext::DeleteDataModifiedSince,
cutoff));
DCHECK(result);
+ return;
+ }
+
+ dom_storage_context_->DeleteDataModifiedSince(cutoff);
+}
+
+
+void WebKitContext::DeleteSessionStorageNamespace(
+ int64 session_storage_namespace_id) {
+ if (!ChromeThread::CurrentlyOn(ChromeThread::WEBKIT)) {
+ ChromeThread::PostTask(
+ ChromeThread::WEBKIT, FROM_HERE,
+ NewRunnableMethod(this, &WebKitContext::DeleteSessionStorageNamespace,
+ session_storage_namespace_id));
+ return;
}
+
+ dom_storage_context_->DeleteSessionStorageNamespace(
+ session_storage_namespace_id);
}