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/InspectorInstrumentation.h" | |
| 40 #include "core/inspector/ScriptCallFrame.h" | |
| 41 #include "core/inspector/ScriptCallStack.h" | |
| 37 #include "modules/IndexedDBNames.h" | 42 #include "modules/IndexedDBNames.h" |
| 38 #include "modules/indexeddb/IDBCursorWithValue.h" | 43 #include "modules/indexeddb/IDBCursorWithValue.h" |
| 39 #include "modules/indexeddb/IDBDatabase.h" | 44 #include "modules/indexeddb/IDBDatabase.h" |
| 40 #include "modules/indexeddb/IDBEventDispatcher.h" | 45 #include "modules/indexeddb/IDBEventDispatcher.h" |
| 41 #include "modules/indexeddb/IDBTracing.h" | 46 #include "modules/indexeddb/IDBTracing.h" |
| 42 #include "platform/SharedBuffer.h" | 47 #include "platform/SharedBuffer.h" |
| 43 #include "public/platform/WebBlobInfo.h" | 48 #include "public/platform/WebBlobInfo.h" |
| 44 | 49 |
| 45 using blink::WebIDBCursor; | 50 using blink::WebIDBCursor; |
| 46 | 51 |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 65 , m_scriptState(scriptState) | 70 , m_scriptState(scriptState) |
| 66 , m_source(source) | 71 , m_source(source) |
| 67 , m_hasPendingActivity(true) | 72 , m_hasPendingActivity(true) |
| 68 , m_cursorType(IndexedDB::CursorKeyAndValue) | 73 , m_cursorType(IndexedDB::CursorKeyAndValue) |
| 69 , m_cursorDirection(WebIDBCursorDirectionNext) | 74 , m_cursorDirection(WebIDBCursorDirectionNext) |
| 70 , m_pendingCursor(nullptr) | 75 , m_pendingCursor(nullptr) |
| 71 , m_didFireUpgradeNeededEvent(false) | 76 , m_didFireUpgradeNeededEvent(false) |
| 72 , m_preventPropagation(false) | 77 , m_preventPropagation(false) |
| 73 , m_resultDirty(true) | 78 , m_resultDirty(true) |
| 74 { | 79 { |
| 80 const size_t stackSize = InspectorInstrumentation::consoleAgentEnabled(scrip tState->executionContext()) ? ScriptCallStack::maxCallStackSizeToCapture : 1; | |
| 81 m_creationStackTrace = createScriptCallStack(stackSize, false); | |
|
aandrey
2014/12/19 00:40:28
use createScriptCallStackForConsole().
if you need
| |
| 82 ASSERT(m_creationStackTrace && m_creationStackTrace->size()); | |
| 75 } | 83 } |
| 76 | 84 |
| 77 IDBRequest::~IDBRequest() | 85 IDBRequest::~IDBRequest() |
| 78 { | 86 { |
| 79 ASSERT(m_readyState == DONE || m_readyState == EarlyDeath || !executionConte xt()); | 87 ASSERT(m_readyState == DONE || m_readyState == EarlyDeath || !executionConte xt()); |
| 80 ASSERT(!m_blobInfo || m_blobInfo->size() == 0); | 88 ASSERT(!m_blobInfo || m_blobInfo->size() == 0); |
| 81 } | 89 } |
| 82 | 90 |
| 83 void IDBRequest::dispose() | 91 void IDBRequest::dispose() |
| 84 { | 92 { |
| 85 handleBlobAcks(); | 93 handleBlobAcks(); |
| 86 } | 94 } |
| 87 | 95 |
| 88 void IDBRequest::trace(Visitor* visitor) | 96 void IDBRequest::trace(Visitor* visitor) |
| 89 { | 97 { |
| 90 visitor->trace(m_transaction); | 98 visitor->trace(m_transaction); |
| 91 visitor->trace(m_source); | 99 visitor->trace(m_source); |
| 92 visitor->trace(m_result); | 100 visitor->trace(m_result); |
| 93 visitor->trace(m_error); | 101 visitor->trace(m_error); |
| 94 #if ENABLE(OILPAN) | 102 #if ENABLE(OILPAN) |
| 95 visitor->trace(m_enqueuedEvents); | 103 visitor->trace(m_enqueuedEvents); |
| 96 #endif | 104 #endif |
| 97 visitor->trace(m_pendingCursor); | 105 visitor->trace(m_pendingCursor); |
| 98 visitor->trace(m_cursorKey); | 106 visitor->trace(m_cursorKey); |
| 99 visitor->trace(m_cursorPrimaryKey); | 107 visitor->trace(m_cursorPrimaryKey); |
| 108 visitor->trace(m_creationStackTrace); | |
| 100 EventTargetWithInlineData::trace(visitor); | 109 EventTargetWithInlineData::trace(visitor); |
| 101 } | 110 } |
| 102 | 111 |
| 103 ScriptValue IDBRequest::result(ExceptionState& exceptionState) | 112 ScriptValue IDBRequest::result(ExceptionState& exceptionState) |
| 104 { | 113 { |
| 105 if (m_readyState != DONE) { | 114 if (m_readyState != DONE) { |
| 106 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::request NotFinishedErrorMessage); | 115 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::request NotFinishedErrorMessage); |
| 107 return ScriptValue(); | 116 return ScriptValue(); |
| 108 } | 117 } |
| 109 if (m_contextStopped || !executionContext()) | 118 if (m_contextStopped || !executionContext()) |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 496 } | 505 } |
| 497 | 506 |
| 498 if (cursorToNotify) | 507 if (cursorToNotify) |
| 499 cursorToNotify->postSuccessHandlerCallback(); | 508 cursorToNotify->postSuccessHandlerCallback(); |
| 500 | 509 |
| 501 // An upgradeneeded event will always be followed by a success or error even t, so must | 510 // An upgradeneeded event will always be followed by a success or error even t, so must |
| 502 // be kept alive. | 511 // be kept alive. |
| 503 if (m_readyState == DONE && event->type() != EventTypeNames::upgradeneeded) | 512 if (m_readyState == DONE && event->type() != EventTypeNames::upgradeneeded) |
| 504 m_hasPendingActivity = false; | 513 m_hasPendingActivity = false; |
| 505 | 514 |
| 515 // Fire window.onerror (or the equivalent for workers) for errors that were not prevented. | |
| 516 if (!m_preventPropagation && dontPreventDefault && event->type() == EventTyp eNames::error) { | |
| 517 const ScriptCallFrame& frame = m_creationStackTrace->at(0); | |
| 518 const AccessControlStatus corsStatus = NotSharableCrossOrigin; | |
| 519 RefPtrWillBeRawPtr<ErrorEvent> errorEvent; | |
| 520 if (executionContext()->shouldSanitizeScriptError(frame.sourceURL(), cor sStatus)) { | |
| 521 errorEvent = ErrorEvent::createSanitizedError(&m_scriptState->world( )); | |
| 522 } else { | |
| 523 String message = m_error->name() + ": " + m_error->message(); | |
| 524 errorEvent = ErrorEvent::create(message, frame.sourceURL(), frame.li neNumber(), frame.columnNumber(), &m_scriptState->world()); | |
| 525 } | |
| 526 executionContext()->reportException(errorEvent, frame.scriptId().toInt() , m_creationStackTrace, corsStatus); | |
| 527 } | |
| 528 | |
| 506 return dontPreventDefault; | 529 return dontPreventDefault; |
| 507 } | 530 } |
| 508 | 531 |
| 509 void IDBRequest::uncaughtExceptionInEventHandler() | 532 void IDBRequest::uncaughtExceptionInEventHandler() |
| 510 { | 533 { |
| 511 if (m_transaction && !m_requestAborted) { | 534 if (m_transaction && !m_requestAborted) { |
| 512 m_transaction->setError(DOMError::create(AbortError, "Uncaught exception in event handler.")); | 535 m_transaction->setError(DOMError::create(AbortError, "Uncaught exception in event handler.")); |
| 513 m_transaction->abort(IGNORE_EXCEPTION); | 536 m_transaction->abort(IGNORE_EXCEPTION); |
| 514 } | 537 } |
| 515 } | 538 } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 550 | 573 |
| 551 void IDBRequest::dequeueEvent(Event* event) | 574 void IDBRequest::dequeueEvent(Event* event) |
| 552 { | 575 { |
| 553 for (size_t i = 0; i < m_enqueuedEvents.size(); ++i) { | 576 for (size_t i = 0; i < m_enqueuedEvents.size(); ++i) { |
| 554 if (m_enqueuedEvents[i].get() == event) | 577 if (m_enqueuedEvents[i].get() == event) |
| 555 m_enqueuedEvents.remove(i); | 578 m_enqueuedEvents.remove(i); |
| 556 } | 579 } |
| 557 } | 580 } |
| 558 | 581 |
| 559 } // namespace blink | 582 } // namespace blink |
| OLD | NEW |