| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Apple Inc. All rights reserved. | 2 * Copyright (C) 2013 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 | 259 |
| 260 bool Database::openAndVerifyVersion(bool setVersionInNewDatabase, DatabaseError&
error, String& errorMessage) | 260 bool Database::openAndVerifyVersion(bool setVersionInNewDatabase, DatabaseError&
error, String& errorMessage) |
| 261 { | 261 { |
| 262 TaskSynchronizer synchronizer; | 262 TaskSynchronizer synchronizer; |
| 263 if (!getDatabaseContext()->databaseThreadAvailable()) | 263 if (!getDatabaseContext()->databaseThreadAvailable()) |
| 264 return false; | 264 return false; |
| 265 | 265 |
| 266 DatabaseTracker::tracker().prepareToOpenDatabase(this); | 266 DatabaseTracker::tracker().prepareToOpenDatabase(this); |
| 267 bool success = false; | 267 bool success = false; |
| 268 OwnPtr<DatabaseOpenTask> task = DatabaseOpenTask::create(this, setVersionInN
ewDatabase, &synchronizer, error, errorMessage, success); | 268 OwnPtr<DatabaseOpenTask> task = DatabaseOpenTask::create(this, setVersionInN
ewDatabase, &synchronizer, error, errorMessage, success); |
| 269 getDatabaseContext()->databaseThread()->scheduleTask(task.release()); | 269 getDatabaseContext()->databaseThread()->scheduleTask(std::move(task)); |
| 270 synchronizer.waitForTaskCompletion(); | 270 synchronizer.waitForTaskCompletion(); |
| 271 | 271 |
| 272 return success; | 272 return success; |
| 273 } | 273 } |
| 274 | 274 |
| 275 void Database::close() | 275 void Database::close() |
| 276 { | 276 { |
| 277 ASSERT(getDatabaseContext()->databaseThread()); | 277 ASSERT(getDatabaseContext()->databaseThread()); |
| 278 ASSERT(getDatabaseContext()->databaseThread()->isDatabaseThread()); | 278 ASSERT(getDatabaseContext()->databaseThread()->isDatabaseThread()); |
| 279 | 279 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 ASSERT(!m_transactionInProgressMutex.tryLock()); // Locked by caller. | 327 ASSERT(!m_transactionInProgressMutex.tryLock()); // Locked by caller. |
| 328 SQLTransactionBackend* transaction = nullptr; | 328 SQLTransactionBackend* transaction = nullptr; |
| 329 | 329 |
| 330 if (m_isTransactionQueueEnabled && !m_transactionQueue.isEmpty()) | 330 if (m_isTransactionQueueEnabled && !m_transactionQueue.isEmpty()) |
| 331 transaction = m_transactionQueue.takeFirst(); | 331 transaction = m_transactionQueue.takeFirst(); |
| 332 | 332 |
| 333 if (transaction && getDatabaseContext()->databaseThreadAvailable()) { | 333 if (transaction && getDatabaseContext()->databaseThreadAvailable()) { |
| 334 OwnPtr<DatabaseTransactionTask> task = DatabaseTransactionTask::create(t
ransaction); | 334 OwnPtr<DatabaseTransactionTask> task = DatabaseTransactionTask::create(t
ransaction); |
| 335 WTF_LOG(StorageAPI, "Scheduling DatabaseTransactionTask %p for transacti
on %p\n", task.get(), task->transaction()); | 335 WTF_LOG(StorageAPI, "Scheduling DatabaseTransactionTask %p for transacti
on %p\n", task.get(), task->transaction()); |
| 336 m_transactionInProgress = true; | 336 m_transactionInProgress = true; |
| 337 getDatabaseContext()->databaseThread()->scheduleTask(task.release()); | 337 getDatabaseContext()->databaseThread()->scheduleTask(std::move(task)); |
| 338 } else { | 338 } else { |
| 339 m_transactionInProgress = false; | 339 m_transactionInProgress = false; |
| 340 } | 340 } |
| 341 } | 341 } |
| 342 | 342 |
| 343 void Database::scheduleTransactionStep(SQLTransactionBackend* transaction) | 343 void Database::scheduleTransactionStep(SQLTransactionBackend* transaction) |
| 344 { | 344 { |
| 345 if (!getDatabaseContext()->databaseThreadAvailable()) | 345 if (!getDatabaseContext()->databaseThreadAvailable()) |
| 346 return; | 346 return; |
| 347 | 347 |
| 348 OwnPtr<DatabaseTransactionTask> task = DatabaseTransactionTask::create(trans
action); | 348 OwnPtr<DatabaseTransactionTask> task = DatabaseTransactionTask::create(trans
action); |
| 349 WTF_LOG(StorageAPI, "Scheduling DatabaseTransactionTask %p for the transacti
on step\n", task.get()); | 349 WTF_LOG(StorageAPI, "Scheduling DatabaseTransactionTask %p for the transacti
on step\n", task.get()); |
| 350 getDatabaseContext()->databaseThread()->scheduleTask(task.release()); | 350 getDatabaseContext()->databaseThread()->scheduleTask(std::move(task)); |
| 351 } | 351 } |
| 352 | 352 |
| 353 SQLTransactionClient* Database::transactionClient() const | 353 SQLTransactionClient* Database::transactionClient() const |
| 354 { | 354 { |
| 355 return getDatabaseContext()->databaseThread()->transactionClient(); | 355 return getDatabaseContext()->databaseThread()->transactionClient(); |
| 356 } | 356 } |
| 357 | 357 |
| 358 SQLTransactionCoordinator* Database::transactionCoordinator() const | 358 SQLTransactionCoordinator* Database::transactionCoordinator() const |
| 359 { | 359 { |
| 360 return getDatabaseContext()->databaseThread()->transactionCoordinator(); | 360 return getDatabaseContext()->databaseThread()->transactionCoordinator(); |
| (...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 829 #if ENABLE(ASSERT) | 829 #if ENABLE(ASSERT) |
| 830 SQLTransactionErrorCallback* originalErrorCallback = errorCallback; | 830 SQLTransactionErrorCallback* originalErrorCallback = errorCallback; |
| 831 #endif | 831 #endif |
| 832 SQLTransaction* transaction = SQLTransaction::create(this, callback, success
Callback, errorCallback, readOnly); | 832 SQLTransaction* transaction = SQLTransaction::create(this, callback, success
Callback, errorCallback, readOnly); |
| 833 SQLTransactionBackend* transactionBackend = runTransaction(transaction, read
Only, changeVersionData); | 833 SQLTransactionBackend* transactionBackend = runTransaction(transaction, read
Only, changeVersionData); |
| 834 if (!transactionBackend) { | 834 if (!transactionBackend) { |
| 835 SQLTransactionErrorCallback* callback = transaction->releaseErrorCallbac
k(); | 835 SQLTransactionErrorCallback* callback = transaction->releaseErrorCallbac
k(); |
| 836 ASSERT(callback == originalErrorCallback); | 836 ASSERT(callback == originalErrorCallback); |
| 837 if (callback) { | 837 if (callback) { |
| 838 OwnPtr<SQLErrorData> error = SQLErrorData::create(SQLError::UNKNOWN_
ERR, "database has been closed"); | 838 OwnPtr<SQLErrorData> error = SQLErrorData::create(SQLError::UNKNOWN_
ERR, "database has been closed"); |
| 839 getExecutionContext()->postTask(BLINK_FROM_HERE, createSameThreadTas
k(&callTransactionErrorCallback, callback, passed(error.release()))); | 839 getExecutionContext()->postTask(BLINK_FROM_HERE, createSameThreadTas
k(&callTransactionErrorCallback, callback, passed(std::move(error)))); |
| 840 } | 840 } |
| 841 } | 841 } |
| 842 } | 842 } |
| 843 | 843 |
| 844 void Database::scheduleTransactionCallback(SQLTransaction* transaction) | 844 void Database::scheduleTransactionCallback(SQLTransaction* transaction) |
| 845 { | 845 { |
| 846 // The task is constructed in a database thread, and destructed in the | 846 // The task is constructed in a database thread, and destructed in the |
| 847 // context thread. | 847 // context thread. |
| 848 getExecutionContext()->postTask(BLINK_FROM_HERE, createCrossThreadTask(&SQLT
ransaction::performPendingCallback, AllowCrossThreadAccess(transaction))); | 848 getExecutionContext()->postTask(BLINK_FROM_HERE, createCrossThreadTask(&SQLT
ransaction::performPendingCallback, AllowCrossThreadAccess(transaction))); |
| 849 } | 849 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 881 { | 881 { |
| 882 // FIXME: Not using isolatedCopy on these strings looks ok since threads | 882 // FIXME: Not using isolatedCopy on these strings looks ok since threads |
| 883 // take strict turns in dealing with them. However, if the code changes, | 883 // take strict turns in dealing with them. However, if the code changes, |
| 884 // this may not be true anymore. | 884 // this may not be true anymore. |
| 885 Vector<String> result; | 885 Vector<String> result; |
| 886 TaskSynchronizer synchronizer; | 886 TaskSynchronizer synchronizer; |
| 887 if (!getDatabaseContext()->databaseThreadAvailable()) | 887 if (!getDatabaseContext()->databaseThreadAvailable()) |
| 888 return result; | 888 return result; |
| 889 | 889 |
| 890 OwnPtr<DatabaseTableNamesTask> task = DatabaseTableNamesTask::create(this, &
synchronizer, result); | 890 OwnPtr<DatabaseTableNamesTask> task = DatabaseTableNamesTask::create(this, &
synchronizer, result); |
| 891 getDatabaseContext()->databaseThread()->scheduleTask(task.release()); | 891 getDatabaseContext()->databaseThread()->scheduleTask(std::move(task)); |
| 892 synchronizer.waitForTaskCompletion(); | 892 synchronizer.waitForTaskCompletion(); |
| 893 | 893 |
| 894 return result; | 894 return result; |
| 895 } | 895 } |
| 896 | 896 |
| 897 SecurityOrigin* Database::getSecurityOrigin() const | 897 SecurityOrigin* Database::getSecurityOrigin() const |
| 898 { | 898 { |
| 899 if (getExecutionContext()->isContextThread()) | 899 if (getExecutionContext()->isContextThread()) |
| 900 return m_contextThreadSecurityOrigin.get(); | 900 return m_contextThreadSecurityOrigin.get(); |
| 901 if (getDatabaseContext()->databaseThread()->isDatabaseThread()) | 901 if (getDatabaseContext()->databaseThread()->isDatabaseThread()) |
| 902 return m_databaseThreadSecurityOrigin.get(); | 902 return m_databaseThreadSecurityOrigin.get(); |
| 903 return 0; | 903 return 0; |
| 904 } | 904 } |
| 905 | 905 |
| 906 bool Database::opened() | 906 bool Database::opened() |
| 907 { | 907 { |
| 908 return static_cast<bool>(acquireLoad(&m_opened)); | 908 return static_cast<bool>(acquireLoad(&m_opened)); |
| 909 } | 909 } |
| 910 | 910 |
| 911 } // namespace blink | 911 } // namespace blink |
| OLD | NEW |