summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/webkit/WebCore/storage/StorageNamespaceImpl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/webkit/WebCore/storage/StorageNamespaceImpl.cpp')
-rw-r--r--src/3rdparty/webkit/WebCore/storage/StorageNamespaceImpl.cpp33
1 files changed, 22 insertions, 11 deletions
diff --git a/src/3rdparty/webkit/WebCore/storage/StorageNamespaceImpl.cpp b/src/3rdparty/webkit/WebCore/storage/StorageNamespaceImpl.cpp
index 8b08a27..5ac22cf 100644
--- a/src/3rdparty/webkit/WebCore/storage/StorageNamespaceImpl.cpp
+++ b/src/3rdparty/webkit/WebCore/storage/StorageNamespaceImpl.cpp
@@ -64,11 +64,9 @@ PassRefPtr<StorageNamespace> StorageNamespaceImpl::sessionStorageNamespace()
StorageNamespaceImpl::StorageNamespaceImpl(StorageType storageType, const String& path)
: m_storageType(storageType)
- , m_path(path.copy()) // FIXME: Is the .copy necessary?
+ , m_path(path.copy()) // Copy makes it safe for our other thread to access the path.
, m_syncManager(0)
-#ifndef NDEBUG
, m_isShutdown(false)
-#endif
{
if (m_storageType == LocalStorage && !m_path.isEmpty())
m_syncManager = StorageSyncManager::create(m_path);
@@ -82,21 +80,22 @@ StorageNamespaceImpl::~StorageNamespaceImpl()
ASSERT(localStorageNamespaceMap().get(m_path) == this);
localStorageNamespaceMap().remove(m_path);
}
+
+ if (!m_isShutdown)
+ close();
}
PassRefPtr<StorageNamespace> StorageNamespaceImpl::copy()
{
ASSERT(isMainThread());
ASSERT(!m_isShutdown);
+ ASSERT(m_storageType == SessionStorage);
StorageNamespaceImpl* newNamespace = new StorageNamespaceImpl(m_storageType, m_path);
StorageAreaMap::iterator end = m_storageAreaMap.end();
- for (StorageAreaMap::iterator i = m_storageAreaMap.begin(); i != end; ++i) {
- RefPtr<StorageAreaImpl> areaCopy = i->second->copy(i->first.get());
- newNamespace->m_storageAreaMap.set(i->first, areaCopy.release());
- }
-
+ for (StorageAreaMap::iterator i = m_storageAreaMap.begin(); i != end; ++i)
+ newNamespace->m_storageAreaMap.set(i->first, i->second->copy());
return adoptRef(newNamespace);
}
@@ -109,7 +108,7 @@ PassRefPtr<StorageArea> StorageNamespaceImpl::storageArea(SecurityOrigin* origin
if (storageArea = m_storageAreaMap.get(origin))
return storageArea.release();
- storageArea = new StorageAreaImpl(m_storageType, origin, m_syncManager);
+ storageArea = adoptRef(new StorageAreaImpl(m_storageType, origin, m_syncManager));
m_storageAreaMap.set(origin, storageArea);
return storageArea.release();
}
@@ -119,13 +118,25 @@ void StorageNamespaceImpl::close()
ASSERT(isMainThread());
ASSERT(!m_isShutdown);
+ // If we're session storage, we shouldn't need to do any work here.
+ if (m_storageType == SessionStorage) {
+ ASSERT(!m_syncManager);
+ return;
+ }
+
StorageAreaMap::iterator end = m_storageAreaMap.end();
for (StorageAreaMap::iterator it = m_storageAreaMap.begin(); it != end; ++it)
it->second->close();
-#ifndef NDEBUG
+ if (m_syncManager)
+ m_syncManager->close();
+
m_isShutdown = true;
-#endif
+}
+
+void StorageNamespaceImpl::unlock()
+{
+ // Because there's a single event loop per-process, this is a no-op.
}
} // namespace WebCore