Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google 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 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 300 | 300 |
| 301 abortOutstandingRequests(); | 301 abortOutstandingRequests(); |
| 302 revertDatabaseMetadata(); | 302 revertDatabaseMetadata(); |
| 303 | 303 |
| 304 m_state = Finishing; | 304 m_state = Finishing; |
| 305 } | 305 } |
| 306 | 306 |
| 307 if (isVersionChange()) | 307 if (isVersionChange()) |
| 308 m_database->close(); | 308 m_database->close(); |
| 309 | 309 |
| 310 // Enqueue events before notifying database, as database may close which enque ues more events and order matters. | 310 // Enqueue events before notifying database, as database may close which |
| 311 // enqueues more events and order matters. | |
| 311 enqueueEvent(Event::createBubble(EventTypeNames::abort)); | 312 enqueueEvent(Event::createBubble(EventTypeNames::abort)); |
| 312 finished(); | 313 finished(); |
| 313 } | 314 } |
| 314 | 315 |
| 315 void IDBTransaction::onComplete() { | 316 void IDBTransaction::onComplete() { |
| 316 IDB_TRACE("IDBTransaction::onComplete"); | 317 IDB_TRACE("IDBTransaction::onComplete"); |
| 317 if (m_contextStopped) { | 318 if (m_contextStopped) { |
| 318 finished(); | 319 finished(); |
| 319 return; | 320 return; |
| 320 } | 321 } |
| 321 | 322 |
| 322 DCHECK_NE(m_state, Finished); | 323 DCHECK_NE(m_state, Finished); |
| 323 m_state = Finishing; | 324 m_state = Finishing; |
| 324 | 325 |
| 325 // Enqueue events before notifying database, as database may close which enque ues more events and order matters. | 326 // Enqueue events before notifying database, as database may close which |
| 327 // enqueues more events and order matters. | |
| 326 enqueueEvent(Event::create(EventTypeNames::complete)); | 328 enqueueEvent(Event::create(EventTypeNames::complete)); |
| 327 finished(); | 329 finished(); |
| 328 } | 330 } |
| 329 | 331 |
| 330 bool IDBTransaction::hasPendingActivity() const { | 332 bool IDBTransaction::hasPendingActivity() const { |
| 331 // FIXME: In an ideal world, we should return true as long as anyone has a or can | 333 // FIXME: In an ideal world, we should return true as long as anyone has a or |
|
dcheng
2016/10/04 23:03:04
Nit: same comment about FIXME; alignment
Nico
2016/10/05 01:33:17
Done.
| |
| 332 // get a handle to us or any child request object and any of those have | 334 // can get a handle to us or any child request object and any of those |
| 333 // event listeners. This is in order to handle user generated events p roperly. | 335 // have event listeners. This is in order to handle user generated |
| 336 // events properly. | |
| 334 return m_hasPendingActivity && !m_contextStopped; | 337 return m_hasPendingActivity && !m_contextStopped; |
| 335 } | 338 } |
| 336 | 339 |
| 337 WebIDBTransactionMode IDBTransaction::stringToMode(const String& modeString) { | 340 WebIDBTransactionMode IDBTransaction::stringToMode(const String& modeString) { |
| 338 if (modeString == IndexedDBNames::readonly) | 341 if (modeString == IndexedDBNames::readonly) |
| 339 return WebIDBTransactionModeReadOnly; | 342 return WebIDBTransactionModeReadOnly; |
| 340 if (modeString == IndexedDBNames::readwrite) | 343 if (modeString == IndexedDBNames::readwrite) |
| 341 return WebIDBTransactionModeReadWrite; | 344 return WebIDBTransactionModeReadWrite; |
| 342 if (modeString == IndexedDBNames::versionchange) | 345 if (modeString == IndexedDBNames::versionchange) |
| 343 return WebIDBTransactionModeVersionChange; | 346 return WebIDBTransactionModeVersionChange; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 394 DCHECK_NE(m_state, Finished); | 397 DCHECK_NE(m_state, Finished); |
| 395 DCHECK(m_hasPendingActivity); | 398 DCHECK(m_hasPendingActivity); |
| 396 DCHECK(getExecutionContext()); | 399 DCHECK(getExecutionContext()); |
| 397 DCHECK_EQ(event->target(), this); | 400 DCHECK_EQ(event->target(), this); |
| 398 m_state = Finished; | 401 m_state = Finished; |
| 399 | 402 |
| 400 HeapVector<Member<EventTarget>> targets; | 403 HeapVector<Member<EventTarget>> targets; |
| 401 targets.append(this); | 404 targets.append(this); |
| 402 targets.append(db()); | 405 targets.append(db()); |
| 403 | 406 |
| 404 // FIXME: When we allow custom event dispatching, this will probably need to c hange. | 407 // FIXME: When we allow custom event dispatching, this will probably need to |
| 408 // change. | |
| 405 DCHECK(event->type() == EventTypeNames::complete || | 409 DCHECK(event->type() == EventTypeNames::complete || |
| 406 event->type() == EventTypeNames::abort); | 410 event->type() == EventTypeNames::abort); |
| 407 DispatchEventResult dispatchResult = | 411 DispatchEventResult dispatchResult = |
| 408 IDBEventDispatcher::dispatch(event, targets); | 412 IDBEventDispatcher::dispatch(event, targets); |
| 409 // FIXME: Try to construct a test where |this| outlives openDBRequest and we | 413 // FIXME: Try to construct a test where |this| outlives openDBRequest and we |
| 410 // get a crash. | 414 // get a crash. |
| 411 if (m_openDBRequest) { | 415 if (m_openDBRequest) { |
| 412 DCHECK(isVersionChange()); | 416 DCHECK(isVersionChange()); |
| 413 m_openDBRequest->transactionDidFinishAndDispatch(); | 417 m_openDBRequest->transactionDidFinishAndDispatch(); |
| 414 } | 418 } |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 478 m_objectStoreMap.clear(); | 482 m_objectStoreMap.clear(); |
| 479 for (auto& it : m_deletedObjectStores) | 483 for (auto& it : m_deletedObjectStores) |
| 480 it->transactionFinished(); | 484 it->transactionFinished(); |
| 481 m_createdObjectStores.clear(); | 485 m_createdObjectStores.clear(); |
| 482 m_deletedObjectStores.clear(); | 486 m_deletedObjectStores.clear(); |
| 483 | 487 |
| 484 m_objectStoreCleanupMap.clear(); | 488 m_objectStoreCleanupMap.clear(); |
| 485 } | 489 } |
| 486 | 490 |
| 487 } // namespace blink | 491 } // namespace blink |
| OLD | NEW |