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 13 matching lines...) Expand all Loading... | |
| 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/core/v8/ExceptionState.h" | 32 #include "bindings/core/v8/ExceptionState.h" |
| 33 #include "bindings/core/v8/ExceptionStatePlaceholder.h" | 33 #include "bindings/core/v8/ExceptionStatePlaceholder.h" |
| 34 #include "bindings/core/v8/ScriptCallStackFactory.h" | |
| 34 #include "bindings/modules/v8/IDBBindingUtilities.h" | 35 #include "bindings/modules/v8/IDBBindingUtilities.h" |
| 35 #include "core/dom/ExecutionContext.h" | 36 #include "core/dom/ExecutionContext.h" |
| 37 #include "core/events/ErrorEvent.h" | |
| 36 #include "core/events/EventQueue.h" | 38 #include "core/events/EventQueue.h" |
| 39 #include "core/inspector/ScriptCallFrame.h" | |
| 40 #include "core/inspector/ScriptCallStack.h" | |
| 37 #include "modules/indexeddb/IDBCursorWithValue.h" | 41 #include "modules/indexeddb/IDBCursorWithValue.h" |
| 38 #include "modules/indexeddb/IDBDatabase.h" | 42 #include "modules/indexeddb/IDBDatabase.h" |
| 39 #include "modules/indexeddb/IDBEventDispatcher.h" | 43 #include "modules/indexeddb/IDBEventDispatcher.h" |
| 40 #include "modules/indexeddb/IDBTracing.h" | 44 #include "modules/indexeddb/IDBTracing.h" |
| 41 #include "platform/SharedBuffer.h" | 45 #include "platform/SharedBuffer.h" |
| 42 #include "public/platform/WebBlobInfo.h" | 46 #include "public/platform/WebBlobInfo.h" |
| 43 | 47 |
| 44 using blink::WebIDBCursor; | 48 using blink::WebIDBCursor; |
| 45 | 49 |
| 46 namespace WebCore { | 50 namespace WebCore { |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 65 , m_source(source) | 69 , m_source(source) |
| 66 , m_hasPendingActivity(true) | 70 , m_hasPendingActivity(true) |
| 67 , m_cursorType(IndexedDB::CursorKeyAndValue) | 71 , m_cursorType(IndexedDB::CursorKeyAndValue) |
| 68 , m_cursorDirection(blink::WebIDBCursorDirectionNext) | 72 , m_cursorDirection(blink::WebIDBCursorDirectionNext) |
| 69 , m_pendingCursor(nullptr) | 73 , m_pendingCursor(nullptr) |
| 70 , m_didFireUpgradeNeededEvent(false) | 74 , m_didFireUpgradeNeededEvent(false) |
| 71 , m_preventPropagation(false) | 75 , m_preventPropagation(false) |
| 72 , m_resultDirty(true) | 76 , m_resultDirty(true) |
| 73 { | 77 { |
| 74 ScriptWrappable::init(this); | 78 ScriptWrappable::init(this); |
| 79 | |
| 80 m_creationStackTrace = createScriptCallStack(ScriptCallStack::maxCallStackSi zeToCapture, false); | |
| 81 ASSERT(m_creationStackTrace && m_creationStackTrace->size()); | |
| 75 } | 82 } |
| 76 | 83 |
| 77 IDBRequest::~IDBRequest() | 84 IDBRequest::~IDBRequest() |
| 78 { | 85 { |
| 79 ASSERT(m_readyState == DONE || m_readyState == EarlyDeath || !executionConte xt()); | 86 ASSERT(m_readyState == DONE || m_readyState == EarlyDeath || !executionConte xt()); |
| 80 handleBlobAcks(); | 87 handleBlobAcks(); |
| 81 } | 88 } |
| 82 | 89 |
| 83 void IDBRequest::trace(Visitor* visitor) | 90 void IDBRequest::trace(Visitor* visitor) |
| 84 { | 91 { |
| 85 visitor->trace(m_transaction); | 92 visitor->trace(m_transaction); |
| 86 visitor->trace(m_source); | 93 visitor->trace(m_source); |
| 87 visitor->trace(m_result); | 94 visitor->trace(m_result); |
| 88 visitor->trace(m_error); | 95 visitor->trace(m_error); |
| 89 #if ENABLE(OILPAN) | 96 #if ENABLE(OILPAN) |
| 90 visitor->trace(m_enqueuedEvents); | 97 visitor->trace(m_enqueuedEvents); |
| 91 #endif | 98 #endif |
| 92 visitor->trace(m_pendingCursor); | 99 visitor->trace(m_pendingCursor); |
| 93 visitor->trace(m_cursorKey); | 100 visitor->trace(m_cursorKey); |
| 94 visitor->trace(m_cursorPrimaryKey); | 101 visitor->trace(m_cursorPrimaryKey); |
| 102 visitor->trace(m_creationStackTrace); | |
| 95 EventTargetWithInlineData::trace(visitor); | 103 EventTargetWithInlineData::trace(visitor); |
| 96 } | 104 } |
| 97 | 105 |
| 98 ScriptValue IDBRequest::result(ExceptionState& exceptionState) | 106 ScriptValue IDBRequest::result(ExceptionState& exceptionState) |
| 99 { | 107 { |
| 100 if (m_readyState != DONE) { | 108 if (m_readyState != DONE) { |
| 101 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::request NotFinishedErrorMessage); | 109 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::request NotFinishedErrorMessage); |
| 102 return ScriptValue(); | 110 return ScriptValue(); |
| 103 } | 111 } |
| 104 if (m_contextStopped || !executionContext()) | 112 if (m_contextStopped || !executionContext()) |
| (...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 486 } | 494 } |
| 487 | 495 |
| 488 if (cursorToNotify) | 496 if (cursorToNotify) |
| 489 cursorToNotify->postSuccessHandlerCallback(); | 497 cursorToNotify->postSuccessHandlerCallback(); |
| 490 | 498 |
| 491 // An upgradeneeded event will always be followed by a success or error even t, so must | 499 // An upgradeneeded event will always be followed by a success or error even t, so must |
| 492 // be kept alive. | 500 // be kept alive. |
| 493 if (m_readyState == DONE && event->type() != EventTypeNames::upgradeneeded) | 501 if (m_readyState == DONE && event->type() != EventTypeNames::upgradeneeded) |
| 494 m_hasPendingActivity = false; | 502 m_hasPendingActivity = false; |
| 495 | 503 |
| 504 if (!m_preventPropagation && dontPreventDefault && event->type() == EventTyp eNames::error) { | |
|
haraken
2014/07/02 23:25:39
Let's add a comment what this is doing.
| |
| 505 const ScriptCallFrame& frame = m_creationStackTrace->at(0); | |
| 506 const AccessControlStatus corsStatus = NotSharableCrossOrigin; | |
| 507 RefPtrWillBeRawPtr<ErrorEvent> errorEvent; | |
| 508 if (executionContext()->shouldSanitizeScriptError(frame.sourceURL(), cor sStatus)) { | |
| 509 errorEvent = ErrorEvent::createSanitizedError(&m_scriptState->world( )); | |
| 510 } else { | |
| 511 String message = m_error->name() + ": " + m_error->message(); | |
| 512 errorEvent = ErrorEvent::create(message, frame.sourceURL(), frame.li neNumber(), frame.columnNumber(), &m_scriptState->world()); | |
| 513 } | |
| 514 executionContext()->reportException(errorEvent, m_creationStackTrace, co rsStatus); | |
| 515 } | |
| 516 | |
| 496 return dontPreventDefault; | 517 return dontPreventDefault; |
| 497 } | 518 } |
| 498 | 519 |
| 499 void IDBRequest::uncaughtExceptionInEventHandler() | 520 void IDBRequest::uncaughtExceptionInEventHandler() |
| 500 { | 521 { |
| 501 if (m_transaction && !m_requestAborted) { | 522 if (m_transaction && !m_requestAborted) { |
| 502 m_transaction->setError(DOMError::create(AbortError, "Uncaught exception in event handler.")); | 523 m_transaction->setError(DOMError::create(AbortError, "Uncaught exception in event handler.")); |
| 503 m_transaction->abort(IGNORE_EXCEPTION); | 524 m_transaction->abort(IGNORE_EXCEPTION); |
| 504 } | 525 } |
| 505 } | 526 } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 540 | 561 |
| 541 void IDBRequest::dequeueEvent(Event* event) | 562 void IDBRequest::dequeueEvent(Event* event) |
| 542 { | 563 { |
| 543 for (size_t i = 0; i < m_enqueuedEvents.size(); ++i) { | 564 for (size_t i = 0; i < m_enqueuedEvents.size(); ++i) { |
| 544 if (m_enqueuedEvents[i].get() == event) | 565 if (m_enqueuedEvents[i].get() == event) |
| 545 m_enqueuedEvents.remove(i); | 566 m_enqueuedEvents.remove(i); |
| 546 } | 567 } |
| 547 } | 568 } |
| 548 | 569 |
| 549 } // namespace WebCore | 570 } // namespace WebCore |
| OLD | NEW |