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 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 const AtomicString& IDBRequest::interfaceName() const | 403 const AtomicString& IDBRequest::interfaceName() const |
404 { | 404 { |
405 return EventTargetNames::IDBRequest; | 405 return EventTargetNames::IDBRequest; |
406 } | 406 } |
407 | 407 |
408 ExecutionContext* IDBRequest::executionContext() const | 408 ExecutionContext* IDBRequest::executionContext() const |
409 { | 409 { |
410 return ActiveDOMObject::executionContext(); | 410 return ActiveDOMObject::executionContext(); |
411 } | 411 } |
412 | 412 |
413 bool IDBRequest::dispatchEventInternal(PassRefPtrWillBeRawPtr<Event> event) | 413 DispatchEventResult IDBRequest::dispatchEventInternal(PassRefPtrWillBeRawPtr<Eve
nt> event) |
414 { | 414 { |
415 IDB_TRACE("IDBRequest::dispatchEvent"); | 415 IDB_TRACE("IDBRequest::dispatchEvent"); |
416 if (m_contextStopped || !executionContext()) | 416 if (m_contextStopped || !executionContext()) |
417 return false; | 417 return DispatchEventResult::CanceledBeforeDispatch; |
418 ASSERT(m_readyState == PENDING); | 418 ASSERT(m_readyState == PENDING); |
419 ASSERT(m_hasPendingActivity); | 419 ASSERT(m_hasPendingActivity); |
420 ASSERT(m_enqueuedEvents.size()); | 420 ASSERT(m_enqueuedEvents.size()); |
421 ASSERT(event->target() == this); | 421 ASSERT(event->target() == this); |
422 | 422 |
423 ScriptState::Scope scope(m_scriptState.get()); | 423 ScriptState::Scope scope(m_scriptState.get()); |
424 | 424 |
425 if (event->type() != EventTypeNames::blocked) | 425 if (event->type() != EventTypeNames::blocked) |
426 m_readyState = DONE; | 426 m_readyState = DONE; |
427 dequeueEvent(event.get()); | 427 dequeueEvent(event.get()); |
(...skipping 22 matching lines...) Expand all Loading... |
450 m_didFireUpgradeNeededEvent = true; | 450 m_didFireUpgradeNeededEvent = true; |
451 } | 451 } |
452 | 452 |
453 // FIXME: When we allow custom event dispatching, this will probably need to
change. | 453 // FIXME: When we allow custom event dispatching, this will probably need to
change. |
454 ASSERT_WITH_MESSAGE(event->type() == EventTypeNames::success || event->type(
) == EventTypeNames::error || event->type() == EventTypeNames::blocked || event-
>type() == EventTypeNames::upgradeneeded, "event type was %s", event->type().utf
8().data()); | 454 ASSERT_WITH_MESSAGE(event->type() == EventTypeNames::success || event->type(
) == EventTypeNames::error || event->type() == EventTypeNames::blocked || event-
>type() == EventTypeNames::upgradeneeded, "event type was %s", event->type().utf
8().data()); |
455 const bool setTransactionActive = m_transaction && (event->type() == EventTy
peNames::success || event->type() == EventTypeNames::upgradeneeded || (event->ty
pe() == EventTypeNames::error && !m_requestAborted)); | 455 const bool setTransactionActive = m_transaction && (event->type() == EventTy
peNames::success || event->type() == EventTypeNames::upgradeneeded || (event->ty
pe() == EventTypeNames::error && !m_requestAborted)); |
456 | 456 |
457 if (setTransactionActive) | 457 if (setTransactionActive) |
458 m_transaction->setActive(true); | 458 m_transaction->setActive(true); |
459 | 459 |
460 bool dontPreventDefault = IDBEventDispatcher::dispatch(event.get(), targets)
; | 460 DispatchEventResult dispatchResult = IDBEventDispatcher::dispatch(event.get(
), targets); |
461 | 461 |
462 if (m_transaction) { | 462 if (m_transaction) { |
463 if (m_readyState == DONE) | 463 if (m_readyState == DONE) |
464 m_transaction->unregisterRequest(this); | 464 m_transaction->unregisterRequest(this); |
465 | 465 |
466 // Possibly abort the transaction. This must occur after unregistering (
so this request | 466 // Possibly abort the transaction. This must occur after unregistering (
so this request |
467 // doesn't receive a second error) and before deactivating (which might
trigger commit). | 467 // doesn't receive a second error) and before deactivating (which might
trigger commit). |
468 if (event->type() == EventTypeNames::error && dontPreventDefault && !m_r
equestAborted) { | 468 if (event->type() == EventTypeNames::error && dispatchResult == Dispatch
EventResult::NotCanceled && !m_requestAborted) { |
469 m_transaction->setError(m_error); | 469 m_transaction->setError(m_error); |
470 m_transaction->abort(IGNORE_EXCEPTION); | 470 m_transaction->abort(IGNORE_EXCEPTION); |
471 } | 471 } |
472 | 472 |
473 // If this was the last request in the transaction's list, it may commit
here. | 473 // If this was the last request in the transaction's list, it may commit
here. |
474 if (setTransactionActive) | 474 if (setTransactionActive) |
475 m_transaction->setActive(false); | 475 m_transaction->setActive(false); |
476 } | 476 } |
477 | 477 |
478 if (cursorToNotify) | 478 if (cursorToNotify) |
479 cursorToNotify->postSuccessHandlerCallback(); | 479 cursorToNotify->postSuccessHandlerCallback(); |
480 | 480 |
481 // An upgradeneeded event will always be followed by a success or error even
t, so must | 481 // An upgradeneeded event will always be followed by a success or error even
t, so must |
482 // be kept alive. | 482 // be kept alive. |
483 if (m_readyState == DONE && event->type() != EventTypeNames::upgradeneeded) | 483 if (m_readyState == DONE && event->type() != EventTypeNames::upgradeneeded) |
484 m_hasPendingActivity = false; | 484 m_hasPendingActivity = false; |
485 | 485 |
486 return dontPreventDefault; | 486 return dispatchResult; |
487 } | 487 } |
488 | 488 |
489 void IDBRequest::uncaughtExceptionInEventHandler() | 489 void IDBRequest::uncaughtExceptionInEventHandler() |
490 { | 490 { |
491 if (m_transaction && !m_requestAborted) { | 491 if (m_transaction && !m_requestAborted) { |
492 m_transaction->setError(DOMException::create(AbortError, "Uncaught excep
tion in event handler.")); | 492 m_transaction->setError(DOMException::create(AbortError, "Uncaught excep
tion in event handler.")); |
493 m_transaction->abort(IGNORE_EXCEPTION); | 493 m_transaction->abort(IGNORE_EXCEPTION); |
494 } | 494 } |
495 } | 495 } |
496 | 496 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
530 | 530 |
531 void IDBRequest::dequeueEvent(Event* event) | 531 void IDBRequest::dequeueEvent(Event* event) |
532 { | 532 { |
533 for (size_t i = 0; i < m_enqueuedEvents.size(); ++i) { | 533 for (size_t i = 0; i < m_enqueuedEvents.size(); ++i) { |
534 if (m_enqueuedEvents[i].get() == event) | 534 if (m_enqueuedEvents[i].get() == event) |
535 m_enqueuedEvents.remove(i); | 535 m_enqueuedEvents.remove(i); |
536 } | 536 } |
537 } | 537 } |
538 | 538 |
539 } // namespace blink | 539 } // namespace blink |
OLD | NEW |