Changeset 30184 in webkit
- Timestamp:
- Feb 12, 2008, 5:10:42 PM (17 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r30182 r30184 1 2008-02-12 Brady Eidson <beidson@apple.com> 2 3 Reviewed by Darin Adler 4 5 Fix for <rdar://problem/5737692> - Database API needs to support SuccessCallback 6 7 Layout tests will come shortly with a mess of DRT changes 8 9 * platform/SecurityOrigin.cpp: 10 (WebCore::SecurityOrigin::SecurityOrigin): Standardize on "empty string" instead of null string 11 as different paths of constructing a SecurityOrigin were causing different hashes for the "same" 12 SecurityOrigin 13 14 * storage/Database.cpp: 15 (WebCore::Database::changeVersion): Pass in the successCallback 16 (WebCore::Database::transaction): Ditto 17 18 * storage/SQLTransaction.cpp: 19 (WebCore::SQLTransaction::SQLTransaction): 20 (WebCore::SQLTransaction::debugStepName): 21 (WebCore::SQLTransaction::performNextStep): Update ASSERTs for the new valid steps 22 (WebCore::SQLTransaction::performPendingCallback): Ditto 23 (WebCore::SQLTransaction::postflightAndCommit): Schedule the success callback if it exists - otherwise 24 skip straight to cleanupAfterSuccessCallback() 25 (WebCore::SQLTransaction::deliverSuccessCallback): Deliver success callback on the main thread, then 26 schedule cleanupAfterSuccessCallback() 27 (WebCore::SQLTransaction::cleanupAfterSuccessCallback): Cleanup and end the transaction 28 (WebCore::SQLTransaction::handleTransactionError): 29 (WebCore::SQLTransaction::deliverTransactionErrorCallback): 30 (WebCore::SQLTransaction::cleanupAfterTransactionErrorCallback): 31 * storage/SQLTransaction.h: 32 1 33 2008-02-12 Steve Falkenburg <sfalken@apple.com> 2 34 -
trunk/WebCore/platform/SecurityOrigin.cpp
r30009 r30184 55 55 56 56 SecurityOrigin::SecurityOrigin(const String& protocol, const String& host, unsigned short port) 57 : m_protocol(protocol. lower())58 , m_host(host. lower())57 : m_protocol(protocol.isNull() ? "" : protocol.lower()) 58 , m_host(host.isNull() ? "" : host.lower()) 59 59 , m_port(port) 60 60 , m_portSet(port) … … 64 64 // These protocols do not create security origins; the owner frame provides the origin 65 65 if (m_protocol == "about" || m_protocol == "javascript") 66 m_protocol = String();66 m_protocol = ""; 67 67 68 68 // data: URLs are not allowed access to anything other than themselves. -
trunk/WebCore/storage/Database.cpp
r30172 r30184 425 425 PassRefPtr<VoidCallback> successCallback) 426 426 { 427 // FIXME: pass successCallback, too. 428 m_transactionQueue.append(new SQLTransaction(this, callback, errorCallback, new ChangeVersionWrapper(oldVersion, newVersion))); 427 m_transactionQueue.append(new SQLTransaction(this, callback, errorCallback, successCallback, new ChangeVersionWrapper(oldVersion, newVersion))); 429 428 MutexLocker locker(m_transactionInProgressMutex); 430 429 if (!m_transactionInProgress) … … 435 434 PassRefPtr<VoidCallback> successCallback) 436 435 { 437 // FIXME: pass successCallback, too. 438 m_transactionQueue.append(new SQLTransaction(this, callback, errorCallback, 0)); 436 m_transactionQueue.append(new SQLTransaction(this, callback, errorCallback, successCallback, 0)); 439 437 MutexLocker locker(m_transactionInProgressMutex); 440 438 if (!m_transactionInProgress) -
trunk/WebCore/storage/SQLTransaction.cpp
r30172 r30184 57 57 namespace WebCore { 58 58 59 SQLTransaction::SQLTransaction(Database* db, PassRefPtr<SQLTransactionCallback> callback, PassRefPtr<SQLTransactionErrorCallback> errorCallback, PassRefPtr<SQLTransactionWrapper> wrapper) 59 SQLTransaction::SQLTransaction(Database* db, PassRefPtr<SQLTransactionCallback> callback, PassRefPtr<SQLTransactionErrorCallback> errorCallback, PassRefPtr<VoidCallback> successCallback, 60 PassRefPtr<SQLTransactionWrapper> wrapper) 60 61 : m_nextStep(&SQLTransaction::openTransactionAndPreflight) 61 62 , m_executeSqlAllowed(false) … … 63 64 , m_wrapper(wrapper) 64 65 , m_callback(callback) 66 , m_successCallback(successCallback) 65 67 , m_errorCallback(errorCallback) 66 68 , m_shouldRetryCurrentStatement(false) … … 119 121 else if (step == &SQLTransaction::deliverQuotaIncreaseCallback) 120 122 return "deliverQuotaIncreaseCallback"; 123 else if (step == &SQLTransaction::deliverSuccessCallback) 124 return "deliverSuccessCallback"; 125 else if (step == &SQLTransaction::cleanupAfterSuccessCallback) 126 return "cleanupAfterSuccessCallback"; 121 127 else 122 128 return "UNKNOWN"; … … 131 137 m_nextStep == &SQLTransaction::runStatements || 132 138 m_nextStep == &SQLTransaction::postflightAndCommit || 139 m_nextStep == &SQLTransaction::cleanupAfterSuccessCallback || 133 140 m_nextStep == &SQLTransaction::cleanupAfterTransactionErrorCallback); 134 141 … … 146 153 m_nextStep == &SQLTransaction::deliverTransactionErrorCallback || 147 154 m_nextStep == &SQLTransaction::deliverStatementCallback || 148 m_nextStep == &SQLTransaction::deliverQuotaIncreaseCallback); 155 m_nextStep == &SQLTransaction::deliverQuotaIncreaseCallback || 156 m_nextStep == &SQLTransaction::deliverSuccessCallback); 149 157 150 158 (this->*m_nextStep)(); … … 395 403 DatabaseTracker::tracker().scheduleNotifyDatabaseChanged(m_database->m_securityOrigin.get(), m_database->m_name); 396 404 397 // Transaction Step 10 - End transaction steps 405 // Now release our unneeded callbacks, to break reference cycles. 406 m_callback = 0; 407 m_errorCallback = 0; 408 409 // Transaction Step 10 - Deliver success callback, if there is one 410 if (m_successCallback) { 411 m_nextStep = &SQLTransaction::deliverSuccessCallback; 412 LOG(StorageAPI, "Scheduling deliverSuccessCallback for transaction %p\n", this); 413 m_database->scheduleTransactionCallback(this); 414 } else 415 cleanupAfterSuccessCallback(); 416 } 417 418 void SQLTransaction::deliverSuccessCallback() 419 { 420 // Transaction Step 10 - Deliver success callback 421 ASSERT(m_successCallback); 422 m_successCallback->handleEvent(); 423 424 // Release the last callback to break reference cycle 425 m_successCallback = 0; 426 427 // Schedule a "post-success callback" step to return control to the database thread in case there 428 // are further transactions queued up for this Database 429 m_nextStep = &SQLTransaction::cleanupAfterSuccessCallback; 430 LOG(StorageAPI, "Scheduling cleanupAfterSuccessCallback for transaction %p\n", this); 431 m_database->scheduleTransactionStep(this); 432 } 433 434 void SQLTransaction::cleanupAfterSuccessCallback() 435 { 436 // Transaction Step 11 - End transaction steps 398 437 // There is no next step 399 438 LOG(StorageAPI, "Transaction %p is complete\n", this); 400 439 ASSERT(!m_database->m_sqliteDatabase.transactionInProgress()); 401 440 m_nextStep = 0; 402 403 // Now release our callbacks, to break reference cycles.404 m_callback = 0;405 m_errorCallback = 0;406 441 } 407 442 … … 419 454 } 420 455 421 // Transaction Step 1 1- If the callback couldn't be called, then rollback the transaction.456 // Transaction Step 12 - If the callback couldn't be called, then rollback the transaction. 422 457 m_shouldCommitAfterErrorCallback = false; 423 458 if (inCallback) { … … 434 469 ASSERT(m_transactionError); 435 470 436 // Transaction Step 1 1- If the callback didn't return false, then rollback the transaction.471 // Transaction Step 12 - If the callback didn't return false, then rollback the transaction. 437 472 // This includes the callback not existing, returning true, or throwing an exception 438 473 if (!m_errorCallback || m_errorCallback->handleEvent(m_transactionError.get())) … … 448 483 m_database->m_databaseAuthorizer->disable(); 449 484 if (m_sqliteTransaction) { 450 // Transaction Step 1 1-If the error callback returned false, and the last error wasn't itself a485 // Transaction Step 12 -If the error callback returned false, and the last error wasn't itself a 451 486 // failure when committing the transaction, then try to commit the transaction 452 487 if (m_shouldCommitAfterErrorCallback) … … 454 489 455 490 if (m_sqliteTransaction->inProgress()) { 456 // Transaction Step 1 1- If that fails, or if the callback couldn't be called491 // Transaction Step 12 - If that fails, or if the callback couldn't be called 457 492 // or if it didn't return false, then rollback the transaction. 458 493 m_sqliteTransaction->rollback(); … … 467 502 m_database->m_databaseAuthorizer->enable(); 468 503 469 // Transaction Step 1 1- Any still-pending statements in the transaction are discarded.504 // Transaction Step 12 - Any still-pending statements in the transaction are discarded. 470 505 { 471 506 MutexLocker locker(m_statementMutex); -
trunk/WebCore/storage/SQLTransaction.h
r30172 r30184 52 52 class SQLValue; 53 53 class String; 54 class VoidCallback; 54 55 55 56 class SQLTransactionWrapper : public ThreadSafeShared<SQLTransactionWrapper> { … … 64 65 class SQLTransaction : public ThreadSafeShared<SQLTransaction> { 65 66 public: 66 SQLTransaction(Database*, PassRefPtr<SQLTransactionCallback>, PassRefPtr<SQLTransactionErrorCallback>, PassRefPtr< SQLTransactionWrapper>);67 SQLTransaction(Database*, PassRefPtr<SQLTransactionCallback>, PassRefPtr<SQLTransactionErrorCallback>, PassRefPtr<VoidCallback>, PassRefPtr<SQLTransactionWrapper>); 67 68 ~SQLTransaction(); 68 69 … … 91 92 void deliverQuotaIncreaseCallback(); 92 93 void postflightAndCommit(); 94 void deliverSuccessCallback(); 95 void cleanupAfterSuccessCallback(); 93 96 void handleTransactionError(bool inCallback); 94 97 void deliverTransactionErrorCallback(); … … 106 109 RefPtr<SQLTransactionWrapper> m_wrapper; 107 110 RefPtr<SQLTransactionCallback> m_callback; 111 RefPtr<VoidCallback> m_successCallback; 108 112 RefPtr<SQLTransactionErrorCallback> m_errorCallback; 109 113 RefPtr<SQLError> m_transactionError;
Note:
See TracChangeset
for help on using the changeset viewer.