| 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 11 matching lines...) Expand all Loading... |
| 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 */ | 27 */ |
| 28 | 28 |
| 29 #include "config.h" | 29 #include "config.h" |
| 30 #include "modules/indexeddb/IDBRequest.h" | 30 #include "modules/indexeddb/IDBRequest.h" |
| 31 | 31 |
| 32 #include "bindings/v8/ExceptionStatePlaceholder.h" |
| 32 #include "bindings/v8/IDBBindingUtilities.h" | 33 #include "bindings/v8/IDBBindingUtilities.h" |
| 33 #include "core/dom/DOMError.h" | 34 #include "core/dom/DOMError.h" |
| 34 #include "core/dom/EventListener.h" | 35 #include "core/dom/EventListener.h" |
| 35 #include "core/dom/EventNames.h" | 36 #include "core/dom/EventNames.h" |
| 36 #include "core/dom/EventQueue.h" | 37 #include "core/dom/EventQueue.h" |
| 37 #include "core/dom/ExceptionCode.h" | |
| 38 #include "core/dom/ExceptionCodePlaceholder.h" | |
| 39 #include "core/dom/ScriptExecutionContext.h" | 38 #include "core/dom/ScriptExecutionContext.h" |
| 40 #include "modules/indexeddb/IDBCursorBackendInterface.h" | 39 #include "modules/indexeddb/IDBCursorBackendInterface.h" |
| 41 #include "modules/indexeddb/IDBCursorWithValue.h" | 40 #include "modules/indexeddb/IDBCursorWithValue.h" |
| 42 #include "modules/indexeddb/IDBDatabase.h" | 41 #include "modules/indexeddb/IDBDatabase.h" |
| 43 #include "modules/indexeddb/IDBEventDispatcher.h" | 42 #include "modules/indexeddb/IDBEventDispatcher.h" |
| 44 #include "modules/indexeddb/IDBTracing.h" | 43 #include "modules/indexeddb/IDBTracing.h" |
| 45 #include "modules/indexeddb/IDBTransaction.h" | 44 #include "modules/indexeddb/IDBTransaction.h" |
| 46 | 45 |
| 47 namespace WebCore { | 46 namespace WebCore { |
| 48 | 47 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 , m_requestState(context) | 84 , m_requestState(context) |
| 86 { | 85 { |
| 87 ScriptWrappable::init(this); | 86 ScriptWrappable::init(this); |
| 88 } | 87 } |
| 89 | 88 |
| 90 IDBRequest::~IDBRequest() | 89 IDBRequest::~IDBRequest() |
| 91 { | 90 { |
| 92 ASSERT(m_readyState == DONE || m_readyState == EarlyDeath || !scriptExecutio
nContext()); | 91 ASSERT(m_readyState == DONE || m_readyState == EarlyDeath || !scriptExecutio
nContext()); |
| 93 } | 92 } |
| 94 | 93 |
| 95 PassRefPtr<IDBAny> IDBRequest::result(ExceptionCode& ec) const | 94 PassRefPtr<IDBAny> IDBRequest::result(ExceptionState& es) const |
| 96 { | 95 { |
| 97 if (m_readyState != DONE) { | 96 if (m_readyState != DONE) { |
| 98 ec = InvalidStateError; | 97 es.throwDOMException(InvalidStateError); |
| 99 return 0; | 98 return 0; |
| 100 } | 99 } |
| 101 return m_result; | 100 return m_result; |
| 102 } | 101 } |
| 103 | 102 |
| 104 PassRefPtr<DOMError> IDBRequest::error(ExceptionCode& ec) const | 103 PassRefPtr<DOMError> IDBRequest::error(ExceptionState& es) const |
| 105 { | 104 { |
| 106 if (m_readyState != DONE) { | 105 if (m_readyState != DONE) { |
| 107 ec = InvalidStateError; | 106 es.throwDOMException(InvalidStateError); |
| 108 return 0; | 107 return 0; |
| 109 } | 108 } |
| 110 return m_error; | 109 return m_error; |
| 111 } | 110 } |
| 112 | 111 |
| 113 PassRefPtr<IDBAny> IDBRequest::source() const | 112 PassRefPtr<IDBAny> IDBRequest::source() const |
| 114 { | 113 { |
| 115 return m_source; | 114 return m_source; |
| 116 } | 115 } |
| 117 | 116 |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 bool dontPreventDefault = IDBEventDispatcher::dispatch(event.get(), targets)
; | 480 bool dontPreventDefault = IDBEventDispatcher::dispatch(event.get(), targets)
; |
| 482 | 481 |
| 483 if (m_transaction) { | 482 if (m_transaction) { |
| 484 if (m_readyState == DONE) | 483 if (m_readyState == DONE) |
| 485 m_transaction->unregisterRequest(this); | 484 m_transaction->unregisterRequest(this); |
| 486 | 485 |
| 487 // Possibly abort the transaction. This must occur after unregistering (
so this request | 486 // Possibly abort the transaction. This must occur after unregistering (
so this request |
| 488 // doesn't receive a second error) and before deactivating (which might
trigger commit). | 487 // doesn't receive a second error) and before deactivating (which might
trigger commit). |
| 489 if (event->type() == eventNames().errorEvent && dontPreventDefault && !m
_requestAborted) { | 488 if (event->type() == eventNames().errorEvent && dontPreventDefault && !m
_requestAborted) { |
| 490 m_transaction->setError(m_error); | 489 m_transaction->setError(m_error); |
| 491 m_transaction->abort(IGNORE_EXCEPTION); | 490 m_transaction->abort(IGNORE_EXCEPTION_STATE); |
| 492 } | 491 } |
| 493 | 492 |
| 494 // If this was the last request in the transaction's list, it may commit
here. | 493 // If this was the last request in the transaction's list, it may commit
here. |
| 495 if (setTransactionActive) | 494 if (setTransactionActive) |
| 496 m_transaction->setActive(false); | 495 m_transaction->setActive(false); |
| 497 } | 496 } |
| 498 | 497 |
| 499 if (cursorToNotify) | 498 if (cursorToNotify) |
| 500 cursorToNotify->postSuccessHandlerCallback(); | 499 cursorToNotify->postSuccessHandlerCallback(); |
| 501 | 500 |
| 502 if (m_readyState == DONE && (!cursorToNotify || m_cursorFinished) && event->
type() != eventNames().upgradeneededEvent) | 501 if (m_readyState == DONE && (!cursorToNotify || m_cursorFinished) && event->
type() != eventNames().upgradeneededEvent) |
| 503 m_hasPendingActivity = false; | 502 m_hasPendingActivity = false; |
| 504 | 503 |
| 505 return dontPreventDefault; | 504 return dontPreventDefault; |
| 506 } | 505 } |
| 507 | 506 |
| 508 void IDBRequest::uncaughtExceptionInEventHandler() | 507 void IDBRequest::uncaughtExceptionInEventHandler() |
| 509 { | 508 { |
| 510 if (m_transaction && !m_requestAborted) { | 509 if (m_transaction && !m_requestAborted) { |
| 511 m_transaction->setError(DOMError::create(AbortError, "Uncaught exception
in event handler.")); | 510 m_transaction->setError(DOMError::create(AbortError, "Uncaught exception
in event handler.")); |
| 512 m_transaction->abort(IGNORE_EXCEPTION); | 511 m_transaction->abort(IGNORE_EXCEPTION_STATE); |
| 513 } | 512 } |
| 514 } | 513 } |
| 515 | 514 |
| 516 void IDBRequest::transactionDidFinishAndDispatch() | 515 void IDBRequest::transactionDidFinishAndDispatch() |
| 517 { | 516 { |
| 518 ASSERT(m_transaction); | 517 ASSERT(m_transaction); |
| 519 ASSERT(m_transaction->isVersionChange()); | 518 ASSERT(m_transaction->isVersionChange()); |
| 520 ASSERT(m_readyState == DONE); | 519 ASSERT(m_readyState == DONE); |
| 521 ASSERT(scriptExecutionContext()); | 520 ASSERT(scriptExecutionContext()); |
| 522 m_transaction.clear(); | 521 m_transaction.clear(); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 543 { | 542 { |
| 544 return &m_eventTargetData; | 543 return &m_eventTargetData; |
| 545 } | 544 } |
| 546 | 545 |
| 547 EventTargetData* IDBRequest::ensureEventTargetData() | 546 EventTargetData* IDBRequest::ensureEventTargetData() |
| 548 { | 547 { |
| 549 return &m_eventTargetData; | 548 return &m_eventTargetData; |
| 550 } | 549 } |
| 551 | 550 |
| 552 } // namespace WebCore | 551 } // namespace WebCore |
| OLD | NEW |