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 1 - v3
1.20090616.patch (text/plain), 39.55 KB, created by
Jeremy Orlow
on 2009-06-16 15:56:30 PDT
(
hide
)
Description:
patch 1 - v3
Filename:
MIME Type:
Creator:
Jeremy Orlow
Created:
2009-06-16 15:56:30 PDT
Size:
39.55 KB
patch
obsolete
>Index: WebCore/ChangeLog >=================================================================== >--- WebCore/ChangeLog (revision 44745) >+++ WebCore/ChangeLog (working copy) >@@ -1,3 +1,62 @@ >+2009-06-16 Jeremy Orlow <jorlow@chromium.org> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ First step in https://bugs.webkit.org/show_bug.cgi?id=25376 >+ >+ Add StorageSyncManager.cpp/h >+ >+ * GNUmakefile.am: >+ * WebCore.pro: >+ * WebCore.vcproj/WebCore.vcproj: >+ * WebCore.xcodeproj/project.pbxproj: >+ * WebCoreSources.bkl: >+ >+ In preparation for combining SessionStorage and LocalStorage into a >+ single StorageManager, move the syncing bits out of LocalStorage and >+ into its own class. >+ >+ The next step is to combine LocalStorageArea and SessionStorageArea >+ into one. Then SessionStorage and LocalStorage can be combined. >+ >+ Note that combining them will cut down on code paths that must be >+ proxied, eliminate virtual dispatch, and allow Chromium to (eventually) >+ write historical sessionStorage to disk when memory is getting tight. >+ >+ Also remove a couple bits of cruft including code for quotas which is >+ unnecessary (since a meta-data db is unnecessary since you can just >+ count bytes as you read the local storage databases into memory). >+ >+ * storage/LocalStorage.cpp: >+ (WebCore::LocalStorage::LocalStorage): >+ (WebCore::LocalStorage::storageArea): >+ (WebCore::LocalStorage::close): >+ * storage/LocalStorage.h: >+ * storage/LocalStorageArea.cpp: >+ (WebCore::LocalStorageArea::LocalStorageArea): >+ (WebCore::LocalStorageArea::scheduleFinalSync): >+ (WebCore::LocalStorageArea::syncTimerFired): >+ (WebCore::LocalStorageArea::performImport): >+ * storage/LocalStorageArea.h: >+ (WebCore::LocalStorageArea::create): >+ * storage/LocalStorageTask.cpp: >+ (WebCore::LocalStorageTask::performTask): >+ * storage/LocalStorageTask.h: >+ (WebCore::LocalStorageTask::): >+ (WebCore::LocalStorageTask::createImport): >+ * storage/LocalStorageThread.cpp: >+ * storage/LocalStorageThread.h: >+ * storage/SessionStorage.h: >+ * storage/StorageSyncManager.cpp: Copied from WebCore/storage/LocalStorage.cpp. >+ (WebCore::StorageSyncManager::create): >+ (WebCore::StorageSyncManager::StorageSyncManager): >+ (WebCore::StorageSyncManager::fullDatabaseFilename): >+ (WebCore::StorageSyncManager::close): >+ (WebCore::StorageSyncManager::scheduleImport): >+ (WebCore::StorageSyncManager::scheduleSync): >+ * storage/StorageSyncManager.h: Copied from WebCore/storage/LocalStorage.h. >+ (WebCore::): >+ > 2009-06-16 Jian Li <jianli@chromium.org> > > Reviewed by Dimitri Glazkov. >Index: WebCore/GNUmakefile.am >=================================================================== >--- WebCore/GNUmakefile.am (revision 44745) >+++ WebCore/GNUmakefile.am (working copy) >@@ -2079,7 +2079,9 @@ webcore_sources += \ > WebCore/storage/StorageEvent.cpp \ > WebCore/storage/StorageEvent.h \ > WebCore/storage/StorageMap.cpp \ >- WebCore/storage/StorageMap.h >+ WebCore/storage/StorageMap.h \ >+ WebCore/storage/StorageSyncManager.cpp \ >+ WebCore/storage/StorageSyncManager.h > endif # END ENABLE_DOM_STORAGE > > # ---- >Index: WebCore/WebCore.pro >=================================================================== >--- WebCore/WebCore.pro (revision 44745) >+++ WebCore/WebCore.pro (working copy) >@@ -1364,6 +1364,7 @@ contains(DEFINES, ENABLE_DOM_STORAGE=1) > storage/StorageEvent.cpp \ > storage/SessionStorage.cpp \ > storage/SessionStorageArea.cpp \ >+ storage/StorageSyncManager.cpp \ > bindings/js/JSStorageCustom.cpp > > IDL_BINDINGS += \ >Index: WebCore/WebCoreSources.bkl >=================================================================== >--- WebCore/WebCoreSources.bkl (revision 44745) >+++ WebCore/WebCoreSources.bkl (working copy) >@@ -1015,6 +1015,7 @@ This file contains the list of files nee > storage/StorageMap.cpp > storage/SessionStorage.cpp > storage/SessionStorageArea.cpp >+ storage/StorageSyncManager.cpp > </set> > > <set append="1" var="WEBCORE_SOURCES_XML"> >Index: WebCore/WebCore.vcproj/WebCore.vcproj >=================================================================== >--- WebCore/WebCore.vcproj/WebCore.vcproj (revision 44745) >+++ WebCore/WebCore.vcproj/WebCore.vcproj (working copy) >@@ -15659,6 +15659,14 @@ > > > </File> > <File >+ RelativePath="..\storage\StorageSyncManager.cpp" >+ > >+ </File> >+ <File >+ RelativePath="..\storage\StorageSyncManager.h" >+ > >+ </File> >+ <File > RelativePath="..\storage\VersionChangeCallback.h" > > > </File> >Index: WebCore/WebCore.xcodeproj/project.pbxproj >=================================================================== >--- WebCore/WebCore.xcodeproj/project.pbxproj (revision 44745) >+++ WebCore/WebCore.xcodeproj/project.pbxproj (working copy) >@@ -4258,6 +4258,8 @@ > C0DFC8700DB6841A003EAE7C /* JSConsoleCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C0DFC86F0DB6841A003EAE7C /* JSConsoleCustom.cpp */; }; > C105DA620F3AA68F001DD44F /* TextEncodingDetectorICU.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C105DA610F3AA68F001DD44F /* TextEncodingDetectorICU.cpp */; }; > C105DA640F3AA6B8001DD44F /* TextEncodingDetector.h in Headers */ = {isa = PBXBuildFile; fileRef = C105DA630F3AA6B8001DD44F /* TextEncodingDetector.h */; }; >+ C5102D940FD9AA2D00FAFF04 /* StorageSyncManager.h in Headers */ = {isa = PBXBuildFile; fileRef = C5102D920FD9AA2D00FAFF04 /* StorageSyncManager.h */; }; >+ C5102D950FD9AA2D00FAFF04 /* StorageSyncManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C5102D930FD9AA2D00FAFF04 /* StorageSyncManager.cpp */; }; > C6D74AD509AA282E000B0A52 /* ModifySelectionListLevel.h in Headers */ = {isa = PBXBuildFile; fileRef = C6D74AD309AA282E000B0A52 /* ModifySelectionListLevel.h */; }; > C6D74AE409AA290A000B0A52 /* ModifySelectionListLevel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C6D74AE309AA290A000B0A52 /* ModifySelectionListLevel.cpp */; }; > D05CED290A40BB2C00C5AF38 /* FormatBlockCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D05CED270A40BB2C00C5AF38 /* FormatBlockCommand.cpp */; }; >@@ -9057,6 +9059,8 @@ > C0DFC86F0DB6841A003EAE7C /* JSConsoleCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSConsoleCustom.cpp; sourceTree = "<group>"; }; > C105DA610F3AA68F001DD44F /* TextEncodingDetectorICU.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextEncodingDetectorICU.cpp; sourceTree = "<group>"; }; > C105DA630F3AA6B8001DD44F /* TextEncodingDetector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextEncodingDetector.h; sourceTree = "<group>"; }; >+ C5102D920FD9AA2D00FAFF04 /* StorageSyncManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StorageSyncManager.h; sourceTree = "<group>"; }; >+ C5102D930FD9AA2D00FAFF04 /* StorageSyncManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StorageSyncManager.cpp; sourceTree = "<group>"; }; > C6D74AD309AA282E000B0A52 /* ModifySelectionListLevel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ModifySelectionListLevel.h; sourceTree = "<group>"; }; > C6D74AE309AA290A000B0A52 /* ModifySelectionListLevel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ModifySelectionListLevel.cpp; sourceTree = "<group>"; }; > D05CED270A40BB2C00C5AF38 /* FormatBlockCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = FormatBlockCommand.cpp; sourceTree = "<group>"; }; >@@ -9646,6 +9650,8 @@ > 51E0BABD0DA5548400A9E417 /* StorageEvent.idl */, > 51E0BB370DA5ACB600A9E417 /* StorageMap.cpp */, > 51E0BB360DA5ACB600A9E417 /* StorageMap.h */, >+ C5102D920FD9AA2D00FAFF04 /* StorageSyncManager.h */, >+ C5102D930FD9AA2D00FAFF04 /* StorageSyncManager.cpp */, > ); > indentWidth = 4; > path = storage; >@@ -16795,6 +16801,7 @@ > 081EBF3B0FD34F4100DA7559 /* SVGFilterBuilder.h in Headers */, > 18F831B80FD48C7800D8C56B /* WorkerLoaderProxy.h in Headers */, > A89CCC530F44E98100B5DA10 /* ReplaceNodeWithSpanCommand.h in Headers */, >+ C5102D940FD9AA2D00FAFF04 /* StorageSyncManager.h in Headers */, > 2EA768040FE7126400AB9C8A /* WorkerScriptLoaderClient.h in Headers */, > ); > runOnlyForDeploymentPostprocessing = 0; >@@ -18789,6 +18796,7 @@ > 845E72FB0FD2623900A87D79 /* SVGFilter.cpp in Sources */, > 081EBF3A0FD34F4100DA7559 /* SVGFilterBuilder.cpp in Sources */, > A89CCC520F44E98100B5DA10 /* ReplaceNodeWithSpanCommand.cpp in Sources */, >+ C5102D950FD9AA2D00FAFF04 /* StorageSyncManager.cpp in Sources */, > ); > runOnlyForDeploymentPostprocessing = 0; > }; >Index: WebCore/storage/LocalStorage.cpp >=================================================================== >--- WebCore/storage/LocalStorage.cpp (revision 44745) >+++ WebCore/storage/LocalStorage.cpp (working copy) >@@ -37,6 +37,7 @@ > #include "Page.h" > #include "PageGroup.h" > #include "StorageArea.h" >+#include "StorageSyncManager.h" > #include <wtf/StdLibExtras.h> > > namespace WebCore { >@@ -64,15 +65,10 @@ PassRefPtr<LocalStorage> LocalStorage::l > > LocalStorage::LocalStorage(const String& path) > : m_path(path.copy()) >+ , m_syncManager(0) > { >- // If the path is empty, we know we're never going to be using the thread for anything, so don't start it. >- // In the future, we might also want to consider removing it from the DOM in that case - <rdar://problem/5960470> >- if (path.isEmpty()) >- return; >- >- m_thread = LocalStorageThread::create(); >- m_thread->start(); >- m_thread->scheduleImport(this); >+ if (!m_path.isEmpty()) >+ m_syncManager = StorageSyncManager::create(m_path); > } > > LocalStorage::~LocalStorage() >@@ -92,54 +88,18 @@ PassRefPtr<StorageArea> LocalStorage::st > // 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<LocalStorageArea> storageArea; > if (storageArea = m_storageAreaMap.get(origin)) > return storageArea.release(); >- >- storageArea = LocalStorageArea::create(origin, this); >+ >+ storageArea = LocalStorageArea::create(origin, m_syncManager); > m_storageAreaMap.set(origin, storageArea); > return storageArea.release(); > } > >-String LocalStorage::fullDatabaseFilename(SecurityOrigin* origin) >-{ >- // FIXME: Once we actually track origin/quota entries to see which origins have local storage established, >- // we will return an empty path name if the origin isn't allowed to have LocalStorage. >- // We'll need to wait here until the AreaImport task to complete before making that decision. >- >- if (m_path.isEmpty()) >- return String(); >- >- ASSERT(origin); >- if (!origin) >- return String(); >- >- if (!makeAllDirectories(m_path)) { >- LOG_ERROR("Unabled to create LocalStorage database path %s", m_path.utf8().data()); >- return String(); >- } >- >- return pathByAppendingComponent(m_path, origin->databaseIdentifier() + ".localstorage"); >-} >- >-void LocalStorage::performImport() >-{ >- ASSERT(!isMainThread()); >- >- // FIXME: Import all known local storage origins here along with their quotas >-} >- >-void LocalStorage::performSync() >-{ >- ASSERT(!isMainThread()); >- >- // FIXME: Write out new origins and quotas here >-} >- > void LocalStorage::close() > { > ASSERT(isMainThread()); >@@ -147,28 +107,8 @@ void LocalStorage::close() > LocalStorageAreaMap::iterator end = m_storageAreaMap.end(); > for (LocalStorageAreaMap::iterator it = m_storageAreaMap.begin(); it != end; ++it) > it->second->scheduleFinalSync(); >- >- if (m_thread) { >- m_thread->terminate(); >- m_thread = 0; >- } >-} >- >-bool LocalStorage::scheduleImport(PassRefPtr<LocalStorageArea> area) >-{ >- ASSERT(isMainThread()); >- >- if (m_thread) >- m_thread->scheduleImport(area); >- >- return m_thread; >-} >- >-void LocalStorage::scheduleSync(PassRefPtr<LocalStorageArea> area) >-{ >- ASSERT(isMainThread()); >- if (m_thread) >- m_thread->scheduleSync(area); >+ >+ m_syncManager = 0; > } > > } // namespace WebCore >Index: WebCore/storage/LocalStorage.h >=================================================================== >--- WebCore/storage/LocalStorage.h (revision 44745) >+++ WebCore/storage/LocalStorage.h (working copy) >@@ -29,20 +29,17 @@ > #if ENABLE(DOM_STORAGE) > > #include "LocalStorageArea.h" >-#include "LocalStorageTask.h" >-#include "LocalStorageThread.h" > #include "SecurityOriginHash.h" > > #include <wtf/HashMap.h> >-#include <wtf/HashSet.h> >-#include <wtf/Threading.h> >+#include <wtf/RefCounted.h> > > namespace WebCore { > >- class PageGroup; > class StorageArea; >+ class StorageSyncManager; > >- class LocalStorage : public ThreadSafeShared<LocalStorage> { >+ class LocalStorage : public RefCounted<LocalStorage> { > public: > ~LocalStorage(); > >@@ -50,9 +47,6 @@ namespace WebCore { > > PassRefPtr<StorageArea> storageArea(SecurityOrigin*); > >- bool scheduleImport(PassRefPtr<LocalStorageArea>); >- void scheduleSync(PassRefPtr<LocalStorageArea>); >- > void close(); > > private: >@@ -61,21 +55,8 @@ namespace WebCore { > typedef HashMap<RefPtr<SecurityOrigin>, RefPtr<LocalStorageArea>, SecurityOriginHash> LocalStorageAreaMap; > LocalStorageAreaMap m_storageAreaMap; > >- RefPtr<LocalStorageThread> m_thread; >- >- // The following members are subject to thread synchronization issues >- public: >- // To be called from the background thread: >- String fullDatabaseFilename(SecurityOrigin*); >- >- void performImport(); >- void performSync(); >- >- private: > String m_path; >- >- typedef HashMap<RefPtr<SecurityOrigin>, unsigned long long, SecurityOriginHash> SecurityOriginQuoteMap; >- SecurityOriginQuoteMap m_securityOriginQuoteMap; >+ RefPtr<StorageSyncManager> m_syncManager; > }; > > } // namespace WebCore >Index: WebCore/storage/LocalStorageArea.cpp >=================================================================== >--- WebCore/storage/LocalStorageArea.cpp (revision 44745) >+++ WebCore/storage/LocalStorageArea.cpp (working copy) >@@ -46,19 +46,17 @@ namespace WebCore { > // Instead, queue up a batch of items to sync and actually do the sync at the following interval. > static const double LocalStorageSyncInterval = 1.0; > >-LocalStorageArea::LocalStorageArea(SecurityOrigin* origin, LocalStorage* localStorage) >+LocalStorageArea::LocalStorageArea(SecurityOrigin* origin, PassRefPtr<StorageSyncManager> syncManager) > : StorageArea(origin) > , m_syncTimer(this, &LocalStorageArea::syncTimerFired) > , m_itemsCleared(false) > , m_finalSyncScheduled(false) >- , m_localStorage(localStorage) >+ , m_syncManager(syncManager) > , m_clearItemsWhileSyncing(false) > , m_syncScheduled(false) > , m_importComplete(false) > { >- ASSERT(m_localStorage); >- >- if (!m_localStorage->scheduleImport(this)) >+ if (!m_syncManager || !m_syncManager->scheduleImport(this)) > m_importComplete = true; > } > >@@ -69,6 +67,10 @@ LocalStorageArea::~LocalStorageArea() > > void LocalStorageArea::scheduleFinalSync() > { >+ ASSERT(isMainThread()); >+ if (!m_syncManager) >+ return; >+ > if (m_syncTimer.isActive()) > m_syncTimer.stop(); > else { >@@ -269,6 +271,8 @@ void LocalStorageArea::scheduleClear() > void LocalStorageArea::syncTimerFired(Timer<LocalStorageArea>*) > { > ASSERT(isMainThread()); >+ if (!m_syncManager) >+ return; > > HashMap<String, String>::iterator it = m_changedItems.begin(); > HashMap<String, String>::iterator end = m_changedItems.end(); >@@ -292,7 +296,7 @@ void LocalStorageArea::syncTimerFired(Ti > // performSync function. > disableSuddenTermination(); > >- m_localStorage->scheduleSync(this); >+ m_syncManager->scheduleSync(this); > } > } > >@@ -307,9 +311,11 @@ void LocalStorageArea::performImport() > { > ASSERT(!isMainThread()); > ASSERT(!m_database.isOpen()); >+ if (!m_syncManager) >+ return; >+ >+ String databaseFilename = m_syncManager->fullDatabaseFilename(securityOrigin()); > >- String databaseFilename = m_localStorage->fullDatabaseFilename(securityOrigin()); >- > if (databaseFilename.isEmpty()) { > LOG_ERROR("Filename for local storage database is empty - cannot open for persistent storage"); > markImported(); >Index: WebCore/storage/LocalStorageArea.h >=================================================================== >--- WebCore/storage/LocalStorageArea.h (revision 44745) >+++ WebCore/storage/LocalStorageArea.h (working copy) >@@ -31,23 +31,24 @@ > #include "SQLiteDatabase.h" > #include "StorageArea.h" > #include "StringHash.h" >+#include "StorageSyncManager.h" > #include "Timer.h" > #include <wtf/HashMap.h> > > namespace WebCore { > >- class LocalStorage; >+ class StorageSyncManager; > > class LocalStorageArea : public StorageArea { > public: > virtual ~LocalStorageArea(); > >- static PassRefPtr<LocalStorageArea> create(SecurityOrigin* origin, LocalStorage* localStorage) { return adoptRef(new LocalStorageArea(origin, localStorage)); } >+ static PassRefPtr<LocalStorageArea> create(SecurityOrigin* origin, PassRefPtr<StorageSyncManager> syncManager) { return adoptRef(new LocalStorageArea(origin, syncManager)); } > > void scheduleFinalSync(); > > private: >- LocalStorageArea(SecurityOrigin*, LocalStorage*); >+ LocalStorageArea(SecurityOrigin*, PassRefPtr<StorageSyncManager> syncManager); > > virtual void itemChanged(const String& key, const String& oldValue, const String& newValue, Frame* sourceFrame); > virtual void itemRemoved(const String& key, const String& oldValue, Frame* sourceFrame); >@@ -63,7 +64,7 @@ namespace WebCore { > > bool m_finalSyncScheduled; > >- LocalStorage* m_localStorage; >+ RefPtr<StorageSyncManager> m_syncManager; > > // The database handle will only ever be opened and used on the background thread. > SQLiteDatabase m_database; >Index: WebCore/storage/LocalStorageTask.cpp >=================================================================== >--- WebCore/storage/LocalStorageTask.cpp (revision 44745) >+++ WebCore/storage/LocalStorageTask.cpp (working copy) >@@ -42,14 +42,6 @@ LocalStorageTask::LocalStorageTask(Type > ASSERT(m_type == AreaImport || m_type == AreaSync); > } > >-LocalStorageTask::LocalStorageTask(Type type, PassRefPtr<LocalStorage> storage) >- : m_type(type) >- , m_storage(storage) >-{ >- ASSERT(m_storage); >- ASSERT(m_type == StorageImport || m_type == StorageSync); >-} >- > LocalStorageTask::LocalStorageTask(Type type, PassRefPtr<LocalStorageThread> thread) > : m_type(type) > , m_thread(thread) >@@ -61,14 +53,6 @@ LocalStorageTask::LocalStorageTask(Type > void LocalStorageTask::performTask() > { > switch (m_type) { >- case StorageImport: >- ASSERT(m_storage); >- m_storage->performImport(); >- break; >- case StorageSync: >- ASSERT(m_storage); >- m_storage->performSync(); >- break; > case AreaImport: > ASSERT(m_area); > m_area->performImport(); >Index: WebCore/storage/LocalStorageTask.h >=================================================================== >--- WebCore/storage/LocalStorageTask.h (revision 44745) >+++ WebCore/storage/LocalStorageTask.h (working copy) >@@ -34,17 +34,14 @@ > > namespace WebCore { > >- class LocalStorage; > class LocalStorageArea; > class LocalStorageThread; > > class LocalStorageTask : public ThreadSafeShared<LocalStorageTask> { > public: >- enum Type { StorageImport, StorageSync, AreaImport, AreaSync, TerminateThread }; >+ enum Type { AreaImport, AreaSync, TerminateThread }; > >- static PassRefPtr<LocalStorageTask> createImport(PassRefPtr<LocalStorage> storage) { return adoptRef(new LocalStorageTask(StorageImport, storage)); } > static PassRefPtr<LocalStorageTask> createImport(PassRefPtr<LocalStorageArea> area) { return adoptRef(new LocalStorageTask(AreaImport, area)); } >- static PassRefPtr<LocalStorageTask> createSync(PassRefPtr<LocalStorage> storage) { return adoptRef(new LocalStorageTask(StorageSync, storage)); } > static PassRefPtr<LocalStorageTask> createSync(PassRefPtr<LocalStorageArea> area) { return adoptRef(new LocalStorageTask(AreaSync, area)); } > static PassRefPtr<LocalStorageTask> createTerminate(PassRefPtr<LocalStorageThread> thread) { return adoptRef(new LocalStorageTask(TerminateThread, thread)); } > >@@ -52,12 +49,10 @@ namespace WebCore { > > private: > LocalStorageTask(Type, PassRefPtr<LocalStorageArea>); >- LocalStorageTask(Type, PassRefPtr<LocalStorage>); > LocalStorageTask(Type, PassRefPtr<LocalStorageThread>); > > Type m_type; > RefPtr<LocalStorageArea> m_area; >- RefPtr<LocalStorage> m_storage; > RefPtr<LocalStorageThread> m_thread; > }; > >Index: WebCore/storage/LocalStorageThread.cpp >=================================================================== >--- WebCore/storage/LocalStorageThread.cpp (revision 44745) >+++ WebCore/storage/LocalStorageThread.cpp (working copy) >@@ -87,18 +87,6 @@ void* LocalStorageThread::localStorageTh > return 0; > } > >-void LocalStorageThread::scheduleImport(PassRefPtr<LocalStorage> storage) >-{ >- ASSERT(!m_queue.killed() && m_threadID); >- m_queue.append(LocalStorageTask::createImport(storage)); >-} >- >-void LocalStorageThread::scheduleSync(PassRefPtr<LocalStorage> storage) >-{ >- ASSERT(!m_queue.killed() && m_threadID); >- m_queue.append(LocalStorageTask::createSync(storage)); >-} >- > void LocalStorageThread::scheduleImport(PassRefPtr<LocalStorageArea> area) > { > ASSERT(!m_queue.killed() && m_threadID); >Index: WebCore/storage/LocalStorageThread.h >=================================================================== >--- WebCore/storage/LocalStorageThread.h (revision 44745) >+++ WebCore/storage/LocalStorageThread.h (working copy) >@@ -35,7 +35,6 @@ > > namespace WebCore { > >- class LocalStorage; > class LocalStorageArea; > class LocalStorageTask; > >@@ -45,8 +44,6 @@ namespace WebCore { > > bool start(); > >- void scheduleImport(PassRefPtr<LocalStorage>); >- void scheduleSync(PassRefPtr<LocalStorage>); > void scheduleImport(PassRefPtr<LocalStorageArea>); > void scheduleSync(PassRefPtr<LocalStorageArea>); > >Index: WebCore/storage/SessionStorage.h >=================================================================== >--- WebCore/storage/SessionStorage.h (revision 44745) >+++ WebCore/storage/SessionStorage.h (working copy) >@@ -32,7 +32,6 @@ > #include "SessionStorageArea.h" > > #include <wtf/HashMap.h> >-#include <wtf/HashSet.h> > #include <wtf/RefCounted.h> > > namespace WebCore { >Index: WebCore/storage/StorageSyncManager.cpp >=================================================================== >--- WebCore/storage/StorageSyncManager.cpp (revision 44745) (from WebCore/storage/LocalStorage.cpp:44745) >+++ WebCore/storage/StorageSyncManager.cpp (working copy) >@@ -0,0 +1,177 @@ >+/* >+ * 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" >+ >+#if ENABLE(DOM_STORAGE) >+ >+#include "CString.h" >+#include "EventNames.h" >+#include "FileSystem.h" >+#include "Frame.h" >+#include "FrameTree.h" >+#include "LocalStorageArea.h" >+#include "Page.h" >+#include "PageGroup.h" >+#include "StorageArea.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()) >+{ >+ // If the path is empty, we know we're never going to be using the thread for anything, so don't start it. >+ // In the future, we might also want to consider removing it from the DOM in that case - <rdar://problem/5960470> >+ if (path.isEmpty()) >+ return; >+ >+ m_thread = LocalStorageThread::create(); >+ m_thread->start(); >+ m_thread->scheduleImport(this); >+} >+ >+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<LocalStorageArea> storageArea; >+ if (storageArea = m_storageAreaMap.get(origin)) >+ return storageArea.release(); >+ >+ storageArea = LocalStorageArea::create(origin, this); >+ m_storageAreaMap.set(origin, storageArea); >+ return storageArea.release(); >+} >+ >+String LocalStorage::fullDatabaseFilename(SecurityOrigin* origin) >+{ >+ // FIXME: Once we actually track origin/quota entries to see which origins have local storage established, >+ // we will return an empty path name if the origin isn't allowed to have LocalStorage. >+ // We'll need to wait here until the AreaImport task to complete before making that decision. >+ >+ if (m_path.isEmpty()) >+ return String(); >+ >+ ASSERT(origin); >+ if (!origin) >+ return String(); >+ >+ if (!makeAllDirectories(m_path)) { >+ LOG_ERROR("Unabled to create LocalStorage database path %s", m_path.utf8().data()); >+ return String(); >+ } >+ >+ return pathByAppendingComponent(m_path, origin->databaseIdentifier() + ".localstorage"); >+} >+ >+void LocalStorage::performImport() >+{ >+ ASSERT(!isMainThread()); >+ >+ // FIXME: Import all known local storage origins here along with their quotas >+} >+ >+void LocalStorage::performSync() >+{ >+ ASSERT(!isMainThread()); >+ >+ // FIXME: Write out new origins and quotas here >+} >+ >+void LocalStorage::close() >+{ >+ ASSERT(isMainThread()); >+ >+ LocalStorageAreaMap::iterator end = m_storageAreaMap.end(); >+ for (LocalStorageAreaMap::iterator it = m_storageAreaMap.begin(); it != end; ++it) >+ it->second->scheduleFinalSync(); >+ >+ if (m_thread) { >+ m_thread->terminate(); >+ m_thread = 0; >+ } >+} >+ >+bool LocalStorage::scheduleImport(PassRefPtr<LocalStorageArea> area) >+{ >+ ASSERT(isMainThread()); >+ >+ if (m_thread) >+ m_thread->scheduleImport(area); >+ >+ return m_thread; >+} >+ >+void LocalStorage::scheduleSync(PassRefPtr<LocalStorageArea> area) >+{ >+ ASSERT(isMainThread()); >+ if (m_thread) >+ m_thread->scheduleSync(area); >+} >+ >+} // namespace WebCore >+ >+#endif // ENABLE(DOM_STORAGE) >+ >Index: WebCore/storage/StorageSyncManager.cpp >=================================================================== >--- WebCore/storage/StorageSyncManager.cpp (revision 44745) >+++ WebCore/storage/StorageSyncManager.cpp (working copy) >@@ -24,16 +24,13 @@ > */ > > #include "config.h" >-#include "LocalStorage.h" >- >-#if ENABLE(DOM_STORAGE) >+#include "StorageSyncManager.h" > > #include "CString.h" > #include "EventNames.h" > #include "FileSystem.h" > #include "Frame.h" > #include "FrameTree.h" >-#include "LocalStorageArea.h" > #include "Page.h" > #include "PageGroup.h" > #include "StorageArea.h" >@@ -41,82 +38,23 @@ > > namespace WebCore { > >-typedef HashMap<String, LocalStorage*> LocalStorageMap; >- >-static LocalStorageMap& localStorageMap() >-{ >- DEFINE_STATIC_LOCAL(LocalStorageMap, localStorageMap, ()); >- return localStorageMap; >-} >- >-PassRefPtr<LocalStorage> LocalStorage::localStorage(const String& path) >+PassRefPtr<StorageSyncManager> StorageSyncManager::create(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; >+ return adoptRef(new StorageSyncManager(path)); > } > >-LocalStorage::LocalStorage(const String& path) >+StorageSyncManager::StorageSyncManager(const String& path) > : m_path(path.copy()) > { >- // If the path is empty, we know we're never going to be using the thread for anything, so don't start it. >- // In the future, we might also want to consider removing it from the DOM in that case - <rdar://problem/5960470> >- if (path.isEmpty()) >- return; >+ ASSERT(!m_path.isEmpty()); > > m_thread = LocalStorageThread::create(); > m_thread->start(); >- m_thread->scheduleImport(this); >-} >- >-LocalStorage::~LocalStorage() >-{ >- ASSERT(localStorageMap().get(m_path) == this); >- localStorageMap().remove(m_path); > } > >-PassRefPtr<StorageArea> LocalStorage::storageArea(SecurityOrigin* origin) >+String StorageSyncManager::fullDatabaseFilename(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<LocalStorageArea> storageArea; >- if (storageArea = m_storageAreaMap.get(origin)) >- return storageArea.release(); >- >- storageArea = LocalStorageArea::create(origin, this); >- m_storageAreaMap.set(origin, storageArea); >- return storageArea.release(); >-} >- >-String LocalStorage::fullDatabaseFilename(SecurityOrigin* origin) >-{ >- // FIXME: Once we actually track origin/quota entries to see which origins have local storage established, >- // we will return an empty path name if the origin isn't allowed to have LocalStorage. >- // We'll need to wait here until the AreaImport task to complete before making that decision. >- >- if (m_path.isEmpty()) >- return String(); >- > ASSERT(origin); >- if (!origin) >- return String(); > > if (!makeAllDirectories(m_path)) { > LOG_ERROR("Unabled to create LocalStorage database path %s", m_path.utf8().data()); >@@ -126,52 +64,32 @@ String LocalStorage::fullDatabaseFilenam > return pathByAppendingComponent(m_path, origin->databaseIdentifier() + ".localstorage"); > } > >-void LocalStorage::performImport() >-{ >- ASSERT(!isMainThread()); >- >- // FIXME: Import all known local storage origins here along with their quotas >-} >- >-void LocalStorage::performSync() >-{ >- ASSERT(!isMainThread()); >- >- // FIXME: Write out new origins and quotas here >-} >- >-void LocalStorage::close() >+void StorageSyncManager::close() > { > ASSERT(isMainThread()); >- >- LocalStorageAreaMap::iterator end = m_storageAreaMap.end(); >- for (LocalStorageAreaMap::iterator it = m_storageAreaMap.begin(); it != end; ++it) >- it->second->scheduleFinalSync(); >- >+ > if (m_thread) { > m_thread->terminate(); > m_thread = 0; > } > } > >-bool LocalStorage::scheduleImport(PassRefPtr<LocalStorageArea> area) >+bool StorageSyncManager::scheduleImport(PassRefPtr<LocalStorageArea> area) > { > ASSERT(isMainThread()); >- >+ > if (m_thread) > m_thread->scheduleImport(area); > > return m_thread; > } > >-void LocalStorage::scheduleSync(PassRefPtr<LocalStorageArea> area) >+void StorageSyncManager::scheduleSync(PassRefPtr<LocalStorageArea> area) > { > ASSERT(isMainThread()); >+ > if (m_thread) > m_thread->scheduleSync(area); > } > > } // namespace WebCore >- >-#endif // ENABLE(DOM_STORAGE) >- >Index: WebCore/storage/StorageSyncManager.h >=================================================================== >--- WebCore/storage/StorageSyncManager.h (revision 44745) (from WebCore/storage/LocalStorage.h:44745) >+++ WebCore/storage/StorageSyncManager.h (working copy) >@@ -0,0 +1,85 @@ >+/* >+ * 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 >+ >+#if ENABLE(DOM_STORAGE) >+ >+#include "LocalStorageArea.h" >+#include "LocalStorageTask.h" >+#include "LocalStorageThread.h" >+#include "SecurityOriginHash.h" >+ >+#include <wtf/HashMap.h> >+#include <wtf/HashSet.h> >+#include <wtf/Threading.h> >+ >+namespace WebCore { >+ >+ class PageGroup; >+ class StorageArea; >+ >+ class LocalStorage : public ThreadSafeShared<LocalStorage> { >+ public: >+ ~LocalStorage(); >+ >+ static PassRefPtr<LocalStorage> localStorage(const String& path); >+ >+ PassRefPtr<StorageArea> storageArea(SecurityOrigin*); >+ >+ bool scheduleImport(PassRefPtr<LocalStorageArea>); >+ void scheduleSync(PassRefPtr<LocalStorageArea>); >+ >+ void close(); >+ >+ private: >+ LocalStorage(const String& path); >+ >+ typedef HashMap<RefPtr<SecurityOrigin>, RefPtr<LocalStorageArea>, SecurityOriginHash> LocalStorageAreaMap; >+ LocalStorageAreaMap m_storageAreaMap; >+ >+ RefPtr<LocalStorageThread> m_thread; >+ >+ // The following members are subject to thread synchronization issues >+ public: >+ // To be called from the background thread: >+ String fullDatabaseFilename(SecurityOrigin*); >+ >+ void performImport(); >+ void performSync(); >+ >+ private: >+ String m_path; >+ >+ typedef HashMap<RefPtr<SecurityOrigin>, unsigned long long, SecurityOriginHash> SecurityOriginQuoteMap; >+ SecurityOriginQuoteMap m_securityOriginQuoteMap; >+ }; >+ >+} // namespace WebCore >+ >+#endif // ENABLE(DOM_STORAGE) >+ >+#endif // LocalStorage_h >Index: WebCore/storage/StorageSyncManager.h >=================================================================== >--- WebCore/storage/StorageSyncManager.h (revision 44745) >+++ WebCore/storage/StorageSyncManager.h (working copy) >@@ -23,32 +23,20 @@ > * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. > */ > >-#ifndef LocalStorage_h >-#define LocalStorage_h >- >-#if ENABLE(DOM_STORAGE) >+#ifndef StorageSyncManager_h >+#define StorageSyncManager_h > > #include "LocalStorageArea.h" > #include "LocalStorageTask.h" > #include "LocalStorageThread.h" >-#include "SecurityOriginHash.h" > >-#include <wtf/HashMap.h> >-#include <wtf/HashSet.h> > #include <wtf/Threading.h> > > namespace WebCore { > >- class PageGroup; >- class StorageArea; >- >- class LocalStorage : public ThreadSafeShared<LocalStorage> { >+ class StorageSyncManager: public ThreadSafeShared<StorageSyncManager> { > public: >- ~LocalStorage(); >- >- static PassRefPtr<LocalStorage> localStorage(const String& path); >- >- PassRefPtr<StorageArea> storageArea(SecurityOrigin*); >+ static PassRefPtr<StorageSyncManager> create(const String& path); > > bool scheduleImport(PassRefPtr<LocalStorageArea>); > void scheduleSync(PassRefPtr<LocalStorageArea>); >@@ -56,10 +44,7 @@ namespace WebCore { > void close(); > > private: >- LocalStorage(const String& path); >- >- typedef HashMap<RefPtr<SecurityOrigin>, RefPtr<LocalStorageArea>, SecurityOriginHash> LocalStorageAreaMap; >- LocalStorageAreaMap m_storageAreaMap; >+ StorageSyncManager(const String& path); > > RefPtr<LocalStorageThread> m_thread; > >@@ -68,18 +53,10 @@ namespace WebCore { > // To be called from the background thread: > String fullDatabaseFilename(SecurityOrigin*); > >- void performImport(); >- void performSync(); >- > private: > String m_path; >- >- typedef HashMap<RefPtr<SecurityOrigin>, unsigned long long, SecurityOriginHash> SecurityOriginQuoteMap; >- SecurityOriginQuoteMap m_securityOriginQuoteMap; > }; > > } // namespace WebCore > >-#endif // ENABLE(DOM_STORAGE) >- >-#endif // LocalStorage_h >+#endif // StorageSyncManager_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