Chromium Code Reviews| 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 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 253 { | 253 { |
| 254 visitor->trace(m_databaseContext); | 254 visitor->trace(m_databaseContext); |
| 255 visitor->trace(m_sqliteDatabase); | 255 visitor->trace(m_sqliteDatabase); |
| 256 visitor->trace(m_databaseAuthorizer); | 256 visitor->trace(m_databaseAuthorizer); |
| 257 visitor->trace(m_transactionQueue); | 257 visitor->trace(m_transactionQueue); |
| 258 } | 258 } |
| 259 | 259 |
| 260 bool DatabaseBackend::openAndVerifyVersion(bool setVersionInNewDatabase, Databas eError& error, String& errorMessage) | 260 bool DatabaseBackend::openAndVerifyVersion(bool setVersionInNewDatabase, Databas eError& error, String& errorMessage) |
| 261 { | 261 { |
| 262 TaskSynchronizer synchronizer; | 262 TaskSynchronizer synchronizer; |
| 263 if (!databaseContext()->databaseThread() || databaseContext()->databaseThrea d()->terminationRequested(&synchronizer)) | 263 if (!databaseContext()->databaseThread() || databaseContext()->databaseThrea d()->terminationRequested()) |
|
tkent
2014/09/24 02:14:04
We should have DatabaseContext::databaseThreadIsAv
haraken
2014/09/24 02:23:18
Done.
| |
| 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 databaseContext()->databaseThread()->scheduleTask(task.release()); | 269 databaseContext()->databaseThread()->scheduleTask(task.release()); |
| 270 synchronizer.waitForTaskCompletion(); | 270 synchronizer.waitForTaskCompletion(); |
| 271 | 271 |
| 272 return success; | 272 return success; |
| 273 } | 273 } |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 324 } | 324 } |
| 325 | 325 |
| 326 void DatabaseBackend::scheduleTransaction() | 326 void DatabaseBackend::scheduleTransaction() |
| 327 { | 327 { |
| 328 ASSERT(!m_transactionInProgressMutex.tryLock()); // Locked by caller. | 328 ASSERT(!m_transactionInProgressMutex.tryLock()); // Locked by caller. |
| 329 RefPtrWillBeRawPtr<SQLTransactionBackend> transaction = nullptr; | 329 RefPtrWillBeRawPtr<SQLTransactionBackend> transaction = nullptr; |
| 330 | 330 |
| 331 if (m_isTransactionQueueEnabled && !m_transactionQueue.isEmpty()) | 331 if (m_isTransactionQueueEnabled && !m_transactionQueue.isEmpty()) |
| 332 transaction = m_transactionQueue.takeFirst(); | 332 transaction = m_transactionQueue.takeFirst(); |
| 333 | 333 |
| 334 if (transaction && databaseContext()->databaseThread()) { | 334 if (transaction && databaseContext()->databaseThread() && !databaseContext() ->databaseThread()->terminationRequested()) { |
| 335 OwnPtr<DatabaseTransactionTask> task = DatabaseTransactionTask::create(t ransaction); | 335 OwnPtr<DatabaseTransactionTask> task = DatabaseTransactionTask::create(t ransaction); |
| 336 WTF_LOG(StorageAPI, "Scheduling DatabaseTransactionTask %p for transacti on %p\n", task.get(), task->transaction()); | 336 WTF_LOG(StorageAPI, "Scheduling DatabaseTransactionTask %p for transacti on %p\n", task.get(), task->transaction()); |
| 337 m_transactionInProgress = true; | 337 m_transactionInProgress = true; |
| 338 databaseContext()->databaseThread()->scheduleTask(task.release()); | 338 databaseContext()->databaseThread()->scheduleTask(task.release()); |
| 339 } else | 339 } else |
| 340 m_transactionInProgress = false; | 340 m_transactionInProgress = false; |
| 341 } | 341 } |
| 342 | 342 |
| 343 void DatabaseBackend::scheduleTransactionStep(SQLTransactionBackend* transaction ) | 343 void DatabaseBackend::scheduleTransactionStep(SQLTransactionBackend* transaction ) |
| 344 { | 344 { |
| 345 if (!databaseContext()->databaseThread()) | 345 if (!databaseContext()->databaseThread() || databaseContext()->databaseThrea d()->terminationRequested()) |
| 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 databaseContext()->databaseThread()->scheduleTask(task.release()); | 350 databaseContext()->databaseThread()->scheduleTask(task.release()); |
| 351 } | 351 } |
| 352 | 352 |
| 353 SQLTransactionClient* DatabaseBackend::transactionClient() const | 353 SQLTransactionClient* DatabaseBackend::transactionClient() const |
| 354 { | 354 { |
| 355 return databaseContext()->databaseThread()->transactionClient(); | 355 return databaseContext()->databaseThread()->transactionClient(); |
| (...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 906 return tableNames; | 906 return tableNames; |
| 907 } | 907 } |
| 908 | 908 |
| 909 Vector<String> DatabaseBackend::tableNames() | 909 Vector<String> DatabaseBackend::tableNames() |
| 910 { | 910 { |
| 911 // FIXME: Not using isolatedCopy on these strings looks ok since threads | 911 // FIXME: Not using isolatedCopy on these strings looks ok since threads |
| 912 // take strict turns in dealing with them. However, if the code changes, | 912 // take strict turns in dealing with them. However, if the code changes, |
| 913 // this may not be true anymore. | 913 // this may not be true anymore. |
| 914 Vector<String> result; | 914 Vector<String> result; |
| 915 TaskSynchronizer synchronizer; | 915 TaskSynchronizer synchronizer; |
| 916 if (!databaseContext()->databaseThread() || databaseContext()->databaseThrea d()->terminationRequested(&synchronizer)) | 916 if (!databaseContext()->databaseThread() || databaseContext()->databaseThrea d()->terminationRequested()) |
| 917 return result; | 917 return result; |
| 918 | 918 |
| 919 OwnPtr<DatabaseTableNamesTask> task = DatabaseTableNamesTask::create(this, & synchronizer, result); | 919 OwnPtr<DatabaseTableNamesTask> task = DatabaseTableNamesTask::create(this, & synchronizer, result); |
| 920 databaseContext()->databaseThread()->scheduleTask(task.release()); | 920 databaseContext()->databaseThread()->scheduleTask(task.release()); |
| 921 synchronizer.waitForTaskCompletion(); | 921 synchronizer.waitForTaskCompletion(); |
| 922 | 922 |
| 923 return result; | 923 return result; |
| 924 } | 924 } |
| 925 | 925 |
| 926 SecurityOrigin* DatabaseBackend::securityOrigin() const | 926 SecurityOrigin* DatabaseBackend::securityOrigin() const |
| 927 { | 927 { |
| 928 if (executionContext()->isContextThread()) | 928 if (executionContext()->isContextThread()) |
| 929 return m_contextThreadSecurityOrigin.get(); | 929 return m_contextThreadSecurityOrigin.get(); |
| 930 if (databaseContext()->databaseThread()->isDatabaseThread()) | 930 if (databaseContext()->databaseThread()->isDatabaseThread()) |
| 931 return m_databaseThreadSecurityOrigin.get(); | 931 return m_databaseThreadSecurityOrigin.get(); |
| 932 return 0; | 932 return 0; |
| 933 } | 933 } |
| 934 | 934 |
| 935 } // namespace blink | 935 } // namespace blink |
| OLD | NEW |