| Differences between
and this patch
- a/Source/WebCore/ChangeLog +42 lines
Lines 1-3 a/Source/WebCore/ChangeLog_sec1
1
2014-01-20  Zan Dobersek  <zdobersek@igalia.com>
2
3
        Move the webdatabase module source code to std::unique_ptr
4
        https://bugs.webkit.org/show_bug.cgi?id=127278
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        Replace the majority of OwnPtr uses in the webdatabase module with std::unique_ptr.
9
        The only remaining uses are due to ScriptExecutionContext::Task subclasses.
10
11
        * Modules/webdatabase/AbstractSQLTransactionBackend.h:
12
        * Modules/webdatabase/Database.cpp:
13
        * Modules/webdatabase/DatabaseTask.h:
14
        * Modules/webdatabase/DatabaseThread.cpp:
15
        (WebCore::DatabaseThread::DatabaseThread):
16
        * Modules/webdatabase/DatabaseThread.h:
17
        * Modules/webdatabase/DatabaseTracker.cpp:
18
        (WebCore::DatabaseTracker::addOpenDatabase):
19
        * Modules/webdatabase/DatabaseTracker.h:
20
        * Modules/webdatabase/OriginLock.cpp:
21
        * Modules/webdatabase/SQLStatement.cpp:
22
        * Modules/webdatabase/SQLStatement.h:
23
        * Modules/webdatabase/SQLStatementBackend.cpp:
24
        (WebCore::SQLStatementBackend::create):
25
        (WebCore::SQLStatementBackend::SQLStatementBackend):
26
        * Modules/webdatabase/SQLStatementBackend.h:
27
        * Modules/webdatabase/SQLTransaction.cpp:
28
        (WebCore::SQLTransaction::executeSQL):
29
        * Modules/webdatabase/SQLTransactionBackend.cpp:
30
        (WebCore::SQLTransactionBackend::doCleanup):
31
        (WebCore::SQLTransactionBackend::computeNextStateAndCleanupIfNeeded):
32
        (WebCore::SQLTransactionBackend::executeSQL):
33
        (WebCore::SQLTransactionBackend::openTransactionAndPreflight):
34
        (WebCore::SQLTransactionBackend::cleanupAfterTransactionErrorCallback):
35
        * Modules/webdatabase/SQLTransactionBackend.h:
36
        * Modules/webdatabase/SQLTransactionBackendSync.cpp:
37
        (WebCore::SQLTransactionBackendSync::SQLTransactionBackendSync):
38
        (WebCore::SQLTransactionBackendSync::begin):
39
        (WebCore::SQLTransactionBackendSync::commit):
40
        (WebCore::SQLTransactionBackendSync::rollback):
41
        * Modules/webdatabase/SQLTransactionBackendSync.h:
42
1
2014-01-20  Morten Stenshorne  <mstensho@opera.com>
43
2014-01-20  Morten Stenshorne  <mstensho@opera.com>
2
44
3
        Region based multicol: tall line causes taller multicol container than necessary
45
        Region based multicol: tall line causes taller multicol container than necessary
- a/Source/WebCore/Modules/webdatabase/AbstractSQLTransactionBackend.h -2 / +2 lines
Lines 32-38 a/Source/WebCore/Modules/webdatabase/AbstractSQLTransactionBackend.h_sec1
32
#include "SQLError.h"
32
#include "SQLError.h"
33
#include "SQLTransactionState.h"
33
#include "SQLTransactionState.h"
34
#include "SQLValue.h"
34
#include "SQLValue.h"
35
#include <wtf/PassOwnPtr.h>
35
#include <memory>
36
#include <wtf/ThreadSafeRefCounted.h>
36
#include <wtf/ThreadSafeRefCounted.h>
37
#include <wtf/Vector.h>
37
#include <wtf/Vector.h>
38
#include <wtf/text/WTFString.h>
38
#include <wtf/text/WTFString.h>
Lines 49-55 public: a/Source/WebCore/Modules/webdatabase/AbstractSQLTransactionBackend.h_sec2
49
    virtual AbstractSQLStatement* currentStatement() = 0;
49
    virtual AbstractSQLStatement* currentStatement() = 0;
50
    virtual void setShouldRetryCurrentStatement(bool) = 0;
50
    virtual void setShouldRetryCurrentStatement(bool) = 0;
51
51
52
    virtual void executeSQL(PassOwnPtr<AbstractSQLStatement>, const String& statement,
52
    virtual void executeSQL(std::unique_ptr<AbstractSQLStatement>, const String& statement,
53
        const Vector<SQLValue>& arguments, int permissions) = 0;
53
        const Vector<SQLValue>& arguments, int permissions) = 0;
54
54
55
};
55
};
- a/Source/WebCore/Modules/webdatabase/Database.cpp -1 lines
Lines 53-59 a/Source/WebCore/Modules/webdatabase/Database.cpp_sec1
53
#include "ScriptExecutionContext.h"
53
#include "ScriptExecutionContext.h"
54
#include "SecurityOrigin.h"
54
#include "SecurityOrigin.h"
55
#include "VoidCallback.h"
55
#include "VoidCallback.h"
56
#include <wtf/OwnPtr.h>
57
#include <wtf/PassOwnPtr.h>
56
#include <wtf/PassOwnPtr.h>
58
#include <wtf/PassRefPtr.h>
57
#include <wtf/PassRefPtr.h>
59
#include <wtf/RefPtr.h>
58
#include <wtf/RefPtr.h>
- a/Source/WebCore/Modules/webdatabase/DatabaseTask.h -2 lines
Lines 34-41 a/Source/WebCore/Modules/webdatabase/DatabaseTask.h_sec1
34
#include "DatabaseBasicTypes.h"
34
#include "DatabaseBasicTypes.h"
35
#include "DatabaseError.h"
35
#include "DatabaseError.h"
36
#include "SQLTransactionBackend.h"
36
#include "SQLTransactionBackend.h"
37
#include <wtf/OwnPtr.h>
38
#include <wtf/PassOwnPtr.h>
39
#include <wtf/PassRefPtr.h>
37
#include <wtf/PassRefPtr.h>
40
#include <wtf/Threading.h>
38
#include <wtf/Threading.h>
41
#include <wtf/Vector.h>
39
#include <wtf/Vector.h>
- a/Source/WebCore/Modules/webdatabase/DatabaseThread.cpp -2 / +2 lines
Lines 45-52 DatabaseThread::DatabaseThread() a/Source/WebCore/Modules/webdatabase/DatabaseThread.cpp_sec1
45
#if PLATFORM(IOS)
45
#if PLATFORM(IOS)
46
    , m_paused(false)
46
    , m_paused(false)
47
#endif
47
#endif
48
    , m_transactionClient(adoptPtr(new SQLTransactionClient()))
48
    , m_transactionClient(std::make_unique<SQLTransactionClient>())
49
    , m_transactionCoordinator(adoptPtr(new SQLTransactionCoordinator()))
49
    , m_transactionCoordinator(std::make_unique<SQLTransactionCoordinator>())
50
    , m_cleanupSync(0)
50
    , m_cleanupSync(0)
51
{
51
{
52
    m_selfRef = this;
52
    m_selfRef = this;
- a/Source/WebCore/Modules/webdatabase/DatabaseThread.h -4 / +3 lines
Lines 30-41 a/Source/WebCore/Modules/webdatabase/DatabaseThread.h_sec1
30
30
31
#if ENABLE(SQL_DATABASE)
31
#if ENABLE(SQL_DATABASE)
32
32
33
#include <memory>
33
#include <wtf/Deque.h>
34
#include <wtf/Deque.h>
34
#include <wtf/HashMap.h>
35
#include <wtf/HashMap.h>
35
#include <wtf/HashSet.h>
36
#include <wtf/HashSet.h>
36
#include <wtf/MessageQueue.h>
37
#include <wtf/MessageQueue.h>
37
#include <wtf/OwnPtr.h>
38
#include <wtf/PassOwnPtr.h>
39
#include <wtf/PassRefPtr.h>
38
#include <wtf/PassRefPtr.h>
40
#include <wtf/RefPtr.h>
39
#include <wtf/RefPtr.h>
41
#include <wtf/Threading.h>
40
#include <wtf/Threading.h>
Lines 95-102 private: a/Source/WebCore/Modules/webdatabase/DatabaseThread.h_sec2
95
    typedef HashSet<RefPtr<DatabaseBackend>> DatabaseSet;
94
    typedef HashSet<RefPtr<DatabaseBackend>> DatabaseSet;
96
    DatabaseSet m_openDatabaseSet;
95
    DatabaseSet m_openDatabaseSet;
97
96
98
    OwnPtr<SQLTransactionClient> m_transactionClient;
97
    std::unique_ptr<SQLTransactionClient> m_transactionClient;
99
    OwnPtr<SQLTransactionCoordinator> m_transactionCoordinator;
98
    std::unique_ptr<SQLTransactionCoordinator> m_transactionCoordinator;
100
    DatabaseTaskSynchronizer* m_cleanupSync;
99
    DatabaseTaskSynchronizer* m_cleanupSync;
101
};
100
};
102
101
- a/Source/WebCore/Modules/webdatabase/DatabaseTracker.cpp -1 / +1 lines
Lines 563-569 void DatabaseTracker::addOpenDatabase(DatabaseBackendBase* database) a/Source/WebCore/Modules/webdatabase/DatabaseTracker.cpp_sec1
563
        MutexLocker openDatabaseMapLock(m_openDatabaseMapGuard);
563
        MutexLocker openDatabaseMapLock(m_openDatabaseMapGuard);
564
564
565
        if (!m_openDatabaseMap)
565
        if (!m_openDatabaseMap)
566
            m_openDatabaseMap = adoptPtr(new DatabaseOriginMap);
566
            m_openDatabaseMap = std::make_unique<DatabaseOriginMap>();
567
567
568
        String name(database->stringIdentifier());
568
        String name(database->stringIdentifier());
569
        DatabaseNameMap* nameMap = m_openDatabaseMap->get(database->securityOrigin());
569
        DatabaseNameMap* nameMap = m_openDatabaseMap->get(database->securityOrigin());
- a/Source/WebCore/Modules/webdatabase/DatabaseTracker.h -2 / +1 lines
Lines 37-43 a/Source/WebCore/Modules/webdatabase/DatabaseTracker.h_sec1
37
#include "SecurityOriginHash.h"
37
#include "SecurityOriginHash.h"
38
#include <wtf/HashMap.h>
38
#include <wtf/HashMap.h>
39
#include <wtf/HashSet.h>
39
#include <wtf/HashSet.h>
40
#include <wtf/OwnPtr.h>
41
#include <wtf/text/StringHash.h>
40
#include <wtf/text/StringHash.h>
42
#include <wtf/text/WTFString.h>
41
#include <wtf/text/WTFString.h>
43
42
Lines 153-159 private: a/Source/WebCore/Modules/webdatabase/DatabaseTracker.h_sec2
153
    typedef HashMap<RefPtr<SecurityOrigin>, DatabaseNameMap*> DatabaseOriginMap;
152
    typedef HashMap<RefPtr<SecurityOrigin>, DatabaseNameMap*> DatabaseOriginMap;
154
153
155
    Mutex m_openDatabaseMapGuard;
154
    Mutex m_openDatabaseMapGuard;
156
    mutable OwnPtr<DatabaseOriginMap> m_openDatabaseMap;
155
    mutable std::unique_ptr<DatabaseOriginMap> m_openDatabaseMap;
157
156
158
    // This lock protects m_database, m_originLockMap, m_databaseDirectoryPath, m_originsBeingDeleted, m_beingCreated, and m_beingDeleted.
157
    // This lock protects m_database, m_originLockMap, m_databaseDirectoryPath, m_originsBeingDeleted, m_beingCreated, and m_beingDeleted.
159
    Mutex m_databaseGuard;
158
    Mutex m_databaseGuard;
- a/Source/WebCore/Modules/webdatabase/OriginLock.cpp -1 lines
Lines 29-35 a/Source/WebCore/Modules/webdatabase/OriginLock.cpp_sec1
29
#if ENABLE(SQL_DATABASE)
29
#if ENABLE(SQL_DATABASE)
30
30
31
#include "FileSystem.h"
31
#include "FileSystem.h"
32
#include <wtf/PassOwnPtr.h>
33
32
34
namespace WebCore {
33
namespace WebCore {
35
34
- a/Source/WebCore/Modules/webdatabase/SQLStatement.cpp -6 lines
Lines 45-56 a/Source/WebCore/Modules/webdatabase/SQLStatement.cpp_sec1
45
45
46
namespace WebCore {
46
namespace WebCore {
47
47
48
PassOwnPtr<SQLStatement> SQLStatement::create(Database* database,
49
    PassRefPtr<SQLStatementCallback> callback, PassRefPtr<SQLStatementErrorCallback> errorCallback)
50
{
51
    return adoptPtr(new SQLStatement(database, callback, errorCallback));
52
}
53
54
SQLStatement::SQLStatement(Database* database, PassRefPtr<SQLStatementCallback> callback,
48
SQLStatement::SQLStatement(Database* database, PassRefPtr<SQLStatementCallback> callback,
55
    PassRefPtr<SQLStatementErrorCallback> errorCallback)
49
    PassRefPtr<SQLStatementErrorCallback> errorCallback)
56
    : m_statementCallbackWrapper(callback, database->scriptExecutionContext())
50
    : m_statementCallbackWrapper(callback, database->scriptExecutionContext())
- a/Source/WebCore/Modules/webdatabase/SQLStatement.h -4 / +1 lines
Lines 49-56 class SQLTransaction; a/Source/WebCore/Modules/webdatabase/SQLStatement.h_sec1
49
49
50
class SQLStatement : public AbstractSQLStatement {
50
class SQLStatement : public AbstractSQLStatement {
51
public:
51
public:
52
    static PassOwnPtr<SQLStatement> create(Database*,
52
    SQLStatement(Database*, PassRefPtr<SQLStatementCallback>, PassRefPtr<SQLStatementErrorCallback>);
53
        PassRefPtr<SQLStatementCallback>, PassRefPtr<SQLStatementErrorCallback>);
54
53
55
    bool performCallback(SQLTransaction*);
54
    bool performCallback(SQLTransaction*);
56
55
Lines 60-67 public: a/Source/WebCore/Modules/webdatabase/SQLStatement.h_sec2
60
    virtual bool hasErrorCallback();
59
    virtual bool hasErrorCallback();
61
60
62
private:
61
private:
63
    SQLStatement(Database*, PassRefPtr<SQLStatementCallback>, PassRefPtr<SQLStatementErrorCallback>);
64
65
    // The AbstractSQLStatementBackend owns the SQLStatement. Hence, the backend is
62
    // The AbstractSQLStatementBackend owns the SQLStatement. Hence, the backend is
66
    // guaranteed to be outlive the SQLStatement, and it is safe for us to refer
63
    // guaranteed to be outlive the SQLStatement, and it is safe for us to refer
67
    // to the backend using a raw pointer here.
64
    // to the backend using a raw pointer here.
- a/Source/WebCore/Modules/webdatabase/SQLStatementBackend.cpp -6 / +7 lines
Lines 47-59 a/Source/WebCore/Modules/webdatabase/SQLStatementBackend.cpp_sec1
47
//     At birth (in SQLTransactionBackend::executeSQL()):
47
//     At birth (in SQLTransactionBackend::executeSQL()):
48
//     =================================================
48
//     =================================================
49
//     SQLTransactionBackend           // Deque<RefPtr<SQLStatementBackend>> m_statementQueue points to ...
49
//     SQLTransactionBackend           // Deque<RefPtr<SQLStatementBackend>> m_statementQueue points to ...
50
//     --> SQLStatementBackend         // OwnPtr<SQLStatement> m_frontend points to ...
50
//     --> SQLStatementBackend         // std::unique_ptr<SQLStatement> m_frontend points to ...
51
//         --> SQLStatement
51
//         --> SQLStatement
52
//
52
//
53
//     After grabbing the statement for execution (in SQLTransactionBackend::getNextStatement()):
53
//     After grabbing the statement for execution (in SQLTransactionBackend::getNextStatement()):
54
//     =========================================================================================
54
//     =========================================================================================
55
//     SQLTransactionBackend           // RefPtr<SQLStatementBackend> m_currentStatementBackend points to ...
55
//     SQLTransactionBackend           // RefPtr<SQLStatementBackend> m_currentStatementBackend points to ...
56
//     --> SQLStatementBackend         // OwnPtr<SQLStatement> m_frontend points to ...
56
//     --> SQLStatementBackend         // std::unique_ptr<SQLStatement> m_frontend points to ...
57
//         --> SQLStatement
57
//         --> SQLStatement
58
//
58
//
59
//     Then we execute the statement in SQLTransactionBackend::runCurrentStatementAndGetNextState().
59
//     Then we execute the statement in SQLTransactionBackend::runCurrentStatementAndGetNextState().
Lines 74-88 a/Source/WebCore/Modules/webdatabase/SQLStatementBackend.cpp_sec2
74
74
75
namespace WebCore {
75
namespace WebCore {
76
76
77
PassRefPtr<SQLStatementBackend> SQLStatementBackend::create(PassOwnPtr<AbstractSQLStatement> frontend,
77
PassRefPtr<SQLStatementBackend> SQLStatementBackend::create(std::unique_ptr<AbstractSQLStatement> frontend,
78
    const String& statement, const Vector<SQLValue>& arguments, int permissions)
78
    const String& statement, const Vector<SQLValue>& arguments, int permissions)
79
{
79
{
80
    return adoptRef(new SQLStatementBackend(frontend, statement, arguments, permissions));
80
    return adoptRef(new SQLStatementBackend(std::forward<std::unique_ptr<AbstractSQLStatement>>(frontend),
81
        statement, arguments, permissions));
81
}
82
}
82
83
83
SQLStatementBackend::SQLStatementBackend(PassOwnPtr<AbstractSQLStatement> frontend,
84
SQLStatementBackend::SQLStatementBackend(std::unique_ptr<AbstractSQLStatement> frontend,
84
    const String& statement, const Vector<SQLValue>& arguments, int permissions)
85
    const String& statement, const Vector<SQLValue>& arguments, int permissions)
85
    : m_frontend(frontend)
86
    : m_frontend(std::move(frontend))
86
    , m_statement(statement.isolatedCopy())
87
    , m_statement(statement.isolatedCopy())
87
    , m_arguments(arguments)
88
    , m_arguments(arguments)
88
    , m_hasCallback(m_frontend->hasCallback())
89
    , m_hasCallback(m_frontend->hasCallback())
- a/Source/WebCore/Modules/webdatabase/SQLStatementBackend.h -4 / +3 lines
Lines 33-39 a/Source/WebCore/Modules/webdatabase/SQLStatementBackend.h_sec1
33
#include "AbstractSQLStatementBackend.h"
33
#include "AbstractSQLStatementBackend.h"
34
#include "SQLValue.h"
34
#include "SQLValue.h"
35
#include <wtf/Forward.h>
35
#include <wtf/Forward.h>
36
#include <wtf/PassOwnPtr.h>
37
#include <wtf/Vector.h>
36
#include <wtf/Vector.h>
38
#include <wtf/text/WTFString.h>
37
#include <wtf/text/WTFString.h>
39
38
Lines 46-52 class SQLTransactionBackend; a/Source/WebCore/Modules/webdatabase/SQLStatementBackend.h_sec2
46
45
47
class SQLStatementBackend : public AbstractSQLStatementBackend {
46
class SQLStatementBackend : public AbstractSQLStatementBackend {
48
public:
47
public:
49
    static PassRefPtr<SQLStatementBackend> create(PassOwnPtr<AbstractSQLStatement>,
48
    static PassRefPtr<SQLStatementBackend> create(std::unique_ptr<AbstractSQLStatement>,
50
        const String& sqlStatement, const Vector<SQLValue>& arguments, int permissions);
49
        const String& sqlStatement, const Vector<SQLValue>& arguments, int permissions);
51
50
52
    bool execute(DatabaseBackend*);
51
    bool execute(DatabaseBackend*);
Lines 63-75 public: a/Source/WebCore/Modules/webdatabase/SQLStatementBackend.h_sec3
63
    virtual PassRefPtr<SQLResultSet> sqlResultSet() const;
62
    virtual PassRefPtr<SQLResultSet> sqlResultSet() const;
64
63
65
private:
64
private:
66
    SQLStatementBackend(PassOwnPtr<AbstractSQLStatement>, const String& statement,
65
    SQLStatementBackend(std::unique_ptr<AbstractSQLStatement>, const String& statement,
67
        const Vector<SQLValue>& arguments, int permissions);
66
        const Vector<SQLValue>& arguments, int permissions);
68
67
69
    void setFailureDueToQuota();
68
    void setFailureDueToQuota();
70
    void clearFailureDueToQuota();
69
    void clearFailureDueToQuota();
71
70
72
    OwnPtr<AbstractSQLStatement> m_frontend;
71
    std::unique_ptr<AbstractSQLStatement> m_frontend;
73
    String m_statement;
72
    String m_statement;
74
    Vector<SQLValue> m_arguments;
73
    Vector<SQLValue> m_arguments;
75
    bool m_hasCallback;
74
    bool m_hasCallback;
- a/Source/WebCore/Modules/webdatabase/SQLTransaction.cpp -2 / +2 lines
Lines 261-268 void SQLTransaction::executeSQL(const String& sqlStatement, const Vector<SQLValu a/Source/WebCore/Modules/webdatabase/SQLTransaction.cpp_sec1
261
    else if (m_readOnly)
261
    else if (m_readOnly)
262
        permissions |= DatabaseAuthorizer::ReadOnlyMask;
262
        permissions |= DatabaseAuthorizer::ReadOnlyMask;
263
263
264
    OwnPtr<SQLStatement> statement = SQLStatement::create(m_database.get(), callback, callbackError);
264
    auto statement = std::make_unique<SQLStatement>(m_database.get(), callback, callbackError);
265
    m_backend->executeSQL(statement.release(), sqlStatement, arguments, permissions);
265
    m_backend->executeSQL(std::move(statement), sqlStatement, arguments, permissions);
266
}
266
}
267
267
268
bool SQLTransaction::computeNextStateAndCleanupIfNeeded()
268
bool SQLTransaction::computeNextStateAndCleanupIfNeeded()
- a/Source/WebCore/Modules/webdatabase/SQLTransactionBackend.cpp -11 / +12 lines
Lines 260-266 a/Source/WebCore/Modules/webdatabase/SQLTransactionBackend.cpp_sec1
260
//
260
//
261
//     When executing the transaction (in DatabaseThread::databaseThread()):
261
//     When executing the transaction (in DatabaseThread::databaseThread()):
262
//     ====================================================================
262
//     ====================================================================
263
//     OwnPtr<DatabaseTask> task;             // points to ...
263
//     std::unique_ptr<DatabaseTask> task;    // points to ...
264
//     --> DatabaseTransactionTask            // RefPtr<SQLTransactionBackend> m_transaction points to ...
264
//     --> DatabaseTransactionTask            // RefPtr<SQLTransactionBackend> m_transaction points to ...
265
//         --> SQLTransactionBackend          // RefPtr<SQLTransaction> m_frontend;
265
//         --> SQLTransactionBackend          // RefPtr<SQLTransaction> m_frontend;
266
//             --> SQLTransaction             // RefPtr<SQLTransactionBackend> m_backend points to ...
266
//             --> SQLTransaction             // RefPtr<SQLTransactionBackend> m_backend points to ...
Lines 284-290 a/Source/WebCore/Modules/webdatabase/SQLTransactionBackend.cpp_sec2
284
//     However, there will still be a DatabaseTask pointing to the SQLTransactionBackend (see
284
//     However, there will still be a DatabaseTask pointing to the SQLTransactionBackend (see
285
//     the "When executing the transaction" chain above). This will keep the
285
//     the "When executing the transaction" chain above). This will keep the
286
//     SQLTransactionBackend alive until DatabaseThread::databaseThread() releases its
286
//     SQLTransactionBackend alive until DatabaseThread::databaseThread() releases its
287
//     task OwnPtr.
287
//     task std::unique_ptr.
288
//
288
//
289
//     What happens if a transaction is interrupted?
289
//     What happens if a transaction is interrupted?
290
//     ============================================
290
//     ============================================
Lines 393-399 void SQLTransactionBackend::doCleanup() a/Source/WebCore/Modules/webdatabase/SQLTransactionBackend.cpp_sec3
393
        // m_sqliteTransaction invokes SQLiteTransaction's destructor which does
393
        // m_sqliteTransaction invokes SQLiteTransaction's destructor which does
394
        // just that. We might as well do this unconditionally and free up its
394
        // just that. We might as well do this unconditionally and free up its
395
        // resources because we're already terminating.
395
        // resources because we're already terminating.
396
        m_sqliteTransaction.clear();
396
        m_sqliteTransaction.reset();
397
    }
397
    }
398
398
399
    // Release the lock on this database
399
    // Release the lock on this database
Lines 500-506 void SQLTransactionBackend::computeNextStateAndCleanupIfNeeded() a/Source/WebCore/Modules/webdatabase/SQLTransactionBackend.cpp_sec4
500
    // The current SQLite transaction should be stopped, as well
500
    // The current SQLite transaction should be stopped, as well
501
    if (m_sqliteTransaction) {
501
    if (m_sqliteTransaction) {
502
        m_sqliteTransaction->stop();
502
        m_sqliteTransaction->stop();
503
        m_sqliteTransaction.clear();
503
        m_sqliteTransaction.reset();
504
    }
504
    }
505
505
506
    // Terminate the frontend state machine. This also gets the frontend to
506
    // Terminate the frontend state machine. This also gets the frontend to
Lines 526-536 bool SQLTransactionBackend::shouldPerformWhilePaused() const a/Source/WebCore/Modules/webdatabase/SQLTransactionBackend.cpp_sec5
526
}
526
}
527
#endif
527
#endif
528
528
529
void SQLTransactionBackend::executeSQL(PassOwnPtr<AbstractSQLStatement> statement,
529
void SQLTransactionBackend::executeSQL(std::unique_ptr<AbstractSQLStatement> statement,
530
    const String& sqlStatement, const Vector<SQLValue>& arguments, int permissions)
530
    const String& sqlStatement, const Vector<SQLValue>& arguments, int permissions)
531
{
531
{
532
    RefPtr<SQLStatementBackend> statementBackend;
532
    RefPtr<SQLStatementBackend> statementBackend;
533
    statementBackend = SQLStatementBackend::create(statement, sqlStatement, arguments, permissions);
533
    statementBackend = SQLStatementBackend::create(std::forward<std::unique_ptr<AbstractSQLStatement>>(statement),
534
        sqlStatement, arguments, permissions);
534
535
535
    if (Database::from(m_database.get())->deleted())
536
    if (Database::from(m_database.get())->deleted())
536
        statementBackend->setDatabaseDeletedError();
537
        statementBackend->setDatabaseDeletedError();
Lines 582-588 SQLTransactionState SQLTransactionBackend::openTransactionAndPreflight() a/Source/WebCore/Modules/webdatabase/SQLTransactionBackend.cpp_sec6
582
    }
583
    }
583
584
584
    ASSERT(!m_sqliteTransaction);
585
    ASSERT(!m_sqliteTransaction);
585
    m_sqliteTransaction = adoptPtr(new SQLiteTransaction(m_database->sqliteDatabase(), m_readOnly));
586
    m_sqliteTransaction = std::make_unique<SQLiteTransaction>(m_database->sqliteDatabase(), m_readOnly);
586
587
587
    m_database->resetDeletes();
588
    m_database->resetDeletes();
588
    m_database->disableAuthorizer();
589
    m_database->disableAuthorizer();
Lines 594-600 SQLTransactionState SQLTransactionBackend::openTransactionAndPreflight() a/Source/WebCore/Modules/webdatabase/SQLTransactionBackend.cpp_sec7
594
        ASSERT(!m_database->sqliteDatabase().transactionInProgress());
595
        ASSERT(!m_database->sqliteDatabase().transactionInProgress());
595
        m_transactionError = SQLError::create(SQLError::DATABASE_ERR, "unable to begin transaction",
596
        m_transactionError = SQLError::create(SQLError::DATABASE_ERR, "unable to begin transaction",
596
            m_database->sqliteDatabase().lastError(), m_database->sqliteDatabase().lastErrorMsg());
597
            m_database->sqliteDatabase().lastError(), m_database->sqliteDatabase().lastErrorMsg());
597
        m_sqliteTransaction.clear();
598
        m_sqliteTransaction.reset();
598
        return nextStateForTransactionError();
599
        return nextStateForTransactionError();
599
    }
600
    }
600
601
Lines 606-612 SQLTransactionState SQLTransactionBackend::openTransactionAndPreflight() a/Source/WebCore/Modules/webdatabase/SQLTransactionBackend.cpp_sec8
606
        m_transactionError = SQLError::create(SQLError::DATABASE_ERR, "unable to read version",
607
        m_transactionError = SQLError::create(SQLError::DATABASE_ERR, "unable to read version",
607
            m_database->sqliteDatabase().lastError(), m_database->sqliteDatabase().lastErrorMsg());
608
            m_database->sqliteDatabase().lastError(), m_database->sqliteDatabase().lastErrorMsg());
608
        m_database->disableAuthorizer();
609
        m_database->disableAuthorizer();
609
        m_sqliteTransaction.clear();
610
        m_sqliteTransaction.reset();
610
        m_database->enableAuthorizer();
611
        m_database->enableAuthorizer();
611
        return nextStateForTransactionError();
612
        return nextStateForTransactionError();
612
    }
613
    }
Lines 615-621 SQLTransactionState SQLTransactionBackend::openTransactionAndPreflight() a/Source/WebCore/Modules/webdatabase/SQLTransactionBackend.cpp_sec9
615
    // Spec 4.3.2.3: Perform preflight steps, jumping to the error callback if they fail
616
    // Spec 4.3.2.3: Perform preflight steps, jumping to the error callback if they fail
616
    if (m_wrapper && !m_wrapper->performPreflight(this)) {
617
    if (m_wrapper && !m_wrapper->performPreflight(this)) {
617
        m_database->disableAuthorizer();
618
        m_database->disableAuthorizer();
618
        m_sqliteTransaction.clear();
619
        m_sqliteTransaction.reset();
619
        m_database->enableAuthorizer();
620
        m_database->enableAuthorizer();
620
        m_transactionError = m_wrapper->sqlError();
621
        m_transactionError = m_wrapper->sqlError();
621
        if (!m_transactionError)
622
        if (!m_transactionError)
Lines 799-805 SQLTransactionState SQLTransactionBackend::cleanupAfterTransactionErrorCallback( a/Source/WebCore/Modules/webdatabase/SQLTransactionBackend.cpp_sec10
799
        m_sqliteTransaction->rollback();
800
        m_sqliteTransaction->rollback();
800
801
801
        ASSERT(!m_database->sqliteDatabase().transactionInProgress());
802
        ASSERT(!m_database->sqliteDatabase().transactionInProgress());
802
        m_sqliteTransaction.clear();
803
        m_sqliteTransaction.reset();
803
    }
804
    }
804
    m_database->enableAuthorizer();
805
    m_database->enableAuthorizer();
805
806
- a/Source/WebCore/Modules/webdatabase/SQLTransactionBackend.h -2 / +3 lines
Lines 34-39 a/Source/WebCore/Modules/webdatabase/SQLTransactionBackend.h_sec1
34
#include "AbstractSQLTransactionBackend.h"
34
#include "AbstractSQLTransactionBackend.h"
35
#include "DatabaseBasicTypes.h"
35
#include "DatabaseBasicTypes.h"
36
#include "SQLTransactionStateMachine.h"
36
#include "SQLTransactionStateMachine.h"
37
#include <memory>
37
#include <wtf/Deque.h>
38
#include <wtf/Deque.h>
38
#include <wtf/Forward.h>
39
#include <wtf/Forward.h>
39
#include <wtf/text/WTFString.h>
40
#include <wtf/text/WTFString.h>
Lines 85-91 private: a/Source/WebCore/Modules/webdatabase/SQLTransactionBackend.h_sec2
85
    virtual PassRefPtr<SQLError> transactionError() override;
86
    virtual PassRefPtr<SQLError> transactionError() override;
86
    virtual AbstractSQLStatement* currentStatement() override;
87
    virtual AbstractSQLStatement* currentStatement() override;
87
    virtual void setShouldRetryCurrentStatement(bool) override;
88
    virtual void setShouldRetryCurrentStatement(bool) override;
88
    virtual void executeSQL(PassOwnPtr<AbstractSQLStatement>, const String& statement,
89
    virtual void executeSQL(std::unique_ptr<AbstractSQLStatement>, const String& statement,
89
        const Vector<SQLValue>& arguments, int permissions) override;
90
        const Vector<SQLValue>& arguments, int permissions) override;
90
91
91
    void doCleanup();
92
    void doCleanup();
Lines 135-141 private: a/Source/WebCore/Modules/webdatabase/SQLTransactionBackend.h_sec3
135
    Mutex m_statementMutex;
136
    Mutex m_statementMutex;
136
    Deque<RefPtr<SQLStatementBackend>> m_statementQueue;
137
    Deque<RefPtr<SQLStatementBackend>> m_statementQueue;
137
138
138
    OwnPtr<SQLiteTransaction> m_sqliteTransaction;
139
    std::unique_ptr<SQLiteTransaction> m_sqliteTransaction;
139
    RefPtr<OriginLock> m_originLock;
140
    RefPtr<OriginLock> m_originLock;
140
};
141
};
141
142
- a/Source/WebCore/Modules/webdatabase/SQLTransactionBackendSync.cpp -5 / +5 lines
Lines 58-64 SQLTransactionBackendSync::SQLTransactionBackendSync(DatabaseSync* db, PassRefPt a/Source/WebCore/Modules/webdatabase/SQLTransactionBackendSync.cpp_sec1
58
    , m_readOnly(readOnly)
58
    , m_readOnly(readOnly)
59
    , m_hasVersionMismatch(false)
59
    , m_hasVersionMismatch(false)
60
    , m_modifiedDatabase(false)
60
    , m_modifiedDatabase(false)
61
    , m_transactionClient(adoptPtr(new SQLTransactionClient()))
61
    , m_transactionClient(std::make_unique<SQLTransactionClient>())
62
{
62
{
63
    ASSERT(m_database->scriptExecutionContext()->isContextThread());
63
    ASSERT(m_database->scriptExecutionContext()->isContextThread());
64
}
64
}
Lines 142-148 ExceptionCode SQLTransactionBackendSync::begin() a/Source/WebCore/Modules/webdatabase/SQLTransactionBackendSync.cpp_sec2
142
        m_database->sqliteDatabase().setMaximumSize(m_database->maximumSize());
142
        m_database->sqliteDatabase().setMaximumSize(m_database->maximumSize());
143
143
144
    ASSERT(!m_sqliteTransaction);
144
    ASSERT(!m_sqliteTransaction);
145
    m_sqliteTransaction = adoptPtr(new SQLiteTransaction(m_database->sqliteDatabase(), m_readOnly));
145
    m_sqliteTransaction = std::make_unique<SQLiteTransaction>(m_database->sqliteDatabase(), m_readOnly);
146
146
147
    m_database->resetDeletes();
147
    m_database->resetDeletes();
148
    m_database->disableAuthorizer();
148
    m_database->disableAuthorizer();
Lines 154-160 ExceptionCode SQLTransactionBackendSync::begin() a/Source/WebCore/Modules/webdatabase/SQLTransactionBackendSync.cpp_sec3
154
        ASSERT(!m_database->sqliteDatabase().transactionInProgress());
154
        ASSERT(!m_database->sqliteDatabase().transactionInProgress());
155
        m_database->setLastErrorMessage("unable to begin transaction",
155
        m_database->setLastErrorMessage("unable to begin transaction",
156
            m_database->sqliteDatabase().lastError(), m_database->sqliteDatabase().lastErrorMsg());
156
            m_database->sqliteDatabase().lastError(), m_database->sqliteDatabase().lastErrorMsg());
157
        m_sqliteTransaction.clear();
157
        m_sqliteTransaction.reset();
158
        return SQLException::DATABASE_ERR;
158
        return SQLException::DATABASE_ERR;
159
    }
159
    }
160
160
Lines 207-213 ExceptionCode SQLTransactionBackendSync::commit() a/Source/WebCore/Modules/webdatabase/SQLTransactionBackendSync.cpp_sec4
207
        return SQLException::DATABASE_ERR;
207
        return SQLException::DATABASE_ERR;
208
    }
208
    }
209
209
210
    m_sqliteTransaction.clear();
210
    m_sqliteTransaction.reset();
211
211
212
    // Vacuum the database if anything was deleted.
212
    // Vacuum the database if anything was deleted.
213
    if (m_database->hadDeletes())
213
    if (m_database->hadDeletes())
Lines 225-231 void SQLTransactionBackendSync::rollback() a/Source/WebCore/Modules/webdatabase/SQLTransactionBackendSync.cpp_sec5
225
    m_database->disableAuthorizer();
225
    m_database->disableAuthorizer();
226
    if (m_sqliteTransaction) {
226
    if (m_sqliteTransaction) {
227
        m_sqliteTransaction->rollback();
227
        m_sqliteTransaction->rollback();
228
        m_sqliteTransaction.clear();
228
        m_sqliteTransaction.reset();
229
    }
229
    }
230
    m_database->enableAuthorizer();
230
    m_database->enableAuthorizer();
231
231
- a/Source/WebCore/Modules/webdatabase/SQLTransactionBackendSync.h -2 / +3 lines
Lines 35-40 a/Source/WebCore/Modules/webdatabase/SQLTransactionBackendSync.h_sec1
35
#if ENABLE(SQL_DATABASE)
35
#if ENABLE(SQL_DATABASE)
36
36
37
#include "DatabaseBasicTypes.h"
37
#include "DatabaseBasicTypes.h"
38
#include <memory>
38
#include <wtf/Forward.h>
39
#include <wtf/Forward.h>
39
#include <wtf/RefCounted.h>
40
#include <wtf/RefCounted.h>
40
#include <wtf/Vector.h>
41
#include <wtf/Vector.h>
Lines 73-80 private: a/Source/WebCore/Modules/webdatabase/SQLTransactionBackendSync.h_sec2
73
    bool m_hasVersionMismatch;
74
    bool m_hasVersionMismatch;
74
75
75
    bool m_modifiedDatabase;
76
    bool m_modifiedDatabase;
76
    OwnPtr<SQLTransactionClient> m_transactionClient;
77
    std::unique_ptr<SQLTransactionClient> m_transactionClient;
77
    OwnPtr<SQLiteTransaction> m_sqliteTransaction;
78
    std::unique_ptr<SQLiteTransaction> m_sqliteTransaction;
78
79
79
    friend class SQLTransactionSync; // FIXME: Remove this once the front-end has been properly isolated.
80
    friend class SQLTransactionSync; // FIXME: Remove this once the front-end has been properly isolated.
80
};
81
};

Return to Bug 127278