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

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

Issue 72363002: Rename es => exceptionState in other than bindings/ (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Retry Created 7 years, 1 month 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
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 ASSERT(m_request); 88 ASSERT(m_request);
89 ASSERT(m_source->type() == IDBAny::IDBObjectStoreType || m_source->type() == IDBAny::IDBIndexType); 89 ASSERT(m_source->type() == IDBAny::IDBObjectStoreType || m_source->type() == IDBAny::IDBIndexType);
90 ASSERT(m_transaction); 90 ASSERT(m_transaction);
91 ScriptWrappable::init(this); 91 ScriptWrappable::init(this);
92 } 92 }
93 93
94 IDBCursor::~IDBCursor() 94 IDBCursor::~IDBCursor()
95 { 95 {
96 } 96 }
97 97
98 PassRefPtr<IDBRequest> IDBCursor::update(ScriptState* state, ScriptValue& value, ExceptionState& es) 98 PassRefPtr<IDBRequest> IDBCursor::update(ScriptState* state, ScriptValue& value, ExceptionState& exceptionState)
99 { 99 {
100 IDB_TRACE("IDBCursor::update"); 100 IDB_TRACE("IDBCursor::update");
101 101
102 if (!m_gotValue) { 102 if (!m_gotValue) {
103 es.throwDOMException(InvalidStateError, ExceptionMessages::failedToExecu te("update", "IDBCursor", IDBDatabase::noValueErrorMessage)); 103 exceptionState.throwDOMException(InvalidStateError, ExceptionMessages::f ailedToExecute("update", "IDBCursor", IDBDatabase::noValueErrorMessage));
104 return 0; 104 return 0;
105 } 105 }
106 if (isKeyCursor()) { 106 if (isKeyCursor()) {
107 es.throwDOMException(InvalidStateError, ExceptionMessages::failedToExecu te("update", "IDBCursor", IDBDatabase::isKeyCursorErrorMessage)); 107 exceptionState.throwDOMException(InvalidStateError, ExceptionMessages::f ailedToExecute("update", "IDBCursor", IDBDatabase::isKeyCursorErrorMessage));
108 return 0; 108 return 0;
109 } 109 }
110 if (isDeleted()) { 110 if (isDeleted()) {
111 es.throwDOMException(InvalidStateError, ExceptionMessages::failedToExecu te("update", "IDBCursor", IDBDatabase::sourceDeletedErrorMessage)); 111 exceptionState.throwDOMException(InvalidStateError, ExceptionMessages::f ailedToExecute("update", "IDBCursor", IDBDatabase::sourceDeletedErrorMessage));
112 return 0; 112 return 0;
113 } 113 }
114 if (m_transaction->isFinished()) { 114 if (m_transaction->isFinished()) {
115 es.throwDOMException(TransactionInactiveError, ExceptionMessages::failed ToExecute("update", "IDBCursor", IDBDatabase::transactionFinishedErrorMessage)); 115 exceptionState.throwDOMException(TransactionInactiveError, ExceptionMess ages::failedToExecute("update", "IDBCursor", IDBDatabase::transactionFinishedErr orMessage));
116 return 0; 116 return 0;
117 } 117 }
118 if (!m_transaction->isActive()) { 118 if (!m_transaction->isActive()) {
119 es.throwDOMException(TransactionInactiveError, ExceptionMessages::failed ToExecute("update", "IDBCursor", IDBDatabase::transactionInactiveErrorMessage)); 119 exceptionState.throwDOMException(TransactionInactiveError, ExceptionMess ages::failedToExecute("update", "IDBCursor", IDBDatabase::transactionInactiveErr orMessage));
120 return 0; 120 return 0;
121 } 121 }
122 if (m_transaction->isReadOnly()) { 122 if (m_transaction->isReadOnly()) {
123 es.throwDOMException(ReadOnlyError, ExceptionMessages::failedToExecute(" update", "IDBCursor", "The record may not be updated inside a read-only transact ion.")); 123 exceptionState.throwDOMException(ReadOnlyError, ExceptionMessages::faile dToExecute("update", "IDBCursor", "The record may not be updated inside a read-o nly transaction."));
124 return 0; 124 return 0;
125 } 125 }
126 126
127 RefPtr<IDBObjectStore> objectStore = effectiveObjectStore(); 127 RefPtr<IDBObjectStore> objectStore = effectiveObjectStore();
128 const IDBKeyPath& keyPath = objectStore->metadata().keyPath; 128 const IDBKeyPath& keyPath = objectStore->metadata().keyPath;
129 const bool usesInLineKeys = !keyPath.isNull(); 129 const bool usesInLineKeys = !keyPath.isNull();
130 if (usesInLineKeys) { 130 if (usesInLineKeys) {
131 RefPtr<IDBKey> keyPathKey = createIDBKeyFromScriptValueAndKeyPath(m_requ est->requestState(), value, keyPath); 131 RefPtr<IDBKey> keyPathKey = createIDBKeyFromScriptValueAndKeyPath(m_requ est->requestState(), value, keyPath);
132 if (!keyPathKey || !keyPathKey->isEqual(m_primaryKey.get())) { 132 if (!keyPathKey || !keyPathKey->isEqual(m_primaryKey.get())) {
133 es.throwDOMException(DataError, ExceptionMessages::failedToExecute(" update", "IDBCursor", "The effective object store of this cursor uses in-line ke ys and evaluating the key path of the value parameter results in a different val ue than the cursor's effective key.")); 133 exceptionState.throwDOMException(DataError, ExceptionMessages::faile dToExecute("update", "IDBCursor", "The effective object store of this cursor use s in-line keys and evaluating the key path of the value parameter results in a d ifferent value than the cursor's effective key."));
134 return 0; 134 return 0;
135 } 135 }
136 } 136 }
137 137
138 return objectStore->put(IDBDatabaseBackendInterface::CursorUpdate, IDBAny::c reate(this), state, value, m_primaryKey, es); 138 return objectStore->put(IDBDatabaseBackendInterface::CursorUpdate, IDBAny::c reate(this), state, value, m_primaryKey, exceptionState);
139 } 139 }
140 140
141 void IDBCursor::advance(unsigned long count, ExceptionState& es) 141 void IDBCursor::advance(unsigned long count, ExceptionState& exceptionState)
142 { 142 {
143 IDB_TRACE("IDBCursor::advance"); 143 IDB_TRACE("IDBCursor::advance");
144 if (!m_gotValue) { 144 if (!m_gotValue) {
145 es.throwDOMException(InvalidStateError, ExceptionMessages::failedToExecu te("advance", "IDBCursor", IDBDatabase::noValueErrorMessage)); 145 exceptionState.throwDOMException(InvalidStateError, ExceptionMessages::f ailedToExecute("advance", "IDBCursor", IDBDatabase::noValueErrorMessage));
146 return; 146 return;
147 } 147 }
148 if (isDeleted()) { 148 if (isDeleted()) {
149 es.throwDOMException(InvalidStateError, ExceptionMessages::failedToExecu te("advance", "IDBCursor", IDBDatabase::sourceDeletedErrorMessage)); 149 exceptionState.throwDOMException(InvalidStateError, ExceptionMessages::f ailedToExecute("advance", "IDBCursor", IDBDatabase::sourceDeletedErrorMessage));
150 return; 150 return;
151 } 151 }
152 152
153 if (m_transaction->isFinished()) { 153 if (m_transaction->isFinished()) {
154 es.throwDOMException(TransactionInactiveError, ExceptionMessages::failed ToExecute("advance", "IDBCursor", IDBDatabase::transactionFinishedErrorMessage)) ; 154 exceptionState.throwDOMException(TransactionInactiveError, ExceptionMess ages::failedToExecute("advance", "IDBCursor", IDBDatabase::transactionFinishedEr rorMessage));
155 return; 155 return;
156 } 156 }
157 if (!m_transaction->isActive()) { 157 if (!m_transaction->isActive()) {
158 es.throwDOMException(TransactionInactiveError, ExceptionMessages::failed ToExecute("advance", "IDBCursor", IDBDatabase::transactionInactiveErrorMessage)) ; 158 exceptionState.throwDOMException(TransactionInactiveError, ExceptionMess ages::failedToExecute("advance", "IDBCursor", IDBDatabase::transactionInactiveEr rorMessage));
159 return; 159 return;
160 } 160 }
161 161
162 if (!count) { 162 if (!count) {
163 es.throwUninformativeAndGenericTypeError(); 163 exceptionState.throwUninformativeAndGenericTypeError();
164 return; 164 return;
165 } 165 }
166 166
167 m_request->setPendingCursor(this); 167 m_request->setPendingCursor(this);
168 m_gotValue = false; 168 m_gotValue = false;
169 m_backend->advance(count, m_request); 169 m_backend->advance(count, m_request);
170 } 170 }
171 171
172 void IDBCursor::continueFunction(ExecutionContext* context, const ScriptValue& k eyValue, ExceptionState& es) 172 void IDBCursor::continueFunction(ExecutionContext* context, const ScriptValue& k eyValue, ExceptionState& exceptionState)
173 { 173 {
174 DOMRequestState requestState(context); 174 DOMRequestState requestState(context);
175 RefPtr<IDBKey> key = keyValue.isUndefined() ? 0 : scriptValueToIDBKey(&reque stState, keyValue); 175 RefPtr<IDBKey> key = keyValue.isUndefined() ? 0 : scriptValueToIDBKey(&reque stState, keyValue);
176 continueFunction(key.release(), es); 176 continueFunction(key.release(), exceptionState);
177 } 177 }
178 178
179 void IDBCursor::continueFunction(PassRefPtr<IDBKey> key, ExceptionState& es) 179 void IDBCursor::continueFunction(PassRefPtr<IDBKey> key, ExceptionState& excepti onState)
180 { 180 {
181 IDB_TRACE("IDBCursor::continue"); 181 IDB_TRACE("IDBCursor::continue");
182 if (key && !key->isValid()) { 182 if (key && !key->isValid()) {
183 es.throwDOMException(DataError, ExceptionMessages::failedToExecute("cont inue", "IDBCursor", IDBDatabase::notValidKeyErrorMessage)); 183 exceptionState.throwDOMException(DataError, ExceptionMessages::failedToE xecute("continue", "IDBCursor", IDBDatabase::notValidKeyErrorMessage));
184 return; 184 return;
185 } 185 }
186 186
187 if (m_transaction->isFinished()) { 187 if (m_transaction->isFinished()) {
188 es.throwDOMException(TransactionInactiveError, ExceptionMessages::failed ToExecute("continue", "IDBCursor", IDBDatabase::transactionFinishedErrorMessage) ); 188 exceptionState.throwDOMException(TransactionInactiveError, ExceptionMess ages::failedToExecute("continue", "IDBCursor", IDBDatabase::transactionFinishedE rrorMessage));
189 return; 189 return;
190 } 190 }
191 if (!m_transaction->isActive()) { 191 if (!m_transaction->isActive()) {
192 es.throwDOMException(TransactionInactiveError, ExceptionMessages::failed ToExecute("continue", "IDBCursor", IDBDatabase::transactionInactiveErrorMessage) ); 192 exceptionState.throwDOMException(TransactionInactiveError, ExceptionMess ages::failedToExecute("continue", "IDBCursor", IDBDatabase::transactionInactiveE rrorMessage));
193 return; 193 return;
194 } 194 }
195 195
196 if (!m_gotValue) { 196 if (!m_gotValue) {
197 es.throwDOMException(InvalidStateError, ExceptionMessages::failedToExecu te("continue", "IDBCursor", IDBDatabase::noValueErrorMessage)); 197 exceptionState.throwDOMException(InvalidStateError, ExceptionMessages::f ailedToExecute("continue", "IDBCursor", IDBDatabase::noValueErrorMessage));
198 return; 198 return;
199 } 199 }
200 200
201 if (isDeleted()) { 201 if (isDeleted()) {
202 es.throwDOMException(InvalidStateError, ExceptionMessages::failedToExecu te("continue", "IDBCursor", IDBDatabase::sourceDeletedErrorMessage)); 202 exceptionState.throwDOMException(InvalidStateError, ExceptionMessages::f ailedToExecute("continue", "IDBCursor", IDBDatabase::sourceDeletedErrorMessage)) ;
203 return; 203 return;
204 } 204 }
205 205
206 if (key) { 206 if (key) {
207 ASSERT(m_key); 207 ASSERT(m_key);
208 if (m_direction == IndexedDB::CursorNext || m_direction == IndexedDB::Cu rsorNextNoDuplicate) { 208 if (m_direction == IndexedDB::CursorNext || m_direction == IndexedDB::Cu rsorNextNoDuplicate) {
209 if (!m_key->isLessThan(key.get())) { 209 if (!m_key->isLessThan(key.get())) {
210 es.throwDOMException(DataError, ExceptionMessages::failedToExecu te("continue", "IDBCursor", "The parameter is less than or equal to this cursor' s position.")); 210 exceptionState.throwDOMException(DataError, ExceptionMessages::f ailedToExecute("continue", "IDBCursor", "The parameter is less than or equal to this cursor's position."));
211 return; 211 return;
212 } 212 }
213 } else { 213 } else {
214 if (!key->isLessThan(m_key.get())) { 214 if (!key->isLessThan(m_key.get())) {
215 es.throwDOMException(DataError, ExceptionMessages::failedToExecu te("continue", "IDBCursor", "The parameter is greater than or equal to this curs or's position.")); 215 exceptionState.throwDOMException(DataError, ExceptionMessages::f ailedToExecute("continue", "IDBCursor", "The parameter is greater than or equal to this cursor's position."));
216 return; 216 return;
217 } 217 }
218 } 218 }
219 } 219 }
220 220
221 // FIXME: We're not using the context from when continue was called, which m eans the callback 221 // FIXME: We're not using the context from when continue was called, which m eans the callback
222 // will be on the original context openCursor was called on. Is this right? 222 // will be on the original context openCursor was called on. Is this right?
223 m_request->setPendingCursor(this); 223 m_request->setPendingCursor(this);
224 m_gotValue = false; 224 m_gotValue = false;
225 m_backend->continueFunction(key, m_request); 225 m_backend->continueFunction(key, m_request);
226 } 226 }
227 227
228 PassRefPtr<IDBRequest> IDBCursor::deleteFunction(ExecutionContext* context, Exce ptionState& es) 228 PassRefPtr<IDBRequest> IDBCursor::deleteFunction(ExecutionContext* context, Exce ptionState& exceptionState)
229 { 229 {
230 IDB_TRACE("IDBCursor::delete"); 230 IDB_TRACE("IDBCursor::delete");
231 if (m_transaction->isFinished()) { 231 if (m_transaction->isFinished()) {
232 es.throwDOMException(TransactionInactiveError, ExceptionMessages::failed ToExecute("delete", "IDBCursor", IDBDatabase::transactionFinishedErrorMessage)); 232 exceptionState.throwDOMException(TransactionInactiveError, ExceptionMess ages::failedToExecute("delete", "IDBCursor", IDBDatabase::transactionFinishedErr orMessage));
233 return 0; 233 return 0;
234 } 234 }
235 if (!m_transaction->isActive()) { 235 if (!m_transaction->isActive()) {
236 es.throwDOMException(TransactionInactiveError, ExceptionMessages::failed ToExecute("delete", "IDBCursor", IDBDatabase::transactionInactiveErrorMessage)); 236 exceptionState.throwDOMException(TransactionInactiveError, ExceptionMess ages::failedToExecute("delete", "IDBCursor", IDBDatabase::transactionInactiveErr orMessage));
237 return 0; 237 return 0;
238 } 238 }
239 if (m_transaction->isReadOnly()) { 239 if (m_transaction->isReadOnly()) {
240 es.throwDOMException(ReadOnlyError, ExceptionMessages::failedToExecute(" delete", "IDBCursor", "The record may not be deleted inside a read-only transact ion.")); 240 exceptionState.throwDOMException(ReadOnlyError, ExceptionMessages::faile dToExecute("delete", "IDBCursor", "The record may not be deleted inside a read-o nly transaction."));
241 return 0; 241 return 0;
242 } 242 }
243 243
244 if (!m_gotValue) { 244 if (!m_gotValue) {
245 es.throwDOMException(InvalidStateError, ExceptionMessages::failedToExecu te("delete", "IDBCursor", IDBDatabase::noValueErrorMessage)); 245 exceptionState.throwDOMException(InvalidStateError, ExceptionMessages::f ailedToExecute("delete", "IDBCursor", IDBDatabase::noValueErrorMessage));
246 return 0; 246 return 0;
247 } 247 }
248 if (isKeyCursor()) { 248 if (isKeyCursor()) {
249 es.throwDOMException(InvalidStateError, ExceptionMessages::failedToExecu te("delete", "IDBCursor", IDBDatabase::isKeyCursorErrorMessage)); 249 exceptionState.throwDOMException(InvalidStateError, ExceptionMessages::f ailedToExecute("delete", "IDBCursor", IDBDatabase::isKeyCursorErrorMessage));
250 return 0; 250 return 0;
251 } 251 }
252 if (isDeleted()) { 252 if (isDeleted()) {
253 es.throwDOMException(InvalidStateError, ExceptionMessages::failedToExecu te("delete", "IDBCursor", IDBDatabase::sourceDeletedErrorMessage)); 253 exceptionState.throwDOMException(InvalidStateError, ExceptionMessages::f ailedToExecute("delete", "IDBCursor", IDBDatabase::sourceDeletedErrorMessage));
254 return 0; 254 return 0;
255 } 255 }
256 256
257 RefPtr<IDBKeyRange> keyRange = IDBKeyRange::only(m_primaryKey, es); 257 RefPtr<IDBKeyRange> keyRange = IDBKeyRange::only(m_primaryKey, exceptionStat e);
258 ASSERT(!es.hadException()); 258 ASSERT(!exceptionState.hadException());
259 259
260 RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this ), m_transaction.get()); 260 RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this ), m_transaction.get());
261 m_transaction->backendDB()->deleteRange(m_transaction->id(), effectiveObject Store()->id(), keyRange, request); 261 m_transaction->backendDB()->deleteRange(m_transaction->id(), effectiveObject Store()->id(), keyRange, request);
262 return request.release(); 262 return request.release();
263 } 263 }
264 264
265 void IDBCursor::postSuccessHandlerCallback() 265 void IDBCursor::postSuccessHandlerCallback()
266 { 266 {
267 if (m_backend) 267 if (m_backend)
268 m_backend->postSuccessHandlerCallback(); 268 m_backend->postSuccessHandlerCallback();
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 return index->objectStore(); 348 return index->objectStore();
349 } 349 }
350 350
351 bool IDBCursor::isDeleted() const 351 bool IDBCursor::isDeleted() const
352 { 352 {
353 if (m_source->type() == IDBAny::IDBObjectStoreType) 353 if (m_source->type() == IDBAny::IDBObjectStoreType)
354 return m_source->idbObjectStore()->isDeleted(); 354 return m_source->idbObjectStore()->isDeleted();
355 return m_source->idbIndex()->isDeleted(); 355 return m_source->idbIndex()->isDeleted();
356 } 356 }
357 357
358 IndexedDB::CursorDirection IDBCursor::stringToDirection(const String& directionS tring, ExceptionState& es) 358 IndexedDB::CursorDirection IDBCursor::stringToDirection(const String& directionS tring, ExceptionState& exceptionState)
359 { 359 {
360 if (directionString.isNull() || directionString == IDBCursor::directionNext( )) 360 if (directionString.isNull() || directionString == IDBCursor::directionNext( ))
361 return IndexedDB::CursorNext; 361 return IndexedDB::CursorNext;
362 if (directionString == IDBCursor::directionNextUnique()) 362 if (directionString == IDBCursor::directionNextUnique())
363 return IndexedDB::CursorNextNoDuplicate; 363 return IndexedDB::CursorNextNoDuplicate;
364 if (directionString == IDBCursor::directionPrev()) 364 if (directionString == IDBCursor::directionPrev())
365 return IndexedDB::CursorPrev; 365 return IndexedDB::CursorPrev;
366 if (directionString == IDBCursor::directionPrevUnique()) 366 if (directionString == IDBCursor::directionPrevUnique())
367 return IndexedDB::CursorPrevNoDuplicate; 367 return IndexedDB::CursorPrevNoDuplicate;
368 368
369 es.throwUninformativeAndGenericTypeError(); 369 exceptionState.throwUninformativeAndGenericTypeError();
370 return IndexedDB::CursorNext; 370 return IndexedDB::CursorNext;
371 } 371 }
372 372
373 const AtomicString& IDBCursor::directionToString(unsigned short direction) 373 const AtomicString& IDBCursor::directionToString(unsigned short direction)
374 { 374 {
375 switch (direction) { 375 switch (direction) {
376 case IndexedDB::CursorNext: 376 case IndexedDB::CursorNext:
377 return IDBCursor::directionNext(); 377 return IDBCursor::directionNext();
378 378
379 case IndexedDB::CursorNextNoDuplicate: 379 case IndexedDB::CursorNextNoDuplicate:
380 return IDBCursor::directionNextUnique(); 380 return IDBCursor::directionNextUnique();
381 381
382 case IndexedDB::CursorPrev: 382 case IndexedDB::CursorPrev:
383 return IDBCursor::directionPrev(); 383 return IDBCursor::directionPrev();
384 384
385 case IndexedDB::CursorPrevNoDuplicate: 385 case IndexedDB::CursorPrevNoDuplicate:
386 return IDBCursor::directionPrevUnique(); 386 return IDBCursor::directionPrevUnique();
387 387
388 default: 388 default:
389 ASSERT_NOT_REACHED(); 389 ASSERT_NOT_REACHED();
390 return IDBCursor::directionNext(); 390 return IDBCursor::directionNext();
391 } 391 }
392 } 392 }
393 393
394 } // namespace WebCore 394 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/modules/imagebitmap/ImageBitmapFactories.cpp ('k') | Source/modules/indexeddb/IDBDatabase.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698