Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(186)

Side by Side Diff: Source/modules/indexeddb/IDBTransaction.cpp

Issue 18398002: Remove IDBNotFoundError ExceptionCode (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add missing include in code gen wich causes win compile failure Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
11 * notice, this list of conditions and the following disclaimer in the 11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution. 12 * documentation and/or other materials provided with the distribution.
13 * 13 *
14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY 14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY 17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #include "config.h" 26 #include "config.h"
27 #include "modules/indexeddb/IDBTransaction.h" 27 #include "modules/indexeddb/IDBTransaction.h"
28 28
29 #include "bindings/v8/ExceptionState.h"
30 #include "bindings/v8/ExceptionStatePlaceholder.h"
29 #include "core/dom/DOMError.h" 31 #include "core/dom/DOMError.h"
30 #include "core/dom/EventQueue.h" 32 #include "core/dom/EventQueue.h"
31 #include "core/dom/ExceptionCode.h"
32 #include "core/dom/ExceptionCodePlaceholder.h"
33 #include "core/dom/ScriptExecutionContext.h" 33 #include "core/dom/ScriptExecutionContext.h"
34 #include "core/inspector/ScriptCallStack.h" 34 #include "core/inspector/ScriptCallStack.h"
35 #include "modules/indexeddb/IDBDatabase.h" 35 #include "modules/indexeddb/IDBDatabase.h"
36 #include "modules/indexeddb/IDBEventDispatcher.h" 36 #include "modules/indexeddb/IDBEventDispatcher.h"
37 #include "modules/indexeddb/IDBIndex.h" 37 #include "modules/indexeddb/IDBIndex.h"
38 #include "modules/indexeddb/IDBObjectStore.h" 38 #include "modules/indexeddb/IDBObjectStore.h"
39 #include "modules/indexeddb/IDBOpenDBRequest.h" 39 #include "modules/indexeddb/IDBOpenDBRequest.h"
40 #include "modules/indexeddb/IDBPendingTransactionMonitor.h" 40 #include "modules/indexeddb/IDBPendingTransactionMonitor.h"
41 #include "modules/indexeddb/IDBTracing.h" 41 #include "modules/indexeddb/IDBTracing.h"
42 42
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 ASSERT(m_state != Finished); 129 ASSERT(m_state != Finished);
130 ASSERT(error); 130 ASSERT(error);
131 131
132 // The first error to be set is the true cause of the 132 // The first error to be set is the true cause of the
133 // transaction abort. 133 // transaction abort.
134 if (!m_error) { 134 if (!m_error) {
135 m_error = error; 135 m_error = error;
136 } 136 }
137 } 137 }
138 138
139 PassRefPtr<IDBObjectStore> IDBTransaction::objectStore(const String& name, Excep tionCode& ec) 139 PassRefPtr<IDBObjectStore> IDBTransaction::objectStore(const String& name, Excep tionState& es)
140 { 140 {
141 if (m_state == Finished) { 141 if (m_state == Finished) {
142 ec = InvalidStateError; 142 es.throwDOMException(InvalidStateError);
143 return 0; 143 return 0;
144 } 144 }
145 145
146 IDBObjectStoreMap::iterator it = m_objectStoreMap.find(name); 146 IDBObjectStoreMap::iterator it = m_objectStoreMap.find(name);
147 if (it != m_objectStoreMap.end()) 147 if (it != m_objectStoreMap.end())
148 return it->value; 148 return it->value;
149 149
150 if (!isVersionChange() && !m_objectStoreNames.contains(name)) { 150 if (!isVersionChange() && !m_objectStoreNames.contains(name)) {
151 // FIXME: Should use (NotFoundError, "..."). 151 es.throwDOMException(NotFoundError, IDBDatabase::notFoundErrorMessage);
152 ec = IDBNotFoundError;
153 return 0; 152 return 0;
154 } 153 }
155 154
156 int64_t objectStoreId = m_database->findObjectStoreId(name); 155 int64_t objectStoreId = m_database->findObjectStoreId(name);
157 if (objectStoreId == IDBObjectStoreMetadata::InvalidId) { 156 if (objectStoreId == IDBObjectStoreMetadata::InvalidId) {
158 ASSERT(isVersionChange()); 157 ASSERT(isVersionChange());
159 // FIXME: Should use (NotFoundError, "..."). 158 es.throwDOMException(NotFoundError, IDBDatabase::notFoundErrorMessage);
160 ec = IDBNotFoundError;
161 return 0; 159 return 0;
162 } 160 }
163 161
164 const IDBDatabaseMetadata& metadata = m_database->metadata(); 162 const IDBDatabaseMetadata& metadata = m_database->metadata();
165 163
166 RefPtr<IDBObjectStore> objectStore = IDBObjectStore::create(metadata.objectS tores.get(objectStoreId), this); 164 RefPtr<IDBObjectStore> objectStore = IDBObjectStore::create(metadata.objectS tores.get(objectStoreId), this);
167 objectStoreCreated(name, objectStore); 165 objectStoreCreated(name, objectStore);
168 return objectStore.release(); 166 return objectStore.release();
169 } 167 }
170 168
(...skipping 25 matching lines...) Expand all
196 ASSERT_WITH_MESSAGE(m_state != Finished, "A finished transaction tried to se tActive(%s)", active ? "true" : "false"); 194 ASSERT_WITH_MESSAGE(m_state != Finished, "A finished transaction tried to se tActive(%s)", active ? "true" : "false");
197 if (m_state == Finishing) 195 if (m_state == Finishing)
198 return; 196 return;
199 ASSERT(active != (m_state == Active)); 197 ASSERT(active != (m_state == Active));
200 m_state = active ? Active : Inactive; 198 m_state = active ? Active : Inactive;
201 199
202 if (!active && m_requestList.isEmpty()) 200 if (!active && m_requestList.isEmpty())
203 backendDB()->commit(m_id); 201 backendDB()->commit(m_id);
204 } 202 }
205 203
206 void IDBTransaction::abort(ExceptionCode& ec) 204 void IDBTransaction::abort(ExceptionState& es)
207 { 205 {
208 if (m_state == Finishing || m_state == Finished) { 206 if (m_state == Finishing || m_state == Finished) {
209 ec = InvalidStateError; 207 es.throwDOMException(InvalidStateError);
210 return; 208 return;
211 } 209 }
212 210
213 m_state = Finishing; 211 m_state = Finishing;
214 212
215 if (!m_contextStopped) { 213 if (!m_contextStopped) {
216 while (!m_requestList.isEmpty()) { 214 while (!m_requestList.isEmpty()) {
217 RefPtr<IDBRequest> request = *m_requestList.begin(); 215 RefPtr<IDBRequest> request = *m_requestList.begin();
218 m_requestList.remove(request); 216 m_requestList.remove(request);
219 request->abort(); 217 request->abort();
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 } 324 }
327 325
328 bool IDBTransaction::hasPendingActivity() const 326 bool IDBTransaction::hasPendingActivity() const
329 { 327 {
330 // FIXME: In an ideal world, we should return true as long as anyone has a o r can 328 // FIXME: In an ideal world, we should return true as long as anyone has a o r can
331 // get a handle to us or any child request object and any of those ha ve 329 // get a handle to us or any child request object and any of those ha ve
332 // event listeners. This is in order to handle user generated events properly. 330 // event listeners. This is in order to handle user generated events properly.
333 return m_hasPendingActivity && !m_contextStopped; 331 return m_hasPendingActivity && !m_contextStopped;
334 } 332 }
335 333
336 IndexedDB::TransactionMode IDBTransaction::stringToMode(const String& modeString , ExceptionCode& ec) 334 IndexedDB::TransactionMode IDBTransaction::stringToMode(const String& modeString , ExceptionState& es)
337 { 335 {
338 if (modeString.isNull() 336 if (modeString.isNull()
339 || modeString == IDBTransaction::modeReadOnly()) 337 || modeString == IDBTransaction::modeReadOnly())
340 return IndexedDB::TransactionReadOnly; 338 return IndexedDB::TransactionReadOnly;
341 if (modeString == IDBTransaction::modeReadWrite()) 339 if (modeString == IDBTransaction::modeReadWrite())
342 return IndexedDB::TransactionReadWrite; 340 return IndexedDB::TransactionReadWrite;
343 341
344 ec = TypeError; 342 es.throwTypeError();
345 return IndexedDB::TransactionReadOnly; 343 return IndexedDB::TransactionReadOnly;
346 } 344 }
347 345
348 const AtomicString& IDBTransaction::modeToString(IndexedDB::TransactionMode mode ) 346 const AtomicString& IDBTransaction::modeToString(IndexedDB::TransactionMode mode )
349 { 347 {
350 switch (mode) { 348 switch (mode) {
351 case IndexedDB::TransactionReadOnly: 349 case IndexedDB::TransactionReadOnly:
352 return IDBTransaction::modeReadOnly(); 350 return IDBTransaction::modeReadOnly();
353 break; 351 break;
354 352
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 return m_state == Finished; 414 return m_state == Finished;
417 } 415 }
418 416
419 void IDBTransaction::stop() 417 void IDBTransaction::stop()
420 { 418 {
421 if (m_contextStopped) 419 if (m_contextStopped)
422 return; 420 return;
423 421
424 m_contextStopped = true; 422 m_contextStopped = true;
425 423
426 abort(IGNORE_EXCEPTION); 424 abort(IGNORE_EXCEPTION_STATE);
427 } 425 }
428 426
429 void IDBTransaction::enqueueEvent(PassRefPtr<Event> event) 427 void IDBTransaction::enqueueEvent(PassRefPtr<Event> event)
430 { 428 {
431 ASSERT_WITH_MESSAGE(m_state != Finished, "A finished transaction tried to en queue an event of type %s.", event->type().string().utf8().data()); 429 ASSERT_WITH_MESSAGE(m_state != Finished, "A finished transaction tried to en queue an event of type %s.", event->type().string().utf8().data());
432 if (m_contextStopped || !scriptExecutionContext()) 430 if (m_contextStopped || !scriptExecutionContext())
433 return; 431 return;
434 432
435 EventQueue* eventQueue = scriptExecutionContext()->eventQueue(); 433 EventQueue* eventQueue = scriptExecutionContext()->eventQueue();
436 event->setTarget(this); 434 event->setTarget(this);
437 eventQueue->enqueueEvent(event); 435 eventQueue->enqueueEvent(event);
438 } 436 }
439 437
440 EventTargetData* IDBTransaction::eventTargetData() 438 EventTargetData* IDBTransaction::eventTargetData()
441 { 439 {
442 return &m_eventTargetData; 440 return &m_eventTargetData;
443 } 441 }
444 442
445 EventTargetData* IDBTransaction::ensureEventTargetData() 443 EventTargetData* IDBTransaction::ensureEventTargetData()
446 { 444 {
447 return &m_eventTargetData; 445 return &m_eventTargetData;
448 } 446 }
449 447
450 IDBDatabaseBackendInterface* IDBTransaction::backendDB() const 448 IDBDatabaseBackendInterface* IDBTransaction::backendDB() const
451 { 449 {
452 return db()->backend(); 450 return db()->backend();
453 } 451 }
454 452
455 } // namespace WebCore 453 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698