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

Side by Side Diff: Source/modules/indexeddb/IDBIndex.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/IDBIndex.h" 27 #include "modules/indexeddb/IDBIndex.h"
28 28
29 #include "bindings/v8/ExceptionState.h"
29 #include "core/dom/ExceptionCode.h" 30 #include "core/dom/ExceptionCode.h"
30 #include "core/dom/ScriptExecutionContext.h" 31 #include "core/dom/ScriptExecutionContext.h"
31 #include "modules/indexeddb/IDBKey.h" 32 #include "modules/indexeddb/IDBKey.h"
32 #include "modules/indexeddb/IDBKeyRange.h" 33 #include "modules/indexeddb/IDBKeyRange.h"
33 #include "modules/indexeddb/IDBObjectStore.h" 34 #include "modules/indexeddb/IDBObjectStore.h"
34 #include "modules/indexeddb/IDBRequest.h" 35 #include "modules/indexeddb/IDBRequest.h"
35 #include "modules/indexeddb/IDBTracing.h" 36 #include "modules/indexeddb/IDBTracing.h"
36 #include "modules/indexeddb/IDBTransaction.h" 37 #include "modules/indexeddb/IDBTransaction.h"
37 38
38 namespace WebCore { 39 namespace WebCore {
39 40
40 static const unsigned short defaultDirection = IndexedDB::CursorNext; 41 static const unsigned short defaultDirection = IndexedDB::CursorNext;
41 42
42 IDBIndex::IDBIndex(const IDBIndexMetadata& metadata, IDBObjectStore* objectStore , IDBTransaction* transaction) 43 IDBIndex::IDBIndex(const IDBIndexMetadata& metadata, IDBObjectStore* objectStore , IDBTransaction* transaction)
43 : m_metadata(metadata) 44 : m_metadata(metadata)
44 , m_objectStore(objectStore) 45 , m_objectStore(objectStore)
45 , m_transaction(transaction) 46 , m_transaction(transaction)
46 , m_deleted(false) 47 , m_deleted(false)
47 { 48 {
48 ASSERT(m_objectStore); 49 ASSERT(m_objectStore);
49 ASSERT(m_transaction); 50 ASSERT(m_transaction);
50 ASSERT(m_metadata.id != IDBIndexMetadata::InvalidId); 51 ASSERT(m_metadata.id != IDBIndexMetadata::InvalidId);
51 ScriptWrappable::init(this); 52 ScriptWrappable::init(this);
52 } 53 }
53 54
54 IDBIndex::~IDBIndex() 55 IDBIndex::~IDBIndex()
55 { 56 {
56 } 57 }
57 58
58 PassRefPtr<IDBRequest> IDBIndex::openCursor(ScriptExecutionContext* context, Pas sRefPtr<IDBKeyRange> keyRange, const String& directionString, ExceptionCode& ec) 59 PassRefPtr<IDBRequest> IDBIndex::openCursor(ScriptExecutionContext* context, Pas sRefPtr<IDBKeyRange> keyRange, const String& directionString, ExceptionState& es )
59 { 60 {
60 IDB_TRACE("IDBIndex::openCursor"); 61 IDB_TRACE("IDBIndex::openCursor");
61 if (isDeleted()) { 62 if (isDeleted()) {
62 ec = InvalidStateError; 63 es.throwDOMException(InvalidStateError);
63 return 0; 64 return 0;
64 } 65 }
65 if (!m_transaction->isActive()) { 66 if (!m_transaction->isActive()) {
66 ec = TransactionInactiveError; 67 es.throwDOMException(TransactionInactiveError);
67 return 0; 68 return 0;
68 } 69 }
69 IndexedDB::CursorDirection direction = IDBCursor::stringToDirection(directio nString, ec); 70 IndexedDB::CursorDirection direction = IDBCursor::stringToDirection(directio nString, es);
70 if (ec) 71 if (es.hadException())
71 return 0; 72 return 0;
72 73
73 RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this ), m_transaction.get()); 74 RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this ), m_transaction.get());
74 request->setCursorDetails(IndexedDB::CursorKeyAndValue, direction); 75 request->setCursorDetails(IndexedDB::CursorKeyAndValue, direction);
75 backendDB()->openCursor(m_transaction->id(), m_objectStore->id(), m_metadata .id, keyRange, direction, false, IDBDatabaseBackendInterface::NormalTask, reques t); 76 backendDB()->openCursor(m_transaction->id(), m_objectStore->id(), m_metadata .id, keyRange, direction, false, IDBDatabaseBackendInterface::NormalTask, reques t);
76 return request; 77 return request;
77 } 78 }
78 79
79 PassRefPtr<IDBRequest> IDBIndex::openCursor(ScriptExecutionContext* context, con st ScriptValue& key, const String& direction, ExceptionCode& ec) 80 PassRefPtr<IDBRequest> IDBIndex::openCursor(ScriptExecutionContext* context, con st ScriptValue& key, const String& direction, ExceptionState& es)
80 { 81 {
81 IDB_TRACE("IDBIndex::openCursor"); 82 IDB_TRACE("IDBIndex::openCursor");
82 RefPtr<IDBKeyRange> keyRange = IDBKeyRange::only(context, key, ec); 83 RefPtr<IDBKeyRange> keyRange = IDBKeyRange::only(context, key, es);
83 if (ec) 84 if (es.hadException())
84 return 0; 85 return 0;
85 return openCursor(context, keyRange.release(), direction, ec); 86 return openCursor(context, keyRange.release(), direction, es);
86 } 87 }
87 88
88 PassRefPtr<IDBRequest> IDBIndex::count(ScriptExecutionContext* context, PassRefP tr<IDBKeyRange> keyRange, ExceptionCode& ec) 89 PassRefPtr<IDBRequest> IDBIndex::count(ScriptExecutionContext* context, PassRefP tr<IDBKeyRange> keyRange, ExceptionState& es)
89 { 90 {
90 IDB_TRACE("IDBIndex::count"); 91 IDB_TRACE("IDBIndex::count");
91 if (isDeleted()) { 92 if (isDeleted()) {
92 ec = InvalidStateError; 93 es.throwDOMException(InvalidStateError);
93 return 0; 94 return 0;
94 } 95 }
95 if (!m_transaction->isActive()) { 96 if (!m_transaction->isActive()) {
96 ec = TransactionInactiveError; 97 es.throwDOMException(TransactionInactiveError);
97 return 0; 98 return 0;
98 } 99 }
99 RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this ), m_transaction.get()); 100 RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this ), m_transaction.get());
100 backendDB()->count(m_transaction->id(), m_objectStore->id(), m_metadata.id, keyRange, request); 101 backendDB()->count(m_transaction->id(), m_objectStore->id(), m_metadata.id, keyRange, request);
101 return request; 102 return request;
102 } 103 }
103 104
104 PassRefPtr<IDBRequest> IDBIndex::count(ScriptExecutionContext* context, const Sc riptValue& key, ExceptionCode& ec) 105 PassRefPtr<IDBRequest> IDBIndex::count(ScriptExecutionContext* context, const Sc riptValue& key, ExceptionState& es)
105 { 106 {
106 IDB_TRACE("IDBIndex::count"); 107 IDB_TRACE("IDBIndex::count");
107 RefPtr<IDBKeyRange> keyRange = IDBKeyRange::only(context, key, ec); 108 RefPtr<IDBKeyRange> keyRange = IDBKeyRange::only(context, key, es);
108 if (ec) 109 if (es.hadException())
109 return 0; 110 return 0;
110 return count(context, keyRange.release(), ec); 111 return count(context, keyRange.release(), es);
111 } 112 }
112 113
113 PassRefPtr<IDBRequest> IDBIndex::openKeyCursor(ScriptExecutionContext* context, PassRefPtr<IDBKeyRange> keyRange, const String& directionString, ExceptionCode& ec) 114 PassRefPtr<IDBRequest> IDBIndex::openKeyCursor(ScriptExecutionContext* context, PassRefPtr<IDBKeyRange> keyRange, const String& directionString, ExceptionState& es)
114 { 115 {
115 IDB_TRACE("IDBIndex::openKeyCursor"); 116 IDB_TRACE("IDBIndex::openKeyCursor");
116 if (isDeleted()) { 117 if (isDeleted()) {
117 ec = InvalidStateError; 118 es.throwDOMException(InvalidStateError);
118 return 0; 119 return 0;
119 } 120 }
120 if (!m_transaction->isActive()) { 121 if (!m_transaction->isActive()) {
121 ec = TransactionInactiveError; 122 es.throwDOMException(TransactionInactiveError);
122 return 0; 123 return 0;
123 } 124 }
124 IndexedDB::CursorDirection direction = IDBCursor::stringToDirection(directio nString, ec); 125 IndexedDB::CursorDirection direction = IDBCursor::stringToDirection(directio nString, es);
125 if (ec) 126 if (es.hadException())
126 return 0; 127 return 0;
127 128
128 RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this ), m_transaction.get()); 129 RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this ), m_transaction.get());
129 request->setCursorDetails(IndexedDB::CursorKeyOnly, direction); 130 request->setCursorDetails(IndexedDB::CursorKeyOnly, direction);
130 backendDB()->openCursor(m_transaction->id(), m_objectStore->id(), m_metadata .id, keyRange, direction, true, IDBDatabaseBackendInterface::NormalTask, request ); 131 backendDB()->openCursor(m_transaction->id(), m_objectStore->id(), m_metadata .id, keyRange, direction, true, IDBDatabaseBackendInterface::NormalTask, request );
131 return request; 132 return request;
132 } 133 }
133 134
134 PassRefPtr<IDBRequest> IDBIndex::openKeyCursor(ScriptExecutionContext* context, const ScriptValue& key, const String& direction, ExceptionCode& ec) 135 PassRefPtr<IDBRequest> IDBIndex::openKeyCursor(ScriptExecutionContext* context, const ScriptValue& key, const String& direction, ExceptionState& es)
135 { 136 {
136 IDB_TRACE("IDBIndex::openKeyCursor"); 137 IDB_TRACE("IDBIndex::openKeyCursor");
137 RefPtr<IDBKeyRange> keyRange = IDBKeyRange::only(context, key, ec); 138 RefPtr<IDBKeyRange> keyRange = IDBKeyRange::only(context, key, es);
138 if (ec) 139 if (es.hadException())
139 return 0; 140 return 0;
140 return openKeyCursor(context, keyRange.release(), direction, ec); 141 return openKeyCursor(context, keyRange.release(), direction, es);
141 } 142 }
142 143
143 PassRefPtr<IDBRequest> IDBIndex::get(ScriptExecutionContext* context, const Scri ptValue& key, ExceptionCode& ec) 144 PassRefPtr<IDBRequest> IDBIndex::get(ScriptExecutionContext* context, const Scri ptValue& key, ExceptionState& es)
144 { 145 {
145 IDB_TRACE("IDBIndex::get"); 146 IDB_TRACE("IDBIndex::get");
146 RefPtr<IDBKeyRange> keyRange = IDBKeyRange::only(context, key, ec); 147 RefPtr<IDBKeyRange> keyRange = IDBKeyRange::only(context, key, es);
147 if (ec) 148 if (es.hadException())
148 return 0; 149 return 0;
149 return get(context, keyRange.release(), ec); 150 return get(context, keyRange.release(), es);
150 } 151 }
151 152
152 PassRefPtr<IDBRequest> IDBIndex::get(ScriptExecutionContext* context, PassRefPtr <IDBKeyRange> keyRange, ExceptionCode& ec) 153 PassRefPtr<IDBRequest> IDBIndex::get(ScriptExecutionContext* context, PassRefPtr <IDBKeyRange> keyRange, ExceptionState& es)
153 { 154 {
154 IDB_TRACE("IDBIndex::get"); 155 IDB_TRACE("IDBIndex::get");
155 if (isDeleted()) { 156 if (isDeleted()) {
156 ec = InvalidStateError; 157 es.throwDOMException(InvalidStateError);
157 return 0; 158 return 0;
158 } 159 }
159 if (!m_transaction->isActive()) { 160 if (!m_transaction->isActive()) {
160 ec = TransactionInactiveError; 161 es.throwDOMException(TransactionInactiveError);
161 return 0; 162 return 0;
162 } 163 }
163 if (!keyRange) { 164 if (!keyRange) {
164 ec = DataError; 165 es.throwDOMException(DataError);
165 return 0; 166 return 0;
166 } 167 }
167 168
168 RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this ), m_transaction.get()); 169 RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this ), m_transaction.get());
169 backendDB()->get(m_transaction->id(), m_objectStore->id(), m_metadata.id, ke yRange, false, request); 170 backendDB()->get(m_transaction->id(), m_objectStore->id(), m_metadata.id, ke yRange, false, request);
170 return request; 171 return request;
171 } 172 }
172 173
173 PassRefPtr<IDBRequest> IDBIndex::getKey(ScriptExecutionContext* context, const S criptValue& key, ExceptionCode& ec) 174 PassRefPtr<IDBRequest> IDBIndex::getKey(ScriptExecutionContext* context, const S criptValue& key, ExceptionState& es)
174 { 175 {
175 IDB_TRACE("IDBIndex::getKey"); 176 IDB_TRACE("IDBIndex::getKey");
176 RefPtr<IDBKeyRange> keyRange = IDBKeyRange::only(context, key, ec); 177 RefPtr<IDBKeyRange> keyRange = IDBKeyRange::only(context, key, es);
177 if (ec) 178 if (es.hadException())
178 return 0; 179 return 0;
179 180
180 return getKey(context, keyRange.release(), ec); 181 return getKey(context, keyRange.release(), es);
181 } 182 }
182 183
183 PassRefPtr<IDBRequest> IDBIndex::getKey(ScriptExecutionContext* context, PassRef Ptr<IDBKeyRange> keyRange, ExceptionCode& ec) 184 PassRefPtr<IDBRequest> IDBIndex::getKey(ScriptExecutionContext* context, PassRef Ptr<IDBKeyRange> keyRange, ExceptionState& es)
184 { 185 {
185 IDB_TRACE("IDBIndex::getKey"); 186 IDB_TRACE("IDBIndex::getKey");
186 if (isDeleted()) { 187 if (isDeleted()) {
187 ec = InvalidStateError; 188 es.throwDOMException(InvalidStateError);
188 return 0; 189 return 0;
189 } 190 }
190 if (!m_transaction->isActive()) { 191 if (!m_transaction->isActive()) {
191 ec = TransactionInactiveError; 192 es.throwDOMException(TransactionInactiveError);
192 return 0; 193 return 0;
193 } 194 }
194 if (!keyRange) { 195 if (!keyRange) {
195 ec = DataError; 196 es.throwDOMException(DataError);
196 return 0; 197 return 0;
197 } 198 }
198 199
199 RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this ), m_transaction.get()); 200 RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this ), m_transaction.get());
200 backendDB()->get(m_transaction->id(), m_objectStore->id(), m_metadata.id, ke yRange, true, request); 201 backendDB()->get(m_transaction->id(), m_objectStore->id(), m_metadata.id, ke yRange, true, request);
201 return request; 202 return request;
202 } 203 }
203 204
204 IDBDatabaseBackendInterface* IDBIndex::backendDB() const 205 IDBDatabaseBackendInterface* IDBIndex::backendDB() const
205 { 206 {
206 return m_transaction->backendDB(); 207 return m_transaction->backendDB();
207 } 208 }
208 209
209 bool IDBIndex::isDeleted() const 210 bool IDBIndex::isDeleted() const
210 { 211 {
211 return m_deleted || m_objectStore->isDeleted(); 212 return m_deleted || m_objectStore->isDeleted();
212 } 213 }
213 214
214 } // namespace WebCore 215 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698