Changeset 135332 in webkit
- Timestamp:
- Nov 20, 2012, 4:35:09 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r135329 r135332 1 2012-11-20 Joshua Bell <jsbell@chromium.org> 2 3 IndexedDB: Move control of transaction completion to front end 4 https://bugs.webkit.org/show_bug.cgi?id=100903 5 6 Reviewed by Tony Chang. 7 8 "When a transaction can no longer become active, the implementation must attempt to 9 commit it" - that is, all requests have dispatched success/error events and no further 10 requests have been made. Previously, this was done by the back end waiting for events 11 from the front end, but the front end can more efficiently make the decision. 12 13 There should be no detectable behavior change. 14 15 Tests: storage/indexeddb/transaction-*.html 16 17 * Modules/indexeddb/IDBTransaction.cpp: 18 (WebCore::IDBTransaction::IDBTransaction): 19 (WebCore::IDBTransaction::setActive): 20 (WebCore::IDBTransaction::registerRequest): 21 * Modules/indexeddb/IDBTransaction.h: 22 * Modules/indexeddb/IDBTransactionBackendImpl.cpp: 23 (WebCore::IDBTransactionBackendImpl::hasPendingTasks): Added. 24 (WebCore::IDBTransactionBackendImpl::didCompleteTaskEvents): 25 (WebCore::IDBTransactionBackendImpl::run): 26 (WebCore::IDBTransactionBackendImpl::taskEventTimerFired): 27 1 28 2012-11-20 Kentaro Hara <haraken@chromium.org> 2 29 -
trunk/Source/WebCore/Modules/indexeddb/IDBRequest.cpp
r134989 r135332 501 501 502 502 bool dontPreventDefault = IDBEventDispatcher::dispatch(event.get(), targets); 503 504 if (m_transaction && m_readyState == DONE) 505 m_transaction->unregisterRequest(this); 506 507 // If this was the last request in the transaction's list, it may commit here. 503 508 if (setTransactionActive) 504 509 m_transaction->setActive(false); … … 519 524 if (event->type() != eventNames().blockedEvent) 520 525 m_transaction->backend()->didCompleteTaskEvents(); 521 522 if (m_readyState == DONE)523 m_transaction->unregisterRequest(this);524 526 } 525 527 -
trunk/Source/WebCore/Modules/indexeddb/IDBTransaction.cpp
r135308 r135332 96 96 , m_openDBRequest(openDBRequest) 97 97 , m_mode(mode) 98 , m_active(true) 99 , m_state(Unused) 98 , m_state(Active) 100 99 , m_hasPendingActivity(true) 101 100 , m_contextStopped(false) … … 105 104 if (mode == VERSION_CHANGE) { 106 105 // Not active until the callback. 107 m_active = false; 108 // Implicitly used by the version change itself. 109 m_state = Used; 106 m_state = Inactive; 110 107 } 111 108 112 109 // We pass a reference of this object before it can be adopted. 113 110 relaxAdoptionRequirement(); 114 if (m_ active)111 if (m_state == Active) 115 112 IDBPendingTransactionMonitor::addNewTransaction(this); 116 113 m_database->transactionCreated(this); … … 207 204 if (m_state == Finishing) 208 205 return; 209 ASSERT(m_state == Unused || m_state == Used); 210 ASSERT(active != m_active); 211 m_active = active; 212 213 if (!active && m_state == Unused) 206 ASSERT(active != (m_state == Active)); 207 m_state = active ? Active : Inactive; 208 209 if (!active && m_requestList.isEmpty()) 214 210 m_backend->commit(); 215 211 } … … 223 219 224 220 m_state = Finishing; 225 m_active = false;226 221 227 222 while (!m_requestList.isEmpty()) { … … 279 274 { 280 275 ASSERT(request); 281 ASSERT(m_state == Unused || m_state == Used); 282 ASSERT(m_active); 276 ASSERT(m_state == Active); 283 277 m_requestList.add(request); 284 m_state = Used;285 278 } 286 279 -
trunk/Source/WebCore/Modules/indexeddb/IDBTransaction.h
r134040 r135332 71 71 72 72 IDBTransactionBackendInterface* backend() const; 73 bool isActive() const { return m_ active; }73 bool isActive() const { return m_state == Active; } 74 74 bool isFinished() const { return m_state == Finished; } 75 75 bool isReadOnly() const { return m_mode == READ_ONLY; } … … 138 138 139 139 enum State { 140 Unused, // No requests have been made.141 Used, // At least one request has been made.140 Inactive, // Created or started, but not in an event callback 141 Active, // Created or started, in creation scope or an event callback 142 142 Finishing, // In the process of aborting or completing. 143 143 Finished, // No more events will fire and no new requests may be filed. … … 149 149 IDBOpenDBRequest* m_openDBRequest; 150 150 const Mode m_mode; 151 bool m_active;152 151 State m_state; 153 152 bool m_hasPendingActivity; -
trunk/Source/WebCore/Modules/indexeddb/IDBTransactionBackendImpl.cpp
r134968 r135332 152 152 } 153 153 154 bool IDBTransactionBackendImpl::hasPendingTasks() const 155 { 156 return m_pendingEvents || m_pendingPreemptiveEvents || !isTaskQueueEmpty(); 157 } 158 154 159 void IDBTransactionBackendImpl::registerOpenCursor(IDBCursorBackendImpl* cursor) 155 160 { … … 177 182 m_pendingEvents--; 178 183 184 // A single task has completed and error/success events fired. Schedule 185 // timer to process another. 179 186 if (!m_taskEventTimer.isActive()) 180 187 m_taskEventTimer.startOneShot(0); … … 183 190 void IDBTransactionBackendImpl::run() 184 191 { 192 // TransactionCoordinator has started this transaction. Schedule a timer 193 // to process the first task. 185 194 ASSERT(m_state == StartPending || m_state == Running); 186 195 ASSERT(!m_taskTimer.isActive()); … … 201 210 { 202 211 IDB_TRACE("IDBTransactionBackendImpl::commit"); 212 213 ASSERT(m_state == Unused || m_state == Running); 214 215 // Front-end has requested a commit, but there may be tasks like createIndex which 216 // are considered synchronous by the front-end but are processed asynchronously. 217 if (hasPendingTasks()) 218 return; 219 203 220 // The last reference to this object may be released while performing the 204 221 // commit steps below. We therefore take a self reference to keep ourselves 205 222 // alive while executing this method. 206 223 RefPtr<IDBTransactionBackendImpl> protect(this); 207 ASSERT(m_state == Unused || m_state == Running);208 ASSERT(isTaskQueueEmpty());209 224 210 225 bool unused = m_state == Unused; … … 268 283 ASSERT(m_state == Running); 269 284 270 if (! m_pendingEvents && !m_pendingPreemptiveEvents && isTaskQueueEmpty()) {285 if (!hasPendingTasks()) { 271 286 // The last task event has completed and the task 272 287 // queue is empty. Commit the transaction. -
trunk/Source/WebCore/Modules/indexeddb/IDBTransactionBackendImpl.h
r134129 r135332 75 75 enum State { 76 76 Unused, // Created, but no tasks yet. 77 StartPending, // Enqueued tasks, but SQLite transaction not yet started.78 Running, // SQLite transaction started but not yet finished.77 StartPending, // Enqueued tasks, but backing store transaction not yet started. 78 Running, // Backing store transaction started but not yet finished. 79 79 Finished, // Either aborted or committed. 80 80 }; … … 84 84 85 85 bool isTaskQueueEmpty() const; 86 bool hasPendingTasks() const; 86 87 87 88 void taskTimerFired(Timer<IDBTransactionBackendImpl>*);
Note:
See TracChangeset
for help on using the changeset viewer.