Commit c2b0a80f authored by mark.lam@apple.com's avatar mark.lam@apple.com

Initial refactoring of database functionality into the manager and server.

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

Reviewed by Brady Eidson.

This is not a complete refactor, but a stepping stone on the way to isolating
script side database activity from the SQL backend.

No new tests.

* CMakeLists.txt:
* GNUmakefile.list.am:
* Modules/webdatabase/AbstractDatabase.cpp:
(WebCore):
(WebCore::updateGuidVersionMap):
(WebCore::guidForOriginAndName):
(WebCore::AbstractDatabase::AbstractDatabase):
(WebCore::AbstractDatabase::maximumSize):
* Modules/webdatabase/AbstractDatabase.h:
(AbstractDatabase):
- Moved isAvailable() and setIsAvailable() to the DatabaseManager.
* Modules/webdatabase/AbstractDatabaseServer.h:
(AbstractDatabaseServer):
* Modules/webdatabase/DBBackendServer.cpp: Added.
(WebCore::DBBackend::Server::initialize):
(WebCore::DBBackend::Server::setClient):
(WebCore::DBBackend::Server::databaseDirectoryPath):
(WebCore::DBBackend::Server::setDatabaseDirectoryPath):
(WebCore::DBBackend::Server::fullPathForDatabase):
(WebCore::DBBackend::Server::hasEntryForOrigin):
(WebCore::DBBackend::Server::origins):
(WebCore::DBBackend::Server::databaseNamesForOrigin):
(WebCore::DBBackend::Server::detailsForNameAndOrigin):
(WebCore::DBBackend::Server::usageForOrigin):
(WebCore::DBBackend::Server::quotaForOrigin):
(WebCore::DBBackend::Server::setQuota):
(WebCore::DBBackend::Server::deleteAllDatabases):
(WebCore::DBBackend::Server::deleteOrigin):
(WebCore::DBBackend::Server::deleteDatabase):
(WebCore::DBBackend::Server::scheduleNotifyDatabaseChanged):
(WebCore::DBBackend::Server::databaseChanged):
(WebCore::DBBackend::Server::closeDatabasesImmediately):
(WebCore::DBBackend::Server::interruptAllDatabasesForContext):
(WebCore::DBBackend::Server::canEstablishDatabase):
(WebCore::DBBackend::Server::addOpenDatabase):
(WebCore::DBBackend::Server::removeOpenDatabase):
(WebCore::DBBackend::Server::setDatabaseDetails):
(WebCore::DBBackend::Server::getMaxSizeForDatabase):
- Refactored all calls to the DatabaseTracker to go thru the DBBackend::Server.
* Modules/webdatabase/DBBackendServer.h:
* Modules/webdatabase/DOMWindowWebDatabase.cpp:
(WebCore::DOMWindowWebDatabase::openDatabase):
* Modules/webdatabase/Database.cpp:
(WebCore::Database::close):
(WebCore::Database::maximumSize):
* Modules/webdatabase/Database.h:
(Database):
- Moved the openDatabase() factory method to the DatabaseManager.
- Removed the unused deliverPendingCallback() prototype.
* Modules/webdatabase/DatabaseBasicTypes.h: Added.
- A place to define some common basic types used by the database module.
* Modules/webdatabase/DatabaseContext.cpp:
(WebCore::DatabaseContext::databaseExceededQuota):
* Modules/webdatabase/DatabaseManager.cpp:
(WebCore::DatabaseManager::DatabaseManager):
(WebCore::DatabaseManager::initialize):
(WebCore::DatabaseManager::setClient):
(WebCore::DatabaseManager::databaseDirectoryPath):
(WebCore::DatabaseManager::setDatabaseDirectoryPath):
(WebCore::DatabaseManager::isAvailable):
(WebCore::DatabaseManager::setIsAvailable):
(DatabaseCreationCallbackTask):
(WebCore::DatabaseCreationCallbackTask::create):
(WebCore::DatabaseCreationCallbackTask::performTask):
(WebCore::DatabaseCreationCallbackTask::DatabaseCreationCallbackTask):
(WebCore::DatabaseManager::openDatabase):
(WebCore::DatabaseManager::openDatabaseSync):
(WebCore::DatabaseManager::setHasOpenDatabases):
(WebCore::DatabaseManager::fullPathForDatabase):
(WebCore::DatabaseManager::hasEntryForOrigin):
(WebCore::DatabaseManager::origins):
(WebCore::DatabaseManager::databaseNamesForOrigin):
(WebCore::DatabaseManager::detailsForNameAndOrigin):
(WebCore::DatabaseManager::usageForOrigin):
(WebCore::DatabaseManager::quotaForOrigin):
(WebCore::DatabaseManager::setQuota):
(WebCore::DatabaseManager::deleteAllDatabases):
(WebCore::DatabaseManager::deleteOrigin):
(WebCore::DatabaseManager::deleteDatabase):
(WebCore::DatabaseManager::scheduleNotifyDatabaseChanged):
(WebCore::DatabaseManager::databaseChanged):
(WebCore::DatabaseManager::closeDatabasesImmediately):
(WebCore::DatabaseManager::interruptAllDatabasesForContext):
(WebCore::DatabaseManager::canEstablishDatabase):
(WebCore::DatabaseManager::addOpenDatabase):
(WebCore::DatabaseManager::removeOpenDatabase):
(WebCore::DatabaseManager::setDatabaseDetails):
(WebCore::DatabaseManager::getMaxSizeForDatabase):
* Modules/webdatabase/DatabaseManager.h:
(DatabaseManager):
* Modules/webdatabase/DatabaseSync.cpp:
(WebCore::DatabaseSync::~DatabaseSync):
(WebCore::DatabaseSync::closeImmediately):
* Modules/webdatabase/DatabaseSync.h:
(DatabaseSync):
- Moved the openDatabaseSync() factory method to the DatabaseManager.
* Modules/webdatabase/DatabaseTask.h:
* Modules/webdatabase/SQLResultSet.h:
* Modules/webdatabase/SQLStatementSync.h:
* Modules/webdatabase/SQLTransaction.h:
* Modules/webdatabase/SQLTransactionClient.cpp:
(WebCore::SQLTransactionClient::didCommitWriteTransaction):
(WebCore::SQLTransactionClient::didExecuteStatement):
(WebCore::SQLTransactionClient::didExceedQuota):
* Modules/webdatabase/SQLTransactionSync.h:
* Modules/webdatabase/WorkerContextWebDatabase.cpp:
(WebCore::WorkerContextWebDatabase::openDatabase):
(WebCore::WorkerContextWebDatabase::openDatabaseSync):
* Target.pri:
* WebCore.gypi:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@138085 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 321af1ab
......@@ -952,6 +952,7 @@ set(WebCore_SOURCES
Modules/webdatabase/DatabaseTask.cpp
Modules/webdatabase/DatabaseThread.cpp
Modules/webdatabase/DatabaseTracker.cpp
Modules/webdatabase/DBBackendServer.cpp
Modules/webdatabase/OriginQuotaManager.cpp
Modules/webdatabase/OriginUsageRecord.cpp
Modules/webdatabase/SQLException.cpp
......
2012-12-18 Mark Lam <mark.lam@apple.com>
Initial refactoring of database functionality into the manager and server.
https://bugs.webkit.org/show_bug.cgi?id=104748.
Reviewed by Brady Eidson.
This is not a complete refactor, but a stepping stone on the way to isolating
script side database activity from the SQL backend.
No new tests.
* CMakeLists.txt:
* GNUmakefile.list.am:
* Modules/webdatabase/AbstractDatabase.cpp:
(WebCore):
(WebCore::updateGuidVersionMap):
(WebCore::guidForOriginAndName):
(WebCore::AbstractDatabase::AbstractDatabase):
(WebCore::AbstractDatabase::maximumSize):
* Modules/webdatabase/AbstractDatabase.h:
(AbstractDatabase):
- Moved isAvailable() and setIsAvailable() to the DatabaseManager.
* Modules/webdatabase/AbstractDatabaseServer.h:
(AbstractDatabaseServer):
* Modules/webdatabase/DBBackendServer.cpp: Added.
(WebCore::DBBackend::Server::initialize):
(WebCore::DBBackend::Server::setClient):
(WebCore::DBBackend::Server::databaseDirectoryPath):
(WebCore::DBBackend::Server::setDatabaseDirectoryPath):
(WebCore::DBBackend::Server::fullPathForDatabase):
(WebCore::DBBackend::Server::hasEntryForOrigin):
(WebCore::DBBackend::Server::origins):
(WebCore::DBBackend::Server::databaseNamesForOrigin):
(WebCore::DBBackend::Server::detailsForNameAndOrigin):
(WebCore::DBBackend::Server::usageForOrigin):
(WebCore::DBBackend::Server::quotaForOrigin):
(WebCore::DBBackend::Server::setQuota):
(WebCore::DBBackend::Server::deleteAllDatabases):
(WebCore::DBBackend::Server::deleteOrigin):
(WebCore::DBBackend::Server::deleteDatabase):
(WebCore::DBBackend::Server::scheduleNotifyDatabaseChanged):
(WebCore::DBBackend::Server::databaseChanged):
(WebCore::DBBackend::Server::closeDatabasesImmediately):
(WebCore::DBBackend::Server::interruptAllDatabasesForContext):
(WebCore::DBBackend::Server::canEstablishDatabase):
(WebCore::DBBackend::Server::addOpenDatabase):
(WebCore::DBBackend::Server::removeOpenDatabase):
(WebCore::DBBackend::Server::setDatabaseDetails):
(WebCore::DBBackend::Server::getMaxSizeForDatabase):
- Refactored all calls to the DatabaseTracker to go thru the DBBackend::Server.
* Modules/webdatabase/DBBackendServer.h:
* Modules/webdatabase/DOMWindowWebDatabase.cpp:
(WebCore::DOMWindowWebDatabase::openDatabase):
* Modules/webdatabase/Database.cpp:
(WebCore::Database::close):
(WebCore::Database::maximumSize):
* Modules/webdatabase/Database.h:
(Database):
- Moved the openDatabase() factory method to the DatabaseManager.
- Removed the unused deliverPendingCallback() prototype.
* Modules/webdatabase/DatabaseBasicTypes.h: Added.
- A place to define some common basic types used by the database module.
* Modules/webdatabase/DatabaseContext.cpp:
(WebCore::DatabaseContext::databaseExceededQuota):
* Modules/webdatabase/DatabaseManager.cpp:
(WebCore::DatabaseManager::DatabaseManager):
(WebCore::DatabaseManager::initialize):
(WebCore::DatabaseManager::setClient):
(WebCore::DatabaseManager::databaseDirectoryPath):
(WebCore::DatabaseManager::setDatabaseDirectoryPath):
(WebCore::DatabaseManager::isAvailable):
(WebCore::DatabaseManager::setIsAvailable):
(DatabaseCreationCallbackTask):
(WebCore::DatabaseCreationCallbackTask::create):
(WebCore::DatabaseCreationCallbackTask::performTask):
(WebCore::DatabaseCreationCallbackTask::DatabaseCreationCallbackTask):
(WebCore::DatabaseManager::openDatabase):
(WebCore::DatabaseManager::openDatabaseSync):
(WebCore::DatabaseManager::setHasOpenDatabases):
(WebCore::DatabaseManager::fullPathForDatabase):
(WebCore::DatabaseManager::hasEntryForOrigin):
(WebCore::DatabaseManager::origins):
(WebCore::DatabaseManager::databaseNamesForOrigin):
(WebCore::DatabaseManager::detailsForNameAndOrigin):
(WebCore::DatabaseManager::usageForOrigin):
(WebCore::DatabaseManager::quotaForOrigin):
(WebCore::DatabaseManager::setQuota):
(WebCore::DatabaseManager::deleteAllDatabases):
(WebCore::DatabaseManager::deleteOrigin):
(WebCore::DatabaseManager::deleteDatabase):
(WebCore::DatabaseManager::scheduleNotifyDatabaseChanged):
(WebCore::DatabaseManager::databaseChanged):
(WebCore::DatabaseManager::closeDatabasesImmediately):
(WebCore::DatabaseManager::interruptAllDatabasesForContext):
(WebCore::DatabaseManager::canEstablishDatabase):
(WebCore::DatabaseManager::addOpenDatabase):
(WebCore::DatabaseManager::removeOpenDatabase):
(WebCore::DatabaseManager::setDatabaseDetails):
(WebCore::DatabaseManager::getMaxSizeForDatabase):
* Modules/webdatabase/DatabaseManager.h:
(DatabaseManager):
* Modules/webdatabase/DatabaseSync.cpp:
(WebCore::DatabaseSync::~DatabaseSync):
(WebCore::DatabaseSync::closeImmediately):
* Modules/webdatabase/DatabaseSync.h:
(DatabaseSync):
- Moved the openDatabaseSync() factory method to the DatabaseManager.
* Modules/webdatabase/DatabaseTask.h:
* Modules/webdatabase/SQLResultSet.h:
* Modules/webdatabase/SQLStatementSync.h:
* Modules/webdatabase/SQLTransaction.h:
* Modules/webdatabase/SQLTransactionClient.cpp:
(WebCore::SQLTransactionClient::didCommitWriteTransaction):
(WebCore::SQLTransactionClient::didExecuteStatement):
(WebCore::SQLTransactionClient::didExceedQuota):
* Modules/webdatabase/SQLTransactionSync.h:
* Modules/webdatabase/WorkerContextWebDatabase.cpp:
(WebCore::WorkerContextWebDatabase::openDatabase):
(WebCore::WorkerContextWebDatabase::openDatabaseSync):
* Target.pri:
* WebCore.gypi:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
2012-12-18 Per-Erik Brodin <per-erik.brodin@ericsson.com>
EventSource should support CORS
......@@ -2110,6 +2110,7 @@ webcore_modules_sources += \
Source/WebCore/Modules/webdatabase/DatabaseThread.h \
Source/WebCore/Modules/webdatabase/DatabaseTracker.cpp \
Source/WebCore/Modules/webdatabase/DatabaseTracker.h \
Source/WebCore/Modules/webdatabase/DBBackendServer.cpp \
Source/WebCore/Modules/webdatabase/DBBackendServer.h \
Source/WebCore/Modules/webdatabase/OriginQuotaManager.cpp \
Source/WebCore/Modules/webdatabase/OriginQuotaManager.h \
......
......@@ -33,7 +33,7 @@
#include "DatabaseAuthorizer.h"
#include "DatabaseContext.h"
#include "DatabaseTracker.h"
#include "DatabaseManager.h"
#include "ExceptionCode.h"
#include "Logging.h"
#include "SQLiteStatement.h"
......@@ -115,7 +115,7 @@ static Mutex& guidMutex()
return mutex;
}
typedef HashMap<int, String> GuidVersionMap;
typedef HashMap<DatabaseGuid, String> GuidVersionMap;
static GuidVersionMap& guidToVersionMap()
{
// Ensure the the mutex is locked.
......@@ -125,7 +125,7 @@ static GuidVersionMap& guidToVersionMap()
}
// NOTE: Caller must lock guidMutex().
static inline void updateGuidVersionMap(int guid, String newVersion)
static inline void updateGuidVersionMap(DatabaseGuid guid, String newVersion)
{
// Ensure the the mutex is locked.
ASSERT(!guidMutex().tryLock());
......@@ -140,7 +140,7 @@ static inline void updateGuidVersionMap(int guid, String newVersion)
guidToVersionMap().set(guid, newVersion.isEmpty() ? String() : newVersion.isolatedCopy());
}
typedef HashMap<int, HashSet<AbstractDatabase*>*> GuidDatabaseMap;
typedef HashMap<DatabaseGuid, HashSet<AbstractDatabase*>*> GuidDatabaseMap;
static GuidDatabaseMap& guidToDatabaseMap()
{
// Ensure the the mutex is locked.
......@@ -149,7 +149,7 @@ static GuidDatabaseMap& guidToDatabaseMap()
return map;
}
static int guidForOriginAndName(const String& origin, const String& name)
static DatabaseGuid guidForOriginAndName(const String& origin, const String& name)
{
// Ensure the the mutex is locked.
ASSERT(!guidMutex().tryLock());
......@@ -158,7 +158,7 @@ static int guidForOriginAndName(const String& origin, const String& name)
typedef HashMap<String, int> IDGuidMap;
DEFINE_STATIC_LOCAL(IDGuidMap, stringIdentifierToGUIDMap, ());
int guid = stringIdentifierToGUIDMap.get(stringID);
DatabaseGuid guid = stringIdentifierToGUIDMap.get(stringID);
if (!guid) {
static int currentNewGUID = 1;
guid = currentNewGUID++;
......@@ -168,18 +168,6 @@ static int guidForOriginAndName(const String& origin, const String& name)
return guid;
}
static bool isDatabaseAvailable = true;
bool AbstractDatabase::isAvailable()
{
return isDatabaseAvailable;
}
void AbstractDatabase::setIsAvailable(bool available)
{
isDatabaseAvailable = available;
}
// static
const char* AbstractDatabase::databaseInfoTableName()
{
......@@ -219,8 +207,8 @@ AbstractDatabase::AbstractDatabase(ScriptExecutionContext* context, const String
hashSet->add(this);
}
m_filename = DatabaseTracker::tracker().fullPathForDatabase(securityOrigin(), m_name);
DatabaseTracker::tracker().addOpenDatabase(this);
m_filename = DatabaseManager::manager().fullPathForDatabase(securityOrigin(), m_name);
DatabaseManager::manager().addOpenDatabase(this);
}
AbstractDatabase::~AbstractDatabase()
......@@ -539,7 +527,7 @@ void AbstractDatabase::resetAuthorizer()
unsigned long long AbstractDatabase::maximumSize() const
{
return DatabaseTracker::tracker().getMaxSizeForDatabase(this);
return DatabaseManager::manager().getMaxSizeForDatabase(this);
}
void AbstractDatabase::incrementalVacuumIfNeeded()
......
......@@ -31,6 +31,7 @@
#if ENABLE(SQL_DATABASE)
#include "DatabaseBasicTypes.h"
#include "SQLiteDatabase.h"
#include <wtf/Forward.h>
#include <wtf/ThreadSafeRefCounted.h>
......@@ -47,13 +48,8 @@ class DatabaseContext;
class ScriptExecutionContext;
class SecurityOrigin;
typedef int ExceptionCode;
class AbstractDatabase : public ThreadSafeRefCounted<AbstractDatabase> {
public:
static bool isAvailable();
static void setIsAvailable(bool available);
virtual ~AbstractDatabase();
virtual String version() const;
......@@ -143,7 +139,7 @@ protected:
#endif
private:
int m_guid;
DatabaseGuid m_guid;
bool m_opened;
bool m_new;
const bool m_isSyncDatabase;
......
......@@ -28,9 +28,60 @@
#if ENABLE(SQL_DATABASE)
#include "DatabaseDetails.h"
#include <wtf/RefPtr.h>
#include <wtf/Vector.h>
#include <wtf/text/WTFString.h>
namespace WebCore {
class AbstractDatabase;
class DatabaseManagerClient;
class ScriptExecutionContext;
class SecurityOrigin;
class AbstractDatabaseServer {
public:
virtual void initialize(const String& databasePath) = 0;
virtual void setClient(DatabaseManagerClient*) = 0;
virtual String databaseDirectoryPath() const = 0;
virtual void setDatabaseDirectoryPath(const String&) = 0;
virtual String fullPathForDatabase(SecurityOrigin*, const String& name, bool createIfDoesNotExist = true) = 0;
#if !PLATFORM(CHROMIUM)
virtual bool hasEntryForOrigin(SecurityOrigin*) = 0;
virtual void origins(Vector<RefPtr<SecurityOrigin> >& result) = 0;
virtual bool databaseNamesForOrigin(SecurityOrigin*, Vector<String>& result) = 0;
virtual DatabaseDetails detailsForNameAndOrigin(const String&, SecurityOrigin*) = 0;
virtual unsigned long long usageForOrigin(SecurityOrigin*) = 0;
virtual unsigned long long quotaForOrigin(SecurityOrigin*) = 0;
virtual void setQuota(SecurityOrigin*, unsigned long long) = 0;
virtual void deleteAllDatabases() = 0;
virtual bool deleteOrigin(SecurityOrigin*) = 0;
virtual bool deleteDatabase(SecurityOrigin*, const String& name) = 0;
// From a secondary thread, must be thread safe with its data
virtual void scheduleNotifyDatabaseChanged(SecurityOrigin*, const String& name) = 0;
virtual void databaseChanged(AbstractDatabase*) = 0;
#else // PLATFORM(CHROMIUM)
virtual void closeDatabasesImmediately(const String& originIdentifier, const String& name) = 0;
#endif // PLATFORM(CHROMIUM)
virtual void interruptAllDatabasesForContext(const ScriptExecutionContext*) = 0;
virtual bool canEstablishDatabase(ScriptExecutionContext*, const String& name, const String& displayName, unsigned long estimatedSize) = 0;
virtual void addOpenDatabase(AbstractDatabase*) = 0;
virtual void removeOpenDatabase(AbstractDatabase*) = 0;
virtual void setDatabaseDetails(SecurityOrigin*, const String& name, const String& displayName, unsigned long estimatedSize) = 0;
virtual unsigned long long getMaxSizeForDatabase(const AbstractDatabase*) = 0;
protected:
AbstractDatabaseServer() { }
virtual ~AbstractDatabaseServer() { }
......
/*
* Copyright (C) 2012 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 "DBBackendServer.h"
#if ENABLE(SQL_DATABASE)
#include "DatabaseTracker.h"
#include <wtf/UnusedParam.h>
namespace WebCore {
namespace DBBackend {
void Server::initialize(const String& databasePath)
{
#if !PLATFORM(CHROMIUM)
DatabaseTracker::initializeTracker(databasePath);
#else
UNUSED_PARAM(databasePath);
#endif
}
void Server::setClient(DatabaseManagerClient* client)
{
#if !PLATFORM(CHROMIUM)
DatabaseTracker::tracker().setClient(client);
#else
UNUSED_PARAM(client);
#endif
}
String Server::databaseDirectoryPath() const
{
#if !PLATFORM(CHROMIUM)
return DatabaseTracker::tracker().databaseDirectoryPath();
#else
return "";
#endif
}
void Server::setDatabaseDirectoryPath(const String& path)
{
#if !PLATFORM(CHROMIUM)
DatabaseTracker::tracker().setDatabaseDirectoryPath(path);
#endif
}
String Server::fullPathForDatabase(SecurityOrigin* origin, const String& name, bool createIfDoesNotExist)
{
return DatabaseTracker::tracker().fullPathForDatabase(origin, name, createIfDoesNotExist);
}
#if !PLATFORM(CHROMIUM)
bool Server::hasEntryForOrigin(SecurityOrigin* origin)
{
return DatabaseTracker::tracker().hasEntryForOrigin(origin);
}
void Server::origins(Vector<RefPtr<SecurityOrigin> >& result)
{
DatabaseTracker::tracker().origins(result);
}
bool Server::databaseNamesForOrigin(SecurityOrigin* origin, Vector<String>& result)
{
return DatabaseTracker::tracker().databaseNamesForOrigin(origin, result);
}
DatabaseDetails Server::detailsForNameAndOrigin(const String& name, SecurityOrigin* origin)
{
return DatabaseTracker::tracker().detailsForNameAndOrigin(name, origin);
}
unsigned long long Server::usageForOrigin(SecurityOrigin* origin)
{
return DatabaseTracker::tracker().usageForOrigin(origin);
}
unsigned long long Server::quotaForOrigin(SecurityOrigin* origin)
{
return DatabaseTracker::tracker().quotaForOrigin(origin);
}
void Server::setQuota(SecurityOrigin* origin, unsigned long long quotaSize)
{
DatabaseTracker::tracker().setQuota(origin, quotaSize);
}
void Server::deleteAllDatabases()
{
DatabaseTracker::tracker().deleteAllDatabases();
}
bool Server::deleteOrigin(SecurityOrigin* origin)
{
return DatabaseTracker::tracker().deleteOrigin(origin);
}
bool Server::deleteDatabase(SecurityOrigin* origin, const String& name)
{
return DatabaseTracker::tracker().deleteDatabase(origin, name);
}
// From a secondary thread, must be thread safe with its data
void Server::scheduleNotifyDatabaseChanged(SecurityOrigin* origin, const String& name)
{
DatabaseTracker::tracker().scheduleNotifyDatabaseChanged(origin, name);
}
void Server::databaseChanged(AbstractDatabase* database)
{
DatabaseTracker::tracker().databaseChanged(database);
}
#else // PLATFORM(CHROMIUM)
void Server::closeDatabasesImmediately(const String& originIdentifier, const String& name)
{
DatabaseTracker::tracker().closeDatabasesImmediately(originIdentifier, name);
}
#endif // PLATFORM(CHROMIUM)
void Server::interruptAllDatabasesForContext(const ScriptExecutionContext* context)
{
DatabaseTracker::tracker().interruptAllDatabasesForContext(context);
}
bool Server::canEstablishDatabase(ScriptExecutionContext* context, const String& name, const String& displayName, unsigned long estimatedSize)
{
return DatabaseTracker::tracker().canEstablishDatabase(context, name, displayName, estimatedSize);
}
void Server::addOpenDatabase(AbstractDatabase* database)
{
DatabaseTracker::tracker().addOpenDatabase(database);
}
void Server::removeOpenDatabase(AbstractDatabase* database)
{
DatabaseTracker::tracker().removeOpenDatabase(database);
}
void Server::setDatabaseDetails(SecurityOrigin* origin, const String& name, const String& displayName, unsigned long estimatedSize)
{
DatabaseTracker::tracker().setDatabaseDetails(origin, name, displayName, estimatedSize);
}
unsigned long long Server::getMaxSizeForDatabase(const AbstractDatabase* database)
{
return DatabaseTracker::tracker().getMaxSizeForDatabase(database);
}
} // namespace DBBackend
} // namespace WebCore
#endif // ENABLE(SQL_DATABASE)
/*
* Copyright (C) 2012 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 "DBBackendServer.h"
#if ENABLE(SQL_DATABASE)
#include "DatabaseTracker.h"
#include <wtf/UnusedParam.h>
namespace WebCore {
namespace DBBackend {
void Server::initialize(const String& databasePath)
{
#if !PLATFORM(CHROMIUM)
DatabaseTracker::tracker().initializeTracker(databasePath);
#else
UNUSED_PARAM(databasePath);
#endif
}
void Server::setClient(DatabaseManagerClient* client)
{
#if !PLATFORM(CHROMIUM)
DatabaseTracker::tracker().setClient(client);
#else
UNUSED_PARAM(client);
#endif
}
String Server::databaseDirectoryPath() const
{
#if !PLATFORM(CHROMIUM)
return DatabaseTracker::tracker().databaseDirectoryPath();
#else
return "";
#endif
}
void Server::setDatabaseDirectoryPath(const String& path)
{
#if !PLATFORM(CHROMIUM)
DatabaseTracker::tracker().setDatabaseDirectoryPath(path);
#endif
}
String Server::fullPathForDatabase(SecurityOrigin* origin, const String& name, bool createIfDoesNotExist)
{
return DatabaseTracker::tracker().fullPathForDatabase(origin, name, createIfDoesNotExist);
}
#if !PLATFORM(CHROMIUM)
bool Server::hasEntryForOrigin(SecurityOrigin* origin)
{
return DatabaseTracker::tracker().hasEntryForOrigin(origin);
}
void Server::origins(Vector<RefPtr<SecurityOrigin> >& result)
{
DatabaseTracker::tracker().origins(result);
}
bool Server::databaseNamesForOrigin(SecurityOrigin* origin, Vector<String>& result)
{
return DatabaseTracker::tracker().databaseNamesForOrigin(origin, result);
}
DatabaseDetails Server::detailsForNameAndOrigin(const String& name, SecurityOrigin* origin)
{
return DatabaseTracker::tracker().detailsForNameAndOrigin(name, origin);
}
unsigned long long Server::usageForOrigin(SecurityOrigin* origin)
{
return DatabaseTracker::tracker().usageForOrigin(origin);
}
unsigned long long Server::quotaForOrigin(SecurityOrigin* origin)
{
return DatabaseTracker::tracker().quotaForOrigin(origin);
}
void Server::setQuota(SecurityOrigin* origin, unsigned long long quotaSize)
{
DatabaseTracker::tracker().setQuota(origin, quotaSize);
}
void Server::deleteAllDatabases()
{
DatabaseTracker::tracker().deleteAllDatabases();
}