Commit a4946bc1 authored by benjamin@webkit.org's avatar benjamin@webkit.org

Clean the chromium bits of WebCore's WebDatabase

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

Reviewed by Ryosuke Niwa.

* Modules/webdatabase/AbstractDatabaseServer.h:
* Modules/webdatabase/ChangeVersionWrapper.cpp:
(WebCore::ChangeVersionWrapper::performPreflight):
(WebCore::ChangeVersionWrapper::performPostflight):
* Modules/webdatabase/Database.cpp:
* Modules/webdatabase/Database.h:
(Database):
* Modules/webdatabase/DatabaseBackend.cpp:
(WebCore::DatabaseBackend::openAndVerifyVersion):
* Modules/webdatabase/DatabaseBackendBase.cpp:
(WebCore::DoneCreatingDatabaseOnExitCaller::~DoneCreatingDatabaseOnExitCaller):
(WebCore::DatabaseBackendBase::performOpenAndVerify):
(WebCore::DatabaseBackendBase::getActualVersionForTransaction):
(WebCore::DatabaseBackendBase::incrementalVacuumIfNeeded):
* Modules/webdatabase/DatabaseBackendBase.h:
(DatabaseBackendBase):
* Modules/webdatabase/DatabaseBackendSync.cpp:
(WebCore::DatabaseBackendSync::openAndVerifyVersion):
* Modules/webdatabase/DatabaseContext.cpp:
(WebCore::DatabaseContext::databaseExceededQuota):
* Modules/webdatabase/DatabaseManager.cpp:
* Modules/webdatabase/DatabaseManager.h:
(DatabaseManager):
* Modules/webdatabase/DatabaseServer.cpp:
(WebCore::DatabaseServer::initialize):
(WebCore::DatabaseServer::setClient):
(WebCore::DatabaseServer::databaseDirectoryPath):
(WebCore::DatabaseServer::setDatabaseDirectoryPath):
(WebCore::DatabaseServer::openDatabase):
* Modules/webdatabase/DatabaseServer.h:
* Modules/webdatabase/DatabaseSync.cpp:
(WebCore::DatabaseSync::changeVersion):
* Modules/webdatabase/DatabaseTracker.cpp:
(WebCore::DatabaseTracker::canEstablishDatabase):
(WebCore::DatabaseTracker::retryCanEstablishDatabase):
* Modules/webdatabase/DatabaseTracker.h:
(WebCore):
(DatabaseTracker):
* Modules/webdatabase/SQLStatementBackend.cpp:
(WebCore::SQLStatementBackend::execute):
(WebCore::SQLStatementBackend::setDatabaseDeletedError):
(WebCore::SQLStatementBackend::setVersionMismatchedError):
(WebCore::SQLStatementBackend::setFailureDueToQuota):
* Modules/webdatabase/SQLStatementBackend.h:
(SQLStatementBackend):
* Modules/webdatabase/SQLTransaction.cpp:
(WebCore::SQLTransaction::deliverTransactionCallback):
(WebCore::SQLTransaction::deliverStatementCallback):
* Modules/webdatabase/SQLTransactionBackend.cpp:
(WebCore::SQLTransactionBackend::executeSQL):
(WebCore::SQLTransactionBackend::openTransactionAndPreflight):
(WebCore::SQLTransactionBackend::runCurrentStatementAndGetNextState):
(WebCore::SQLTransactionBackend::nextStateForCurrentStatementError):
(WebCore::SQLTransactionBackend::postflightAndCommit):
(WebCore::SQLTransactionBackend::acquireOriginLock):
(WebCore::SQLTransactionBackend::releaseOriginLockIfNeeded):
* Modules/webdatabase/SQLTransactionBackend.h:
(SQLTransactionBackend):
* Modules/webdatabase/SQLTransactionBackendSync.cpp:
(WebCore::SQLTransactionBackendSync::begin):
(WebCore::SQLTransactionBackendSync::commit):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@147796 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 95708e2b
2013-04-05 Benjamin Poulain <benjamin@webkit.org>
Clean the chromium bits of WebCore's WebDatabase
https://bugs.webkit.org/show_bug.cgi?id=114010
Reviewed by Ryosuke Niwa.
* Modules/webdatabase/AbstractDatabaseServer.h:
* Modules/webdatabase/ChangeVersionWrapper.cpp:
(WebCore::ChangeVersionWrapper::performPreflight):
(WebCore::ChangeVersionWrapper::performPostflight):
* Modules/webdatabase/Database.cpp:
* Modules/webdatabase/Database.h:
(Database):
* Modules/webdatabase/DatabaseBackend.cpp:
(WebCore::DatabaseBackend::openAndVerifyVersion):
* Modules/webdatabase/DatabaseBackendBase.cpp:
(WebCore::DoneCreatingDatabaseOnExitCaller::~DoneCreatingDatabaseOnExitCaller):
(WebCore::DatabaseBackendBase::performOpenAndVerify):
(WebCore::DatabaseBackendBase::getActualVersionForTransaction):
(WebCore::DatabaseBackendBase::incrementalVacuumIfNeeded):
* Modules/webdatabase/DatabaseBackendBase.h:
(DatabaseBackendBase):
* Modules/webdatabase/DatabaseBackendSync.cpp:
(WebCore::DatabaseBackendSync::openAndVerifyVersion):
* Modules/webdatabase/DatabaseContext.cpp:
(WebCore::DatabaseContext::databaseExceededQuota):
* Modules/webdatabase/DatabaseManager.cpp:
* Modules/webdatabase/DatabaseManager.h:
(DatabaseManager):
* Modules/webdatabase/DatabaseServer.cpp:
(WebCore::DatabaseServer::initialize):
(WebCore::DatabaseServer::setClient):
(WebCore::DatabaseServer::databaseDirectoryPath):
(WebCore::DatabaseServer::setDatabaseDirectoryPath):
(WebCore::DatabaseServer::openDatabase):
* Modules/webdatabase/DatabaseServer.h:
* Modules/webdatabase/DatabaseSync.cpp:
(WebCore::DatabaseSync::changeVersion):
* Modules/webdatabase/DatabaseTracker.cpp:
(WebCore::DatabaseTracker::canEstablishDatabase):
(WebCore::DatabaseTracker::retryCanEstablishDatabase):
* Modules/webdatabase/DatabaseTracker.h:
(WebCore):
(DatabaseTracker):
* Modules/webdatabase/SQLStatementBackend.cpp:
(WebCore::SQLStatementBackend::execute):
(WebCore::SQLStatementBackend::setDatabaseDeletedError):
(WebCore::SQLStatementBackend::setVersionMismatchedError):
(WebCore::SQLStatementBackend::setFailureDueToQuota):
* Modules/webdatabase/SQLStatementBackend.h:
(SQLStatementBackend):
* Modules/webdatabase/SQLTransaction.cpp:
(WebCore::SQLTransaction::deliverTransactionCallback):
(WebCore::SQLTransaction::deliverStatementCallback):
* Modules/webdatabase/SQLTransactionBackend.cpp:
(WebCore::SQLTransactionBackend::executeSQL):
(WebCore::SQLTransactionBackend::openTransactionAndPreflight):
(WebCore::SQLTransactionBackend::runCurrentStatementAndGetNextState):
(WebCore::SQLTransactionBackend::nextStateForCurrentStatementError):
(WebCore::SQLTransactionBackend::postflightAndCommit):
(WebCore::SQLTransactionBackend::acquireOriginLock):
(WebCore::SQLTransactionBackend::releaseOriginLockIfNeeded):
* Modules/webdatabase/SQLTransactionBackend.h:
(SQLTransactionBackend):
* Modules/webdatabase/SQLTransactionBackendSync.cpp:
(WebCore::SQLTransactionBackendSync::begin):
(WebCore::SQLTransactionBackendSync::commit):
2013-04-05 Geoffrey Garen <ggaren@apple.com>
Made USE(JSC) unconditional
......@@ -61,7 +61,6 @@ public:
const String& name, const String& expectedVersion, const String& displayName, unsigned long estimatedSize,
bool setVersionInNewDatabase, DatabaseError&, String& errorMessage, OpenAttempt = FirstTryToOpenDatabase) = 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;
......@@ -76,10 +75,6 @@ public:
virtual bool deleteOrigin(SecurityOrigin*) = 0;
virtual bool deleteDatabase(SecurityOrigin*, const String& name) = 0;
#else // PLATFORM(CHROMIUM)
virtual void closeDatabasesImmediately(const String& originIdentifier, const String& name) = 0;
#endif // PLATFORM(CHROMIUM)
virtual void interruptAllDatabasesForContext(const DatabaseBackendContext*) = 0;
protected:
......
......@@ -52,14 +52,12 @@ bool ChangeVersionWrapper::performPreflight(SQLTransactionBackend* transaction)
String actualVersion;
if (!database->getVersionFromDatabase(actualVersion)) {
int sqliteError = database->sqliteDatabase().lastError();
database->reportChangeVersionResult(1, SQLError::UNKNOWN_ERR, sqliteError);
m_sqlError = SQLError::create(SQLError::UNKNOWN_ERR, "unable to read the current version",
sqliteError, database->sqliteDatabase().lastErrorMsg());
return false;
}
if (actualVersion != m_oldVersion) {
database->reportChangeVersionResult(2, SQLError::VERSION_ERR, 0);
m_sqlError = SQLError::create(SQLError::VERSION_ERR, "current version of the database and `oldVersion` argument do not match");
return false;
}
......@@ -75,15 +73,12 @@ bool ChangeVersionWrapper::performPostflight(SQLTransactionBackend* transaction)
if (!database->setVersionInDatabase(m_newVersion)) {
int sqliteError = database->sqliteDatabase().lastError();
database->reportChangeVersionResult(3, SQLError::UNKNOWN_ERR, sqliteError);
m_sqlError = SQLError::create(SQLError::UNKNOWN_ERR, "unable to set new version in database",
sqliteError, database->sqliteDatabase().lastErrorMsg());
return false;
}
database->setExpectedVersion(m_newVersion);
database->reportChangeVersionResult(0, -1, 0); // OK
return true;
}
......
......@@ -283,19 +283,6 @@ SecurityOrigin* Database::securityOrigin() const
return 0;
}
#if PLATFORM(CHROMIUM)
void Database::reportStartTransactionResult(int errorSite, int webSqlErrorCode, int sqliteErrorCode)
{
backend()->reportStartTransactionResult(errorSite, webSqlErrorCode, sqliteErrorCode);
}
void Database::reportCommitTransactionResult(int errorSite, int webSqlErrorCode, int sqliteErrorCode)
{
backend()->reportCommitTransactionResult(errorSite, webSqlErrorCode, sqliteErrorCode);
}
#endif
} // namespace WebCore
#endif // ENABLE(SQL_DATABASE)
......@@ -86,14 +86,6 @@ private:
Vector<String> performGetTableNames();
#if PLATFORM(CHROMIUM)
void reportStartTransactionResult(int errorSite, int webSqlErrorCode, int sqliteErrorCode);
void reportCommitTransactionResult(int errorSite, int webSqlErrorCode, int sqliteErrorCode);
#else
void reportStartTransactionResult(int, int, int) { }
void reportCommitTransactionResult(int, int, int) { }
#endif
RefPtr<SecurityOrigin> m_databaseThreadSecurityOrigin;
RefPtr<DatabaseContext> m_databaseContext;
......
......@@ -55,9 +55,6 @@ bool DatabaseBackend::openAndVerifyVersion(bool setVersionInNewDatabase, Databas
if (!databaseContext()->databaseThread() || databaseContext()->databaseThread()->terminationRequested(&synchronizer))
return false;
#if PLATFORM(CHROMIUM)
DatabaseTracker::tracker().prepareToOpenDatabase(this);
#endif
bool success = false;
OwnPtr<DatabaseOpenTask> task = DatabaseOpenTask::create(this, setVersionInNewDatabase, &synchronizer, error, errorMessage, success);
databaseContext()->databaseThread()->scheduleImmediateTask(task.release());
......
......@@ -51,10 +51,6 @@
#include <wtf/text/CString.h>
#include <wtf/text/StringHash.h>
#if PLATFORM(CHROMIUM)
#include "DatabaseObserver.h" // For error reporting.
#endif
// Registering "opened" databases with the DatabaseTracker
// =======================================================
// The DatabaseTracker maintains a list of databases that have been
......@@ -294,12 +290,7 @@ public:
}
~DoneCreatingDatabaseOnExitCaller()
{
#if !PLATFORM(CHROMIUM)
DatabaseTracker::tracker().doneCreatingDatabase(m_database);
#else
if (!m_openSucceeded)
DatabaseTracker::tracker().failedToOpenDatabase(m_database);
#endif
}
void setOpenSucceeded() { m_openSucceeded = true; }
......@@ -319,7 +310,6 @@ bool DatabaseBackendBase::performOpenAndVerify(bool shouldSetVersionInNewDatabas
const int maxSqliteBusyWaitTime = 30000;
if (!m_sqliteDatabase.open(m_filename, true)) {
reportOpenDatabaseResult(1, INVALID_STATE_ERR, m_sqliteDatabase.lastError());
errorMessage = formatErrorMessage("unable to open database", m_sqliteDatabase.lastError(), m_sqliteDatabase.lastErrorMsg());
return false;
}
......@@ -337,30 +327,12 @@ bool DatabaseBackendBase::performOpenAndVerify(bool shouldSetVersionInNewDatabas
// Map null string to empty string (see updateGuidVersionMap()).
currentVersion = entry->value.isNull() ? emptyString() : entry->value.isolatedCopy();
LOG(StorageAPI, "Current cached version for guid %i is %s", m_guid, currentVersion.ascii().data());
#if PLATFORM(CHROMIUM)
// Note: In multi-process browsers the cached value may be inaccurate, but
// we cannot read the actual version from the database without potentially
// inducing a form of deadlock, a busytimeout error when trying to
// access the database. So we'll use the cached value if we're unable to read
// the value from the database file without waiting.
// FIXME: Add an async openDatabase method to the DatabaseAPI.
const int noSqliteBusyWaitTime = 0;
m_sqliteDatabase.setBusyTimeout(noSqliteBusyWaitTime);
String versionFromDatabase;
if (getVersionFromDatabase(versionFromDatabase, false)) {
currentVersion = versionFromDatabase;
updateGuidVersionMap(m_guid, currentVersion);
}
m_sqliteDatabase.setBusyTimeout(maxSqliteBusyWaitTime);
#endif
} else {
LOG(StorageAPI, "No cached version for guid %i", m_guid);
SQLiteTransaction transaction(m_sqliteDatabase);
transaction.begin();
if (!transaction.inProgress()) {
reportOpenDatabaseResult(2, INVALID_STATE_ERR, m_sqliteDatabase.lastError());
errorMessage = formatErrorMessage("unable to open database, failed to start transaction", m_sqliteDatabase.lastError(), m_sqliteDatabase.lastErrorMsg());
m_sqliteDatabase.close();
return false;
......@@ -371,14 +343,12 @@ bool DatabaseBackendBase::performOpenAndVerify(bool shouldSetVersionInNewDatabas
m_new = true;
if (!m_sqliteDatabase.executeCommand("CREATE TABLE " + tableName + " (key TEXT NOT NULL ON CONFLICT FAIL UNIQUE ON CONFLICT REPLACE,value TEXT NOT NULL ON CONFLICT FAIL);")) {
reportOpenDatabaseResult(3, INVALID_STATE_ERR, m_sqliteDatabase.lastError());
errorMessage = formatErrorMessage("unable to open database, failed to create 'info' table", m_sqliteDatabase.lastError(), m_sqliteDatabase.lastErrorMsg());
transaction.rollback();
m_sqliteDatabase.close();
return false;
}
} else if (!getVersionFromDatabase(currentVersion, false)) {
reportOpenDatabaseResult(4, INVALID_STATE_ERR, m_sqliteDatabase.lastError());
errorMessage = formatErrorMessage("unable to open database, failed to read current version", m_sqliteDatabase.lastError(), m_sqliteDatabase.lastErrorMsg());
transaction.rollback();
m_sqliteDatabase.close();
......@@ -390,7 +360,6 @@ bool DatabaseBackendBase::performOpenAndVerify(bool shouldSetVersionInNewDatabas
} else if (!m_new || shouldSetVersionInNewDatabase) {
LOG(StorageAPI, "Setting version %s in database %s that was just created", m_expectedVersion.ascii().data(), databaseDebugName().ascii().data());
if (!setVersionInDatabase(m_expectedVersion, false)) {
reportOpenDatabaseResult(5, INVALID_STATE_ERR, m_sqliteDatabase.lastError());
errorMessage = formatErrorMessage("unable to open database, failed to write current version", m_sqliteDatabase.lastError(), m_sqliteDatabase.lastErrorMsg());
transaction.rollback();
m_sqliteDatabase.close();
......@@ -411,7 +380,6 @@ bool DatabaseBackendBase::performOpenAndVerify(bool shouldSetVersionInNewDatabas
// If the expected version isn't the empty string, ensure that the current database version we have matches that version. Otherwise, set an exception.
// If the expected version is the empty string, then we always return with whatever version of the database we have.
if ((!m_new || shouldSetVersionInNewDatabase) && m_expectedVersion.length() && m_expectedVersion != currentVersion) {
reportOpenDatabaseResult(6, INVALID_STATE_ERR, 0);
errorMessage = "unable to open database, version mismatch, '" + m_expectedVersion + "' does not match the currentVersion of '" + currentVersion + "'";
m_sqliteDatabase.close();
return false;
......@@ -430,8 +398,6 @@ bool DatabaseBackendBase::performOpenAndVerify(bool shouldSetVersionInNewDatabas
if (m_new && !shouldSetVersionInNewDatabase)
m_expectedVersion = ""; // The caller provided a creationCallback which will set the expected version.
reportOpenDatabaseResult(0, -1, 0); // OK
return true;
}
......@@ -527,14 +493,9 @@ void DatabaseBackendBase::setCachedVersion(const String& actualVersion)
bool DatabaseBackendBase::getActualVersionForTransaction(String &actualVersion)
{
ASSERT(m_sqliteDatabase.transactionInProgress());
#if PLATFORM(CHROMIUM)
// Note: In multi-process browsers the cached value may be inaccurate.
// So we retrieve the value from the database and update the cached value here.
return getVersionFromDatabase(actualVersion, true);
#else
actualVersion = getCachedVersion();
return true;
#endif
}
void DatabaseBackendBase::disableAuthorizer()
......@@ -602,7 +563,6 @@ void DatabaseBackendBase::incrementalVacuumIfNeeded()
int64_t totalSize = m_sqliteDatabase.totalSize();
if (totalSize <= 10 * freeSpaceSize) {
int result = m_sqliteDatabase.runIncrementalVacuumCommand();
reportVacuumDatabaseResult(result);
if (result != SQLResultOk)
m_frontend->logErrorMessage(formatErrorMessage("error vacuuming database", result, m_sqliteDatabase.lastErrorMsg()));
}
......@@ -619,41 +579,6 @@ bool DatabaseBackendBase::isInterrupted()
return m_sqliteDatabase.isInterrupted();
}
#if PLATFORM(CHROMIUM)
// These are used to generate histograms of errors seen with websql.
// See about:histograms in chromium.
void DatabaseBackendBase::reportOpenDatabaseResult(int errorSite, int webSqlErrorCode, int sqliteErrorCode)
{
DatabaseObserver::reportOpenDatabaseResult(this, errorSite, webSqlErrorCode, sqliteErrorCode);
}
void DatabaseBackendBase::reportChangeVersionResult(int errorSite, int webSqlErrorCode, int sqliteErrorCode)
{
DatabaseObserver::reportChangeVersionResult(this, errorSite, webSqlErrorCode, sqliteErrorCode);
}
void DatabaseBackendBase::reportStartTransactionResult(int errorSite, int webSqlErrorCode, int sqliteErrorCode)
{
DatabaseObserver::reportStartTransactionResult(this, errorSite, webSqlErrorCode, sqliteErrorCode);
}
void DatabaseBackendBase::reportCommitTransactionResult(int errorSite, int webSqlErrorCode, int sqliteErrorCode)
{
DatabaseObserver::reportCommitTransactionResult(this, errorSite, webSqlErrorCode, sqliteErrorCode);
}
void DatabaseBackendBase::reportExecuteStatementResult(int errorSite, int webSqlErrorCode, int sqliteErrorCode)
{
DatabaseObserver::reportExecuteStatementResult(this, errorSite, webSqlErrorCode, sqliteErrorCode);
}
void DatabaseBackendBase::reportVacuumDatabaseResult(int sqliteErrorCode)
{
DatabaseObserver::reportVacuumDatabaseResult(this, sqliteErrorCode);
}
#endif // PLATFORM(CHROMIUM)
} // namespace WebCore
#endif // ENABLE(SQL_DATABASE)
......@@ -114,22 +114,6 @@ protected:
void setCachedVersion(const String&);
bool getActualVersionForTransaction(String& version);
#if PLATFORM(CHROMIUM)
void reportOpenDatabaseResult(int errorSite, int webSqlErrorCode, int sqliteErrorCode);
void reportChangeVersionResult(int errorSite, int webSqlErrorCode, int sqliteErrorCode);
void reportStartTransactionResult(int errorSite, int webSqlErrorCode, int sqliteErrorCode);
void reportCommitTransactionResult(int errorSite, int webSqlErrorCode, int sqliteErrorCode);
void reportExecuteStatementResult(int errorSite, int webSqlErrorCode, int sqliteErrorCode);
void reportVacuumDatabaseResult(int sqliteErrorCode);
#else
void reportOpenDatabaseResult(int, int, int) { }
void reportChangeVersionResult(int, int, int) { }
void reportStartTransactionResult(int, int, int) { }
void reportCommitTransactionResult(int, int, int) { }
void reportExecuteStatementResult(int, int, int) { }
void reportVacuumDatabaseResult(int) { }
#endif
static const char* databaseInfoTableName();
RefPtr<SecurityOrigin> m_contextThreadSecurityOrigin;
......
......@@ -54,9 +54,6 @@ DatabaseBackendSync::~DatabaseBackendSync()
bool DatabaseBackendSync::openAndVerifyVersion(bool setVersionInNewDatabase, DatabaseError& error, String& errorMessage)
{
#if PLATFORM(CHROMIUM)
DatabaseTracker::tracker().prepareToOpenDatabase(this);
#endif
return performOpenAndVerify(setVersionInNewDatabase, error, errorMessage);
}
......
......@@ -224,11 +224,9 @@ void DatabaseContext::databaseExceededQuota(const String& name, DatabaseDetails
return;
}
ASSERT(m_scriptExecutionContext->isWorkerContext());
#if !PLATFORM(CHROMIUM)
// FIXME: This needs a real implementation; this is a temporary solution for testing.
const unsigned long long defaultQuota = 5 * 1024 * 1024;
DatabaseManager::manager().setQuota(m_scriptExecutionContext->securityOrigin(), defaultQuota);
#endif
}
} // namespace WebCore
......
......@@ -363,7 +363,6 @@ String DatabaseManager::fullPathForDatabase(SecurityOrigin* origin, const String
return m_server->fullPathForDatabase(origin, name, createIfDoesNotExist);
}
#if !PLATFORM(CHROMIUM)
bool DatabaseManager::hasEntryForOrigin(SecurityOrigin* origin)
{
return m_server->hasEntryForOrigin(origin);
......@@ -414,13 +413,6 @@ bool DatabaseManager::deleteDatabase(SecurityOrigin* origin, const String& name)
return m_server->deleteDatabase(origin, name);
}
#else // PLATFORM(CHROMIUM)
void DatabaseManager::closeDatabasesImmediately(const String& originIdentifier, const String& name)
{
m_server->closeDatabasesImmediately(originIdentifier, name);
}
#endif // PLATFORM(CHROMIUM)
void DatabaseManager::interruptAllDatabasesForContext(ScriptExecutionContext* context)
{
RefPtr<DatabaseContext> databaseContext = existingDatabaseContextFor(context);
......
......@@ -89,7 +89,6 @@ public:
String fullPathForDatabase(SecurityOrigin*, const String& name, bool createIfDoesNotExist = true);
#if !PLATFORM(CHROMIUM)
bool hasEntryForOrigin(SecurityOrigin*);
void origins(Vector<RefPtr<SecurityOrigin> >& result);
bool databaseNamesForOrigin(SecurityOrigin*, Vector<String>& result);
......@@ -104,10 +103,6 @@ public:
bool deleteOrigin(SecurityOrigin*);
bool deleteDatabase(SecurityOrigin*, const String& name);
#else // PLATFORM(CHROMIUM)
void closeDatabasesImmediately(const String& originIdentifier, const String& name);
#endif // PLATFORM(CHROMIUM)
void interruptAllDatabasesForContext(ScriptExecutionContext*);
private:
......
......@@ -40,36 +40,22 @@ namespace WebCore {
void DatabaseServer::initialize(const String& databasePath)
{
#if !PLATFORM(CHROMIUM)
DatabaseTracker::initializeTracker(databasePath);
#else
UNUSED_PARAM(databasePath);
#endif
}
void DatabaseServer::setClient(DatabaseManagerClient* client)
{
#if !PLATFORM(CHROMIUM)
DatabaseTracker::tracker().setClient(client);
#else
UNUSED_PARAM(client);
#endif
}
String DatabaseServer::databaseDirectoryPath() const
{
#if !PLATFORM(CHROMIUM)
return DatabaseTracker::tracker().databaseDirectoryPath();
#else
return "";
#endif
}
void DatabaseServer::setDatabaseDirectoryPath(const String& path)
{
#if !PLATFORM(CHROMIUM)
DatabaseTracker::tracker().setDatabaseDirectoryPath(path);
#endif
}
String DatabaseServer::fullPathForDatabase(SecurityOrigin* origin, const String& name, bool createIfDoesNotExist)
......@@ -77,7 +63,6 @@ String DatabaseServer::fullPathForDatabase(SecurityOrigin* origin, const String&
return DatabaseTracker::tracker().fullPathForDatabase(origin, name, createIfDoesNotExist);
}
#if !PLATFORM(CHROMIUM)
bool DatabaseServer::hasEntryForOrigin(SecurityOrigin* origin)
{
return DatabaseTracker::tracker().hasEntryForOrigin(origin);
......@@ -128,13 +113,6 @@ bool DatabaseServer::deleteDatabase(SecurityOrigin* origin, const String& name)
return DatabaseTracker::tracker().deleteDatabase(origin, name);
}
#else // PLATFORM(CHROMIUM)
void DatabaseServer::closeDatabasesImmediately(const String& originIdentifier, const String& name)
{
DatabaseTracker::tracker().closeDatabasesImmediately(originIdentifier, name);
}
#endif // PLATFORM(CHROMIUM)
void DatabaseServer::interruptAllDatabasesForContext(const DatabaseBackendContext* context)
{
DatabaseTracker::tracker().interruptAllDatabasesForContext(context);
......@@ -150,10 +128,10 @@ PassRefPtr<DatabaseBackendBase> DatabaseServer::openDatabase(RefPtr<DatabaseBack
switch (attempt) {
case FirstTryToOpenDatabase:
success = DatabaseTracker::tracker().canEstablishDatabase(backendContext.get(), name, displayName, estimatedSize, error);
success = DatabaseTracker::tracker().canEstablishDatabase(backendContext.get(), name, estimatedSize, error);
break;
case RetryOpenDatabase:
success = DatabaseTracker::tracker().retryCanEstablishDatabase(backendContext.get(), name, displayName, estimatedSize, error);
success = DatabaseTracker::tracker().retryCanEstablishDatabase(backendContext.get(), name, estimatedSize, error);
}
if (success)
......
......@@ -49,7 +49,6 @@ public:
const String& name, const String& expectedVersion, const String& displayName, unsigned long estimatedSize,
bool setVersionInNewDatabase, DatabaseError&, String& errorMessage, OpenAttempt);
#if !PLATFORM(CHROMIUM)
virtual bool hasEntryForOrigin(SecurityOrigin*);
virtual void origins(Vector<RefPtr<SecurityOrigin> >& result);
virtual bool databaseNamesForOrigin(SecurityOrigin*, Vector<String>& result);
......@@ -64,10 +63,6 @@ public:
virtual bool deleteOrigin(SecurityOrigin*);
virtual bool deleteDatabase(SecurityOrigin*, const String& name);
#else // PLATFORM(CHROMIUM)
virtual void closeDatabasesImmediately(const String& originIdentifier, const String& name);
#endif // PLATFORM(CHROMIUM)
virtual void interruptAllDatabasesForContext(const DatabaseBackendContext*);
protected:
......
......@@ -79,7 +79,6 @@ void DatabaseSync::changeVersion(const String& oldVersion, const String& newVers
ASSERT(m_scriptExecutionContext->isContextThread());
if (sqliteDatabase().transactionInProgress()) {
reportChangeVersionResult(1, SQLException::DATABASE_ERR, 0);
setLastErrorMessage("unable to changeVersion from within a transaction");
ec = SQLException::DATABASE_ERR;
return;
......@@ -93,14 +92,12 @@ void DatabaseSync::changeVersion(const String& oldVersion, const String& newVers
String actualVersion;
if (!getVersionFromDatabase(actualVersion)) {
reportChangeVersionResult(2, SQLException::UNKNOWN_ERR, sqliteDatabase().lastError());
setLastErrorMessage("unable to read the current version", sqliteDatabase().lastError(), sqliteDatabase().lastErrorMsg());
ec = SQLException::UNKNOWN_ERR;
return;
}
if (actualVersion != oldVersion) {
reportChangeVersionResult(3, SQLException::VERSION_ERR, 0);
setLastErrorMessage("current version of the database and `oldVersion` argument do not match");
ec = SQLException::VERSION_ERR;
return;
......@@ -112,7 +109,6 @@ void DatabaseSync::changeVersion(const String& oldVersion, const String& newVers
}
if (!setVersionInDatabase(newVersion)) {
reportChangeVersionResult(4, SQLException::UNKNOWN_ERR, sqliteDatabase().lastError());
setLastErrorMessage("unable to set the new version", sqliteDatabase().lastError(), sqliteDatabase().lastErrorMsg());
ec = SQLException::UNKNOWN_ERR;
return;
......@@ -124,8 +120,6 @@ void DatabaseSync::changeVersion(const String& oldVersion, const String& newVers
return;
}
reportChangeVersionResult(0, -1, 0); // OK
setExpectedVersion(newVersion);
setLastErrorMessage("");
}
......
......@@ -156,9 +156,8 @@ bool DatabaseTracker::hasAdequateQuotaForOrigin(SecurityOrigin* origin, unsigned
return false;
}
bool DatabaseTracker::canEstablishDatabase(DatabaseBackendContext* context, const String& name, const String& displayName, unsigned long estimatedSize, DatabaseError& error)
bool DatabaseTracker::canEstablishDatabase(DatabaseBackendContext* context, const String& name, unsigned long estimatedSize, DatabaseError& error)
{
UNUSED_PARAM(displayName); // Chromium needs the displayName but we don't.
error = DatabaseError::None;
MutexLocker lockDatabase(m_databaseGuard);
......@@ -209,13 +208,8 @@ bool DatabaseTracker::canEstablishDatabase(DatabaseBackendContext* context, cons
// hasAdequateQuotaForOrigin() simple and correct (i.e. bug free), and just
// re-use it. Also note that the path for opening a database involves IO, and
// hence should not be a performance critical path anyway.
bool DatabaseTracker::retryCanEstablishDatabase(DatabaseBackendContext* context, const String& name, const String& displayName, unsigned long estimatedSize, DatabaseError& error)
bool DatabaseTracker::retryCanEstablishDatabase(DatabaseBackendContext* context, const String& name, unsigned long estimatedSize, DatabaseError& error)
{
// Chromium needs the displayName in canEstablishDatabase(), but we don't.
// Though Chromium does not use retryCanEstablishDatabase(), we should
// keep the prototypes for canEstablishDatabase() and its retry function
// the same. Hence, we also have an unneeded displayName arg here.
UNUSED_PARAM(displayName);
error = DatabaseError::None;
MutexLocker lockDatabase(m_databaseGuard);
......
......@@ -31,37 +31,29 @@
#if ENABLE(SQL_DATABASE)
#include "DatabaseDetails.h"
#include "DatabaseError.h"
#include "SQLiteDatabase.h"
#include "SecurityOriginHash.h"
#include <wtf/HashMap.h>
#include <wtf/HashSet.h>
#include <wtf/OwnPtr.h>
#include <wtf/text/StringHash.h>
#include <wtf/text/WTFString.h>
#if !PLATFORM(CHROMIUM)
#include "DatabaseDetails.h"
#include "SQLiteDatabase.h"
#include "SecurityOriginHash.h"
#include <wtf/OwnPtr.h>
#endif // !PLATFORM(CHROMIUM)
namespace WebCore {
class DatabaseBackendBase;
class DatabaseBackendContext;
class DatabaseManagerClient;
class OriginLock;
class SecurityOrigin;
#if !PLATFORM(CHROMIUM)
class DatabaseManagerClient;
#endif // !PLATFORM(CHROMIUM)
class DatabaseTracker {
WTF_MAKE_NONCOPYABLE(DatabaseTracker); WTF_MAKE_FAST_ALLOCATED;<