Diff
Modified: trunk/Source/WebCore/ChangeLog (143411 => 143412)
--- trunk/Source/WebCore/ChangeLog 2013-02-20 00:47:52 UTC (rev 143411)
+++ trunk/Source/WebCore/ChangeLog 2013-02-20 00:48:25 UTC (rev 143412)
@@ -1,3 +1,36 @@
+2013-02-19 Mark Lam <mark....@apple.com>
+
+ Introducing AbstractSQLTransaction and AbstractSQLTransactionBackend.
+ https://bugs.webkit.org/show_bug.cgi?id=110273.
+
+ Reviewed by Anders Carlsson.
+
+ This is part of the webdatabase refactoring for webkit2.
+ - Also changed the frontend and backend to only refer to the
+ abstract interface of each other.
+
+ No new tests.
+
+ * Modules/webdatabase/AbstractSQLTransaction.h: Added.
+ (AbstractSQLTransaction):
+ (WebCore::AbstractSQLTransaction::~AbstractSQLTransaction):
+ * Modules/webdatabase/AbstractSQLTransactionBackend.h: Added.
+ (AbstractSQLTransactionBackend):
+ (WebCore::AbstractSQLTransactionBackend::~AbstractSQLTransactionBackend):
+ * Modules/webdatabase/SQLTransaction.cpp:
+ (WebCore::SQLTransaction::hasCallback):
+ (WebCore::SQLTransaction::hasSuccessCallback):
+ (WebCore::SQLTransaction::hasErrorCallback):
+ (WebCore::SQLTransaction::setBackend):
+ * Modules/webdatabase/SQLTransaction.h:
+ (SQLTransaction):
+ * Modules/webdatabase/SQLTransactionBackend.cpp:
+ (WebCore::SQLTransactionBackend::create):
+ (WebCore::SQLTransactionBackend::SQLTransactionBackend):
+ * Modules/webdatabase/SQLTransactionBackend.h:
+ (SQLTransactionBackend):
+ * Modules/webdatabase/SQLTransactionStateMachine.h:
+
2013-02-19 Emil A Eklund <e...@chromium.org>
Change computeStickyPositionConstraints to use LayoutBoxExtent for margins
Added: trunk/Source/WebCore/Modules/webdatabase/AbstractSQLTransaction.h (0 => 143412)
--- trunk/Source/WebCore/Modules/webdatabase/AbstractSQLTransaction.h (rev 0)
+++ trunk/Source/WebCore/Modules/webdatabase/AbstractSQLTransaction.h 2013-02-20 00:48:25 UTC (rev 143412)
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2013 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 AbstractSQLTransaction_h
+#define AbstractSQLTransaction_h
+
+#if ENABLE(SQL_DATABASE)
+
+#include "SQLTransactionState.h"
+#include <wtf/ThreadSafeRefCounted.h>
+
+namespace WebCore {
+
+class AbstractSQLTransactionBackend;
+
+class AbstractSQLTransaction : public ThreadSafeRefCounted<AbstractSQLTransaction> {
+public:
+ virtual ~AbstractSQLTransaction() { }
+
+ virtual void requestTransitToState(SQLTransactionState) = 0;
+
+ // Used during initialization only.
+ virtual bool hasCallback() const = 0;
+ virtual bool hasSuccessCallback() const = 0;
+ virtual bool hasErrorCallback() const = 0;
+ virtual void setBackend(AbstractSQLTransactionBackend*) = 0;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(SQL_DATABASE)
+
+#endif // AbstractSQLTransaction_h
Added: trunk/Source/WebCore/Modules/webdatabase/AbstractSQLTransactionBackend.h (0 => 143412)
--- trunk/Source/WebCore/Modules/webdatabase/AbstractSQLTransactionBackend.h (rev 0)
+++ trunk/Source/WebCore/Modules/webdatabase/AbstractSQLTransactionBackend.h 2013-02-20 00:48:25 UTC (rev 143412)
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2013 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 AbstractSQLTransactionBackend_h
+#define AbstractSQLTransactionBackend_h
+
+#if ENABLE(SQL_DATABASE)
+
+#include "AbstractSQLStatement.h"
+#include "SQLError.h"
+#include "SQLTransactionState.h"
+#include "SQLValue.h"
+#include <wtf/PassOwnPtr.h>
+#include <wtf/ThreadSafeRefCounted.h>
+#include <wtf/Vector.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+class AbstractSQLTransactionBackend : public ThreadSafeRefCounted<AbstractSQLTransactionBackend> {
+public:
+ virtual ~AbstractSQLTransactionBackend() { }
+
+ virtual void requestTransitToState(SQLTransactionState) = 0;
+
+ virtual PassRefPtr<SQLError> transactionError() = 0;
+ virtual AbstractSQLStatement* currentStatement() = 0;
+ virtual void setShouldRetryCurrentStatement(bool) = 0;
+
+ virtual void executeSQL(PassOwnPtr<AbstractSQLStatement>, const String& statement,
+ const Vector<SQLValue>& arguments, int permissions) = 0;
+
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(SQL_DATABASE)
+
+#endif // AbstractSQLTransactionBackend_h
Modified: trunk/Source/WebCore/Modules/webdatabase/SQLTransaction.cpp (143411 => 143412)
--- trunk/Source/WebCore/Modules/webdatabase/SQLTransaction.cpp 2013-02-20 00:47:52 UTC (rev 143411)
+++ trunk/Source/WebCore/Modules/webdatabase/SQLTransaction.cpp 2013-02-20 00:48:25 UTC (rev 143412)
@@ -31,6 +31,7 @@
#if ENABLE(SQL_DATABASE)
+#include "AbstractSQLTransactionBackend.h"
#include "Database.h"
#include "DatabaseAuthorizer.h"
#include "DatabaseContext.h"
@@ -39,9 +40,8 @@
#include "SQLError.h"
#include "SQLStatementCallback.h"
#include "SQLStatementErrorCallback.h"
-#include "SQLTransactionBackend.h"
#include "SQLTransactionCallback.h"
-#include "SQLTransactionClient.h"
+#include "SQLTransactionClient.h" // FIXME: Should be used in the backend only.
#include "SQLTransactionErrorCallback.h"
#include "VoidCallback.h"
#include <wtf/StdLibExtras.h>
@@ -69,8 +69,23 @@
ASSERT(m_database);
}
-void SQLTransaction::setBackend(SQLTransactionBackend* backend)
+bool SQLTransaction::hasCallback() const
{
+ return m_callbackWrapper.hasCallback();
+}
+
+bool SQLTransaction::hasSuccessCallback() const
+{
+ return m_successCallbackWrapper.hasCallback();
+}
+
+bool SQLTransaction::hasErrorCallback() const
+{
+ return m_errorCallbackWrapper.hasCallback();
+}
+
+void SQLTransaction::setBackend(AbstractSQLTransactionBackend* backend)
+{
ASSERT(!m_backend);
m_backend = backend;
}
Modified: trunk/Source/WebCore/Modules/webdatabase/SQLTransaction.h (143411 => 143412)
--- trunk/Source/WebCore/Modules/webdatabase/SQLTransaction.h 2013-02-20 00:47:52 UTC (rev 143411)
+++ trunk/Source/WebCore/Modules/webdatabase/SQLTransaction.h 2013-02-20 00:48:25 UTC (rev 143412)
@@ -31,6 +31,7 @@
#if ENABLE(SQL_DATABASE)
+#include "AbstractSQLTransaction.h"
#include "SQLCallbackWrapper.h"
#include "SQLStatement.h"
#include "SQLTransactionStateMachine.h"
@@ -39,24 +40,22 @@
namespace WebCore {
+class AbstractSQLTransactionBackend;
class Database;
class SQLError;
class SQLStatementCallback;
class SQLStatementErrorCallback;
-class SQLTransactionBackend;
class SQLTransactionCallback;
class SQLTransactionErrorCallback;
class SQLValue;
class VoidCallback;
-class SQLTransaction : public SQLTransactionStateMachine<SQLTransaction> {
+class SQLTransaction : public SQLTransactionStateMachine<SQLTransaction>, public AbstractSQLTransaction {
public:
static PassRefPtr<SQLTransaction> create(Database*, PassRefPtr<SQLTransactionCallback>,
PassRefPtr<VoidCallback> successCallback, PassRefPtr<SQLTransactionErrorCallback>,
bool readOnly);
- void setBackend(SQLTransactionBackend*);
-
void performPendingCallback();
void executeSQL(const String& sqlStatement, const Vector<SQLValue>& arguments,
@@ -64,10 +63,6 @@
Database* database() { return m_database.get(); }
- bool hasCallback() const { return m_callbackWrapper.hasCallback(); }
- bool hasSuccessCallback() const { return m_successCallbackWrapper.hasCallback(); }
- bool hasErrorCallback() const { return m_errorCallbackWrapper.hasCallback(); }
-
private:
SQLTransaction(Database*, PassRefPtr<SQLTransactionCallback>,
PassRefPtr<VoidCallback> successCallback, PassRefPtr<SQLTransactionErrorCallback>,
@@ -76,9 +71,15 @@
bool checkAndHandleClosedOrInterruptedDatabase();
void clearCallbackWrappers();
+ // APIs called from the backend published via AbstractSQLTransaction:
+ virtual void requestTransitToState(SQLTransactionState) OVERRIDE;
+ virtual bool hasCallback() const OVERRIDE;
+ virtual bool hasSuccessCallback() const OVERRIDE;
+ virtual bool hasErrorCallback() const OVERRIDE;
+ virtual void setBackend(AbstractSQLTransactionBackend*) OVERRIDE;
+
// State Machine functions:
- virtual StateFunction stateFunctionFor(SQLTransactionState);
- void requestTransitToState(SQLTransactionState);
+ virtual StateFunction stateFunctionFor(SQLTransactionState) OVERRIDE;
// State functions:
SQLTransactionState deliverTransactionCallback();
@@ -93,7 +94,7 @@
SQLTransactionState nextStateForTransactionError();
RefPtr<Database> m_database;
- RefPtr<SQLTransactionBackend> m_backend;
+ RefPtr<AbstractSQLTransactionBackend> m_backend;
SQLCallbackWrapper<SQLTransactionCallback> m_callbackWrapper;
SQLCallbackWrapper<VoidCallback> m_successCallbackWrapper;
SQLCallbackWrapper<SQLTransactionErrorCallback> m_errorCallbackWrapper;
@@ -102,8 +103,6 @@
RefPtr<SQLError> m_transactionError;
bool m_readOnly;
-
- friend class SQLTransactionBackend;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/Modules/webdatabase/SQLTransactionBackend.cpp (143411 => 143412)
--- trunk/Source/WebCore/Modules/webdatabase/SQLTransactionBackend.cpp 2013-02-20 00:47:52 UTC (rev 143411)
+++ trunk/Source/WebCore/Modules/webdatabase/SQLTransactionBackend.cpp 2013-02-20 00:48:25 UTC (rev 143412)
@@ -31,7 +31,8 @@
#if ENABLE(SQL_DATABASE)
-#include "Database.h"
+#include "AbstractSQLTransaction.h"
+#include "Database.h" // FIXME: Should only be used in the frontend.
#include "DatabaseAuthorizer.h"
#include "DatabaseBackendAsync.h"
#include "DatabaseBackendContext.h"
@@ -40,7 +41,6 @@
#include "Logging.h"
#include "SQLError.h"
#include "SQLStatementBackend.h"
-#include "SQLTransaction.h"
#include "SQLTransactionClient.h"
#include "SQLTransactionCoordinator.h"
#include "SQLValue.h"
@@ -349,13 +349,13 @@
namespace WebCore {
PassRefPtr<SQLTransactionBackend> SQLTransactionBackend::create(DatabaseBackendAsync* db,
- PassRefPtr<SQLTransaction> frontend, PassRefPtr<SQLTransactionWrapper> wrapper, bool readOnly)
+ PassRefPtr<AbstractSQLTransaction> frontend, PassRefPtr<SQLTransactionWrapper> wrapper, bool readOnly)
{
return adoptRef(new SQLTransactionBackend(db, frontend, wrapper, readOnly));
}
SQLTransactionBackend::SQLTransactionBackend(DatabaseBackendAsync* db,
- PassRefPtr<SQLTransaction> frontend, PassRefPtr<SQLTransactionWrapper> wrapper, bool readOnly)
+ PassRefPtr<AbstractSQLTransaction> frontend, PassRefPtr<SQLTransactionWrapper> wrapper, bool readOnly)
: m_frontend(frontend)
, m_database(db)
, m_wrapper(wrapper)
Modified: trunk/Source/WebCore/Modules/webdatabase/SQLTransactionBackend.h (143411 => 143412)
--- trunk/Source/WebCore/Modules/webdatabase/SQLTransactionBackend.h 2013-02-20 00:47:52 UTC (rev 143411)
+++ trunk/Source/WebCore/Modules/webdatabase/SQLTransactionBackend.h 2013-02-20 00:48:25 UTC (rev 143412)
@@ -31,6 +31,7 @@
#if ENABLE(SQL_DATABASE)
#include "AbstractSQLStatement.h"
+#include "AbstractSQLTransactionBackend.h"
#include "DatabaseBasicTypes.h"
#include "SQLTransactionStateMachine.h"
#include <wtf/Deque.h>
@@ -39,11 +40,11 @@
namespace WebCore {
+class AbstractSQLTransaction;
class DatabaseBackendAsync;
class SQLError;
class SQLiteTransaction;
class SQLStatementBackend;
-class SQLTransaction;
class SQLTransactionBackend;
class SQLValue;
@@ -56,10 +57,10 @@
virtual void handleCommitFailedAfterPostflight(SQLTransactionBackend*) = 0;
};
-class SQLTransactionBackend : public SQLTransactionStateMachine<SQLTransactionBackend> {
+class SQLTransactionBackend : public SQLTransactionStateMachine<SQLTransactionBackend>, public AbstractSQLTransactionBackend {
public:
static PassRefPtr<SQLTransactionBackend> create(DatabaseBackendAsync*,
- PassRefPtr<SQLTransaction>, PassRefPtr<SQLTransactionWrapper>, bool readOnly);
+ PassRefPtr<AbstractSQLTransaction>, PassRefPtr<SQLTransactionWrapper>, bool readOnly);
virtual ~SQLTransactionBackend();
@@ -70,18 +71,18 @@
bool isReadOnly() { return m_readOnly; }
void notifyDatabaseThreadIsShuttingDown();
- // APIs for the frontend:
- AbstractSQLStatement* currentStatement();
- PassRefPtr<SQLError> transactionError();
- void setShouldRetryCurrentStatement(bool);
-
- void executeSQL(PassOwnPtr<AbstractSQLStatement>, const String& statement,
- const Vector<SQLValue>& arguments, int permissions);
-
private:
- SQLTransactionBackend(DatabaseBackendAsync*, PassRefPtr<SQLTransaction>,
+ SQLTransactionBackend(DatabaseBackendAsync*, PassRefPtr<AbstractSQLTransaction>,
PassRefPtr<SQLTransactionWrapper>, bool readOnly);
+ // APIs called from the frontend published via AbstractSQLTransactionBackend:
+ virtual void requestTransitToState(SQLTransactionState) OVERRIDE;
+ virtual PassRefPtr<SQLError> transactionError() OVERRIDE;
+ virtual AbstractSQLStatement* currentStatement() OVERRIDE;
+ virtual void setShouldRetryCurrentStatement(bool) OVERRIDE;
+ virtual void executeSQL(PassOwnPtr<AbstractSQLStatement>, const String& statement,
+ const Vector<SQLValue>& arguments, int permissions) OVERRIDE;
+
void doCleanup();
void enqueueStatementBackend(PassRefPtr<SQLStatementBackend>);
@@ -89,8 +90,7 @@
void checkAndHandleClosedOrInterruptedDatabase();
// State Machine functions:
- virtual StateFunction stateFunctionFor(SQLTransactionState);
- void requestTransitToState(SQLTransactionState);
+ virtual StateFunction stateFunctionFor(SQLTransactionState) OVERRIDE;
// State functions:
SQLTransactionState acquireLock();
@@ -109,7 +109,7 @@
void getNextStatement();
- RefPtr<SQLTransaction> m_frontend; // Has a reference cycle, and will break in doCleanup().
+ RefPtr<AbstractSQLTransaction> m_frontend; // Has a reference cycle, and will break in doCleanup().
RefPtr<SQLStatementBackend> m_currentStatementBackend;
RefPtr<DatabaseBackendAsync> m_database;
@@ -129,8 +129,6 @@
Deque<RefPtr<SQLStatementBackend> > m_statementQueue;
OwnPtr<SQLiteTransaction> m_sqliteTransaction;
-
- friend class SQLTransaction;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/Modules/webdatabase/SQLTransactionStateMachine.h (143411 => 143412)
--- trunk/Source/WebCore/Modules/webdatabase/SQLTransactionStateMachine.h 2013-02-20 00:47:52 UTC (rev 143411)
+++ trunk/Source/WebCore/Modules/webdatabase/SQLTransactionStateMachine.h 2013-02-20 00:48:25 UTC (rev 143412)
@@ -34,7 +34,7 @@
namespace WebCore {
template<typename T>
-class SQLTransactionStateMachine : public ThreadSafeRefCounted<SQLTransactionStateMachine<T> > {
+class SQLTransactionStateMachine {
public:
virtual ~SQLTransactionStateMachine() { }