diff options
author | Steve Block <steveblock@google.com> | 2011-05-06 11:45:16 +0100 |
---|---|---|
committer | Steve Block <steveblock@google.com> | 2011-05-12 13:44:10 +0100 |
commit | cad810f21b803229eb11403f9209855525a25d57 (patch) | |
tree | 29a6fd0279be608e0fe9ffe9841f722f0f4e4269 /Source/WebCore/storage/chromium | |
parent | 121b0cf4517156d0ac5111caf9830c51b69bae8f (diff) | |
download | external_webkit-cad810f21b803229eb11403f9209855525a25d57.zip external_webkit-cad810f21b803229eb11403f9209855525a25d57.tar.gz external_webkit-cad810f21b803229eb11403f9209855525a25d57.tar.bz2 |
Merge WebKit at r75315: Initial merge by git.
Change-Id: I570314b346ce101c935ed22a626b48c2af266b84
Diffstat (limited to 'Source/WebCore/storage/chromium')
7 files changed, 584 insertions, 0 deletions
diff --git a/Source/WebCore/storage/chromium/DatabaseObserver.h b/Source/WebCore/storage/chromium/DatabaseObserver.h new file mode 100644 index 0000000..deb8036 --- /dev/null +++ b/Source/WebCore/storage/chromium/DatabaseObserver.h @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2010 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "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 THE COPYRIGHT + * OWNER 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 DatabaseObserver_h +#define DatabaseObserver_h + +#if ENABLE(DATABASE) + +#include <wtf/Forward.h> + +namespace WebCore { + +class AbstractDatabase; +class ScriptExecutionContext; + +// The implementation of this class is in the WebKit API (Chromium source tree) +// in WebKit/chromium/src/DatabaseObserver.cpp. +class DatabaseObserver { +public: + static bool canEstablishDatabase(ScriptExecutionContext*, const String&, const String&, unsigned long); + static void databaseOpened(AbstractDatabase*); + static void databaseModified(AbstractDatabase*); + static void databaseClosed(AbstractDatabase*); +}; + +} + +#endif // ENABLE(DATABASE) + +#endif // DatabaseObserver_h diff --git a/Source/WebCore/storage/chromium/DatabaseTrackerChromium.cpp b/Source/WebCore/storage/chromium/DatabaseTrackerChromium.cpp new file mode 100644 index 0000000..361e203 --- /dev/null +++ b/Source/WebCore/storage/chromium/DatabaseTrackerChromium.cpp @@ -0,0 +1,208 @@ +/* + * Copyright (C) 2010 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "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 THE COPYRIGHT + * OWNER 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 "DatabaseTracker.h" + +#if ENABLE(DATABASE) + +#include "AbstractDatabase.h" +#include "DatabaseObserver.h" +#include "QuotaTracker.h" +#include "PlatformString.h" +#include "ScriptExecutionContext.h" +#include "SecurityOrigin.h" +#include "SecurityOriginHash.h" +#include "SQLiteFileSystem.h" +#include <wtf/StdLibExtras.h> + +namespace WebCore { + +DatabaseTracker& DatabaseTracker::tracker() +{ + DEFINE_STATIC_LOCAL(DatabaseTracker, tracker, ("")); + return tracker; +} + +DatabaseTracker::DatabaseTracker(const String&) +{ + SQLiteFileSystem::registerSQLiteVFS(); +} + +bool DatabaseTracker::canEstablishDatabase(ScriptExecutionContext* scriptExecutionContext, const String& name, const String& displayName, unsigned long estimatedSize) +{ + return DatabaseObserver::canEstablishDatabase(scriptExecutionContext, name, displayName, estimatedSize); +} + +void DatabaseTracker::setDatabaseDetails(SecurityOrigin*, const String&, const String&, unsigned long) +{ + // Chromium sets the database details when the database is opened +} + +String DatabaseTracker::fullPathForDatabase(SecurityOrigin* origin, const String& name, bool) +{ + return origin->databaseIdentifier() + "/" + name + "#"; +} + +void DatabaseTracker::addOpenDatabase(AbstractDatabase* database) +{ + ASSERT(database->scriptExecutionContext()->isContextThread()); + MutexLocker openDatabaseMapLock(m_openDatabaseMapGuard); + if (!m_openDatabaseMap) + m_openDatabaseMap.set(new DatabaseOriginMap()); + + DatabaseNameMap* nameMap = m_openDatabaseMap->get(database->securityOrigin()); + if (!nameMap) { + nameMap = new DatabaseNameMap(); + m_openDatabaseMap->set(database->securityOrigin(), nameMap); + } + + String name(database->stringIdentifier()); + DatabaseSet* databaseSet = nameMap->get(name); + if (!databaseSet) { + databaseSet = new DatabaseSet(); + nameMap->set(name, databaseSet); + } + + databaseSet->add(database); + + DatabaseObserver::databaseOpened(database); +} + +class TrackerRemoveOpenDatabaseTask : public ScriptExecutionContext::Task { +public: + static PassOwnPtr<TrackerRemoveOpenDatabaseTask> create(PassRefPtr<AbstractDatabase> database) + { + return new TrackerRemoveOpenDatabaseTask(database); + } + + virtual void performTask(ScriptExecutionContext* context) + { + DatabaseTracker::tracker().removeOpenDatabase(m_database.get()); + } + +private: + TrackerRemoveOpenDatabaseTask(PassRefPtr<AbstractDatabase> database) + : m_database(database) + { + } + + RefPtr<AbstractDatabase> m_database; +}; + +void DatabaseTracker::removeOpenDatabase(AbstractDatabase* database) +{ + if (!database->scriptExecutionContext()->isContextThread()) { + database->scriptExecutionContext()->postTask(TrackerRemoveOpenDatabaseTask::create(database)); + return; + } + + MutexLocker openDatabaseMapLock(m_openDatabaseMapGuard); + ASSERT(m_openDatabaseMap); + DatabaseNameMap* nameMap = m_openDatabaseMap->get(database->securityOrigin()); + ASSERT(nameMap); + String name(database->stringIdentifier()); + DatabaseSet* databaseSet = nameMap->get(name); + ASSERT(databaseSet); + databaseSet->remove(database); + + if (databaseSet->isEmpty()) { + nameMap->remove(name); + delete databaseSet; + if (nameMap->isEmpty()) { + m_openDatabaseMap->remove(database->securityOrigin()); + delete nameMap; + } + } + + DatabaseObserver::databaseClosed(database); +} + + +void DatabaseTracker::getOpenDatabases(SecurityOrigin* origin, const String& name, HashSet<RefPtr<AbstractDatabase> >* databases) +{ + MutexLocker openDatabaseMapLock(m_openDatabaseMapGuard); + if (!m_openDatabaseMap) + return; + + DatabaseNameMap* nameMap = m_openDatabaseMap->get(origin); + if (!nameMap) + return; + + DatabaseSet* databaseSet = nameMap->get(name); + if (!databaseSet) + return; + + for (DatabaseSet::iterator it = databaseSet->begin(); it != databaseSet->end(); ++it) + databases->add(*it); +} + +unsigned long long DatabaseTracker::getMaxSizeForDatabase(const AbstractDatabase* database) +{ + unsigned long long spaceAvailable = 0; + unsigned long long databaseSize = 0; + QuotaTracker::instance().getDatabaseSizeAndSpaceAvailableToOrigin( + database->securityOrigin()->databaseIdentifier(), + database->stringIdentifier(), &databaseSize, &spaceAvailable); + return databaseSize + spaceAvailable; +} + +void DatabaseTracker::interruptAllDatabasesForContext(const ScriptExecutionContext* context) +{ + Vector<RefPtr<AbstractDatabase> > openDatabases; + { + MutexLocker openDatabaseMapLock(m_openDatabaseMapGuard); + + if (!m_openDatabaseMap) + return; + + DatabaseNameMap* nameMap = m_openDatabaseMap->get(context->securityOrigin()); + if (!nameMap) + return; + + DatabaseNameMap::const_iterator dbNameMapEndIt = nameMap->end(); + for (DatabaseNameMap::const_iterator dbNameMapIt = nameMap->begin(); dbNameMapIt != dbNameMapEndIt; ++dbNameMapIt) { + DatabaseSet* databaseSet = dbNameMapIt->second; + DatabaseSet::const_iterator dbSetEndIt = databaseSet->end(); + for (DatabaseSet::const_iterator dbSetIt = databaseSet->begin(); dbSetIt != dbSetEndIt; ++dbSetIt) { + if ((*dbSetIt)->scriptExecutionContext() == context) + openDatabases.append(*dbSetIt); + } + } + } + + Vector<RefPtr<AbstractDatabase> >::const_iterator openDatabasesEndIt = openDatabases.end(); + for (Vector<RefPtr<AbstractDatabase> >::const_iterator openDatabasesIt = openDatabases.begin(); openDatabasesIt != openDatabasesEndIt; ++openDatabasesIt) + (*openDatabasesIt)->interrupt(); +} + +} + +#endif // ENABLE(DATABASE) diff --git a/Source/WebCore/storage/chromium/IDBFactoryBackendInterface.cpp b/Source/WebCore/storage/chromium/IDBFactoryBackendInterface.cpp new file mode 100644 index 0000000..c0fb444 --- /dev/null +++ b/Source/WebCore/storage/chromium/IDBFactoryBackendInterface.cpp @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2010 Google 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. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "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 OR ITS 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 "IDBFactoryBackendInterface.h" + +#include "ChromiumBridge.h" + +#if ENABLE(INDEXED_DATABASE) + +namespace WebCore { + +PassRefPtr<IDBFactoryBackendInterface> IDBFactoryBackendInterface::create() +{ + return ChromiumBridge::idbFactory(); +} + +IDBFactoryBackendInterface::~IDBFactoryBackendInterface() +{ + ChromiumBridge::idbShutdown(); +} + +} // namespace WebCore + +#endif // ENABLE(INDEXED_DATABASE) diff --git a/Source/WebCore/storage/chromium/IDBKeyPathBackendImpl.cpp b/Source/WebCore/storage/chromium/IDBKeyPathBackendImpl.cpp new file mode 100644 index 0000000..0f10875 --- /dev/null +++ b/Source/WebCore/storage/chromium/IDBKeyPathBackendImpl.cpp @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2010 Google 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 AND ITS CONTRIBUTORS "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 OR ITS 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 "IDBKeyPathBackendImpl.h" + +#if ENABLE(INDEXED_DATABASE) + +#include "ChromiumBridge.h" + +namespace WebCore { + +void IDBKeyPathBackendImpl::createIDBKeysFromSerializedValuesAndKeyPath(const Vector<RefPtr<SerializedScriptValue>, 0>& values, const String& keyPath, Vector<RefPtr<IDBKey>, 0>& keys) +{ + ChromiumBridge::createIDBKeysFromSerializedValuesAndKeyPath(values, keyPath, keys); +} + +} // namespace WebCore + +#endif diff --git a/Source/WebCore/storage/chromium/QuotaTracker.cpp b/Source/WebCore/storage/chromium/QuotaTracker.cpp new file mode 100644 index 0000000..3f48682 --- /dev/null +++ b/Source/WebCore/storage/chromium/QuotaTracker.cpp @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "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 THE COPYRIGHT + * OWNER 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 "QuotaTracker.h" + +#if ENABLE(DATABASE) + +#include <wtf/StdLibExtras.h> + +namespace WebCore { + +QuotaTracker& QuotaTracker::instance() +{ + DEFINE_STATIC_LOCAL(QuotaTracker, tracker, ()); + return tracker; +} + +void QuotaTracker::getDatabaseSizeAndSpaceAvailableToOrigin( + const String& originIdentifier, const String& databaseName, + unsigned long long* databaseSize, unsigned long long* spaceAvailable) +{ + MutexLocker lockData(m_dataGuard); + ASSERT(m_databaseSizes.contains(originIdentifier)); + HashMap<String, SizeMap>::const_iterator it = m_databaseSizes.find(originIdentifier); + ASSERT(it->second.contains(databaseName)); + *databaseSize = it->second.get(databaseName); + + ASSERT(m_spaceAvailableToOrigins.contains(originIdentifier)); + *spaceAvailable = m_spaceAvailableToOrigins.get(originIdentifier); +} + +void QuotaTracker::updateDatabaseSizeAndSpaceAvailableToOrigin( + const String& originIdentifier, const String& databaseName, + unsigned long long databaseSize, unsigned long long spaceAvailable) +{ + MutexLocker lockData(m_dataGuard); + m_spaceAvailableToOrigins.set(originIdentifier, spaceAvailable); + HashMap<String, SizeMap>::iterator it = m_databaseSizes.add(originIdentifier, SizeMap()).first; + it->second.set(databaseName, databaseSize); +} + +} + +#endif // ENABLE(DATABASE) diff --git a/Source/WebCore/storage/chromium/QuotaTracker.h b/Source/WebCore/storage/chromium/QuotaTracker.h new file mode 100644 index 0000000..774475e --- /dev/null +++ b/Source/WebCore/storage/chromium/QuotaTracker.h @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "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 THE COPYRIGHT + * OWNER 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 QuotaTracker_h +#define QuotaTracker_h + +#if ENABLE(DATABASE) + +#include "PlatformString.h" +#include "SecurityOrigin.h" +#include <wtf/HashMap.h> +#include <wtf/text/StringHash.h> + +namespace WebCore { + +class QuotaTracker { +public: + static QuotaTracker& instance(); + + void getDatabaseSizeAndSpaceAvailableToOrigin( + const String& originIdentifier, const String& databaseName, + unsigned long long* databaseSize, unsigned long long* spaceAvailable); + void updateDatabaseSizeAndSpaceAvailableToOrigin( + const String& originIdentifier, const String& databaseName, + unsigned long long databaseSize, unsigned long long spaceAvailable); + +private: + QuotaTracker() { } + + typedef HashMap<String, unsigned long long> SizeMap; + SizeMap m_spaceAvailableToOrigins; + HashMap<String, SizeMap> m_databaseSizes; + Mutex m_dataGuard; +}; + +} + +#endif // ENABLE(DATABASE) + +#endif // QuotaTracker_h diff --git a/Source/WebCore/storage/chromium/SQLTransactionClientChromium.cpp b/Source/WebCore/storage/chromium/SQLTransactionClientChromium.cpp new file mode 100644 index 0000000..6a10821 --- /dev/null +++ b/Source/WebCore/storage/chromium/SQLTransactionClientChromium.cpp @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2009 Google 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "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 THE COPYRIGHT + * OWNER 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 "SQLTransactionClient.h" + +#if ENABLE(DATABASE) + +#include "AbstractDatabase.h" +#include "DatabaseObserver.h" +#include "ScriptExecutionContext.h" + +namespace WebCore { + +class NotifyDatabaseChangedTask : public ScriptExecutionContext::Task { +public: + static PassOwnPtr<NotifyDatabaseChangedTask> create(AbstractDatabase *database) + { + return new NotifyDatabaseChangedTask(database); + } + + virtual void performTask(ScriptExecutionContext*) + { + WebCore::DatabaseObserver::databaseModified(m_database.get()); + } + +private: + NotifyDatabaseChangedTask(PassRefPtr<AbstractDatabase> database) + : m_database(database) + { + } + + RefPtr<AbstractDatabase> m_database; +}; + +void SQLTransactionClient::didCommitWriteTransaction(AbstractDatabase* database) +{ + if (!database->scriptExecutionContext()->isContextThread()) { + database->scriptExecutionContext()->postTask(NotifyDatabaseChangedTask::create(database)); + return; + } + + WebCore::DatabaseObserver::databaseModified(database); +} + +void SQLTransactionClient::didExecuteStatement(AbstractDatabase* database) +{ + // This method is called after executing every statement that changes the DB. + // Chromium doesn't need to do anything at that point. +} + +bool SQLTransactionClient::didExceedQuota(AbstractDatabase* database) +{ + // Chromium does not allow users to manually change the quota for an origin (for now, at least). + // Don't do anything. + ASSERT(database->scriptExecutionContext()->isContextThread()); + return false; +} + +} + +#endif // ENABLE(DATABASE) |