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

Side by Side Diff: Source/modules/indexeddb/IDBObjectStore.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/IDBObjectStore.h" 27 #include "modules/indexeddb/IDBObjectStore.h"
28 28
29 #include "bindings/v8/ExceptionState.h"
29 #include "bindings/v8/IDBBindingUtilities.h" 30 #include "bindings/v8/IDBBindingUtilities.h"
30 #include "bindings/v8/SerializedScriptValue.h" 31 #include "bindings/v8/SerializedScriptValue.h"
31 #include "core/dom/DOMStringList.h" 32 #include "core/dom/DOMStringList.h"
32 #include "core/dom/ExceptionCode.h" 33 #include "core/dom/ExceptionCode.h"
33 #include "core/dom/ExceptionCodePlaceholder.h" 34 #include "core/dom/ExceptionCodePlaceholder.h"
34 #include "core/dom/ScriptExecutionContext.h" 35 #include "core/dom/ScriptExecutionContext.h"
35 #include "core/platform/SharedBuffer.h" 36 #include "core/platform/SharedBuffer.h"
36 #include "modules/indexeddb/IDBAny.h" 37 #include "modules/indexeddb/IDBAny.h"
37 #include "modules/indexeddb/IDBCursorWithValue.h" 38 #include "modules/indexeddb/IDBCursorWithValue.h"
38 #include "modules/indexeddb/IDBDatabase.h" 39 #include "modules/indexeddb/IDBDatabase.h"
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 return 0; 412 return 0;
412 indexRequest->preventPropagation(); 413 indexRequest->preventPropagation();
413 414
414 // This is kept alive by being the success handler of the request, which is in turn kept alive by the owning transaction. 415 // This is kept alive by being the success handler of the request, which is in turn kept alive by the owning transaction.
415 RefPtr<IndexPopulator> indexPopulator = IndexPopulator::create(backendDB(), m_transaction->id(), id(), metadata); 416 RefPtr<IndexPopulator> indexPopulator = IndexPopulator::create(backendDB(), m_transaction->id(), id(), metadata);
416 indexRequest->setOnsuccess(indexPopulator); 417 indexRequest->setOnsuccess(indexPopulator);
417 418
418 return index.release(); 419 return index.release();
419 } 420 }
420 421
421 PassRefPtr<IDBIndex> IDBObjectStore::index(const String& name, ExceptionCode& ec ) 422 PassRefPtr<IDBIndex> IDBObjectStore::index(const String& name, ExceptionState& e s)
422 { 423 {
423 IDB_TRACE("IDBObjectStore::index"); 424 IDB_TRACE("IDBObjectStore::index");
424 if (isDeleted()) { 425 if (isDeleted()) {
425 ec = INVALID_STATE_ERR; 426 es.throwDOMException(INVALID_STATE_ERR);
426 return 0; 427 return 0;
427 } 428 }
428 if (m_transaction->isFinished()) { 429 if (m_transaction->isFinished()) {
429 ec = INVALID_STATE_ERR; 430 es.throwDOMException(INVALID_STATE_ERR);
430 return 0; 431 return 0;
431 } 432 }
432 433
433 IDBIndexMap::iterator it = m_indexMap.find(name); 434 IDBIndexMap::iterator it = m_indexMap.find(name);
434 if (it != m_indexMap.end()) 435 if (it != m_indexMap.end())
435 return it->value; 436 return it->value;
436 437
437 int64_t indexId = findIndexId(name); 438 int64_t indexId = findIndexId(name);
438 if (indexId == IDBIndexMetadata::InvalidId) { 439 if (indexId == IDBIndexMetadata::InvalidId) {
439 // FIXME: Should use (NotFoundError, "..."). 440 // FIXME: Should use constant
440 ec = IDBNotFoundError; 441 es.throwDOMException(NOT_FOUND_ERR, "An operation failed because the req uested database object could not be found.");
441 return 0; 442 return 0;
442 } 443 }
443 444
444 const IDBIndexMetadata* indexMetadata(0); 445 const IDBIndexMetadata* indexMetadata(0);
445 for (IDBObjectStoreMetadata::IndexMap::const_iterator it = m_metadata.indexe s.begin(); it != m_metadata.indexes.end(); ++it) { 446 for (IDBObjectStoreMetadata::IndexMap::const_iterator it = m_metadata.indexe s.begin(); it != m_metadata.indexes.end(); ++it) {
446 if (it->value.name == name) { 447 if (it->value.name == name) {
447 indexMetadata = &it->value; 448 indexMetadata = &it->value;
448 break; 449 break;
449 } 450 }
450 } 451 }
451 ASSERT(indexMetadata); 452 ASSERT(indexMetadata);
452 ASSERT(indexMetadata->id != IDBIndexMetadata::InvalidId); 453 ASSERT(indexMetadata->id != IDBIndexMetadata::InvalidId);
453 454
454 RefPtr<IDBIndex> index = IDBIndex::create(*indexMetadata, this, m_transactio n.get()); 455 RefPtr<IDBIndex> index = IDBIndex::create(*indexMetadata, this, m_transactio n.get());
455 m_indexMap.set(name, index); 456 m_indexMap.set(name, index);
456 return index.release(); 457 return index.release();
457 } 458 }
458 459
459 void IDBObjectStore::deleteIndex(const String& name, ExceptionCode& ec) 460 void IDBObjectStore::deleteIndex(const String& name, ExceptionState& es)
460 { 461 {
461 IDB_TRACE("IDBObjectStore::deleteIndex"); 462 IDB_TRACE("IDBObjectStore::deleteIndex");
462 if (!m_transaction->isVersionChange() || isDeleted()) { 463 if (!m_transaction->isVersionChange() || isDeleted()) {
463 ec = INVALID_STATE_ERR; 464 es.throwDOMException(INVALID_STATE_ERR);
464 return; 465 return;
465 } 466 }
466 if (!m_transaction->isActive()) { 467 if (!m_transaction->isActive()) {
467 ec = TransactionInactiveError; 468 es.throwDOMException(TransactionInactiveError);
468 return; 469 return;
469 } 470 }
470 int64_t indexId = findIndexId(name); 471 int64_t indexId = findIndexId(name);
471 if (indexId == IDBIndexMetadata::InvalidId) { 472 if (indexId == IDBIndexMetadata::InvalidId) {
472 // FIXME: Should use (NotFoundError, "..."). 473 // FIXME: Should use constant
473 ec = IDBNotFoundError; 474 es.throwDOMException(NOT_FOUND_ERR, "An operation failed because the req uested database object could not be found.");
474 return; 475 return;
475 } 476 }
476 477
477 backendDB()->deleteIndex(m_transaction->id(), id(), indexId); 478 backendDB()->deleteIndex(m_transaction->id(), id(), indexId);
478 479
479 m_metadata.indexes.remove(indexId); 480 m_metadata.indexes.remove(indexId);
480 m_transaction->db()->indexDeleted(id(), indexId); 481 m_transaction->db()->indexDeleted(id(), indexId);
481 IDBIndexMap::iterator it = m_indexMap.find(name); 482 IDBIndexMap::iterator it = m_indexMap.find(name);
482 if (it != m_indexMap.end()) { 483 if (it != m_indexMap.end()) {
483 it->value->markDeleted(); 484 it->value->markDeleted();
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 } 558 }
558 return IDBIndexMetadata::InvalidId; 559 return IDBIndexMetadata::InvalidId;
559 } 560 }
560 561
561 IDBDatabaseBackendInterface* IDBObjectStore::backendDB() const 562 IDBDatabaseBackendInterface* IDBObjectStore::backendDB() const
562 { 563 {
563 return m_transaction->backendDB(); 564 return m_transaction->backendDB();
564 } 565 }
565 566
566 } // namespace WebCore 567 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698