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 15 matching lines...) Expand all Loading... |
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/modules/v8/ToV8ForModules.h" | 34 #include "bindings/modules/v8/ToV8ForModules.h" |
35 #include "bindings/modules/v8/V8BindingForModules.h" | 35 #include "bindings/modules/v8/V8BindingForModules.h" |
| 36 #include "core/dom/DOMException.h" |
| 37 #include "core/dom/ExceptionCode.h" |
36 #include "core/dom/ExecutionContext.h" | 38 #include "core/dom/ExecutionContext.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 "platform/SharedBuffer.h" | 46 #include "platform/SharedBuffer.h" |
45 #include "public/platform/WebBlobInfo.h" | 47 #include "public/platform/WebBlobInfo.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::request
NotFinishedErrorMessage); | 93 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::request
NotFinishedErrorMessage); |
92 return ScriptValue(); | 94 return ScriptValue(); |
93 } | 95 } |
94 if (m_contextStopped || !executionContext()) | 96 if (m_contextStopped || !executionContext()) |
95 return ScriptValue(); | 97 return ScriptValue(); |
96 m_resultDirty = false; | 98 m_resultDirty = false; |
97 ScriptValue value = ScriptValue::from(m_scriptState.get(), m_result); | 99 ScriptValue value = ScriptValue::from(m_scriptState.get(), m_result); |
98 return value; | 100 return value; |
99 } | 101 } |
100 | 102 |
101 DOMError* IDBRequest::error(ExceptionState& exceptionState) const | 103 DOMException* IDBRequest::error(ExceptionState& exceptionState) const |
102 { | 104 { |
103 if (m_readyState != DONE) { | 105 if (m_readyState != DONE) { |
104 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::request
NotFinishedErrorMessage); | 106 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::request
NotFinishedErrorMessage); |
105 return nullptr; | 107 return nullptr; |
106 } | 108 } |
107 return m_error; | 109 return m_error; |
108 } | 110 } |
109 | 111 |
110 ScriptValue IDBRequest::source() const | 112 ScriptValue IDBRequest::source() const |
111 { | 113 { |
(...skipping 24 matching lines...) Expand all Loading... |
136 | 138 |
137 EventQueue* eventQueue = executionContext()->eventQueue(); | 139 EventQueue* eventQueue = executionContext()->eventQueue(); |
138 for (size_t i = 0; i < m_enqueuedEvents.size(); ++i) { | 140 for (size_t i = 0; i < m_enqueuedEvents.size(); ++i) { |
139 bool removed = eventQueue->cancelEvent(m_enqueuedEvents[i].get()); | 141 bool removed = eventQueue->cancelEvent(m_enqueuedEvents[i].get()); |
140 ASSERT_UNUSED(removed, removed); | 142 ASSERT_UNUSED(removed, removed); |
141 } | 143 } |
142 m_enqueuedEvents.clear(); | 144 m_enqueuedEvents.clear(); |
143 | 145 |
144 m_error.clear(); | 146 m_error.clear(); |
145 m_result.clear(); | 147 m_result.clear(); |
146 onError(DOMError::create(AbortError, "The transaction was aborted, so the re
quest cannot be fulfilled.")); | 148 onError(DOMException::create(AbortError, "The transaction was aborted, so th
e request cannot be fulfilled.")); |
147 m_requestAborted = true; | 149 m_requestAborted = true; |
148 } | 150 } |
149 | 151 |
150 void IDBRequest::setCursorDetails(IndexedDB::CursorType cursorType, WebIDBCursor
Direction direction) | 152 void IDBRequest::setCursorDetails(IndexedDB::CursorType cursorType, WebIDBCursor
Direction direction) |
151 { | 153 { |
152 ASSERT(m_readyState == PENDING); | 154 ASSERT(m_readyState == PENDING); |
153 ASSERT(!m_pendingCursor); | 155 ASSERT(!m_pendingCursor); |
154 m_cursorType = cursorType; | 156 m_cursorType = cursorType; |
155 m_cursorDirection = direction; | 157 m_cursorDirection = direction; |
156 } | 158 } |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 if (m_contextStopped || !executionContext()) | 215 if (m_contextStopped || !executionContext()) |
214 return false; | 216 return false; |
215 ASSERT(m_readyState == PENDING || m_readyState == DONE); | 217 ASSERT(m_readyState == PENDING || m_readyState == DONE); |
216 if (m_requestAborted) | 218 if (m_requestAborted) |
217 return false; | 219 return false; |
218 ASSERT(m_readyState == PENDING); | 220 ASSERT(m_readyState == PENDING); |
219 ASSERT(!m_error && !m_result); | 221 ASSERT(!m_error && !m_result); |
220 return true; | 222 return true; |
221 } | 223 } |
222 | 224 |
223 void IDBRequest::onError(DOMError* error) | 225 void IDBRequest::onError(DOMException* error) |
224 { | 226 { |
225 IDB_TRACE("IDBRequest::onError()"); | 227 IDB_TRACE("IDBRequest::onError()"); |
226 if (!shouldEnqueueEvent()) | 228 if (!shouldEnqueueEvent()) |
227 return; | 229 return; |
228 | 230 |
229 m_error = error; | 231 m_error = error; |
230 setResult(IDBAny::createUndefined()); | 232 setResult(IDBAny::createUndefined()); |
231 m_pendingCursor.clear(); | 233 m_pendingCursor.clear(); |
232 enqueueEvent(Event::createCancelableBubble(EventTypeNames::error)); | 234 enqueueEvent(Event::createCancelableBubble(EventTypeNames::error)); |
233 } | 235 } |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
481 // be kept alive. | 483 // be kept alive. |
482 if (m_readyState == DONE && event->type() != EventTypeNames::upgradeneeded) | 484 if (m_readyState == DONE && event->type() != EventTypeNames::upgradeneeded) |
483 m_hasPendingActivity = false; | 485 m_hasPendingActivity = false; |
484 | 486 |
485 return dontPreventDefault; | 487 return dontPreventDefault; |
486 } | 488 } |
487 | 489 |
488 void IDBRequest::uncaughtExceptionInEventHandler() | 490 void IDBRequest::uncaughtExceptionInEventHandler() |
489 { | 491 { |
490 if (m_transaction && !m_requestAborted) { | 492 if (m_transaction && !m_requestAborted) { |
491 m_transaction->setError(DOMError::create(AbortError, "Uncaught exception
in event handler.")); | 493 m_transaction->setError(DOMException::create(AbortError, "Uncaught excep
tion in event handler.")); |
492 m_transaction->abort(IGNORE_EXCEPTION); | 494 m_transaction->abort(IGNORE_EXCEPTION); |
493 } | 495 } |
494 } | 496 } |
495 | 497 |
496 void IDBRequest::transactionDidFinishAndDispatch() | 498 void IDBRequest::transactionDidFinishAndDispatch() |
497 { | 499 { |
498 ASSERT(m_transaction); | 500 ASSERT(m_transaction); |
499 ASSERT(m_transaction->isVersionChange()); | 501 ASSERT(m_transaction->isVersionChange()); |
500 ASSERT(m_didFireUpgradeNeededEvent); | 502 ASSERT(m_didFireUpgradeNeededEvent); |
501 ASSERT(m_readyState == DONE); | 503 ASSERT(m_readyState == DONE); |
(...skipping 27 matching lines...) Expand all Loading... |
529 | 531 |
530 void IDBRequest::dequeueEvent(Event* event) | 532 void IDBRequest::dequeueEvent(Event* event) |
531 { | 533 { |
532 for (size_t i = 0; i < m_enqueuedEvents.size(); ++i) { | 534 for (size_t i = 0; i < m_enqueuedEvents.size(); ++i) { |
533 if (m_enqueuedEvents[i].get() == event) | 535 if (m_enqueuedEvents[i].get() == event) |
534 m_enqueuedEvents.remove(i); | 536 m_enqueuedEvents.remove(i); |
535 } | 537 } |
536 } | 538 } |
537 | 539 |
538 } // namespace blink | 540 } // namespace blink |
OLD | NEW |