summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/in_process_webkit/browser_webkitclient_impl.cc9
-rw-r--r--chrome/browser/in_process_webkit/browser_webkitclient_impl.h1
-rw-r--r--chrome/browser/in_process_webkit/dom_storage_context.cc101
-rw-r--r--chrome/browser/in_process_webkit/dom_storage_context.h28
-rw-r--r--chrome/browser/in_process_webkit/dom_storage_dispatcher_host.cc54
-rw-r--r--chrome/browser/in_process_webkit/dom_storage_dispatcher_host.h2
-rw-r--r--chrome/browser/in_process_webkit/dom_storage_namespace.cc26
-rw-r--r--chrome/browser/in_process_webkit/dom_storage_namespace.h6
-rw-r--r--chrome/browser/in_process_webkit/webkit_context.cc45
-rw-r--r--chrome/browser/in_process_webkit/webkit_context.h8
-rw-r--r--chrome/browser/tab_contents/navigation_controller.cc4
11 files changed, 122 insertions, 162 deletions
diff --git a/chrome/browser/in_process_webkit/browser_webkitclient_impl.cc b/chrome/browser/in_process_webkit/browser_webkitclient_impl.cc
index 4daf282..e0af7ee 100644
--- a/chrome/browser/in_process_webkit/browser_webkitclient_impl.cc
+++ b/chrome/browser/in_process_webkit/browser_webkitclient_impl.cc
@@ -105,15 +105,6 @@ BrowserWebKitClientImpl::createLocalStorageNamespace(
return 0;
}
-WebKit::WebStorageNamespace*
-BrowserWebKitClientImpl::createSessionStorageNamespace() {
- // The "WebStorage" interface is used for renderer WebKit -> browser WebKit
- // communication only. "WebStorageClient" will be used for browser WebKit ->
- // renderer WebKit. So this will never be implemented.
- NOTREACHED();
- return 0;
-}
-
void BrowserWebKitClientImpl::dispatchStorageEvent(
const WebKit::WebString& key, const WebKit::WebString& old_value,
const WebKit::WebString& new_value, const WebKit::WebString& origin,
diff --git a/chrome/browser/in_process_webkit/browser_webkitclient_impl.h b/chrome/browser/in_process_webkit/browser_webkitclient_impl.h
index 0879cc8..831296f 100644
--- a/chrome/browser/in_process_webkit/browser_webkitclient_impl.h
+++ b/chrome/browser/in_process_webkit/browser_webkitclient_impl.h
@@ -33,7 +33,6 @@ class BrowserWebKitClientImpl : public webkit_glue::WebKitClientImpl {
virtual WebKit::WebData loadResource(const char* name);
virtual WebKit::WebStorageNamespace* createLocalStorageNamespace(
const WebKit::WebString& path, unsigned quota);
- virtual WebKit::WebStorageNamespace* createSessionStorageNamespace();
virtual void dispatchStorageEvent(const WebKit::WebString& key,
const WebKit::WebString& oldValue, const WebKit::WebString& newValue,
const WebKit::WebString& origin, const WebKit::WebURL& url,
diff --git a/chrome/browser/in_process_webkit/dom_storage_context.cc b/chrome/browser/in_process_webkit/dom_storage_context.cc
index 15099c2..3997c5f 100644
--- a/chrome/browser/in_process_webkit/dom_storage_context.cc
+++ b/chrome/browser/in_process_webkit/dom_storage_context.cc
@@ -36,37 +36,10 @@ DOMStorageContext::~DOMStorageContext() {
// away. And they remove themselves from this list.
DCHECK(dispatcher_host_set_.empty());
- // If we don't have any work to do on the WebKit thread, bail.
- if (storage_namespace_map_.empty())
- return;
- DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT));
-
- // The storage namespace destructor unregisters the storage namespace, so
- // our iterator becomes invalid. Thus we just keep deleting the first item
- // until there are none left.
- while (!storage_namespace_map_.empty())
- delete storage_namespace_map_.begin()->second;
-}
-
-DOMStorageNamespace* DOMStorageContext::LocalStorage() {
- DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT));
- DOMStorageNamespace* storage_namespace = GetStorageNamespace(
- kLocalStorageNamespaceId);
- if (storage_namespace)
- return storage_namespace;
-
- FilePath data_path = webkit_context_->data_path();
- FilePath dir_path;
- if (!data_path.empty()) {
- MigrateLocalStorageDirectory(data_path);
- dir_path = data_path.AppendASCII(kLocalStorageDirectory);
+ for (StorageNamespaceMap::iterator iter(storage_namespace_map_.begin());
+ iter != storage_namespace_map_.end(); ++iter) {
+ delete iter->second;
}
- return DOMStorageNamespace::CreateLocalStorageNamespace(this, dir_path);
-}
-
-DOMStorageNamespace* DOMStorageContext::NewSessionStorage() {
- DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT));
- return DOMStorageNamespace::CreateSessionStorageNamespace(this);
}
int64 DOMStorageContext::AllocateStorageAreaId() {
@@ -112,28 +85,28 @@ DOMStorageArea* DOMStorageContext::GetStorageArea(int64 id) {
return iter->second;
}
-void DOMStorageContext::RegisterStorageNamespace(
- DOMStorageNamespace* storage_namespace) {
- DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT));
- int64 id = storage_namespace->id();
- DCHECK(!GetStorageNamespace(id));
- storage_namespace_map_[id] = storage_namespace;
-}
-
-void DOMStorageContext::UnregisterStorageNamespace(
- DOMStorageNamespace* storage_namespace) {
+void DOMStorageContext::DeleteSessionStorageNamespace(int64 namespace_id) {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT));
- int64 id = storage_namespace->id();
- DCHECK(GetStorageNamespace(id));
- storage_namespace_map_.erase(id);
+ StorageNamespaceMap::iterator iter =
+ storage_namespace_map_.find(namespace_id);
+ if (iter == storage_namespace_map_.end())
+ return;
+ DCHECK(iter->second->dom_storage_type() == DOM_STORAGE_SESSION);
+ delete iter->second;
+ storage_namespace_map_.erase(iter);
}
-DOMStorageNamespace* DOMStorageContext::GetStorageNamespace(int64 id) {
+DOMStorageNamespace* DOMStorageContext::GetStorageNamespace(
+ int64 id, bool allocation_allowed) {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT));
StorageNamespaceMap::iterator iter = storage_namespace_map_.find(id);
- if (iter == storage_namespace_map_.end())
+ if (iter != storage_namespace_map_.end())
+ return iter->second;
+ if (!allocation_allowed)
return NULL;
- return iter->second;
+ if (id == kLocalStorageNamespaceId)
+ return CreateLocalStorage();
+ return CreateSessionStorage(id);
}
void DOMStorageContext::RegisterDispatcherHost(
@@ -164,7 +137,7 @@ void DOMStorageContext::PurgeMemory() {
// SessionStorage namespace, its data will be gone forever, because it isn't
// currently backed by disk.
DOMStorageNamespace* local_storage =
- GetStorageNamespace(kLocalStorageNamespaceId);
+ GetStorageNamespace(kLocalStorageNamespaceId, false);
if (local_storage)
local_storage->PurgeMemory();
}
@@ -186,12 +159,42 @@ void DOMStorageContext::DeleteDataModifiedSince(const base::Time& cutoff) {
}
}
+DOMStorageNamespace* DOMStorageContext::CreateLocalStorage() {
+ FilePath data_path = webkit_context_->data_path();
+ FilePath dir_path;
+ if (!data_path.empty()) {
+ MigrateLocalStorageDirectory(data_path);
+ dir_path = data_path.AppendASCII(kLocalStorageDirectory);
+ }
+ DOMStorageNamespace* new_namespace =
+ DOMStorageNamespace::CreateLocalStorageNamespace(this, dir_path);
+ RegisterStorageNamespace(new_namespace);
+ return new_namespace;
+}
+
+DOMStorageNamespace* DOMStorageContext::CreateSessionStorage(
+ int64 namespace_id) {
+ DOMStorageNamespace* new_namespace =
+ DOMStorageNamespace::CreateSessionStorageNamespace(this, namespace_id);
+ RegisterStorageNamespace(new_namespace);
+ return new_namespace;
+}
+
+void DOMStorageContext::RegisterStorageNamespace(
+ DOMStorageNamespace* storage_namespace) {
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT));
+ int64 id = storage_namespace->id();
+ DCHECK(!GetStorageNamespace(id, false));
+ storage_namespace_map_[id] = storage_namespace;
+}
+
+/* static */
void DOMStorageContext::CompleteCloningSessionStorage(
DOMStorageContext* context, int64 existing_id, int64 clone_id) {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT));
DOMStorageNamespace* existing_namespace =
- context->GetStorageNamespace(existing_id);
+ context->GetStorageNamespace(existing_id, false);
// If nothing exists, then there's nothing to clone.
if (existing_namespace)
- existing_namespace->Copy(clone_id);
+ context->RegisterStorageNamespace(existing_namespace->Copy(clone_id));
}
diff --git a/chrome/browser/in_process_webkit/dom_storage_context.h b/chrome/browser/in_process_webkit/dom_storage_context.h
index df472f3..fb68f4c9 100644
--- a/chrome/browser/in_process_webkit/dom_storage_context.h
+++ b/chrome/browser/in_process_webkit/dom_storage_context.h
@@ -28,12 +28,6 @@ class DOMStorageContext {
explicit DOMStorageContext(WebKitContext* webkit_context);
virtual ~DOMStorageContext();
- // Get the local storage instance. The pointer is owned by this class.
- DOMStorageNamespace* LocalStorage();
-
- // Get a new session storage namespace (but it's still owned by this class).
- DOMStorageNamespace* NewSessionStorage();
-
// Allocate a new storage area id. Only call on the WebKit thread.
int64 AllocateStorageAreaId();
@@ -50,12 +44,13 @@ class DOMStorageContext {
void UnregisterStorageArea(DOMStorageArea* storage_area);
DOMStorageArea* GetStorageArea(int64 id);
- // Get a namespace from an id. What's returned is owned by this class. The
- // caller of GetStorageNamespace must immediately register itself with the
- // returned StorageNamespace.
- void RegisterStorageNamespace(DOMStorageNamespace* storage_namespace);
- void UnregisterStorageNamespace(DOMStorageNamespace* storage_namespace);
- DOMStorageNamespace* GetStorageNamespace(int64 id);
+ // Called on WebKit thread when a session storage namespace can be deleted.
+ void DeleteSessionStorageNamespace(int64 namespace_id);
+
+ // Get a namespace from an id. What's returned is owned by this class. If
+ // allocation_allowed is true, then this function will create the storage
+ // namespace if it hasn't been already.
+ DOMStorageNamespace* GetStorageNamespace(int64 id, bool allocation_allowed);
// Sometimes an event from one DOM storage dispatcher host requires
// communication to all of them.
@@ -72,6 +67,15 @@ class DOMStorageContext {
void DeleteDataModifiedSince(const base::Time& cutoff);
private:
+ // Get the local storage instance. The object is owned by this class.
+ DOMStorageNamespace* CreateLocalStorage();
+
+ // Get a new session storage namespace. The object is owned by this class.
+ DOMStorageNamespace* CreateSessionStorage(int64 namespace_id);
+
+ // Used internally to register storage namespaces we create.
+ void RegisterStorageNamespace(DOMStorageNamespace* storage_namespace);
+
// The WebKit thread half of CloneSessionStorage above. Static because
// DOMStorageContext isn't ref counted thus we can't use a runnable method.
// That said, we know this is safe because this class is destroyed on the
diff --git a/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.cc b/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.cc
index dc8e3f3..31ed956 100644
--- a/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.cc
+++ b/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.cc
@@ -112,10 +112,6 @@ bool DOMStorageDispatcherHost::OnMessageReceived(const IPC::Message& message,
bool handled = true;
IPC_BEGIN_MESSAGE_MAP_EX(DOMStorageDispatcherHost, message, *msg_is_ok)
- IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_DOMStorageNamespaceId,
- OnNamespaceId)
- IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_DOMStorageCloneNamespaceId,
- OnCloneNamespaceId)
IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_DOMStorageStorageAreaId,
OnStorageAreaId)
IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_DOMStorageLength, OnLength)
@@ -151,50 +147,6 @@ void DOMStorageDispatcherHost::Send(IPC::Message* message) {
NewRunnableMethod(this, &DOMStorageDispatcherHost::Send, message));
}
-void DOMStorageDispatcherHost::OnNamespaceId(DOMStorageType storage_type,
- IPC::Message* reply_msg) {
- if (ChromeThread::CurrentlyOn(ChromeThread::IO)) {
- ChromeThread::PostTask(ChromeThread::WEBKIT, FROM_HERE, NewRunnableMethod(
- this, &DOMStorageDispatcherHost::OnNamespaceId, storage_type,
- reply_msg));
- return;
- }
-
- DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT));
- DOMStorageNamespace* new_namespace;
- if (storage_type == DOM_STORAGE_LOCAL)
- new_namespace = Context()->LocalStorage();
- else
- new_namespace = Context()->NewSessionStorage();
- ViewHostMsg_DOMStorageNamespaceId::WriteReplyParams(reply_msg,
- new_namespace->id());
- Send(reply_msg);
-}
-
-void DOMStorageDispatcherHost::OnCloneNamespaceId(int64 namespace_id,
- IPC::Message* reply_msg) {
- if (ChromeThread::CurrentlyOn(ChromeThread::IO)) {
- ChromeThread::PostTask(ChromeThread::WEBKIT, FROM_HERE, NewRunnableMethod(
- this, &DOMStorageDispatcherHost::OnCloneNamespaceId, namespace_id,
- reply_msg));
- return;
- }
-
- DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT));
- DOMStorageNamespace* existing_namespace =
- Context()->GetStorageNamespace(namespace_id);
- if (!existing_namespace) {
- BrowserRenderProcessHost::BadMessageTerminateProcess(
- ViewHostMsg_DOMStorageCloneNamespaceId::ID, process_handle_);
- delete reply_msg;
- return;
- }
- DOMStorageNamespace* new_namespace = existing_namespace->Copy();
- ViewHostMsg_DOMStorageCloneNamespaceId::WriteReplyParams(reply_msg,
- new_namespace->id());
- Send(reply_msg);
-}
-
void DOMStorageDispatcherHost::OnStorageAreaId(int64 namespace_id,
const string16& origin,
IPC::Message* reply_msg) {
@@ -207,7 +159,7 @@ void DOMStorageDispatcherHost::OnStorageAreaId(int64 namespace_id,
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT));
DOMStorageNamespace* storage_namespace =
- Context()->GetStorageNamespace(namespace_id);
+ Context()->GetStorageNamespace(namespace_id, true);
if (!storage_namespace) {
BrowserRenderProcessHost::BadMessageTerminateProcess(
ViewHostMsg_DOMStorageStorageAreaId::ID, process_handle_);
@@ -215,8 +167,8 @@ void DOMStorageDispatcherHost::OnStorageAreaId(int64 namespace_id,
return;
}
DOMStorageArea* storage_area = storage_namespace->GetStorageArea(origin);
- ViewHostMsg_DOMStorageCloneNamespaceId::WriteReplyParams(reply_msg,
- storage_area->id());
+ ViewHostMsg_DOMStorageStorageAreaId::WriteReplyParams(reply_msg,
+ storage_area->id());
Send(reply_msg);
}
diff --git a/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.h b/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.h
index 24aa739..55a87b5 100644
--- a/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.h
+++ b/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.h
@@ -57,8 +57,6 @@ class DOMStorageDispatcherHost
~DOMStorageDispatcherHost();
// Message Handlers.
- void OnNamespaceId(DOMStorageType storage_type, IPC::Message* reply_msg);
- void OnCloneNamespaceId(int64 namespace_id, IPC::Message* reply_msg);
void OnStorageAreaId(int64 namespace_id, const string16& origin,
IPC::Message* reply_msg);
void OnLength(int64 storage_area_id, IPC::Message* reply_msg);
diff --git a/chrome/browser/in_process_webkit/dom_storage_namespace.cc b/chrome/browser/in_process_webkit/dom_storage_namespace.cc
index 924d954..2750a9f 100644
--- a/chrome/browser/in_process_webkit/dom_storage_namespace.cc
+++ b/chrome/browser/in_process_webkit/dom_storage_namespace.cc
@@ -20,16 +20,15 @@ using WebKit::WebString;
DOMStorageNamespace* DOMStorageNamespace::CreateLocalStorageNamespace(
DOMStorageContext* dom_storage_context, const FilePath& data_dir_path) {
int64 id = kLocalStorageNamespaceId;
- DCHECK(!dom_storage_context->GetStorageNamespace(id));
+ DCHECK(!dom_storage_context->GetStorageNamespace(id, false));
return new DOMStorageNamespace(dom_storage_context, id,
webkit_glue::FilePathToWebString(data_dir_path), DOM_STORAGE_LOCAL);
}
/* static */
DOMStorageNamespace* DOMStorageNamespace::CreateSessionStorageNamespace(
- DOMStorageContext* dom_storage_context) {
- int64 id = dom_storage_context->AllocateSessionStorageNamespaceId();
- DCHECK(!dom_storage_context->GetStorageNamespace(id));
+ DOMStorageContext* dom_storage_context, int64 id) {
+ DCHECK(!dom_storage_context->GetStorageNamespace(id, false));
return new DOMStorageNamespace(dom_storage_context, id, WebString(),
DOM_STORAGE_SESSION);
}
@@ -43,12 +42,11 @@ DOMStorageNamespace::DOMStorageNamespace(DOMStorageContext* dom_storage_context,
data_dir_path_(data_dir_path),
dom_storage_type_(dom_storage_type) {
DCHECK(dom_storage_context_);
- dom_storage_context_->RegisterStorageNamespace(this);
}
DOMStorageNamespace::~DOMStorageNamespace() {
- dom_storage_context_->UnregisterStorageNamespace(this);
-
+ // TODO(jorlow): If the DOMStorageContext is being destructed, there's no need
+ // to do these calls. Maybe we should add a fast path?
for (OriginToStorageAreaMap::iterator iter(origin_to_storage_area_.begin());
iter != origin_to_storage_area_.end(); ++iter) {
dom_storage_context_->UnregisterStorageArea(iter->second);
@@ -71,23 +69,19 @@ DOMStorageArea* DOMStorageNamespace::GetStorageArea(const string16& origin) {
return storage_area;
}
-// TODO(jorlow): Remove in the next patch.
-DOMStorageNamespace* DOMStorageNamespace::Copy() {
- int64 id = dom_storage_context_->AllocateSessionStorageNamespaceId();
- return Copy(id);
-}
-
DOMStorageNamespace* DOMStorageNamespace::Copy(int64 id) {
DCHECK(dom_storage_type_ == DOM_STORAGE_SESSION);
- DCHECK(!dom_storage_context_->GetStorageNamespace(id));
+ DCHECK(!dom_storage_context_->GetStorageNamespace(id, false));
DOMStorageNamespace* new_storage_namespace = new DOMStorageNamespace(
dom_storage_context_, id, data_dir_path_, dom_storage_type_);
- CreateWebStorageNamespaceIfNecessary();
- new_storage_namespace->storage_namespace_.reset(storage_namespace_->copy());
+ // If we haven't used the namespace yet, there's nothing to copy.
+ if (storage_namespace_.get())
+ new_storage_namespace->storage_namespace_.reset(storage_namespace_->copy());
return new_storage_namespace;
}
void DOMStorageNamespace::PurgeMemory() {
+ DCHECK(dom_storage_type_ == DOM_STORAGE_LOCAL);
for (OriginToStorageAreaMap::iterator iter(origin_to_storage_area_.begin());
iter != origin_to_storage_area_.end(); ++iter)
iter->second->PurgeMemory();
diff --git a/chrome/browser/in_process_webkit/dom_storage_namespace.h b/chrome/browser/in_process_webkit/dom_storage_namespace.h
index c317c67..189d696 100644
--- a/chrome/browser/in_process_webkit/dom_storage_namespace.h
+++ b/chrome/browser/in_process_webkit/dom_storage_namespace.h
@@ -26,13 +26,13 @@ class DOMStorageNamespace {
static DOMStorageNamespace* CreateLocalStorageNamespace(
DOMStorageContext* dom_storage_context, const FilePath& data_dir_path);
static DOMStorageNamespace* CreateSessionStorageNamespace(
- DOMStorageContext* dom_storage_context);
+ DOMStorageContext* dom_storage_context, int64 namespace_id);
~DOMStorageNamespace();
DOMStorageArea* GetStorageArea(const string16& origin);
- DOMStorageNamespace* Copy(); // TODO(jorlow): Delete in next patch.
- DOMStorageNamespace* Copy(int64 id);
+ DOMStorageNamespace* Copy(int64 clone_namespace_id);
+
void PurgeMemory();
const DOMStorageContext* dom_storage_context() const {
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);
}
diff --git a/chrome/browser/in_process_webkit/webkit_context.h b/chrome/browser/in_process_webkit/webkit_context.h
index 38d9d7d..229e47f 100644
--- a/chrome/browser/in_process_webkit/webkit_context.h
+++ b/chrome/browser/in_process_webkit/webkit_context.h
@@ -14,7 +14,9 @@
class WebKitThread;
// There's one WebKitContext per profile. Various DispatcherHost classes
-// have a pointer to the Context to store shared state.
+// have a pointer to the Context to store shared state. Unfortunately, this
+// class has become a bit of a dumping ground for calls made on the UI thread
+// that need to be proxied over to the WebKit thread.
//
// This class is created on the UI thread and accessed on the UI, IO, and WebKit
// threads.
@@ -43,6 +45,10 @@ class WebKitContext : public base::RefCountedThreadSafe<WebKitContext> {
// last modified on or after the following time.
void DeleteDataModifiedSince(const base::Time& cutoff);
+ // Delete the session storage namespace associated with this id. Called from
+ // the UI thread.
+ void DeleteSessionStorageNamespace(int64 session_storage_namespace_id);
+
private:
friend class base::RefCountedThreadSafe<WebKitContext>;
~WebKitContext();
diff --git a/chrome/browser/tab_contents/navigation_controller.cc b/chrome/browser/tab_contents/navigation_controller.cc
index 83e7ba5..129bca2 100644
--- a/chrome/browser/tab_contents/navigation_controller.cc
+++ b/chrome/browser/tab_contents/navigation_controller.cc
@@ -149,6 +149,10 @@ NavigationController::~NavigationController() {
NotificationType::TAB_CLOSED,
Source<NavigationController>(this),
NotificationService::NoDetails());
+
+ // When we go away, the session storage namespace will no longer be reachable.
+ profile_->GetWebKitContext()->DeleteSessionStorageNamespace(
+ session_storage_namespace_id_);
}
void NavigationController::RestoreFromState(