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 "modules/indexeddb/IDBRequest.h" | 29 #include "modules/indexeddb/IDBRequest.h" |
30 | 30 |
31 #include "bindings/core/v8/ExceptionState.h" | 31 #include "bindings/core/v8/ExceptionState.h" |
| 32 #include "bindings/core/v8/SourceLocation.h" |
32 #include "bindings/modules/v8/ToV8ForModules.h" | 33 #include "bindings/modules/v8/ToV8ForModules.h" |
33 #include "bindings/modules/v8/V8BindingForModules.h" | 34 #include "bindings/modules/v8/V8BindingForModules.h" |
34 #include "core/dom/DOMException.h" | 35 #include "core/dom/DOMException.h" |
35 #include "core/dom/ExceptionCode.h" | 36 #include "core/dom/ExceptionCode.h" |
36 #include "core/dom/ExecutionContext.h" | 37 #include "core/dom/ExecutionContext.h" |
| 38 #include "core/events/ErrorEvent.h" |
37 #include "core/events/EventQueue.h" | 39 #include "core/events/EventQueue.h" |
38 #include "modules/IndexedDBNames.h" | 40 #include "modules/IndexedDBNames.h" |
39 #include "modules/indexeddb/IDBCursorWithValue.h" | 41 #include "modules/indexeddb/IDBCursorWithValue.h" |
40 #include "modules/indexeddb/IDBDatabase.h" | 42 #include "modules/indexeddb/IDBDatabase.h" |
41 #include "modules/indexeddb/IDBEventDispatcher.h" | 43 #include "modules/indexeddb/IDBEventDispatcher.h" |
42 #include "modules/indexeddb/IDBTracing.h" | 44 #include "modules/indexeddb/IDBTracing.h" |
43 #include "modules/indexeddb/IDBValue.h" | 45 #include "modules/indexeddb/IDBValue.h" |
44 #include "modules/indexeddb/WebIDBCallbacksImpl.h" | 46 #include "modules/indexeddb/WebIDBCallbacksImpl.h" |
45 #include "platform/SharedBuffer.h" | 47 #include "platform/SharedBuffer.h" |
46 #include "public/platform/WebBlobInfo.h" | 48 #include "public/platform/WebBlobInfo.h" |
(...skipping 13 matching lines...) Expand all Loading... |
60 if (transaction) | 62 if (transaction) |
61 transaction->registerRequest(request); | 63 transaction->registerRequest(request); |
62 return request; | 64 return request; |
63 } | 65 } |
64 | 66 |
65 IDBRequest::IDBRequest(ScriptState* scriptState, | 67 IDBRequest::IDBRequest(ScriptState* scriptState, |
66 IDBAny* source, | 68 IDBAny* source, |
67 IDBTransaction* transaction) | 69 IDBTransaction* transaction) |
68 : SuspendableObject(scriptState->getExecutionContext()), | 70 : SuspendableObject(scriptState->getExecutionContext()), |
69 m_transaction(transaction), | 71 m_transaction(transaction), |
70 m_source(source) {} | 72 m_source(source), |
| 73 m_creationSource(SourceLocation::capture()) {} |
71 | 74 |
72 IDBRequest::~IDBRequest() { | 75 IDBRequest::~IDBRequest() { |
73 DCHECK(m_readyState == DONE || m_readyState == EarlyDeath || | 76 DCHECK(m_readyState == DONE || m_readyState == EarlyDeath || |
74 !getExecutionContext()); | 77 !getExecutionContext()); |
75 } | 78 } |
76 | 79 |
77 DEFINE_TRACE(IDBRequest) { | 80 DEFINE_TRACE(IDBRequest) { |
78 visitor->trace(m_transaction); | 81 visitor->trace(m_transaction); |
79 visitor->trace(m_source); | 82 visitor->trace(m_source); |
80 visitor->trace(m_result); | 83 visitor->trace(m_result); |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 } | 499 } |
497 | 500 |
498 if (cursorToNotify) | 501 if (cursorToNotify) |
499 cursorToNotify->postSuccessHandlerCallback(); | 502 cursorToNotify->postSuccessHandlerCallback(); |
500 | 503 |
501 // An upgradeneeded event will always be followed by a success or error event, | 504 // An upgradeneeded event will always be followed by a success or error event, |
502 // so must be kept alive. | 505 // so must be kept alive. |
503 if (m_readyState == DONE && event->type() != EventTypeNames::upgradeneeded) | 506 if (m_readyState == DONE && event->type() != EventTypeNames::upgradeneeded) |
504 m_hasPendingActivity = false; | 507 m_hasPendingActivity = false; |
505 | 508 |
| 509 // Fire window.onerror (or the equivalent for workers) for errors that were |
| 510 // not prevented. |
| 511 if (!m_preventPropagation && event->type() == EventTypeNames::error && |
| 512 dispatchResult == DispatchEventResult::NotCanceled && m_creationSource) { |
| 513 // TODO: This nulls out m_creationSource; when IDBCursor::continue() or |
| 514 // IDBCursor::advance() is called we should re-capture. |
| 515 // TODO: Check Firefox behavior here and add test for continue()! |
| 516 getExecutionContext()->dispatchErrorEvent( |
| 517 ErrorEvent::create(m_error->toStringForConsole(), |
| 518 std::move(m_creationSource), nullptr), |
| 519 NotSharableCrossOrigin); |
| 520 } |
| 521 |
506 return dispatchResult; | 522 return dispatchResult; |
507 } | 523 } |
508 | 524 |
509 void IDBRequest::uncaughtExceptionInEventHandler() { | 525 void IDBRequest::uncaughtExceptionInEventHandler() { |
510 if (m_transaction && !m_requestAborted) { | 526 if (m_transaction && !m_requestAborted) { |
511 m_transaction->setError(DOMException::create( | 527 m_transaction->setError(DOMException::create( |
512 AbortError, "Uncaught exception in event handler.")); | 528 AbortError, "Uncaught exception in event handler.")); |
513 m_transaction->abort(IGNORE_EXCEPTION_FOR_TESTING); | 529 m_transaction->abort(IGNORE_EXCEPTION_FOR_TESTING); |
514 } | 530 } |
515 } | 531 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 } | 565 } |
550 | 566 |
551 void IDBRequest::dequeueEvent(Event* event) { | 567 void IDBRequest::dequeueEvent(Event* event) { |
552 for (size_t i = 0; i < m_enqueuedEvents.size(); ++i) { | 568 for (size_t i = 0; i < m_enqueuedEvents.size(); ++i) { |
553 if (m_enqueuedEvents[i].get() == event) | 569 if (m_enqueuedEvents[i].get() == event) |
554 m_enqueuedEvents.remove(i); | 570 m_enqueuedEvents.remove(i); |
555 } | 571 } |
556 } | 572 } |
557 | 573 |
558 } // namespace blink | 574 } // namespace blink |
OLD | NEW |