diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2009-06-24 11:42:15 (GMT) |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2009-06-24 11:42:15 (GMT) |
commit | 259c32cd921fcbb85f79f21923d0efa0d6743d8a (patch) | |
tree | f9629c9be4b8488eb3221b48c0629a42a6ffce4c /src/3rdparty/webkit/WebCore/storage | |
parent | ff2b98cf81daf585bb657bee7f5f131769b38eca (diff) | |
download | Qt-259c32cd921fcbb85f79f21923d0efa0d6743d8a.zip Qt-259c32cd921fcbb85f79f21923d0efa0d6743d8a.tar.gz Qt-259c32cd921fcbb85f79f21923d0efa0d6743d8a.tar.bz2 |
Updated WebKit from /home/shausman/src/webkit/trunk to qtwebkit-4.6-snapshot-24062009 ( 6d5a2a0472a6af0b7f781da018e76bb8522d57a5 )
++ b/WebKit/qt/ChangeLog
2009-06-19 Daniel <qt-info@nokia.com>
Reviewed by Simon Hausmann.
Remove warnings for QString() constructions from const char *
By explicitly wrapping it with QLatin1String() / QLatin1Char()
* Api/qwebelement.cpp:
(QWebElement::classes): Use QLatin1String.
(QWebElement::addClass): Ditto.
(QWebElement::removeClass): Ditto.
(QWebElement::toggleClass): Ditto.
2009-06-18 Friedemann Kleint <Friedemann.Kleint@nokia.com>
Reviewed by Simon Hausmann.
Fixed MinGW compilation.
* Api/qwebelement.cpp:
(QWebElement::evaluateScript):
2009-06-18 Markus Goetz <Markus.Goetz@nokia.com>
Reviewed by Simon Hausman.
Clarify in docs how to compile with debug information.
* docs/qtwebkit.qdoc:
2009-06-17 Markus Goetz <Markus.Goetz@nokia.com>
Reviewed by Simon Hausmann.
QWebPage: Don't call supportsSsl()
This stops QWebPage from loading the OpenSSL libs,
certificates etc. when they are not needed for the non-HTTPS case.
Loading the SSL libraries can be a very slow operation.
* Api/qwebpage.cpp:
(QWebPage::userAgentForUrl):
2009-06-15 Benjamin C Meyer <benjamin.meyer@torchmobile.com>
Reviewed by Adam Treat.
Support the back/forward/stop/refresh multimedia keys and accept the
event when handling backspace and shift backspace as we should.
* Api/qwebpage.cpp:
(QWebPagePrivate::keyPressEvent):
2009-06-15 Andre Pedralho <andre.pedralho@openbossa.org>
Reviewed by Adam Treat.
https://bugs.webkit.org/show_bug.cgi?id=26351
Remove bool QWebHitTestResult::isScrollBar() const and make sure a null QWebHitTestResult is returned instead.
* Api/qwebframe.cpp:
(QWebFrame::hitTestContent):
* Api/qwebframe.h:
* Api/qwebpage.cpp:
(QWebPage::updatePositionDependentActions):
2009-06-15 Simon Hausmann <simon.hausmann@nokia.com>
Reviewed by Adam Treat.
Fix the logic for disabling the fixed layout feature, when an invalid
QSize is set.
* Api/qwebpage.cpp:
(QWebPage::setFixedContentsSize):
2009-06-13 Adam Barth <abarth@webkit.org>
Reviewed by Darin Fisher.
https://bugs.webkit.org/show_bug.cgi?id=24492
Move registerURLSchemeAsLocal from FrameLoader to SecurityOrigin.
* Api/qwebpage.cpp:
(QWebPage::acceptNavigationRequest):
Rubber-stamped by Simon Hausmann.
2009-06-09 Simon Hausmann <simon.hausmann@nokia.com>
Reviewed by Ariya Hidayat.
Renamed QWebSettings::AllowUniversalAccessFromFileUrls to
LocalContentCanAccessRemoteUrls, as discussed in the API review.
* Api/qwebsettings.cpp:
(QWebSettingsPrivate::apply):
(QWebSettings::QWebSettings):
* Api/qwebsettings.h:
2009-06-09 Simon Hausmann <simon.hausmann@nokia.com>
Reviewed by Ariya Hidayat.
Merged useFixedLayout property with fixedLayoutSize and
renamed the latter to fixedContentsSize.
* Api/qwebpage.cpp:
(QWebPage::fixedContentsSize):
(QWebPage::setFixedContentsSize):
* Api/qwebpage.h:
* WebCoreSupport/FrameLoaderClientQt.cpp:
(WebCore::FrameLoaderClientQt::transitionToCommittedForNewPage):
2009-06-09 Simon Hausmann <simon.hausmann@nokia.com>
Reviewed by Ariya Hidayat.
Renamed QWebHitTestResult::linkTarget to linkElement() and made it return
a QWebElement. The link target itself is always the target DOM attribute.
* Api/qwebframe.cpp:
(QWebHitTestResultPrivate::QWebHitTestResultPrivate):
(QWebHitTestResult::linkElement):
* Api/qwebframe.h:
* Api/qwebframe_p.h:
* tests/qwebframe/tst_qwebframe.cpp:
Diffstat (limited to 'src/3rdparty/webkit/WebCore/storage')
24 files changed, 339 insertions, 279 deletions
diff --git a/src/3rdparty/webkit/WebCore/storage/LocalStorage.cpp b/src/3rdparty/webkit/WebCore/storage/LocalStorage.cpp index 8b84e17..1cfc119 100644 --- a/src/3rdparty/webkit/WebCore/storage/LocalStorage.cpp +++ b/src/3rdparty/webkit/WebCore/storage/LocalStorage.cpp @@ -26,6 +26,8 @@ #include "config.h" #include "LocalStorage.h" +#if ENABLE(DOM_STORAGE) + #include "CString.h" #include "EventNames.h" #include "FileSystem.h" @@ -35,6 +37,7 @@ #include "Page.h" #include "PageGroup.h" #include "StorageArea.h" +#include "StorageSyncManager.h" #include <wtf/StdLibExtras.h> namespace WebCore { @@ -63,14 +66,8 @@ PassRefPtr<LocalStorage> LocalStorage::localStorage(const String& path) 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); + if (!m_path.isEmpty()) + m_syncManager = StorageSyncManager::create(m_path); } LocalStorage::~LocalStorage() @@ -90,54 +87,18 @@ PassRefPtr<StorageArea> LocalStorage::storageArea(SecurityOrigin* origin) // 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()); @@ -145,28 +106,11 @@ 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; - } + + m_syncManager = 0; } -bool LocalStorage::scheduleImport(PassRefPtr<LocalStorageArea> area) -{ - ASSERT(isMainThread()); - - if (m_thread) - m_thread->scheduleImport(area); - - return m_thread; -} +} // namespace WebCore -void LocalStorage::scheduleSync(PassRefPtr<LocalStorageArea> area) -{ - ASSERT(isMainThread()); - if (m_thread) - m_thread->scheduleSync(area); -} +#endif // ENABLE(DOM_STORAGE) -} // namespace WebCore diff --git a/src/3rdparty/webkit/WebCore/storage/LocalStorage.h b/src/3rdparty/webkit/WebCore/storage/LocalStorage.h index 1fd1f7a..cc874d7 100644 --- a/src/3rdparty/webkit/WebCore/storage/LocalStorage.h +++ b/src/3rdparty/webkit/WebCore/storage/LocalStorage.h @@ -26,21 +26,20 @@ #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> +#include <wtf/RefCounted.h> namespace WebCore { - class PageGroup; class StorageArea; + class StorageSyncManager; - class LocalStorage : public ThreadSafeShared<LocalStorage> { + class LocalStorage : public RefCounted<LocalStorage> { public: ~LocalStorage(); @@ -48,9 +47,6 @@ namespace WebCore { PassRefPtr<StorageArea> storageArea(SecurityOrigin*); - bool scheduleImport(PassRefPtr<LocalStorageArea>); - void scheduleSync(PassRefPtr<LocalStorageArea>); - void close(); private: @@ -59,23 +55,12 @@ 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 +#endif // ENABLE(DOM_STORAGE) + #endif // LocalStorage_h diff --git a/src/3rdparty/webkit/WebCore/storage/LocalStorageArea.cpp b/src/3rdparty/webkit/WebCore/storage/LocalStorageArea.cpp index bec0233..1c612a0 100644 --- a/src/3rdparty/webkit/WebCore/storage/LocalStorageArea.cpp +++ b/src/3rdparty/webkit/WebCore/storage/LocalStorageArea.cpp @@ -26,6 +26,8 @@ #include "config.h" #include "LocalStorageArea.h" +#if ENABLE(DOM_STORAGE) + #include "CString.h" #include "DOMWindow.h" #include "EventNames.h" @@ -44,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; } @@ -67,6 +67,10 @@ LocalStorageArea::~LocalStorageArea() void LocalStorageArea::scheduleFinalSync() { + ASSERT(isMainThread()); + if (!m_syncManager) + return; + if (m_syncTimer.isActive()) m_syncTimer.stop(); else { @@ -78,112 +82,6 @@ void LocalStorageArea::scheduleFinalSync() m_finalSyncScheduled = true; } -unsigned LocalStorageArea::length() const -{ - ASSERT(isMainThread()); - - if (m_importComplete) - return internalLength(); - - MutexLocker locker(m_importLock); - if (m_importComplete) - return internalLength(); - - while (!m_importComplete) - m_importCondition.wait(m_importLock); - ASSERT(m_importComplete); - - return internalLength(); -} - -String LocalStorageArea::key(unsigned index, ExceptionCode& ec) const -{ - ASSERT(isMainThread()); - - if (m_importComplete) - return internalKey(index, ec); - - MutexLocker locker(m_importLock); - if (m_importComplete) - return internalKey(index, ec); - - while (!m_importComplete) - m_importCondition.wait(m_importLock); - ASSERT(m_importComplete); - - return internalKey(index, ec); -} - -String LocalStorageArea::getItem(const String& key) const -{ - ASSERT(isMainThread()); - - if (m_importComplete) - return internalGetItem(key); - - MutexLocker locker(m_importLock); - if (m_importComplete) - return internalGetItem(key); - - String item = internalGetItem(key); - if (!item.isNull()) - return item; - - while (!m_importComplete) - m_importCondition.wait(m_importLock); - ASSERT(m_importComplete); - - return internalGetItem(key); -} - -void LocalStorageArea::setItem(const String& key, const String& value, ExceptionCode& ec, Frame* frame) -{ - ASSERT(isMainThread()); - - if (m_importComplete) { - internalSetItem(key, value, ec, frame); - return; - } - - MutexLocker locker(m_importLock); - internalSetItem(key, value, ec, frame); -} - -void LocalStorageArea::removeItem(const String& key, Frame* frame) -{ - ASSERT(isMainThread()); - - if (m_importComplete) { - internalRemoveItem(key, frame); - return; - } - - MutexLocker locker(m_importLock); - internalRemoveItem(key, frame); -} - -bool LocalStorageArea::contains(const String& key) const -{ - ASSERT(isMainThread()); - - if (m_importComplete) - return internalContains(key); - - MutexLocker locker(m_importLock); - if (m_importComplete) - return internalContains(key); - - bool contained = internalContains(key); - if (contained) - return true; - - while (!m_importComplete) - m_importCondition.wait(m_importLock); - ASSERT(m_importComplete); - - return internalContains(key); -} - void LocalStorageArea::itemChanged(const String& key, const String& oldValue, const String& newValue, Frame* sourceFrame) { ASSERT(isMainThread()); @@ -267,6 +165,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(); @@ -290,7 +190,7 @@ void LocalStorageArea::syncTimerFired(Timer<LocalStorageArea>*) // performSync function. disableSuddenTermination(); - m_localStorage->scheduleSync(this); + m_syncManager->scheduleSync(this); } } @@ -305,9 +205,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(); @@ -368,6 +270,27 @@ void LocalStorageArea::markImported() m_importCondition.signal(); } +// FIXME: In the future, we should allow use of localStorage while it's importing (when safe to do so). +// Blocking everything until the import is complete is by far the simplest and safest thing to do, but +// there is certainly room for safe optimization: Key/length will never be able to make use of such an +// optimization (since the order of iteration can change as items are being added). Get can return any +// item currently in the map. Get/remove can work whether or not it's in the map, but we'll need a list +// of items the import should not overwrite. Clear can also work, but it'll need to kill the import +// job first. +void LocalStorageArea::blockUntilImportComplete() const +{ + ASSERT(isMainThread()); + + // Fast path to avoid locking. + if (m_importComplete) + return; + + MutexLocker locker(m_importLock); + while (!m_importComplete) + m_importCondition.wait(m_importLock); + ASSERT(m_importComplete); +} + void LocalStorageArea::sync(bool clearItems, const HashMap<String, String>& items) { ASSERT(!isMainThread()); @@ -450,3 +373,6 @@ void LocalStorageArea::performSync() } } // namespace WebCore + +#endif // ENABLE(DOM_STORAGE) + diff --git a/src/3rdparty/webkit/WebCore/storage/LocalStorageArea.h b/src/3rdparty/webkit/WebCore/storage/LocalStorageArea.h index f3c6dce..7a385aa 100644 --- a/src/3rdparty/webkit/WebCore/storage/LocalStorageArea.h +++ b/src/3rdparty/webkit/WebCore/storage/LocalStorageArea.h @@ -26,26 +26,29 @@ #ifndef LocalStorageArea_h #define LocalStorageArea_h +#if ENABLE(DOM_STORAGE) + #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); @@ -61,21 +64,13 @@ 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; // The following members are subject to thread synchronization issues. public: - // Called on the main thread - virtual unsigned length() const; - virtual String key(unsigned index, ExceptionCode&) const; - virtual String getItem(const String&) const; - virtual void setItem(const String& key, const String& value, ExceptionCode&, Frame* sourceFrame); - virtual void removeItem(const String&, Frame* sourceFrame); - virtual bool contains(const String& key) const; - // Called from the background thread virtual void performImport(); virtual void performSync(); @@ -93,8 +88,11 @@ namespace WebCore { mutable ThreadCondition m_importCondition; mutable bool m_importComplete; void markImported(); + void blockUntilImportComplete() const; }; } // namespace WebCore +#endif // ENABLE(DOM_STORAGE) + #endif // LocalStorageArea_h diff --git a/src/3rdparty/webkit/WebCore/storage/LocalStorageTask.cpp b/src/3rdparty/webkit/WebCore/storage/LocalStorageTask.cpp index 3d5b987..915639a 100644 --- a/src/3rdparty/webkit/WebCore/storage/LocalStorageTask.cpp +++ b/src/3rdparty/webkit/WebCore/storage/LocalStorageTask.cpp @@ -26,6 +26,8 @@ #include "config.h" #include "LocalStorageTask.h" +#if ENABLE(DOM_STORAGE) + #include "LocalStorage.h" #include "LocalStorageArea.h" #include "LocalStorageThread.h" @@ -40,14 +42,6 @@ LocalStorageTask::LocalStorageTask(Type type, PassRefPtr<LocalStorageArea> area) 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) @@ -59,14 +53,6 @@ LocalStorageTask::LocalStorageTask(Type type, PassRefPtr<LocalStorageThread> thr 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(); @@ -82,3 +68,6 @@ void LocalStorageTask::performTask() } } + +#endif // ENABLE(DOM_STORAGE) + diff --git a/src/3rdparty/webkit/WebCore/storage/LocalStorageTask.h b/src/3rdparty/webkit/WebCore/storage/LocalStorageTask.h index 79063d0..eb2cbcc 100644 --- a/src/3rdparty/webkit/WebCore/storage/LocalStorageTask.h +++ b/src/3rdparty/webkit/WebCore/storage/LocalStorageTask.h @@ -26,23 +26,22 @@ #ifndef LocalStorageTask_h #define LocalStorageTask_h +#if ENABLE(DOM_STORAGE) + #include <wtf/PassRefPtr.h> #include <wtf/RefPtr.h> #include <wtf/Threading.h> 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)); } @@ -50,15 +49,15 @@ 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; }; } // namespace WebCore +#endif // ENABLE(DOM_STORAGE) + #endif // LocalStorageTask_h diff --git a/src/3rdparty/webkit/WebCore/storage/LocalStorageThread.cpp b/src/3rdparty/webkit/WebCore/storage/LocalStorageThread.cpp index da50c90..60cc9fa 100644 --- a/src/3rdparty/webkit/WebCore/storage/LocalStorageThread.cpp +++ b/src/3rdparty/webkit/WebCore/storage/LocalStorageThread.cpp @@ -26,6 +26,8 @@ #include "config.h" #include "LocalStorageThread.h" +#if ENABLE(DOM_STORAGE) + #include "LocalStorage.h" #include "LocalStorageArea.h" #include "LocalStorageTask.h" @@ -85,18 +87,6 @@ void* LocalStorageThread::localStorageThread() 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); @@ -137,3 +127,6 @@ void LocalStorageThread::performTerminate() } } + +#endif // ENABLE(DOM_STORAGE) + diff --git a/src/3rdparty/webkit/WebCore/storage/LocalStorageThread.h b/src/3rdparty/webkit/WebCore/storage/LocalStorageThread.h index eb7d1ef..f11660a 100644 --- a/src/3rdparty/webkit/WebCore/storage/LocalStorageThread.h +++ b/src/3rdparty/webkit/WebCore/storage/LocalStorageThread.h @@ -26,6 +26,8 @@ #ifndef LocalStorageThread_h #define LocalStorageThread_h +#if ENABLE(DOM_STORAGE) + #include <wtf/HashSet.h> #include <wtf/MessageQueue.h> #include <wtf/PassRefPtr.h> @@ -33,7 +35,6 @@ namespace WebCore { - class LocalStorage; class LocalStorageArea; class LocalStorageTask; @@ -43,8 +44,6 @@ namespace WebCore { bool start(); - void scheduleImport(PassRefPtr<LocalStorage>); - void scheduleSync(PassRefPtr<LocalStorage>); void scheduleImport(PassRefPtr<LocalStorageArea>); void scheduleSync(PassRefPtr<LocalStorageArea>); @@ -71,4 +70,6 @@ namespace WebCore { } // namespace WebCore +#endif // ENABLE(DOM_STORAGE) + #endif // LocalStorageThread_h diff --git a/src/3rdparty/webkit/WebCore/storage/SessionStorage.cpp b/src/3rdparty/webkit/WebCore/storage/SessionStorage.cpp index e70227a..c10a1be 100644 --- a/src/3rdparty/webkit/WebCore/storage/SessionStorage.cpp +++ b/src/3rdparty/webkit/WebCore/storage/SessionStorage.cpp @@ -26,6 +26,8 @@ #include "config.h" #include "SessionStorage.h" +#if ENABLE(DOM_STORAGE) + #include "EventNames.h" #include "Frame.h" #include "FrameTree.h" @@ -73,3 +75,6 @@ PassRefPtr<StorageArea> SessionStorage::storageArea(SecurityOrigin* origin) } } + +#endif // ENABLE(DOM_STORAGE) + diff --git a/src/3rdparty/webkit/WebCore/storage/SessionStorage.h b/src/3rdparty/webkit/WebCore/storage/SessionStorage.h index 7b59aeb..99fc380 100644 --- a/src/3rdparty/webkit/WebCore/storage/SessionStorage.h +++ b/src/3rdparty/webkit/WebCore/storage/SessionStorage.h @@ -26,11 +26,12 @@ #ifndef SessionStorage_h #define SessionStorage_h +#if ENABLE(DOM_STORAGE) + #include "SecurityOriginHash.h" #include "SessionStorageArea.h" #include <wtf/HashMap.h> -#include <wtf/HashSet.h> #include <wtf/RefCounted.h> namespace WebCore { @@ -61,4 +62,6 @@ namespace WebCore { } // namespace WebCore +#endif // ENABLE(DOM_STORAGE) + #endif // SessionStorage_h diff --git a/src/3rdparty/webkit/WebCore/storage/SessionStorageArea.cpp b/src/3rdparty/webkit/WebCore/storage/SessionStorageArea.cpp index 60c9501..7fb6ca8 100644 --- a/src/3rdparty/webkit/WebCore/storage/SessionStorageArea.cpp +++ b/src/3rdparty/webkit/WebCore/storage/SessionStorageArea.cpp @@ -26,6 +26,8 @@ #include "config.h" #include "SessionStorageArea.h" +#if ENABLE(DOM_STORAGE) + #include "DOMWindow.h" #include "EventNames.h" #include "Frame.h" @@ -87,3 +89,6 @@ void SessionStorageArea::dispatchStorageEvent(const String& key, const String& o } } // namespace WebCore + +#endif // ENABLE(DOM_STORAGE) + diff --git a/src/3rdparty/webkit/WebCore/storage/SessionStorageArea.h b/src/3rdparty/webkit/WebCore/storage/SessionStorageArea.h index 3dad1af..95f425e 100644 --- a/src/3rdparty/webkit/WebCore/storage/SessionStorageArea.h +++ b/src/3rdparty/webkit/WebCore/storage/SessionStorageArea.h @@ -26,6 +26,8 @@ #ifndef SessionStorageArea_h #define SessionStorageArea_h +#if ENABLE(DOM_STORAGE) + #include "StorageArea.h" namespace WebCore { @@ -54,4 +56,6 @@ namespace WebCore { } // namespace WebCore +#endif // ENABLE(DOM_STORAGE) + #endif // SessionStorageArea_h diff --git a/src/3rdparty/webkit/WebCore/storage/Storage.cpp b/src/3rdparty/webkit/WebCore/storage/Storage.cpp index cf4413a..e228971 100644 --- a/src/3rdparty/webkit/WebCore/storage/Storage.cpp +++ b/src/3rdparty/webkit/WebCore/storage/Storage.cpp @@ -26,6 +26,8 @@ #include "config.h" #include "Storage.h" +#if ENABLE(DOM_STORAGE) + #include "StorageArea.h" #include "PlatformString.h" #include <wtf/PassRefPtr.h> @@ -104,3 +106,6 @@ bool Storage::contains(const String& key) const } } + +#endif // ENABLE(DOM_STORAGE) + diff --git a/src/3rdparty/webkit/WebCore/storage/Storage.h b/src/3rdparty/webkit/WebCore/storage/Storage.h index 061f7c4..ca7a32e 100644 --- a/src/3rdparty/webkit/WebCore/storage/Storage.h +++ b/src/3rdparty/webkit/WebCore/storage/Storage.h @@ -26,6 +26,8 @@ #ifndef Storage_h #define Storage_h +#if ENABLE(DOM_STORAGE) + #include "StorageArea.h" #include <wtf/Forward.h> @@ -62,4 +64,6 @@ namespace WebCore { } // namespace WebCore +#endif // ENABLE(DOM_STORAGE) + #endif // Storage_h diff --git a/src/3rdparty/webkit/WebCore/storage/Storage.idl b/src/3rdparty/webkit/WebCore/storage/Storage.idl index 8ff9cd9..00c89ec 100644 --- a/src/3rdparty/webkit/WebCore/storage/Storage.idl +++ b/src/3rdparty/webkit/WebCore/storage/Storage.idl @@ -30,7 +30,8 @@ module storage { HasNameGetter, CustomDeleteProperty, CustomGetPropertyNames, - CustomPutFunction + DelegatingPutFunction, + Conditional=DOM_STORAGE ] Storage { readonly attribute [DontEnum] unsigned long length; [DontEnum] DOMString key(in unsigned long index) diff --git a/src/3rdparty/webkit/WebCore/storage/StorageArea.cpp b/src/3rdparty/webkit/WebCore/storage/StorageArea.cpp index 27f9612..97bfd9f 100644 --- a/src/3rdparty/webkit/WebCore/storage/StorageArea.cpp +++ b/src/3rdparty/webkit/WebCore/storage/StorageArea.cpp @@ -26,6 +26,8 @@ #include "config.h" #include "StorageArea.h" +#if ENABLE(DOM_STORAGE) + #include "CString.h" #include "ExceptionCode.h" #include "Frame.h" @@ -52,13 +54,15 @@ StorageArea::~StorageArea() { } -unsigned StorageArea::internalLength() const +unsigned StorageArea::length() const { return m_storageMap->length(); } -String StorageArea::internalKey(unsigned index, ExceptionCode& ec) const +String StorageArea::key(unsigned index, ExceptionCode& ec) const { + blockUntilImportComplete(); + String key; if (!m_storageMap->key(index, key)) { @@ -69,14 +73,17 @@ String StorageArea::internalKey(unsigned index, ExceptionCode& ec) const return key; } -String StorageArea::internalGetItem(const String& key) const +String StorageArea::getItem(const String& key) const { + blockUntilImportComplete(); + return m_storageMap->getItem(key); } -void StorageArea::internalSetItem(const String& key, const String& value, ExceptionCode& ec, Frame* frame) +void StorageArea::setItem(const String& key, const String& value, ExceptionCode& ec, Frame* frame) { ASSERT(!value.isNull()); + blockUntilImportComplete(); if (frame->page()->settings()->privateBrowsingEnabled()) { ec = QUOTA_EXCEEDED_ERR; @@ -101,8 +108,10 @@ void StorageArea::internalSetItem(const String& key, const String& value, Except itemChanged(key, oldValue, value, frame); } -void StorageArea::internalRemoveItem(const String& key, Frame* frame) +void StorageArea::removeItem(const String& key, Frame* frame) { + blockUntilImportComplete(); + if (frame->page()->settings()->privateBrowsingEnabled()) return; @@ -116,8 +125,10 @@ void StorageArea::internalRemoveItem(const String& key, Frame* frame) itemRemoved(key, oldValue, frame); } -void StorageArea::internalClear(Frame* frame) +void StorageArea::clear(Frame* frame) { + blockUntilImportComplete(); + if (frame->page()->settings()->privateBrowsingEnabled()) return; @@ -126,8 +137,10 @@ void StorageArea::internalClear(Frame* frame) areaCleared(frame); } -bool StorageArea::internalContains(const String& key) const +bool StorageArea::contains(const String& key) const { + blockUntilImportComplete(); + return m_storageMap->contains(key); } @@ -137,3 +150,6 @@ void StorageArea::importItem(const String& key, const String& value) } } + +#endif // ENABLE(DOM_STORAGE) + diff --git a/src/3rdparty/webkit/WebCore/storage/StorageArea.h b/src/3rdparty/webkit/WebCore/storage/StorageArea.h index 2163287..d8e1913 100644 --- a/src/3rdparty/webkit/WebCore/storage/StorageArea.h +++ b/src/3rdparty/webkit/WebCore/storage/StorageArea.h @@ -26,6 +26,8 @@ #ifndef StorageArea_h #define StorageArea_h +#if ENABLE(DOM_STORAGE) + #include "PlatformString.h" #include <wtf/Forward.h> @@ -44,28 +46,22 @@ namespace WebCore { public: virtual ~StorageArea(); - virtual unsigned length() const { return internalLength(); } - virtual String key(unsigned index, ExceptionCode& ec) const { return internalKey(index, ec); } - virtual String getItem(const String& key) const { return internalGetItem(key); } - virtual void setItem(const String& key, const String& value, ExceptionCode& ec, Frame* sourceFrame) { internalSetItem(key, value, ec, sourceFrame); } - virtual void removeItem(const String& key, Frame* sourceFrame) { internalRemoveItem(key, sourceFrame); } - virtual void clear(Frame* sourceFrame) { internalClear(sourceFrame); } - virtual bool contains(const String& key) const { return internalContains(key); } - + // The HTML5 DOM Storage API + unsigned length() const; + String key(unsigned index, ExceptionCode& ec) const; + String getItem(const String& key) const; + void setItem(const String& key, const String& value, ExceptionCode& ec, Frame* sourceFrame); + void removeItem(const String& key, Frame* sourceFrame); + void clear(Frame* sourceFrame); + + bool contains(const String& key) const; + SecurityOrigin* securityOrigin() { return m_securityOrigin.get(); } protected: StorageArea(SecurityOrigin*); StorageArea(SecurityOrigin*, StorageArea*); - unsigned internalLength() const; - String internalKey(unsigned index, ExceptionCode&) const; - String internalGetItem(const String&) const; - void internalSetItem(const String& key, const String& value, ExceptionCode&, Frame* sourceFrame); - void internalRemoveItem(const String&, Frame* sourceFrame); - void internalClear(Frame* sourceFrame); - bool internalContains(const String& key) const; - // This is meant to be called from a background thread for LocalStorageArea's background thread import procedure. void importItem(const String& key, const String& value); @@ -73,6 +69,7 @@ namespace WebCore { virtual void itemChanged(const String& key, const String& oldValue, const String& newValue, Frame* sourceFrame) = 0; virtual void itemRemoved(const String& key, const String& oldValue, Frame* sourceFrame) = 0; virtual void areaCleared(Frame* sourceFrame) = 0; + virtual void blockUntilImportComplete() const { } RefPtr<SecurityOrigin> m_securityOrigin; RefPtr<StorageMap> m_storageMap; @@ -80,4 +77,6 @@ namespace WebCore { } // namespace WebCore +#endif // ENABLE(DOM_STORAGE) + #endif // StorageArea_h diff --git a/src/3rdparty/webkit/WebCore/storage/StorageEvent.cpp b/src/3rdparty/webkit/WebCore/storage/StorageEvent.cpp index 851abb1..f2945a9 100644 --- a/src/3rdparty/webkit/WebCore/storage/StorageEvent.cpp +++ b/src/3rdparty/webkit/WebCore/storage/StorageEvent.cpp @@ -26,6 +26,8 @@ #include "config.h" #include "StorageEvent.h" +#if ENABLE(DOM_STORAGE) + #include "DOMWindow.h" #include "Storage.h" @@ -58,3 +60,6 @@ void StorageEvent::initStorageEvent(const AtomicString& type, bool canBubble, bo } } // namespace WebCore + +#endif // ENABLE(DOM_STORAGE) + diff --git a/src/3rdparty/webkit/WebCore/storage/StorageEvent.h b/src/3rdparty/webkit/WebCore/storage/StorageEvent.h index 3795518..ee3d5ad 100644 --- a/src/3rdparty/webkit/WebCore/storage/StorageEvent.h +++ b/src/3rdparty/webkit/WebCore/storage/StorageEvent.h @@ -26,6 +26,8 @@ #ifndef StorageEvent_h #define StorageEvent_h +#if ENABLE(DOM_STORAGE) + #include "Event.h" #include "Storage.h" @@ -72,4 +74,6 @@ namespace WebCore { } // namespace WebCore +#endif // ENABLE(DOM_STORAGE) + #endif // StorageEvent_h diff --git a/src/3rdparty/webkit/WebCore/storage/StorageEvent.idl b/src/3rdparty/webkit/WebCore/storage/StorageEvent.idl index fe82cf8..5a3f993 100644 --- a/src/3rdparty/webkit/WebCore/storage/StorageEvent.idl +++ b/src/3rdparty/webkit/WebCore/storage/StorageEvent.idl @@ -26,7 +26,8 @@ module storage { interface [ - GenerateConstructor + GenerateConstructor, + Conditional=DOM_STORAGE ] StorageEvent : Event { readonly attribute DOMString key; readonly attribute [ConvertNullStringTo=Null] DOMString oldValue; diff --git a/src/3rdparty/webkit/WebCore/storage/StorageMap.cpp b/src/3rdparty/webkit/WebCore/storage/StorageMap.cpp index 880fc93..4c350c8 100644 --- a/src/3rdparty/webkit/WebCore/storage/StorageMap.cpp +++ b/src/3rdparty/webkit/WebCore/storage/StorageMap.cpp @@ -26,6 +26,8 @@ #include "config.h" #include "StorageMap.h" +#if ENABLE(DOM_STORAGE) + namespace WebCore { PassRefPtr<StorageMap> StorageMap::create() @@ -156,3 +158,6 @@ void StorageMap::importItem(const String& key, const String& value) const } } + +#endif // ENABLE(DOM_STORAGE) + diff --git a/src/3rdparty/webkit/WebCore/storage/StorageMap.h b/src/3rdparty/webkit/WebCore/storage/StorageMap.h index d5d00a9..c6f3bc9 100644 --- a/src/3rdparty/webkit/WebCore/storage/StorageMap.h +++ b/src/3rdparty/webkit/WebCore/storage/StorageMap.h @@ -26,6 +26,8 @@ #ifndef StorageMap_h #define StorageMap_h +#if ENABLE(DOM_STORAGE) + #include "PlatformString.h" #include "StringHash.h" @@ -62,4 +64,6 @@ namespace WebCore { } // namespace WebCore +#endif // ENABLE(DOM_STORAGE) + #endif // StorageMap_h diff --git a/src/3rdparty/webkit/WebCore/storage/StorageSyncManager.cpp b/src/3rdparty/webkit/WebCore/storage/StorageSyncManager.cpp new file mode 100644 index 0000000..b2067bc --- /dev/null +++ b/src/3rdparty/webkit/WebCore/storage/StorageSyncManager.cpp @@ -0,0 +1,98 @@ +/* + * 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 "StorageSyncManager.h" + +#if ENABLE(DOM_STORAGE) + +#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 <wtf/StdLibExtras.h> + +namespace WebCore { + +PassRefPtr<StorageSyncManager> StorageSyncManager::create(const String& path) +{ + return adoptRef(new StorageSyncManager(path)); +} + +StorageSyncManager::StorageSyncManager(const String& path) + : m_path(path.copy()) +{ + ASSERT(!m_path.isEmpty()); + m_thread = LocalStorageThread::create(); + m_thread->start(); +} + +String StorageSyncManager::fullDatabaseFilename(SecurityOrigin* origin) +{ + ASSERT(origin); + 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 StorageSyncManager::close() +{ + ASSERT(isMainThread()); + + if (m_thread) { + m_thread->terminate(); + m_thread = 0; + } +} + +bool StorageSyncManager::scheduleImport(PassRefPtr<LocalStorageArea> area) +{ + ASSERT(isMainThread()); + + if (m_thread) + m_thread->scheduleImport(area); + + return m_thread; +} + +void StorageSyncManager::scheduleSync(PassRefPtr<LocalStorageArea> area) +{ + ASSERT(isMainThread()); + + if (m_thread) + m_thread->scheduleSync(area); +} + +} // namespace WebCore + +#endif // ENABLE(DOM_STORAGE) + diff --git a/src/3rdparty/webkit/WebCore/storage/StorageSyncManager.h b/src/3rdparty/webkit/WebCore/storage/StorageSyncManager.h new file mode 100644 index 0000000..28370aa --- /dev/null +++ b/src/3rdparty/webkit/WebCore/storage/StorageSyncManager.h @@ -0,0 +1,66 @@ +/* + * 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 StorageSyncManager_h +#define StorageSyncManager_h + +#if ENABLE(DOM_STORAGE) + +#include "LocalStorageArea.h" +#include "LocalStorageTask.h" +#include "LocalStorageThread.h" + +#include <wtf/Threading.h> + +namespace WebCore { + + class StorageSyncManager : public ThreadSafeShared<StorageSyncManager> { + public: + static PassRefPtr<StorageSyncManager> create(const String& path); + + bool scheduleImport(PassRefPtr<LocalStorageArea>); + void scheduleSync(PassRefPtr<LocalStorageArea>); + + void close(); + + private: + StorageSyncManager(const String& path); + + RefPtr<LocalStorageThread> m_thread; + + // The following members are subject to thread synchronization issues + public: + // To be called from the background thread: + String fullDatabaseFilename(SecurityOrigin*); + + private: + String m_path; + }; + +} // namespace WebCore + +#endif // ENABLE(DOM_STORAGE) + +#endif // StorageSyncManager_h |