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

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

Issue 18398002: Remove IDBNotFoundError ExceptionCode (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: merge 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/IDBDatabase.h" 27 #include "modules/indexeddb/IDBDatabase.h"
28 28
29 #include "bindings/v8/ExceptionState.h"
29 #include "core/dom/DOMStringList.h" 30 #include "core/dom/DOMStringList.h"
30 #include "core/dom/EventQueue.h" 31 #include "core/dom/EventQueue.h"
31 #include "core/dom/ExceptionCode.h" 32 #include "core/dom/ExceptionCode.h"
32 #include "core/dom/ExceptionCodePlaceholder.h" 33 #include "core/dom/ExceptionCodePlaceholder.h"
33 #include "core/dom/ScriptExecutionContext.h" 34 #include "core/dom/ScriptExecutionContext.h"
34 #include "core/inspector/ScriptCallStack.h" 35 #include "core/inspector/ScriptCallStack.h"
35 #include "core/platform/HistogramSupport.h" 36 #include "core/platform/HistogramSupport.h"
36 #include "modules/indexeddb/IDBAny.h" 37 #include "modules/indexeddb/IDBAny.h"
37 #include "modules/indexeddb/IDBDatabaseCallbacks.h" 38 #include "modules/indexeddb/IDBDatabaseCallbacks.h"
38 #include "modules/indexeddb/IDBEventDispatcher.h" 39 #include "modules/indexeddb/IDBEventDispatcher.h"
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 203
203 IDBObjectStoreMetadata metadata(name, objectStoreId, keyPath, autoIncrement, IDBDatabaseBackendInterface::MinimumIndexId); 204 IDBObjectStoreMetadata metadata(name, objectStoreId, keyPath, autoIncrement, IDBDatabaseBackendInterface::MinimumIndexId);
204 RefPtr<IDBObjectStore> objectStore = IDBObjectStore::create(metadata, m_vers ionChangeTransaction.get()); 205 RefPtr<IDBObjectStore> objectStore = IDBObjectStore::create(metadata, m_vers ionChangeTransaction.get());
205 m_metadata.objectStores.set(metadata.id, metadata); 206 m_metadata.objectStores.set(metadata.id, metadata);
206 ++m_metadata.maxObjectStoreId; 207 ++m_metadata.maxObjectStoreId;
207 208
208 m_versionChangeTransaction->objectStoreCreated(name, objectStore); 209 m_versionChangeTransaction->objectStoreCreated(name, objectStore);
209 return objectStore.release(); 210 return objectStore.release();
210 } 211 }
211 212
212 void IDBDatabase::deleteObjectStore(const String& name, ExceptionCode& ec) 213 void IDBDatabase::deleteObjectStore(const String& name, ExceptionState& es)
213 { 214 {
214 IDB_TRACE("IDBDatabase::deleteObjectStore"); 215 IDB_TRACE("IDBDatabase::deleteObjectStore");
215 HistogramSupport::histogramEnumeration("WebCore.IndexedDB.FrontEndAPICalls", IDBDeleteObjectStoreCall, IDBMethodsMax); 216 HistogramSupport::histogramEnumeration("WebCore.IndexedDB.FrontEndAPICalls", IDBDeleteObjectStoreCall, IDBMethodsMax);
216 if (!m_versionChangeTransaction) { 217 if (!m_versionChangeTransaction) {
217 ec = INVALID_STATE_ERR; 218 es.throwDOMException(INVALID_STATE_ERR);
218 return; 219 return;
219 } 220 }
220 if (!m_versionChangeTransaction->isActive()) { 221 if (!m_versionChangeTransaction->isActive()) {
221 ec = TransactionInactiveError; 222 es.throwDOMException(TransactionInactiveError);
222 return; 223 return;
223 } 224 }
224 225
225 int64_t objectStoreId = findObjectStoreId(name); 226 int64_t objectStoreId = findObjectStoreId(name);
226 if (objectStoreId == IDBObjectStoreMetadata::InvalidId) { 227 if (objectStoreId == IDBObjectStoreMetadata::InvalidId) {
227 // FIXME: Should use (NotFoundError, "..."). 228 // FIXME: Should use constant
arv (Not doing code reviews) 2013/07/01 22:29:31 Where would be a good place to put this string?
jsbell 2013/07/02 18:48:08 For DOMError messages minted in Blink and Chromium
arv (Not doing code reviews) 2013/07/09 23:41:04 Went with a single constant for now.
228 ec = IDBNotFoundError; 229 es.throwDOMException(NOT_FOUND_ERR, "An operation failed because the req uested database object could not be found.");
229 return; 230 return;
230 } 231 }
231 232
232 m_backend->deleteObjectStore(m_versionChangeTransaction->id(), objectStoreId ); 233 m_backend->deleteObjectStore(m_versionChangeTransaction->id(), objectStoreId );
233 m_versionChangeTransaction->objectStoreDeleted(name); 234 m_versionChangeTransaction->objectStoreDeleted(name);
234 m_metadata.objectStores.remove(objectStoreId); 235 m_metadata.objectStores.remove(objectStoreId);
235 } 236 }
236 237
237 PassRefPtr<IDBTransaction> IDBDatabase::transaction(ScriptExecutionContext* cont ext, const Vector<String>& scope, const String& modeString, ExceptionCode& ec) 238 PassRefPtr<IDBTransaction> IDBDatabase::transaction(ScriptExecutionContext* cont ext, const Vector<String>& scope, const String& modeString, ExceptionState& es)
238 { 239 {
239 IDB_TRACE("IDBDatabase::transaction"); 240 IDB_TRACE("IDBDatabase::transaction");
240 HistogramSupport::histogramEnumeration("WebCore.IndexedDB.FrontEndAPICalls", IDBTransactionCall, IDBMethodsMax); 241 HistogramSupport::histogramEnumeration("WebCore.IndexedDB.FrontEndAPICalls", IDBTransactionCall, IDBMethodsMax);
241 if (!scope.size()) { 242 if (!scope.size()) {
242 ec = INVALID_ACCESS_ERR; 243 es.throwDOMException(INVALID_ACCESS_ERR);
243 return 0; 244 return 0;
244 } 245 }
245 246
246 IndexedDB::TransactionMode mode = IDBTransaction::stringToMode(modeString, e c); 247 IndexedDB::TransactionMode mode = IDBTransaction::stringToMode(modeString, e s);
247 if (ec) 248 if (es.hadException())
248 return 0; 249 return 0;
249 250
250 if (m_versionChangeTransaction || m_closePending) { 251 if (m_versionChangeTransaction || m_closePending) {
251 ec = INVALID_STATE_ERR; 252 es.throwDOMException(INVALID_STATE_ERR);
252 return 0; 253 return 0;
253 } 254 }
254 255
255 Vector<int64_t> objectStoreIds; 256 Vector<int64_t> objectStoreIds;
256 for (size_t i = 0; i < scope.size(); ++i) { 257 for (size_t i = 0; i < scope.size(); ++i) {
257 int64_t objectStoreId = findObjectStoreId(scope[i]); 258 int64_t objectStoreId = findObjectStoreId(scope[i]);
258 if (objectStoreId == IDBObjectStoreMetadata::InvalidId) { 259 if (objectStoreId == IDBObjectStoreMetadata::InvalidId) {
259 // FIXME: Should use (NotFoundError, "..."). 260 // FIXME: Should use constant
260 ec = IDBNotFoundError; 261 es.throwDOMException(NOT_FOUND_ERR, "An operation failed because the requested database object could not be found.");
261 return 0; 262 return 0;
262 } 263 }
263 objectStoreIds.append(objectStoreId); 264 objectStoreIds.append(objectStoreId);
264 } 265 }
265 266
266 int64_t transactionId = nextTransactionId(); 267 int64_t transactionId = nextTransactionId();
267 m_backend->createTransaction(transactionId, m_databaseCallbacks, objectStore Ids, mode); 268 m_backend->createTransaction(transactionId, m_databaseCallbacks, objectStore Ids, mode);
268 269
269 RefPtr<IDBTransaction> transaction = IDBTransaction::create(context, transac tionId, scope, mode, this); 270 RefPtr<IDBTransaction> transaction = IDBTransaction::create(context, transac tionId, scope, mode, this);
270 return transaction.release(); 271 return transaction.release();
271 } 272 }
272 273
273 PassRefPtr<IDBTransaction> IDBDatabase::transaction(ScriptExecutionContext* cont ext, const String& storeName, const String& mode, ExceptionCode& ec) 274 PassRefPtr<IDBTransaction> IDBDatabase::transaction(ScriptExecutionContext* cont ext, const String& storeName, const String& mode, ExceptionState& es)
274 { 275 {
275 RefPtr<DOMStringList> storeNames = DOMStringList::create(); 276 RefPtr<DOMStringList> storeNames = DOMStringList::create();
276 storeNames->append(storeName); 277 storeNames->append(storeName);
277 return transaction(context, storeNames, mode, ec); 278 return transaction(context, storeNames, mode, es);
278 } 279 }
279 280
280 void IDBDatabase::forceClose() 281 void IDBDatabase::forceClose()
281 { 282 {
282 for (TransactionMap::const_iterator::Values it = m_transactions.begin().valu es(), end = m_transactions.end().values(); it != end; ++it) 283 for (TransactionMap::const_iterator::Values it = m_transactions.begin().valu es(), end = m_transactions.end().values(); it != end; ++it)
283 (*it)->abort(IGNORE_EXCEPTION); 284 (*it)->abort(IGNORE_EXCEPTION);
284 this->close(); 285 this->close();
285 } 286 }
286 287
287 void IDBDatabase::close() 288 void IDBDatabase::close()
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 { 392 {
392 return &m_eventTargetData; 393 return &m_eventTargetData;
393 } 394 }
394 395
395 EventTargetData* IDBDatabase::ensureEventTargetData() 396 EventTargetData* IDBDatabase::ensureEventTargetData()
396 { 397 {
397 return &m_eventTargetData; 398 return &m_eventTargetData;
398 } 399 }
399 400
400 } // namespace WebCore 401 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698