Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Side by Side Diff: third_party/WebKit/Source/modules/indexeddb/IDBRequest.cpp

Issue 2349413002: Minor IndexedDB refactorings. (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 ackReceivedBlobs(value.get()); 316 ackReceivedBlobs(value.get());
317 317
318 if (m_pendingCursor) { 318 if (m_pendingCursor) {
319 // Value should be null, signifying the end of the cursor's range. 319 // Value should be null, signifying the end of the cursor's range.
320 ASSERT(value->isNull()); 320 ASSERT(value->isNull());
321 ASSERT(!value->blobInfo()->size()); 321 ASSERT(!value->blobInfo()->size());
322 m_pendingCursor->close(); 322 m_pendingCursor->close();
323 m_pendingCursor.clear(); 323 m_pendingCursor.clear();
324 } 324 }
325 325
326 #if ENABLE(ASSERT) 326 #if ENABLE(ASSERT)
cmumford 2016/09/19 23:26:48 If switching to DCHECK should you also switch to:
pwnall 2016/09/20 09:11:14 Done. I also did a bunch more ASSERT->DCHECK chan
327 if (value->primaryKey()) { 327 if (value->primaryKey()) {
328 ASSERT(value->keyPath() == effectiveObjectStore(m_source)->metadata().ke yPath); 328 DCHECK(value->keyPath() == effectiveObjectStore(m_source)->idbKeyPath()) ;
329 assertPrimaryKeyValidOrInjectable(m_scriptState.get(), value.get()); 329 assertPrimaryKeyValidOrInjectable(m_scriptState.get(), value.get());
330 } 330 }
331 #endif 331 #endif
332 332
333 onSuccessInternal(IDBAny::create(value.release())); 333 onSuccessInternal(IDBAny::create(value.release()));
334 } 334 }
335 335
336 void IDBRequest::onSuccess(int64_t value) 336 void IDBRequest::onSuccess(int64_t value)
337 { 337 {
338 IDB_TRACE("IDBRequest::onSuccess(int64_t)"); 338 IDB_TRACE("IDBRequest::onSuccess(int64_t)");
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 ExecutionContext* IDBRequest::getExecutionContext() const 413 ExecutionContext* IDBRequest::getExecutionContext() const
414 { 414 {
415 return ActiveDOMObject::getExecutionContext(); 415 return ActiveDOMObject::getExecutionContext();
416 } 416 }
417 417
418 DispatchEventResult IDBRequest::dispatchEventInternal(Event* event) 418 DispatchEventResult IDBRequest::dispatchEventInternal(Event* event)
419 { 419 {
420 IDB_TRACE("IDBRequest::dispatchEvent"); 420 IDB_TRACE("IDBRequest::dispatchEvent");
421 if (m_contextStopped || !getExecutionContext()) 421 if (m_contextStopped || !getExecutionContext())
422 return DispatchEventResult::CanceledBeforeDispatch; 422 return DispatchEventResult::CanceledBeforeDispatch;
423 ASSERT(m_readyState == PENDING); 423 DCHECK_EQ(m_readyState, PENDING);
424 ASSERT(m_hasPendingActivity); 424 DCHECK(m_hasPendingActivity);
425 ASSERT(m_enqueuedEvents.size()); 425 DCHECK(m_enqueuedEvents.size());
426 ASSERT(event->target() == this); 426 DCHECK_EQ(event->target(), this);
427 427
428 ScriptState::Scope scope(m_scriptState.get()); 428 ScriptState::Scope scope(m_scriptState.get());
429 429
430 if (event->type() != EventTypeNames::blocked) 430 if (event->type() != EventTypeNames::blocked)
431 m_readyState = DONE; 431 m_readyState = DONE;
432 dequeueEvent(event); 432 dequeueEvent(event);
433 433
434 HeapVector<Member<EventTarget>> targets; 434 HeapVector<Member<EventTarget>> targets;
435 targets.append(this); 435 targets.append(this);
436 if (m_transaction && !m_preventPropagation) { 436 if (m_transaction && !m_preventPropagation) {
437 targets.append(m_transaction); 437 targets.append(m_transaction);
438 // If there ever are events that are associated with a database but 438 // If there ever are events that are associated with a database but
439 // that do not have a transaction, then this will not work and we need 439 // that do not have a transaction, then this will not work and we need
440 // this object to actually hold a reference to the database (to ensure 440 // this object to actually hold a reference to the database (to ensure
441 // it stays alive). 441 // it stays alive).
442 targets.append(m_transaction->db()); 442 targets.append(m_transaction->db());
443 } 443 }
444 444
445 // Cursor properties should not be updated until the success event is being dispatched. 445 // Cursor properties should not be updated until the success event is being dispatched.
446 IDBCursor* cursorToNotify = nullptr; 446 IDBCursor* cursorToNotify = nullptr;
447 if (event->type() == EventTypeNames::success) { 447 if (event->type() == EventTypeNames::success) {
448 cursorToNotify = getResultCursor(); 448 cursorToNotify = getResultCursor();
449 if (cursorToNotify) 449 if (cursorToNotify)
450 cursorToNotify->setValueReady(m_cursorKey.release(), m_cursorPrimary Key.release(), m_cursorValue.release()); 450 cursorToNotify->setValueReady(m_cursorKey.release(), m_cursorPrimary Key.release(), m_cursorValue.release());
451 } 451 }
452 452
453 if (event->type() == EventTypeNames::upgradeneeded) { 453 if (event->type() == EventTypeNames::upgradeneeded) {
454 ASSERT(!m_didFireUpgradeNeededEvent); 454 DCHECK(!m_didFireUpgradeNeededEvent);
455 m_didFireUpgradeNeededEvent = true; 455 m_didFireUpgradeNeededEvent = true;
456 } 456 }
457 457
458 // FIXME: When we allow custom event dispatching, this will probably need to change. 458 // FIXME: When we allow custom event dispatching, this will probably need to change.
459 DCHECK(event->type() == EventTypeNames::success || event->type() == EventTyp eNames::error || event->type() == EventTypeNames::blocked || event->type() == Ev entTypeNames::upgradeneeded) << "event type was " << event->type(); 459 DCHECK(event->type() == EventTypeNames::success || event->type() == EventTyp eNames::error || event->type() == EventTypeNames::blocked || event->type() == Ev entTypeNames::upgradeneeded) << "event type was " << event->type();
460 const bool setTransactionActive = m_transaction && (event->type() == EventTy peNames::success || event->type() == EventTypeNames::upgradeneeded || (event->ty pe() == EventTypeNames::error && !m_requestAborted)); 460 const bool setTransactionActive = m_transaction && (event->type() == EventTy peNames::success || event->type() == EventTypeNames::upgradeneeded || (event->ty pe() == EventTypeNames::error && !m_requestAborted));
461 461
462 if (setTransactionActive) 462 if (setTransactionActive)
463 m_transaction->setActive(true); 463 m_transaction->setActive(true);
464 464
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 535
536 void IDBRequest::dequeueEvent(Event* event) 536 void IDBRequest::dequeueEvent(Event* event)
537 { 537 {
538 for (size_t i = 0; i < m_enqueuedEvents.size(); ++i) { 538 for (size_t i = 0; i < m_enqueuedEvents.size(); ++i) {
539 if (m_enqueuedEvents[i].get() == event) 539 if (m_enqueuedEvents[i].get() == event)
540 m_enqueuedEvents.remove(i); 540 m_enqueuedEvents.remove(i);
541 } 541 }
542 } 542 }
543 543
544 } // namespace blink 544 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698