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 14 matching lines...) Expand all Loading... | |
| 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/ExceptionState.h" | 32 #include "bindings/v8/ExceptionState.h" |
| 33 #include "bindings/v8/ExceptionStatePlaceholder.h" | 33 #include "bindings/v8/ExceptionStatePlaceholder.h" |
| 34 #include "bindings/v8/IDBBindingUtilities.h" | 34 #include "bindings/v8/IDBBindingUtilities.h" |
| 35 #include "bindings/v8/ScriptCallStackFactory.h" | |
| 35 #include "core/dom/ExecutionContext.h" | 36 #include "core/dom/ExecutionContext.h" |
| 36 #include "core/events/EventQueue.h" | 37 #include "core/events/EventQueue.h" |
| 38 #include "core/inspector/ScriptCallFrame.h" | |
| 39 #include "core/inspector/ScriptCallStack.h" | |
| 37 #include "modules/indexeddb/IDBCursorWithValue.h" | 40 #include "modules/indexeddb/IDBCursorWithValue.h" |
| 38 #include "modules/indexeddb/IDBDatabase.h" | 41 #include "modules/indexeddb/IDBDatabase.h" |
| 39 #include "modules/indexeddb/IDBEventDispatcher.h" | 42 #include "modules/indexeddb/IDBEventDispatcher.h" |
| 40 #include "modules/indexeddb/IDBTracing.h" | 43 #include "modules/indexeddb/IDBTracing.h" |
| 41 #include "platform/SharedBuffer.h" | 44 #include "platform/SharedBuffer.h" |
| 42 | 45 |
| 43 using blink::WebIDBCursor; | 46 using blink::WebIDBCursor; |
| 44 | 47 |
| 45 namespace WebCore { | 48 namespace WebCore { |
| 46 | 49 |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 64 , m_source(source) | 67 , m_source(source) |
| 65 , m_hasPendingActivity(true) | 68 , m_hasPendingActivity(true) |
| 66 , m_cursorType(IndexedDB::CursorKeyAndValue) | 69 , m_cursorType(IndexedDB::CursorKeyAndValue) |
| 67 , m_cursorDirection(blink::WebIDBCursor::Next) | 70 , m_cursorDirection(blink::WebIDBCursor::Next) |
| 68 , m_pendingCursor(nullptr) | 71 , m_pendingCursor(nullptr) |
| 69 , m_didFireUpgradeNeededEvent(false) | 72 , m_didFireUpgradeNeededEvent(false) |
| 70 , m_preventPropagation(false) | 73 , m_preventPropagation(false) |
| 71 , m_resultDirty(true) | 74 , m_resultDirty(true) |
| 72 { | 75 { |
| 73 ScriptWrappable::init(this); | 76 ScriptWrappable::init(this); |
| 77 | |
| 78 if (toIsolate(context)->InContext()) | |
| 79 m_creationStackTrace = createScriptCallStack(ScriptCallStack::maxCallSta ckSizeToCapture, true); | |
|
haraken
2014/04/21 02:36:13
Is it safe to limit the number of captured stack t
jsbell
2014/04/21 16:28:38
Is it possible to capture more? Maybe I'm misunder
| |
| 74 } | 80 } |
| 75 | 81 |
| 76 IDBRequest::~IDBRequest() | 82 IDBRequest::~IDBRequest() |
| 77 { | 83 { |
| 78 ASSERT(m_readyState == DONE || m_readyState == EarlyDeath || !executionConte xt()); | 84 ASSERT(m_readyState == DONE || m_readyState == EarlyDeath || !executionConte xt()); |
| 79 } | 85 } |
| 80 | 86 |
| 81 ScriptValue IDBRequest::result(ExceptionState& exceptionState) | 87 ScriptValue IDBRequest::result(ExceptionState& exceptionState) |
| 82 { | 88 { |
| 83 if (m_readyState != DONE) { | 89 if (m_readyState != DONE) { |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 464 } | 470 } |
| 465 | 471 |
| 466 if (cursorToNotify) | 472 if (cursorToNotify) |
| 467 cursorToNotify->postSuccessHandlerCallback(); | 473 cursorToNotify->postSuccessHandlerCallback(); |
| 468 | 474 |
| 469 // An upgradeneeded event will always be followed by a success or error even t, so must | 475 // An upgradeneeded event will always be followed by a success or error even t, so must |
| 470 // be kept alive. | 476 // be kept alive. |
| 471 if (m_readyState == DONE && event->type() != EventTypeNames::upgradeneeded) | 477 if (m_readyState == DONE && event->type() != EventTypeNames::upgradeneeded) |
| 472 m_hasPendingActivity = false; | 478 m_hasPendingActivity = false; |
| 473 | 479 |
| 480 if (!m_preventPropagation && dontPreventDefault && event->type() == EventTyp eNames::error && m_creationStackTrace && m_creationStackTrace->size()) { | |
| 481 const ScriptCallFrame& frame = m_creationStackTrace->at(0); | |
| 482 | |
| 483 // FIXME: SharableCrossOrigin or NotSharableCrossOrigin? | |
| 484 const AccessControlStatus corsStatus = NotSharableCrossOrigin; | |
| 485 | |
| 486 RefPtr<ErrorEvent> errorEvent; | |
| 487 if (executionContext()->shouldSanitizeScriptError(frame.sourceURL(), cor sStatus)) { | |
|
haraken
2014/04/21 02:36:13
Is it OK to use the executionContext of this IDBRe
jsbell
2014/04/21 16:28:38
Great question. Anyone?
| |
| 488 errorEvent = ErrorEvent::createSanitizedError(&m_scriptState->world( )); | |
| 489 } else { | |
| 490 // FIXME: Firefox just uses error's name. Should we include the mess age? | |
|
jsbell
2014/04/21 16:28:38
And for the record: I plan to keep the message, es
| |
| 491 String message = m_error->name() + ": " + m_error->message(); | |
| 492 errorEvent = ErrorEvent::create(message, frame.sourceURL(), frame.li neNumber(), frame.columnNumber(), &m_scriptState->world()); | |
| 493 } | |
| 494 executionContext()->reportException(errorEvent, m_creationStackTrace, co rsStatus); | |
| 495 } | |
| 496 | |
| 474 return dontPreventDefault; | 497 return dontPreventDefault; |
| 475 } | 498 } |
| 476 | 499 |
| 477 void IDBRequest::uncaughtExceptionInEventHandler() | 500 void IDBRequest::uncaughtExceptionInEventHandler() |
| 478 { | 501 { |
| 479 if (m_transaction && !m_requestAborted) { | 502 if (m_transaction && !m_requestAborted) { |
| 480 m_transaction->setError(DOMError::create(AbortError, "Uncaught exception in event handler.")); | 503 m_transaction->setError(DOMError::create(AbortError, "Uncaught exception in event handler.")); |
| 481 m_transaction->abort(IGNORE_EXCEPTION); | 504 m_transaction->abort(IGNORE_EXCEPTION); |
| 482 } | 505 } |
| 483 } | 506 } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 518 | 541 |
| 519 void IDBRequest::dequeueEvent(Event* event) | 542 void IDBRequest::dequeueEvent(Event* event) |
| 520 { | 543 { |
| 521 for (size_t i = 0; i < m_enqueuedEvents.size(); ++i) { | 544 for (size_t i = 0; i < m_enqueuedEvents.size(); ++i) { |
| 522 if (m_enqueuedEvents[i].get() == event) | 545 if (m_enqueuedEvents[i].get() == event) |
| 523 m_enqueuedEvents.remove(i); | 546 m_enqueuedEvents.remove(i); |
| 524 } | 547 } |
| 525 } | 548 } |
| 526 | 549 |
| 527 } // namespace WebCore | 550 } // namespace WebCore |
| OLD | NEW |