WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch 5 in this set
5.20090612.patch (text/plain), 44.51 KB, created by
Jeremy Orlow
on 2009-06-12 00:13:37 PDT
(
hide
)
Description:
Patch 5 in this set
Filename:
MIME Type:
Creator:
Jeremy Orlow
Created:
2009-06-12 00:13:37 PDT
Size:
44.51 KB
patch
obsolete
>diff --git a/WebCore/WebCore.xcodeproj/project.pbxproj b/WebCore/WebCore.xcodeproj/project.pbxproj >index bb09d03..0a4d015 100644 >--- a/WebCore/WebCore.xcodeproj/project.pbxproj >+++ b/WebCore/WebCore.xcodeproj/project.pbxproj >@@ -829,8 +829,8 @@ > 51B2417B0D931F3F00E83F5C /* LegacyWebArchiveMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51B2417A0D931F3F00E83F5C /* LegacyWebArchiveMac.mm */; }; > 51BE37DF0DAEE00E001085FC /* StorageArea.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51BE37DD0DAEE00E001085FC /* StorageArea.cpp */; }; > 51BE37E00DAEE00E001085FC /* StorageArea.h in Headers */ = {isa = PBXBuildFile; fileRef = 51BE37DE0DAEE00E001085FC /* StorageArea.h */; }; >- 51BE38280DAEF7DA001085FC /* LocalStorage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51BE38260DAEF7DA001085FC /* LocalStorage.cpp */; }; >- 51BE38290DAEF7DA001085FC /* LocalStorage.h in Headers */ = {isa = PBXBuildFile; fileRef = 51BE38270DAEF7DA001085FC /* LocalStorage.h */; }; >+ 51BE38280DAEF7DA001085FC /* StorageNamespace.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51BE38260DAEF7DA001085FC /* StorageNamespace.cpp */; }; >+ 51BE38290DAEF7DA001085FC /* StorageNamespace.h in Headers */ = {isa = PBXBuildFile; fileRef = 51BE38270DAEF7DA001085FC /* StorageNamespace.h */; }; > 51C0AA390F2AA10A001648C2 /* CachedFrame.h in Headers */ = {isa = PBXBuildFile; fileRef = 51C0AA380F2AA10A001648C2 /* CachedFrame.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 51C0AA410F2AA15E001648C2 /* CachedFrame.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51C0AA400F2AA15E001648C2 /* CachedFrame.cpp */; }; > 51C81B890C4422F70019ECE3 /* FTPDirectoryParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51C81B870C4422F70019ECE3 /* FTPDirectoryParser.cpp */; }; >@@ -844,8 +844,6 @@ > 51E0BABC0DA5547100A9E417 /* StorageEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51E0BABA0DA5547100A9E417 /* StorageEvent.cpp */; }; > 51E0BAEA0DA55D4A00A9E417 /* JSStorageEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51E0BAE80DA55D4A00A9E417 /* JSStorageEvent.cpp */; }; > 51E0BAEB0DA55D4A00A9E417 /* JSStorageEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 51E0BAE90DA55D4A00A9E417 /* JSStorageEvent.h */; }; >- 51E0BB230DA572A600A9E417 /* SessionStorage.h in Headers */ = {isa = PBXBuildFile; fileRef = 51E0BB210DA572A600A9E417 /* SessionStorage.h */; }; >- 51E0BB240DA572A600A9E417 /* SessionStorage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51E0BB220DA572A600A9E417 /* SessionStorage.cpp */; }; > 51E0BB380DA5ACB600A9E417 /* StorageMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 51E0BB360DA5ACB600A9E417 /* StorageMap.h */; }; > 51E0BB390DA5ACB600A9E417 /* StorageMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51E0BB370DA5ACB600A9E417 /* StorageMap.cpp */; }; > 51E1ECAF0C91C54600DC255B /* AutodrainedPool.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51E1ECAD0C91C54600DC255B /* AutodrainedPool.mm */; }; >@@ -5754,8 +5752,8 @@ > 51B2417A0D931F3F00E83F5C /* LegacyWebArchiveMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LegacyWebArchiveMac.mm; sourceTree = "<group>"; }; > 51BE37DD0DAEE00E001085FC /* StorageArea.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StorageArea.cpp; sourceTree = "<group>"; }; > 51BE37DE0DAEE00E001085FC /* StorageArea.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StorageArea.h; sourceTree = "<group>"; }; >- 51BE38260DAEF7DA001085FC /* LocalStorage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LocalStorage.cpp; sourceTree = "<group>"; }; >- 51BE38270DAEF7DA001085FC /* LocalStorage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LocalStorage.h; sourceTree = "<group>"; }; >+ 51BE38260DAEF7DA001085FC /* StorageNamespace.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StorageNamespace.cpp; sourceTree = "<group>"; }; >+ 51BE38270DAEF7DA001085FC /* StorageNamespace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StorageNamespace.h; sourceTree = "<group>"; }; > 51C0AA380F2AA10A001648C2 /* CachedFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CachedFrame.h; sourceTree = "<group>"; }; > 51C0AA400F2AA15E001648C2 /* CachedFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CachedFrame.cpp; sourceTree = "<group>"; }; > 51C81B870C4422F70019ECE3 /* FTPDirectoryParser.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = FTPDirectoryParser.cpp; sourceTree = "<group>"; }; >@@ -5770,8 +5768,6 @@ > 51E0BABD0DA5548400A9E417 /* StorageEvent.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = StorageEvent.idl; sourceTree = "<group>"; }; > 51E0BAE80DA55D4A00A9E417 /* JSStorageEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSStorageEvent.cpp; sourceTree = "<group>"; }; > 51E0BAE90DA55D4A00A9E417 /* JSStorageEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSStorageEvent.h; sourceTree = "<group>"; }; >- 51E0BB210DA572A600A9E417 /* SessionStorage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SessionStorage.h; sourceTree = "<group>"; }; >- 51E0BB220DA572A600A9E417 /* SessionStorage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SessionStorage.cpp; sourceTree = "<group>"; }; > 51E0BB360DA5ACB600A9E417 /* StorageMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StorageMap.h; sourceTree = "<group>"; }; > 51E0BB370DA5ACB600A9E417 /* StorageMap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StorageMap.cpp; sourceTree = "<group>"; }; > 51E1ECAD0C91C54600DC255B /* AutodrainedPool.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AutodrainedPool.mm; sourceTree = "<group>"; }; >@@ -9599,8 +9595,6 @@ > 1AD51A130CB59CD300953D11 /* DatabaseTracker.cpp */, > 1AD51A120CB59CD300953D11 /* DatabaseTracker.h */, > 51FAFE330CECBF2D00BB3F24 /* DatabaseTrackerClient.h */, >- 51BE38260DAEF7DA001085FC /* LocalStorage.cpp */, >- 51BE38270DAEF7DA001085FC /* LocalStorage.h */, > 511F23130DC160DA004F0032 /* LocalStorageTask.cpp */, > 511F23140DC160DA004F0032 /* LocalStorageTask.h */, > 511F23150DC160DA004F0032 /* LocalStorageThread.cpp */, >@@ -9626,8 +9620,6 @@ > 1A7CCB230CD946FD00B7B64E /* SQLTransaction.idl */, > 1A7CCB170CD9469A00B7B64E /* SQLTransactionCallback.h */, > 1A7CCB180CD9469A00B7B64E /* SQLTransactionErrorCallback.h */, >- 51E0BB220DA572A600A9E417 /* SessionStorage.cpp */, >- 51E0BB210DA572A600A9E417 /* SessionStorage.h */, > 51E3F9C50DA059DC00250911 /* Storage.cpp */, > 51E3F9C40DA059DC00250911 /* Storage.h */, > 51E3F9D10DA05D7100250911 /* Storage.idl */, >@@ -9640,6 +9632,8 @@ > 51E0BABD0DA5548400A9E417 /* StorageEvent.idl */, > 51E0BB370DA5ACB600A9E417 /* StorageMap.cpp */, > 51E0BB360DA5ACB600A9E417 /* StorageMap.h */, >+ 51BE38260DAEF7DA001085FC /* StorageNamespace.cpp */, >+ 51BE38270DAEF7DA001085FC /* StorageNamespace.h */, > C5102D920FD9AA2D00FAFF04 /* StorageSyncManager.h */, > C5102D930FD9AA2D00FAFF04 /* StorageSyncManager.cpp */, > ); >@@ -16063,7 +16057,7 @@ > A7AD2F880EC89D07008AB002 /* LinkHash.h in Headers */, > 656D37320ADBA5DE00A4554D /* LoaderNSURLExtras.h in Headers */, > 06E81ED70AB5D5E900C87837 /* LocalCurrentGraphicsContext.h in Headers */, >- 51BE38290DAEF7DA001085FC /* LocalStorage.h in Headers */, >+ 51BE38290DAEF7DA001085FC /* StorageNamespace.h in Headers */, > 511F23180DC160DA004F0032 /* LocalStorageTask.h in Headers */, > 511F231A0DC160DA004F0032 /* LocalStorageThread.h in Headers */, > 935207BE09BD410A00F2038D /* LocalizedStrings.h in Headers */, >@@ -16503,7 +16497,6 @@ > 084AEBE50FB505FA0038483E /* SelectElement.h in Headers */, > 93309E0E099E64920056E581 /* SelectionController.h in Headers */, > BC7FA6810D1F167900DB22A9 /* SelectorNodeList.h in Headers */, >- 51E0BB230DA572A600A9E417 /* SessionStorage.h in Headers */, > 93309E10099E64920056E581 /* SetNodeAttributeCommand.h in Headers */, > 93F1994F08245E59001E9ABC /* Settings.h in Headers */, > BC5EB8C40E82031B00B25965 /* ShadowData.h in Headers */, >@@ -18126,7 +18119,7 @@ > A7AD2F870EC89D07008AB002 /* LinkHash.cpp in Sources */, > 656D37330ADBA5DE00A4554D /* LoaderNSURLExtras.mm in Sources */, > 06E81EEC0AB5DA9700C87837 /* LocalCurrentGraphicsContext.mm in Sources */, >- 51BE38280DAEF7DA001085FC /* LocalStorage.cpp in Sources */, >+ 51BE38280DAEF7DA001085FC /* StorageNamespace.cpp in Sources */, > 511F23170DC160DA004F0032 /* LocalStorageTask.cpp in Sources */, > 511F23190DC160DA004F0032 /* LocalStorageThread.cpp in Sources */, > 935207C009BD412100F2038D /* LocalizedStringsMac.mm in Sources */, >@@ -18526,7 +18519,6 @@ > 93309E0D099E64920056E581 /* SelectionController.cpp in Sources */, > 4A8C96EB0BE69032004EEFF0 /* SelectionControllerMac.mm in Sources */, > BC7FA6820D1F167900DB22A9 /* SelectorNodeList.cpp in Sources */, >- 51E0BB240DA572A600A9E417 /* SessionStorage.cpp in Sources */, > 93309E0F099E64920056E581 /* SetNodeAttributeCommand.cpp in Sources */, > 14C9A5EA0B3D105F005A0232 /* Settings.cpp in Sources */, > BC5EB8C30E82031B00B25965 /* ShadowData.cpp in Sources */, >diff --git a/WebCore/page/Chrome.cpp b/WebCore/page/Chrome.cpp >index 86de82e..2170723 100644 >--- a/WebCore/page/Chrome.cpp >+++ b/WebCore/page/Chrome.cpp >@@ -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 > >diff --git a/WebCore/page/DOMWindow.cpp b/WebCore/page/DOMWindow.cpp >index bc1192d..e5c7157 100644 >--- a/WebCore/page/DOMWindow.cpp >+++ b/WebCore/page/DOMWindow.cpp >@@ -70,9 +70,8 @@ > #endif > > #if ENABLE(DOM_STORAGE) >-#include "LocalStorage.h" >-#include "SessionStorage.h" > #include "Storage.h" >+#include "StorageNamespace.h" > #include "StorageArea.h" > #endif > >@@ -564,7 +563,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); >diff --git a/WebCore/page/DOMWindow.h b/WebCore/page/DOMWindow.h >index 6862cdc..eac936f 100644 >--- a/WebCore/page/DOMWindow.h >+++ b/WebCore/page/DOMWindow.h >@@ -61,7 +61,6 @@ namespace WebCore { > class WebKitPoint; > > #if ENABLE(DOM_STORAGE) >- class SessionStorage; > class Storage; > #endif > >diff --git a/WebCore/page/Page.cpp b/WebCore/page/Page.cpp >index 70b4459..99c510a 100644 >--- a/WebCore/page/Page.cpp >+++ b/WebCore/page/Page.cpp >@@ -57,9 +57,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) >@@ -548,17 +547,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 >diff --git a/WebCore/page/Page.h b/WebCore/page/Page.h >index eedd24c..b390e87 100644 >--- a/WebCore/page/Page.h >+++ b/WebCore/page/Page.h >@@ -63,7 +63,7 @@ namespace WebCore { > class VisibleSelection; > class SelectionController; > #if ENABLE(DOM_STORAGE) >- class SessionStorage; >+ class StorageNamespace; > #endif > class Settings; > #if ENABLE(WML) >@@ -176,8 +176,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) >@@ -248,7 +248,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)) >diff --git a/WebCore/page/PageGroup.cpp b/WebCore/page/PageGroup.cpp >index f0951eb..1b3d853 100644 >--- a/WebCore/page/PageGroup.cpp >+++ b/WebCore/page/PageGroup.cpp >@@ -32,8 +32,8 @@ > #include "Settings.h" > > #if ENABLE(DOM_STORAGE) >-#include "LocalStorage.h" > #include "StorageArea.h" >+#include "StorageNamespace.h" > #endif > > #if PLATFORM(CHROMIUM) >@@ -97,7 +97,7 @@ void PageGroup::closeLocalStorage() > PageGroupMap::iterator end = pageGroups->end(); > > for (PageGroupMap::iterator it = pageGroups->begin(); it != end; ++it) { >- if (LocalStorage* localStorage = it->second->localStorage()) >+ if (StorageNamespace* localStorage = it->second->localStorage()) > localStorage->close(); > } > #endif >@@ -110,7 +110,7 @@ void PageGroup::addPage(Page* page) > m_pages.add(page); > #if ENABLE(DOM_STORAGE) > if (!m_localStorage) >- m_localStorage = LocalStorage::localStorage(page->settings()->localStorageDatabasePath()); >+ m_localStorage = StorageNamespace::localStorageNamespace(page->settings()->localStorageDatabasePath()); > #endif > } > >@@ -185,7 +185,7 @@ void PageGroup::setShouldTrackVisitedLinks(bool shouldTrack) > } > > #if ENABLE(DOM_STORAGE) >-LocalStorage* PageGroup::localStorage() >+StorageNamespace* PageGroup::localStorage() > { > return m_localStorage.get(); > } >diff --git a/WebCore/page/PageGroup.h b/WebCore/page/PageGroup.h >index 097fb87..44527f3 100644 >--- a/WebCore/page/PageGroup.h >+++ b/WebCore/page/PageGroup.h >@@ -34,7 +34,7 @@ > namespace WebCore { > > class KURL; >- class LocalStorage; >+ class StorageNamespace; > class Page; > > class PageGroup : Noncopyable { >@@ -63,7 +63,7 @@ namespace WebCore { > unsigned identifier() { return m_identifier; } > > #if ENABLE(DOM_STORAGE) >- LocalStorage* localStorage(); >+ StorageNamespace* localStorage(); > #endif > > private: >@@ -78,7 +78,7 @@ namespace WebCore { > > unsigned m_identifier; > #if ENABLE(DOM_STORAGE) >- RefPtr<LocalStorage> m_localStorage; >+ RefPtr<StorageNamespace> m_localStorage; > #endif > }; > >diff --git a/WebCore/storage/LocalStorage.cpp b/WebCore/storage/LocalStorage.cpp >deleted file mode 100644 >index 0065eb6..0000000 >--- a/WebCore/storage/LocalStorage.cpp >+++ /dev/null >@@ -1,111 +0,0 @@ >-/* >- * 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 "LocalStorage.h" >- >-#include "CString.h" >-#include "EventNames.h" >-#include "FileSystem.h" >-#include "Frame.h" >-#include "FrameTree.h" >-#include "Page.h" >-#include "PageGroup.h" >-#include "StorageArea.h" >-#include "StorageSyncManager.h" >-#include <wtf/StdLibExtras.h> >- >-namespace WebCore { >- >-typedef HashMap<String, LocalStorage*> LocalStorageMap; >- >-static LocalStorageMap& localStorageMap() >-{ >- DEFINE_STATIC_LOCAL(LocalStorageMap, localStorageMap, ()); >- return localStorageMap; >-} >- >-PassRefPtr<LocalStorage> LocalStorage::localStorage(const String& path) >-{ >- const String lookupPath = path.isNull() ? String("") : path; >- LocalStorageMap::iterator it = localStorageMap().find(lookupPath); >- if (it == localStorageMap().end()) { >- RefPtr<LocalStorage> localStorage = adoptRef(new LocalStorage(lookupPath)); >- localStorageMap().set(lookupPath, localStorage.get()); >- return localStorage.release(); >- } >- >- return it->second; >-} >- >-LocalStorage::LocalStorage(const String& path) >- : m_path(path.copy()) >- , m_syncManager(0) >-{ >- if (!m_path.isEmpty()) >- m_syncManager = StorageSyncManager::create(m_path); >-} >- >-LocalStorage::~LocalStorage() >-{ >- ASSERT(localStorageMap().get(m_path) == this); >- localStorageMap().remove(m_path); >-} >- >-PassRefPtr<StorageArea> LocalStorage::storageArea(SecurityOrigin* origin) >-{ >- ASSERT(isMainThread()); >- >- // FIXME: If the security origin in question has never had a storage area established, >- // we need to ask a client call if establishing it is okay. If the client denies the request, >- // this method will return null. >- // The sourceFrame argument exists for the purpose of asking a client. >- // To know if an area has previously been established, we need to wait until this LocalStorage >- // object has finished it's AreaImport task. >- >- // FIXME: If the storage area is being established for the first time here, we need to >- // sync its existance and quota out to disk via an task of type AreaSync >- >- RefPtr<StorageArea> storageArea; >- if (storageArea = m_storageAreaMap.get(origin)) >- return storageArea.release(); >- >- storageArea = StorageArea::createLocalStorage(origin, m_syncManager); >- m_storageAreaMap.set(origin, storageArea); >- return storageArea.release(); >-} >- >-void LocalStorage::close() >-{ >- ASSERT(isMainThread()); >- >- LocalStorageAreaMap::iterator end = m_storageAreaMap.end(); >- for (LocalStorageAreaMap::iterator it = m_storageAreaMap.begin(); it != end; ++it) >- it->second->scheduleFinalSync(); >- >- m_syncManager = 0; >-} >- >-} // namespace WebCore >diff --git a/WebCore/storage/LocalStorage.h b/WebCore/storage/LocalStorage.h >deleted file mode 100644 >index 3191c8e..0000000 >--- a/WebCore/storage/LocalStorage.h >+++ /dev/null >@@ -1,61 +0,0 @@ >-/* >- * 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 LocalStorage_h >-#define LocalStorage_h >- >-#include "SecurityOriginHash.h" >- >-#include <wtf/HashMap.h> >-#include <wtf/RefCounted.h> >- >-namespace WebCore { >- >- class StorageArea; >- class StorageSyncManager; >- >- class LocalStorage : public RefCounted<LocalStorage> { >- public: >- ~LocalStorage(); >- >- static PassRefPtr<LocalStorage> localStorage(const String& path); >- >- PassRefPtr<StorageArea> storageArea(SecurityOrigin*); >- >- void close(); >- >- private: >- LocalStorage(const String& path); >- >- typedef HashMap<RefPtr<SecurityOrigin>, RefPtr<StorageArea>, SecurityOriginHash> LocalStorageAreaMap; >- LocalStorageAreaMap m_storageAreaMap; >- >- String m_path; >- RefPtr<StorageSyncManager> m_syncManager; >- }; >- >-} // namespace WebCore >- >-#endif // LocalStorage_h >diff --git a/WebCore/storage/LocalStorageTask.cpp b/WebCore/storage/LocalStorageTask.cpp >index 9657ff3..a7d89cd 100644 >--- a/WebCore/storage/LocalStorageTask.cpp >+++ b/WebCore/storage/LocalStorageTask.cpp >@@ -26,9 +26,9 @@ > #include "config.h" > #include "LocalStorageTask.h" > >-#include "LocalStorage.h" > #include "LocalStorageThread.h" > #include "StorageAreaSync.h" >+#include "StorageNamespace.h" > > namespace WebCore { > >diff --git a/WebCore/storage/LocalStorageThread.cpp b/WebCore/storage/LocalStorageThread.cpp >index 9c1d4fd..b2dc50a 100644 >--- a/WebCore/storage/LocalStorageThread.cpp >+++ b/WebCore/storage/LocalStorageThread.cpp >@@ -26,9 +26,9 @@ > #include "config.h" > #include "LocalStorageThread.h" > >-#include "LocalStorage.h" > #include "LocalStorageTask.h" > #include "StorageAreaSync.h" >+#include "StorageNamespace.h" > > namespace WebCore { > >diff --git a/WebCore/storage/SessionStorage.cpp b/WebCore/storage/SessionStorage.cpp >deleted file mode 100644 >index 0fc2712..0000000 >--- a/WebCore/storage/SessionStorage.cpp >+++ /dev/null >@@ -1,75 +0,0 @@ >-/* >- * 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" >- >-#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(); >-} >- >-} >diff --git a/WebCore/storage/SessionStorage.h b/WebCore/storage/SessionStorage.h >deleted file mode 100644 >index 6e62c4c..0000000 >--- a/WebCore/storage/SessionStorage.h >+++ /dev/null >@@ -1,63 +0,0 @@ >-/* >- * 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 >- >-#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 // SessionStorage_h >diff --git a/WebCore/storage/StorageArea.cpp b/WebCore/storage/StorageArea.cpp >index 9ca414e..e00a98d 100644 >--- a/WebCore/storage/StorageArea.cpp >+++ b/WebCore/storage/StorageArea.cpp >@@ -40,17 +40,20 @@ > > 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_storageAreaSync(0) > , m_storageSyncManager(syncManager) >- , m_sessionStoragePage(0) >+#ifndef NDEBUG >+ , m_isShutdown(false) >+#endif > { > ASSERT(m_securityOrigin); > ASSERT(m_storageMap); >@@ -64,39 +67,36 @@ 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, this)); >-} >- >-StorageArea::StorageArea(SecurityOrigin* origin, Page* page, StorageArea* area) >- : m_securityOrigin(origin) >+StorageArea::StorageArea(SecurityOrigin* origin, StorageArea* area) >+ : m_storageType(area->m_storageType) >+ , m_securityOrigin(origin) > , m_storageMap(area->m_storageMap) > , m_storageAreaSync(0) >- , m_storageSyncManager(0) >- , m_sessionStoragePage(page) >+ , 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; >@@ -111,6 +111,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); >@@ -118,6 +119,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(); > >@@ -149,6 +151,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()) >@@ -169,6 +172,7 @@ void StorageArea::removeItem(const String& key, Frame* frame) > > void StorageArea::clear(Frame* frame) > { >+ ASSERT(!m_isShutdown); > blockUntilImportComplete(); > > if (frame->page()->settings()->privateBrowsingEnabled()) >@@ -183,6 +187,7 @@ void StorageArea::clear(Frame* frame) > > bool StorageArea::contains(const String& key) const > { >+ ASSERT(!m_isShutdown); > blockUntilImportComplete(); > > return m_storageMap->contains(key); >@@ -190,19 +195,24 @@ 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::blockUntilImportComplete() const > { > if (m_storageAreaSync) >- m_storageAreaSync->scheduleFinalSync(); >+ m_storageAreaSync->blockUntilImportComplete(); > } > >-void StorageArea::blockUntilImportComplete() const >+void StorageArea::close() > { > if (m_storageAreaSync) >- m_storageAreaSync->blockUntilImportComplete(); >+ m_storageAreaSync->scheduleFinalSync(); >+ >+#ifndef NDEBUG >+ m_isShutdown = true; >+#endif > } > > void StorageArea::dispatchStorageEvent(const String& key, const String& oldValue, const String& newValue, Frame* sourceFrame) >@@ -211,18 +221,18 @@ 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); > } > } 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(); >diff --git a/WebCore/storage/StorageArea.h b/WebCore/storage/StorageArea.h >index 2f17e83..543e7e6 100644 >--- a/WebCore/storage/StorageArea.h >+++ b/WebCore/storage/StorageArea.h >@@ -46,12 +46,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*); > > // The HTML5 DOM Storage API > unsigned length() const; >@@ -62,28 +62,31 @@ namespace WebCore { > void clear(Frame* sourceFrame); > > bool contains(const String& key) const; >- void scheduleFinalSync(); >+ void close(); > > // Could be called from a background thread. > void importItem(const String& key, const String& value); > SecurityOrigin* securityOrigin() { return m_securityOrigin.get(); } > > protected: >- StorageArea(SecurityOrigin*, PassRefPtr<StorageSyncManager>); >- StorageArea(SecurityOrigin*, Page*); >- StorageArea(SecurityOrigin*, Page*, StorageArea*); >+ StorageArea(StorageType, SecurityOrigin*, PassRefPtr<StorageSyncManager>); >+ StorageArea(SecurityOrigin*, StorageArea*); > > private: > void blockUntilImportComplete() const; > > void dispatchStorageEvent(const String& key, const String& oldValue, const String& newValue, Frame* sourceFrame); > >+ StorageType m_storageType; > RefPtr<SecurityOrigin> m_securityOrigin; > RefPtr<StorageMap> m_storageMap; > > RefPtr<StorageAreaSync> m_storageAreaSync; > RefPtr<StorageSyncManager> m_storageSyncManager; >- Page* m_sessionStoragePage; // NULL iff it's LocalStorage >+ >+#ifndef NDEBUG >+ bool m_isShutdown; >+#endif > }; > > } // namespace WebCore >diff --git a/WebCore/storage/StorageAreaSync.cpp b/WebCore/storage/StorageAreaSync.cpp >index e2ffd9d..e8beaf0 100644 >--- a/WebCore/storage/StorageAreaSync.cpp >+++ b/WebCore/storage/StorageAreaSync.cpp >@@ -74,6 +74,9 @@ void StorageAreaSync::scheduleFinalSync() > { > ASSERT(isMainThread()); > >+ // FIXME: Avoid races without having to block on the import here. >+ blockUntilImportComplete(); >+ > if (m_syncTimer.isActive()) > m_syncTimer.stop(); > else { >diff --git a/WebCore/storage/StorageNamespace.cpp b/WebCore/storage/StorageNamespace.cpp >new file mode 100644 >index 0000000..03eef00 >--- /dev/null >+++ b/WebCore/storage/StorageNamespace.cpp >@@ -0,0 +1,135 @@ >+/* >+ * 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 "StorageNamespace.h" >+ >+// FIXME: Do we need all of these >+#include "CString.h" >+#include "EventNames.h" >+#include "FileSystem.h" >+#include "Frame.h" >+#include "FrameTree.h" >+#include "Page.h" >+#include "PageGroup.h" >+#include "StorageArea.h" >+#include "StorageSyncManager.h" >+#include <wtf/StdLibExtras.h> >+ >+namespace WebCore { >+ >+typedef HashMap<String, StorageNamespace*> LocalStorageNamespaceMap; >+ >+static LocalStorageNamespaceMap& localStorageNamespaceMap() >+{ >+ DEFINE_STATIC_LOCAL(LocalStorageNamespaceMap, localStorageNamespaceMap, ()); >+ return localStorageNamespaceMap; >+} >+ >+PassRefPtr<StorageNamespace> StorageNamespace::localStorageNamespace(const String& path) >+{ >+ const String lookupPath = path.isNull() ? String("") : path; >+ LocalStorageNamespaceMap::iterator it = localStorageNamespaceMap().find(lookupPath); >+ if (it == localStorageNamespaceMap().end()) { >+ RefPtr<StorageNamespace> storageNamespace = adoptRef(new StorageNamespace(LocalStorage, lookupPath)); >+ localStorageNamespaceMap().set(lookupPath, storageNamespace.get()); >+ return storageNamespace.release(); >+ } >+ >+ return it->second; >+} >+ >+PassRefPtr<StorageNamespace> StorageNamespace::sessionStorageNamespace() >+{ >+ return adoptRef(new StorageNamespace(SessionStorage, String())); >+} >+ >+StorageNamespace::StorageNamespace(StorageType storageType, const String& path) >+ : m_storageType(storageType) >+ , m_path(path.copy()) // FIXME: Is the .copy necessary? >+ , m_syncManager(0) >+#ifndef NDEBUG >+ , m_isShutdown(false) >+#endif >+{ >+ if (m_storageType == LocalStorage && !m_path.isEmpty()) >+ m_syncManager = StorageSyncManager::create(m_path); >+} >+ >+StorageNamespace::~StorageNamespace() >+{ >+ ASSERT(isMainThread()); >+ >+ if (m_storageType == LocalStorage) { >+ ASSERT(localStorageNamespaceMap().get(m_path) == this); >+ localStorageNamespaceMap().remove(m_path); >+ } >+} >+ >+PassRefPtr<StorageNamespace> StorageNamespace::copy() >+{ >+ ASSERT(isMainThread()); >+ ASSERT(!m_isShutdown); >+ >+ RefPtr<StorageNamespace> newNamespace = adoptRef(new StorageNamespace(m_storageType, m_path)); >+ >+ StorageAreaMap::iterator end = m_storageAreaMap.end(); >+ for (StorageAreaMap::iterator i = m_storageAreaMap.begin(); i != end; ++i) { >+ RefPtr<StorageArea> areaCopy = i->second->copy(i->first.get()); >+ newNamespace->m_storageAreaMap.set(i->first, areaCopy.release()); >+ } >+ >+ return newNamespace.release(); >+} >+ >+PassRefPtr<StorageArea> StorageNamespace::storageArea(SecurityOrigin* origin) >+{ >+ ASSERT(isMainThread()); >+ ASSERT(!m_isShutdown); >+ >+ RefPtr<StorageArea> storageArea; >+ if (storageArea = m_storageAreaMap.get(origin)) >+ return storageArea.release(); >+ >+ storageArea = StorageArea::create(m_storageType, origin, m_syncManager); >+ m_storageAreaMap.set(origin, storageArea); >+ return storageArea.release(); >+} >+ >+void StorageNamespace::close() >+{ >+ ASSERT(isMainThread()); >+ ASSERT(!m_isShutdown); >+ >+ StorageAreaMap::iterator end = m_storageAreaMap.end(); >+ for (StorageAreaMap::iterator it = m_storageAreaMap.begin(); it != end; ++it) >+ it->second->close(); >+ >+#ifndef NDEBUG >+ m_isShutdown = true; >+#endif >+} >+ >+} // namespace WebCore >diff --git a/WebCore/storage/StorageNamespace.h b/WebCore/storage/StorageNamespace.h >new file mode 100644 >index 0000000..77e8fe9 >--- /dev/null >+++ b/WebCore/storage/StorageNamespace.h >@@ -0,0 +1,70 @@ >+/* >+ * 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 StorageNamespace_h >+#define StorageNamespace_h >+ >+#include "SecurityOriginHash.h" >+#include "StorageArea.h" >+ >+#include <wtf/HashMap.h> >+#include <wtf/RefCounted.h> >+ >+namespace WebCore { >+ >+ class StorageArea; >+ class StorageSyncManager; >+ >+ class StorageNamespace : public RefCounted<StorageNamespace> { >+ public: >+ ~StorageNamespace(); >+ >+ static PassRefPtr<StorageNamespace> sessionStorageNamespace(); >+ static PassRefPtr<StorageNamespace> localStorageNamespace(const String& path); >+ >+ PassRefPtr<StorageArea> storageArea(SecurityOrigin*); >+ PassRefPtr<StorageNamespace> copy(); >+ void close(); >+ >+ private: >+ StorageNamespace(StorageType, const String& path); >+ >+ typedef HashMap<RefPtr<SecurityOrigin>, RefPtr<StorageArea>, SecurityOriginHash> StorageAreaMap; >+ StorageAreaMap m_storageAreaMap; >+ >+ StorageType m_storageType; >+ >+ // Only used iff m_storageType == LocalStorage and we're persistent. >+ String m_path; >+ RefPtr<StorageSyncManager> m_syncManager; >+ >+#ifndef NDEBUG >+ bool m_isShutdown; >+#endif >+ }; >+ >+} // namespace WebCore >+ >+#endif // StorageNamespace_h
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 25376
:
30936
|
30978
|
31014
|
31016
|
31024
|
31085
|
31193
|
31389
|
31395
|
31504
|
31571
|
31685