| Index: chrome/browser/in_process_webkit/dom_storage_context.cc
|
| ===================================================================
|
| --- chrome/browser/in_process_webkit/dom_storage_context.cc (revision 27652)
|
| +++ chrome/browser/in_process_webkit/dom_storage_context.cc (working copy)
|
| @@ -14,11 +14,18 @@
|
| : last_storage_area_id_(kFirstStorageAreaId),
|
| last_storage_namespace_id_(kFirstStorageNamespaceId),
|
| webkit_context_(webkit_context) {
|
| - DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT));
|
| }
|
|
|
| DOMStorageContext::~DOMStorageContext() {
|
| + // This should not go away until all DOM Storage Dispatcher hosts have gone
|
| + // 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.
|
| @@ -27,6 +34,7 @@
|
| }
|
|
|
| StorageNamespace* DOMStorageContext::LocalStorage() {
|
| + DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT));
|
| StorageNamespace* storage_namespace = GetStorageNamespace(
|
| kLocalStorageNamespaceId);
|
| if (storage_namespace)
|
| @@ -40,22 +48,26 @@
|
| }
|
|
|
| StorageNamespace* DOMStorageContext::NewSessionStorage() {
|
| + DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT));
|
| return StorageNamespace::CreateSessionStorageNamespace(this);
|
| }
|
|
|
| void DOMStorageContext::RegisterStorageArea(StorageArea* storage_area) {
|
| + DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT));
|
| int64 id = storage_area->id();
|
| DCHECK(!GetStorageArea(id));
|
| storage_area_map_[id] = storage_area;
|
| }
|
|
|
| void DOMStorageContext::UnregisterStorageArea(StorageArea* storage_area) {
|
| + DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT));
|
| int64 id = storage_area->id();
|
| DCHECK(GetStorageArea(id));
|
| storage_area_map_.erase(id);
|
| }
|
|
|
| StorageArea* DOMStorageContext::GetStorageArea(int64 id) {
|
| + DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT));
|
| StorageAreaMap::iterator iter = storage_area_map_.find(id);
|
| if (iter == storage_area_map_.end())
|
| return NULL;
|
| @@ -64,6 +76,7 @@
|
|
|
| void DOMStorageContext::RegisterStorageNamespace(
|
| StorageNamespace* storage_namespace) {
|
| + DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT));
|
| int64 id = storage_namespace->id();
|
| DCHECK(!GetStorageNamespace(id));
|
| storage_namespace_map_[id] = storage_namespace;
|
| @@ -71,14 +84,38 @@
|
|
|
| void DOMStorageContext::UnregisterStorageNamespace(
|
| StorageNamespace* storage_namespace) {
|
| + DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT));
|
| int64 id = storage_namespace->id();
|
| DCHECK(GetStorageNamespace(id));
|
| storage_namespace_map_.erase(id);
|
| }
|
|
|
| StorageNamespace* DOMStorageContext::GetStorageNamespace(int64 id) {
|
| + DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT));
|
| StorageNamespaceMap::iterator iter = storage_namespace_map_.find(id);
|
| if (iter == storage_namespace_map_.end())
|
| return NULL;
|
| return iter->second;
|
| }
|
| +
|
| +void DOMStorageContext::RegisterDispatcherHost(
|
| + DOMStorageDispatcherHost* dispatcher_host) {
|
| + DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
|
| + DCHECK(dispatcher_host_set_.find(dispatcher_host) ==
|
| + dispatcher_host_set_.end());
|
| + dispatcher_host_set_.insert(dispatcher_host);
|
| +}
|
| +
|
| +void DOMStorageContext::UnregisterDispatcherHost(
|
| + DOMStorageDispatcherHost* dispatcher_host) {
|
| + DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
|
| + DCHECK(dispatcher_host_set_.find(dispatcher_host) !=
|
| + dispatcher_host_set_.end());
|
| + dispatcher_host_set_.erase(dispatcher_host);
|
| +}
|
| +
|
| +const DOMStorageContext::DispatcherHostSet*
|
| +DOMStorageContext::GetDispatcherHostSet() const {
|
| + DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
|
| + return &dispatcher_host_set_;
|
| +}
|
|
|