Commit 5626dd64 authored by dglazkov@chromium.org's avatar dglazkov@chromium.org

2009-06-26 Jeremy Orlow <jorlow@chromium.org>

        Reviewed by Darin Fisher.

        https://bugs.webkit.org/show_bug.cgi?id=26732

        For the final step of https://bugs.webkit.org/show_bug.cgi?id=25376,
        combine LocalStorage and SessionStorage into StorageNamespace. The
        synching code (for LocalStorage) has already been removed, so these
        classes are now very similar.  All they do is essentially contain a
        logical grouping of origins that are attached to specific contexts
        (be it PageGroups for LocalStorage and Page for SessionStorage).

        * GNUmakefile.am:
        * WebCore.vcproj/WebCore.vcproj:
        * WebCore.xcodeproj/project.pbxproj:
        * WebCoreSources.bkl:
        * page/Chrome.cpp:
        (WebCore::Chrome::createWindow):
        * page/DOMWindow.cpp:
        (WebCore::DOMWindow::localStorage):
        * page/DOMWindow.h:
        * page/Page.cpp:
        (WebCore::Page::sessionStorage):
        (WebCore::Page::setSessionStorage):
        * page/Page.h:
        * page/PageGroup.cpp:
        (WebCore::PageGroup::localStorage):
        * page/PageGroup.h:
        * storage/LocalStorage.cpp: Removed.
        * storage/LocalStorage.h: Removed.
        * storage/LocalStorageTask.cpp:
        * storage/LocalStorageThread.cpp:
        * storage/SessionStorage.cpp: Removed.
        * storage/SessionStorage.h: Removed.
        * storage/StorageArea.cpp:
        (WebCore::StorageArea::create):
        (WebCore::StorageArea::StorageArea):
        (WebCore::StorageArea::copy):
        (WebCore::StorageArea::length):
        (WebCore::StorageArea::key):
        (WebCore::StorageArea::getItem):
        (WebCore::StorageArea::setItem):
        (WebCore::StorageArea::removeItem):
        (WebCore::StorageArea::clear):
        (WebCore::StorageArea::contains):
        (WebCore::StorageArea::importItem):
        (WebCore::StorageArea::close):
        (WebCore::StorageArea::dispatchStorageEvent):
        * storage/StorageArea.h:
        (WebCore::):
        * storage/StorageAreaSync.cpp:
        (WebCore::StorageAreaSync::scheduleFinalSync):
        * storage/StorageNamespace.cpp: Copied from WebCore/storage/LocalStorage.cpp.
        (WebCore::localStorageNamespaceMap):
        (WebCore::StorageNamespace::localStorageNamespace):
        (WebCore::StorageNamespace::sessionStorageNamespace):
        (WebCore::StorageNamespace::StorageNamespace):
        (WebCore::StorageNamespace::~StorageNamespace):
        (WebCore::StorageNamespace::copy):
        (WebCore::StorageNamespace::storageArea):
        (WebCore::StorageNamespace::close):
        * storage/StorageNamespace.h: Copied from WebCore/storage/LocalStorage.h.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@45290 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent deaca068
2009-06-26 Jeremy Orlow <jorlow@chromium.org>
Reviewed by Darin Fisher.
https://bugs.webkit.org/show_bug.cgi?id=26732
For the final step of https://bugs.webkit.org/show_bug.cgi?id=25376,
combine LocalStorage and SessionStorage into StorageNamespace. The
synching code (for LocalStorage) has already been removed, so these
classes are now very similar. All they do is essentially contain a
logical grouping of origins that are attached to specific contexts
(be it PageGroups for LocalStorage and Page for SessionStorage).
* GNUmakefile.am:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
* WebCoreSources.bkl:
* page/Chrome.cpp:
(WebCore::Chrome::createWindow):
* page/DOMWindow.cpp:
(WebCore::DOMWindow::localStorage):
* page/DOMWindow.h:
* page/Page.cpp:
(WebCore::Page::sessionStorage):
(WebCore::Page::setSessionStorage):
* page/Page.h:
* page/PageGroup.cpp:
(WebCore::PageGroup::localStorage):
* page/PageGroup.h:
* storage/LocalStorage.cpp: Removed.
* storage/LocalStorage.h: Removed.
* storage/LocalStorageTask.cpp:
* storage/LocalStorageThread.cpp:
* storage/SessionStorage.cpp: Removed.
* storage/SessionStorage.h: Removed.
* storage/StorageArea.cpp:
(WebCore::StorageArea::create):
(WebCore::StorageArea::StorageArea):
(WebCore::StorageArea::copy):
(WebCore::StorageArea::length):
(WebCore::StorageArea::key):
(WebCore::StorageArea::getItem):
(WebCore::StorageArea::setItem):
(WebCore::StorageArea::removeItem):
(WebCore::StorageArea::clear):
(WebCore::StorageArea::contains):
(WebCore::StorageArea::importItem):
(WebCore::StorageArea::close):
(WebCore::StorageArea::dispatchStorageEvent):
* storage/StorageArea.h:
(WebCore::):
* storage/StorageAreaSync.cpp:
(WebCore::StorageAreaSync::scheduleFinalSync):
* storage/StorageNamespace.cpp: Copied from WebCore/storage/LocalStorage.cpp.
(WebCore::localStorageNamespaceMap):
(WebCore::StorageNamespace::localStorageNamespace):
(WebCore::StorageNamespace::sessionStorageNamespace):
(WebCore::StorageNamespace::StorageNamespace):
(WebCore::StorageNamespace::~StorageNamespace):
(WebCore::StorageNamespace::copy):
(WebCore::StorageNamespace::storageArea):
(WebCore::StorageNamespace::close):
* storage/StorageNamespace.h: Copied from WebCore/storage/LocalStorage.h.
2009-06-26 Nate Chapin <japhet@chromium.org>
Reviewed by David Levin.
......
......@@ -2085,24 +2085,22 @@ webcore_cppflags += \
webcore_sources += \
WebCore/bindings/js/JSStorageCustom.cpp \
WebCore/storage/LocalStorage.cpp \
WebCore/storage/LocalStorage.h \
WebCore/storage/LocalStorageTask.cpp \
WebCore/storage/LocalStorageTask.h \
WebCore/storage/LocalStorageThread.cpp \
WebCore/storage/LocalStorageThread.h \
WebCore/storage/SessionStorage.cpp \
WebCore/storage/SessionStorage.h \
WebCore/storage/Storage.cpp \
WebCore/storage/Storage.h \
WebCore/storage/StorageArea.cpp \
WebCore/storage/StorageArea.h \
WebCore/storage/StorageAreaSync.cpp \
WebCore/storage/StorageAreaSync.h \
WebCore/storage/StorageEvent.cpp \
WebCore/storage/StorageEvent.h \
WebCore/storage/StorageMap.cpp \
WebCore/storage/StorageMap.h \
WebCore/storage/StorageAreaSync.cpp \
WebCore/storage/StorageAreaSync.h \
WebCore/storage/StorageNamespace.cpp \
WebCore/storage/StorageNamespace.h \
WebCore/storage/StorageSyncManager.cpp \
WebCore/storage/StorageSyncManager.h
endif # END ENABLE_DOM_STORAGE
......
......@@ -29986,14 +29986,6 @@
RelativePath="..\storage\DatabaseTracker.h"
>
</File>
<File
RelativePath="..\storage\LocalStorage.cpp"
>
</File>
<File
RelativePath="..\storage\LocalStorage.h"
>
</File>
<File
RelativePath="..\storage\LocalStorageTask.cpp"
>
......@@ -30026,14 +30018,6 @@
RelativePath="..\storage\OriginUsageRecord.h"
>
</File>
<File
RelativePath="..\storage\SessionStorage.cpp"
>
</File>
<File
RelativePath="..\storage\SessionStorage.h"
>
</File>
<File
RelativePath="..\storage\SQLCallback.h"
>
......@@ -30106,6 +30090,14 @@
RelativePath="..\storage\StorageArea.h"
>
</File>
<File
RelativePath="..\storage\StorageAreaSync.cpp"
>
</File>
<File
RelativePath="..\storage\StorageAreaSync.h"
>
</File>
<File
RelativePath="..\storage\StorageEvent.cpp"
>
......@@ -30123,11 +30115,11 @@
>
</File>
<File
RelativePath="..\storage\StorageAreaSync.cpp"
RelativePath="..\storage\StorageNamespace.cpp"
>
</File>
<File
RelativePath="..\storage\StorageAreaSync.h"
RelativePath="..\storage\StorageNamespace.h"
>
</File>
<File
......
This diff is collapsed.
......@@ -1010,7 +1010,6 @@ This file contains the list of files needed to build WebCore.
storage/DatabaseTask.cpp
storage/DatabaseThread.cpp
storage/DatabaseTracker.cpp
storage/LocalStorage.cpp
storage/LocalStorageTask.cpp
storage/LocalStorageThread.cpp
storage/OriginQuotaManager.cpp
......@@ -1021,10 +1020,10 @@ This file contains the list of files needed to build WebCore.
storage/SQLTransaction.cpp
storage/Storage.cpp
storage/StorageArea.cpp
storage/StorageAreaSync.cpp
storage/StorageEvent.cpp
storage/StorageNamespace.cpp
storage/StorageMap.cpp
storage/SessionStorage.cpp
storage/StorageAreaSync.cpp
storage/StorageSyncManager.cpp
</set>
......
......@@ -46,7 +46,7 @@
#include <wtf/Vector.h>
#if ENABLE(DOM_STORAGE)
#include "SessionStorage.h"
#include "StorageNamespace.h"
#endif
namespace WebCore {
......@@ -147,8 +147,8 @@ Page* Chrome::createWindow(Frame* frame, const FrameLoadRequest& request, const
#if ENABLE(DOM_STORAGE)
if (newPage) {
if (SessionStorage* oldSessionStorage = m_page->sessionStorage(false))
newPage->setSessionStorage(oldSessionStorage->copy(newPage));
if (StorageNamespace* oldSessionStorage = m_page->sessionStorage(false))
newPage->setSessionStorage(oldSessionStorage->copy());
}
#endif
......
......@@ -70,10 +70,9 @@
#endif
#if ENABLE(DOM_STORAGE)
#include "LocalStorage.h"
#include "SessionStorage.h"
#include "Storage.h"
#include "StorageArea.h"
#include "StorageNamespace.h"
#endif
#if ENABLE(OFFLINE_WEB_APPLICATIONS)
......@@ -578,7 +577,7 @@ Storage* DOMWindow::localStorage() const
if (!settings || !settings->localStorageEnabled())
return 0;
LocalStorage* localStorage = page->group().localStorage();
StorageNamespace* localStorage = page->group().localStorage();
RefPtr<StorageArea> storageArea = localStorage ? localStorage->storageArea(document->securityOrigin()) : 0;
if (storageArea) {
page->inspectorController()->didUseDOMStorage(storageArea.get(), true, m_frame);
......
......@@ -61,7 +61,6 @@ namespace WebCore {
class WebKitPoint;
#if ENABLE(DOM_STORAGE)
class SessionStorage;
class Storage;
#endif
......
......@@ -58,9 +58,8 @@
#include <wtf/StdLibExtras.h>
#if ENABLE(DOM_STORAGE)
#include "LocalStorage.h"
#include "SessionStorage.h"
#include "StorageArea.h"
#include "StorageNamespace.h"
#endif
#if ENABLE(JAVASCRIPT_DEBUGGER)
......@@ -550,17 +549,16 @@ void Page::setDebugger(JSC::Debugger* debugger)
}
#if ENABLE(DOM_STORAGE)
SessionStorage* Page::sessionStorage(bool optionalCreate)
StorageNamespace* Page::sessionStorage(bool optionalCreate)
{
if (!m_sessionStorage && optionalCreate)
m_sessionStorage = SessionStorage::create(this);
m_sessionStorage = StorageNamespace::sessionStorageNamespace();
return m_sessionStorage.get();
}
void Page::setSessionStorage(PassRefPtr<SessionStorage> newStorage)
void Page::setSessionStorage(PassRefPtr<StorageNamespace> newStorage)
{
ASSERT(newStorage->page() == this);
m_sessionStorage = newStorage;
}
#endif
......
......@@ -63,10 +63,10 @@ namespace WebCore {
class RenderTheme;
class VisibleSelection;
class SelectionController;
class Settings;
#if ENABLE(DOM_STORAGE)
class SessionStorage;
class StorageNamespace;
#endif
class Settings;
#if ENABLE(WML)
class WMLPageState;
#endif
......@@ -179,8 +179,8 @@ namespace WebCore {
static void visitedStateChanged(PageGroup*, LinkHash visitedHash);
#if ENABLE(DOM_STORAGE)
SessionStorage* sessionStorage(bool optionalCreate = true);
void setSessionStorage(PassRefPtr<SessionStorage>);
StorageNamespace* sessionStorage(bool optionalCreate = true);
void setSessionStorage(PassRefPtr<StorageNamespace>);
#endif
#if ENABLE(WML)
......@@ -253,7 +253,7 @@ namespace WebCore {
int m_customHTMLTokenizerChunkSize;
#if ENABLE(DOM_STORAGE)
RefPtr<SessionStorage> m_sessionStorage;
RefPtr<StorageNamespace> m_sessionStorage;
#endif
#if PLATFORM(WIN) || (PLATFORM(WX) && defined(__WXMSW__)) || (PLATFORM(QT) && defined(Q_WS_WIN))
......
......@@ -32,8 +32,7 @@
#include "Settings.h"
#if ENABLE(DOM_STORAGE)
#include "LocalStorage.h"
#include "StorageArea.h"
#include "StorageNamespace.h"
#endif
#if PLATFORM(CHROMIUM)
......@@ -181,13 +180,13 @@ void PageGroup::setShouldTrackVisitedLinks(bool shouldTrack)
}
#if ENABLE(DOM_STORAGE)
LocalStorage* PageGroup::localStorage()
StorageNamespace* PageGroup::localStorage()
{
if (!m_localStorage) {
// Need a page in this page group to query the settings for the local storage database path.
Page* page = *m_pages.begin();
ASSERT(page);
m_localStorage = LocalStorage::localStorage(page->settings()->localStorageDatabasePath());
m_localStorage = StorageNamespace::localStorageNamespace(page->settings()->localStorageDatabasePath());
}
return m_localStorage.get();
......
......@@ -34,8 +34,8 @@
namespace WebCore {
class KURL;
class LocalStorage;
class Page;
class StorageNamespace;
class PageGroup : Noncopyable {
public:
......@@ -63,7 +63,7 @@ namespace WebCore {
unsigned identifier() { return m_identifier; }
#if ENABLE(DOM_STORAGE)
LocalStorage* localStorage();
StorageNamespace* localStorage();
#endif
private:
......@@ -80,7 +80,7 @@ namespace WebCore {
unsigned m_identifier;
#if ENABLE(DOM_STORAGE)
RefPtr<LocalStorage> m_localStorage;
RefPtr<StorageNamespace> m_localStorage;
#endif
};
......
......@@ -28,7 +28,6 @@
#if ENABLE(DOM_STORAGE)
#include "LocalStorage.h"
#include "LocalStorageThread.h"
#include "StorageAreaSync.h"
......
......@@ -28,7 +28,6 @@
#if ENABLE(DOM_STORAGE)
#include "LocalStorage.h"
#include "LocalStorageTask.h"
#include "StorageAreaSync.h"
......
/*
* Copyright (C) 2008 Apple Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "SessionStorage.h"
#if ENABLE(DOM_STORAGE)
#include "EventNames.h"
#include "Frame.h"
#include "FrameTree.h"
#include "Page.h"
#include "SecurityOrigin.h"
#include "StorageArea.h"
#include "StorageMap.h"
namespace WebCore {
PassRefPtr<SessionStorage> SessionStorage::create(Page* page)
{
return adoptRef(new SessionStorage(page));
}
SessionStorage::SessionStorage(Page* page)
: m_page(page)
{
ASSERT(m_page);
}
PassRefPtr<SessionStorage> SessionStorage::copy(Page* newPage)
{
ASSERT(newPage);
RefPtr<SessionStorage> newSession = SessionStorage::create(newPage);
SessionStorageAreaMap::iterator end = m_storageAreaMap.end();
for (SessionStorageAreaMap::iterator i = m_storageAreaMap.begin(); i != end; ++i) {
RefPtr<StorageArea> areaCopy = i->second->copy(i->first.get(), newPage);
newSession->m_storageAreaMap.set(i->first, areaCopy.release());
}
return newSession.release();
}
PassRefPtr<StorageArea> SessionStorage::storageArea(SecurityOrigin* origin)
{
RefPtr<StorageArea> storageArea;
if (storageArea = m_storageAreaMap.get(origin))
return storageArea.release();
storageArea = StorageArea::createSessionStorage(origin, m_page);
m_storageAreaMap.set(origin, storageArea);
return storageArea.release();
}
}
#endif // ENABLE(DOM_STORAGE)
/*
* Copyright (C) 2008 Apple Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef SessionStorage_h
#define SessionStorage_h
#if ENABLE(DOM_STORAGE)
#include "SecurityOriginHash.h"
#include "StorageArea.h"
#include <wtf/HashMap.h>
#include <wtf/RefCounted.h>
namespace WebCore {
class Page;
class SessionStorage : public RefCounted<SessionStorage> {
public:
static PassRefPtr<SessionStorage> create(Page*);
PassRefPtr<SessionStorage> copy(Page*);
PassRefPtr<StorageArea> storageArea(SecurityOrigin*);
#ifndef NDEBUG
Page* page() { return m_page; }
#endif
private:
SessionStorage(Page*);
void dispatchStorageEvent(StorageArea*, const String& key, const String& oldValue, const String& newValue, Frame* sourceFrame);
Page* m_page;
typedef HashMap<RefPtr<SecurityOrigin>, RefPtr<StorageArea>, SecurityOriginHash> SessionStorageAreaMap;
SessionStorageAreaMap m_storageAreaMap;
};
} // namespace WebCore
#endif // ENABLE(DOM_STORAGE)
#endif // SessionStorage_h
......@@ -42,16 +42,19 @@
namespace WebCore {
PassRefPtr<StorageArea> StorageArea::createLocalStorage(SecurityOrigin* origin, PassRefPtr<StorageSyncManager> syncManager)
PassRefPtr<StorageArea> StorageArea::create(StorageType storageType, SecurityOrigin* origin, PassRefPtr<StorageSyncManager> syncManager)
{
return adoptRef(new StorageArea(origin, syncManager));
return adoptRef(new StorageArea(storageType, origin, syncManager));
}
StorageArea::StorageArea(SecurityOrigin* origin, PassRefPtr<StorageSyncManager> syncManager)
: m_securityOrigin(origin)
StorageArea::StorageArea(StorageType storageType, SecurityOrigin* origin, PassRefPtr<StorageSyncManager> syncManager)
: m_storageType(storageType)
, m_securityOrigin(origin)
, m_storageMap(StorageMap::create())
, m_storageSyncManager(syncManager)
, m_sessionStoragePage(0)
#ifndef NDEBUG
, m_isShutdown(false)
#endif
{
ASSERT(m_securityOrigin);
ASSERT(m_storageMap);
......@@ -64,37 +67,35 @@ StorageArea::StorageArea(SecurityOrigin* origin, PassRefPtr<StorageSyncManager>
}
}
PassRefPtr<StorageArea> StorageArea::createSessionStorage(SecurityOrigin* origin, Page* page)
PassRefPtr<StorageArea> StorageArea::copy(SecurityOrigin* origin)
{
return adoptRef(new StorageArea(origin, page, 0));
ASSERT(!m_isShutdown);
return adoptRef(new StorageArea(origin, this));
}
PassRefPtr<StorageArea> StorageArea::copy(SecurityOrigin* origin, Page* page)
{
return adoptRef(new StorageArea(origin, page, m_storageMap));
}
StorageArea::StorageArea(SecurityOrigin* origin, Page* page, PassRefPtr<StorageMap> storageMap)
: m_securityOrigin(origin)
, m_storageMap(storageMap)
, m_sessionStoragePage(page)
StorageArea::StorageArea(SecurityOrigin* origin, StorageArea* area)
: m_storageType(area->m_storageType)
, m_securityOrigin(origin)
, m_storageMap(area->m_storageMap)
, m_storageSyncManager(area->m_storageSyncManager)
#ifndef NDEBUG
, m_isShutdown(area->m_isShutdown)
#endif
{
ASSERT(m_securityOrigin);
ASSERT(m_sessionStoragePage);
if (!m_storageMap) {
m_storageMap = StorageMap::create();
ASSERT(m_storageMap);
}
ASSERT(m_storageMap);
ASSERT(!m_isShutdown);
}
unsigned StorageArea::length() const
{
ASSERT(!m_isShutdown);
return m_storageMap->length();
}
String StorageArea::key(unsigned index, ExceptionCode& ec) const
{
ASSERT(!m_isShutdown);
blockUntilImportComplete();
String key;
......@@ -109,6 +110,7 @@ String StorageArea::key(unsigned index, ExceptionCode& ec) const
String StorageArea::getItem(const String& key) const
{
ASSERT(!m_isShutdown);
blockUntilImportComplete();
return m_storageMap->getItem(key);
......@@ -116,6 +118,7 @@ String StorageArea::getItem(const String& key) const
void StorageArea::setItem(const String& key, const String& value, ExceptionCode& ec, Frame* frame)
{
ASSERT(!m_isShutdown);
ASSERT(!value.isNull());
blockUntilImportComplete();
......@@ -147,6 +150,7 @@ void StorageArea::setItem(const String& key, const String& value, ExceptionCode&
void StorageArea::removeItem(const String& key, Frame* frame)
{
ASSERT(!m_isShutdown);
blockUntilImportComplete();
if (frame->page()->settings()->privateBrowsingEnabled())
......@@ -167,6 +171,7 @@ void StorageArea::removeItem(const String& key, Frame* frame)
void StorageArea::clear(Frame* frame)
{
ASSERT(!m_isShutdown);
blockUntilImportComplete();
if (frame->page()->settings()->privateBrowsingEnabled())
......@@ -181,6 +186,7 @@ void StorageArea::clear(Frame* frame)
bool StorageArea::contains(const String& key) const
{
ASSERT(!m_isShutdown);
blockUntilImportComplete();
return m_storageMap->contains(key);
......@@ -188,13 +194,18 @@ bool StorageArea::contains(const String& key) const
void StorageArea::importItem(const String& key, const String& value)
{
ASSERT(!m_isShutdown);
m_storageMap->importItem(key, value);
}
void StorageArea::scheduleFinalSync()
void StorageArea::close()
{
if (m_storageAreaSync)
m_storageAreaSync->scheduleFinalSync();
#ifndef NDEBUG
m_isShutdown = true;
#endif
}
void StorageArea::blockUntilImportComplete() const
......@@ -209,9 +220,14 @@ void StorageArea::dispatchStorageEvent(const String& key, const String& oldValue
// of any given page in the group or mutate the page group itself.
Vector<RefPtr<Frame> > frames;
if (m_sessionStoragePage) {
// FIXME: When can this occur?
Page* page = sourceFrame->page();
if (!page)
return;
if (m_storageType == SessionStorage) {
// Send events only to our page.
for (Frame* frame = m_sessionStoragePage->mainFrame(); frame; frame = frame->tree()->traverseNext()) {
for (Frame* frame = page->mainFrame(); frame; frame = frame->tree()->traverseNext()) {
if (frame->document()->securityOrigin()->equal(securityOrigin()))
frames.append(frame);
}
......@@ -219,11 +235,6 @@ void StorageArea::dispatchStorageEvent(const String& key, const String& oldValue
for (unsigned i = 0; i < frames.size(); ++i)
frames[i]->document()->dispatchWindowEvent(StorageEvent::create(eventNames().storageEvent, key, oldValue, newValue, sourceFrame->document()->documentURI(), sourceFrame->domWindow(), frames[i]->domWindow()->sessionStorage()));
} else {
// FIXME: When can this occur?
Page* page = sourceFrame->page();
if (!page)
return;
// Send events to every page.
const HashSet<Page*>& pages = page->group().pages();
HashSet<Page*>::const_iterator end = pages.end();
......
......@@ -48,12 +48,12 @@ namespace WebCore {
class StorageMap;
class StorageSyncManager;
typedef int ExceptionCode;
enum StorageType { LocalStorage, SessionStorage };
class StorageArea : public ThreadSafeShared<StorageArea> {
public:
static PassRefPtr<StorageArea> createLocalStorage(SecurityOrigin* origin, PassRefPtr<StorageSyncManager> syncManager);
static PassRefPtr<StorageArea> createSessionStorage(SecurityOrigin* origin, Page* page);
PassRefPtr<StorageArea> copy(SecurityOrigin*, Page*);
static PassRefPtr<StorageArea> create(StorageType, SecurityOrigin*, PassRefPtr<StorageSyncManager>);
PassRefPtr<StorageArea> copy(SecurityOrigin*);