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

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

Issue 78053006: [oilpan] Move IDBDatabase, IDBDatabaseCallbacks, IDBDatabaseBackendInterface and other related clas… (Closed) Base URL: svn://svn.chromium.org/blink/branches/oilpan
Patch Set: Created 7 years 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
« no previous file with comments | « Source/modules/indexeddb/IDBObjectStore.h ('k') | Source/modules/indexeddb/IDBOpenDBRequest.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 PassRefPtr<DOMStringList> IDBObjectStore::indexNames() const 61 PassRefPtr<DOMStringList> IDBObjectStore::indexNames() const
62 { 62 {
63 IDB_TRACE("IDBObjectStore::indexNames"); 63 IDB_TRACE("IDBObjectStore::indexNames");
64 RefPtr<DOMStringList> indexNames = DOMStringList::create(); 64 RefPtr<DOMStringList> indexNames = DOMStringList::create();
65 for (IDBObjectStoreMetadata::IndexMap::const_iterator it = m_metadata.indexe s.begin(); it != m_metadata.indexes.end(); ++it) 65 for (IDBObjectStoreMetadata::IndexMap::const_iterator it = m_metadata.indexe s.begin(); it != m_metadata.indexes.end(); ++it)
66 indexNames->append(it->value.name); 66 indexNames->append(it->value.name);
67 indexNames->sort(); 67 indexNames->sort();
68 return indexNames.release(); 68 return indexNames.release();
69 } 69 }
70 70
71 PassRefPtr<IDBRequest> IDBObjectStore::get(ScriptExecutionContext* context, Pass RefPtr<IDBKeyRange> keyRange, ExceptionCode& ec) 71 IDBRequest* IDBObjectStore::get(ScriptExecutionContext* context, PassRefPtr<IDBK eyRange> keyRange, ExceptionCode& ec)
72 { 72 {
73 IDB_TRACE("IDBObjectStore::get"); 73 IDB_TRACE("IDBObjectStore::get");
74 if (isDeleted()) { 74 if (isDeleted()) {
75 ec = IDBDatabaseException::InvalidStateError; 75 ec = IDBDatabaseException::InvalidStateError;
76 return 0; 76 return 0;
77 } 77 }
78 if (!keyRange) { 78 if (!keyRange) {
79 ec = IDBDatabaseException::DataError; 79 ec = IDBDatabaseException::DataError;
80 return 0; 80 return 0;
81 } 81 }
82 if (!m_transaction->isActive()) { 82 if (!m_transaction->isActive()) {
83 ec = IDBDatabaseException::TransactionInactiveError; 83 ec = IDBDatabaseException::TransactionInactiveError;
84 return 0; 84 return 0;
85 } 85 }
86 RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this ), m_transaction.get()); 86 IDBRequest* request = IDBRequest::create(context, IDBAny::create(this), m_tr ansaction.get());
87 backendDB()->get(m_transaction->id(), id(), IDBIndexMetadata::InvalidId, key Range, false, request); 87 backendDB()->get(m_transaction->id(), id(), IDBIndexMetadata::InvalidId, key Range, false, request);
88 return request.release(); 88 return request;
89 } 89 }
90 90
91 PassRefPtr<IDBRequest> IDBObjectStore::get(ScriptExecutionContext* context, cons t ScriptValue& key, ExceptionCode& ec) 91 IDBRequest* IDBObjectStore::get(ScriptExecutionContext* context, const ScriptVal ue& key, ExceptionCode& ec)
92 { 92 {
93 RefPtr<IDBKeyRange> keyRange = IDBKeyRange::only(context, key, ec); 93 RefPtr<IDBKeyRange> keyRange = IDBKeyRange::only(context, key, ec);
94 if (ec) 94 if (ec)
95 return 0; 95 return 0;
96 return get(context, keyRange.release(), ec); 96 return get(context, keyRange.release(), ec);
97 } 97 }
98 98
99 static void generateIndexKeysForValue(DOMRequestState* requestState, const IDBIn dexMetadata& indexMetadata, const ScriptValue& objectValue, IDBObjectStore::Inde xKeys* indexKeys) 99 static void generateIndexKeysForValue(DOMRequestState* requestState, const IDBIn dexMetadata& indexMetadata, const ScriptValue& objectValue, IDBObjectStore::Inde xKeys* indexKeys)
100 { 100 {
101 ASSERT(indexKeys); 101 ASSERT(indexKeys);
(...skipping 10 matching lines...) Expand all
112 } else { 112 } else {
113 ASSERT(indexMetadata.multiEntry); 113 ASSERT(indexMetadata.multiEntry);
114 ASSERT(indexKey->type() == IDBKey::ArrayType); 114 ASSERT(indexKey->type() == IDBKey::ArrayType);
115 indexKey = IDBKey::createMultiEntryArray(indexKey->array()); 115 indexKey = IDBKey::createMultiEntryArray(indexKey->array());
116 116
117 for (size_t i = 0; i < indexKey->array().size(); ++i) 117 for (size_t i = 0; i < indexKey->array().size(); ++i)
118 indexKeys->append(indexKey->array()[i]); 118 indexKeys->append(indexKey->array()[i]);
119 } 119 }
120 } 120 }
121 121
122 PassRefPtr<IDBRequest> IDBObjectStore::add(ScriptState* state, ScriptValue& valu e, const ScriptValue& key, ExceptionCode& ec) 122 IDBRequest* IDBObjectStore::add(ScriptState* state, ScriptValue& value, const Sc riptValue& key, ExceptionCode& ec)
123 { 123 {
124 IDB_TRACE("IDBObjectStore::add"); 124 IDB_TRACE("IDBObjectStore::add");
125 return put(IDBDatabaseBackendInterface::AddOnly, IDBAny::create(this), state , value, key, ec); 125 return put(IDBDatabaseBackendInterface::AddOnly, IDBAny::create(this), state , value, key, ec);
126 } 126 }
127 127
128 PassRefPtr<IDBRequest> IDBObjectStore::put(ScriptState* state, ScriptValue& valu e, const ScriptValue& key, ExceptionCode& ec) 128 IDBRequest* IDBObjectStore::put(ScriptState* state, ScriptValue& value, const Sc riptValue& key, ExceptionCode& ec)
129 { 129 {
130 IDB_TRACE("IDBObjectStore::put"); 130 IDB_TRACE("IDBObjectStore::put");
131 return put(IDBDatabaseBackendInterface::AddOrUpdate, IDBAny::create(this), s tate, value, key, ec); 131 return put(IDBDatabaseBackendInterface::AddOrUpdate, IDBAny::create(this), s tate, value, key, ec);
132 } 132 }
133 133
134 PassRefPtr<IDBRequest> IDBObjectStore::put(IDBDatabaseBackendInterface::PutMode putMode, PassRefPtr<IDBAny> source, ScriptState* state, ScriptValue& value, cons t ScriptValue& keyValue, ExceptionCode& ec) 134 IDBRequest* IDBObjectStore::put(IDBDatabaseBackendInterface::PutMode putMode, Pa ssRefPtr<IDBAny> source, ScriptState* state, ScriptValue& value, const ScriptVal ue& keyValue, ExceptionCode& ec)
135 { 135 {
136 ScriptExecutionContext* context = scriptExecutionContextFromScriptState(stat e); 136 ScriptExecutionContext* context = scriptExecutionContextFromScriptState(stat e);
137 DOMRequestState requestState(context); 137 DOMRequestState requestState(context);
138 RefPtr<IDBKey> key = keyValue.isUndefined() ? 0 : scriptValueToIDBKey(&reque stState, keyValue); 138 RefPtr<IDBKey> key = keyValue.isUndefined() ? 0 : scriptValueToIDBKey(&reque stState, keyValue);
139 return put(putMode, source, state, value, key.release(), ec); 139 return put(putMode, source, state, value, key.release(), ec);
140 } 140 }
141 141
142 PassRefPtr<IDBRequest> IDBObjectStore::put(IDBDatabaseBackendInterface::PutMode putMode, PassRefPtr<IDBAny> source, ScriptState* state, ScriptValue& value, Pass RefPtr<IDBKey> prpKey, ExceptionCode& ec) 142 IDBRequest* IDBObjectStore::put(IDBDatabaseBackendInterface::PutMode putMode, Pa ssRefPtr<IDBAny> source, ScriptState* state, ScriptValue& value, PassRefPtr<IDBK ey> prpKey, ExceptionCode& ec)
143 { 143 {
144 RefPtr<IDBKey> key = prpKey; 144 RefPtr<IDBKey> key = prpKey;
145 if (isDeleted()) { 145 if (isDeleted()) {
146 ec = IDBDatabaseException::InvalidStateError; 146 ec = IDBDatabaseException::InvalidStateError;
147 return 0; 147 return 0;
148 } 148 }
149 if (!m_transaction->isActive()) { 149 if (!m_transaction->isActive()) {
150 ec = IDBDatabaseException::TransactionInactiveError; 150 ec = IDBDatabaseException::TransactionInactiveError;
151 return 0; 151 return 0;
152 } 152 }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 210
211 Vector<int64_t> indexIds; 211 Vector<int64_t> indexIds;
212 Vector<IndexKeys> indexKeys; 212 Vector<IndexKeys> indexKeys;
213 for (IDBObjectStoreMetadata::IndexMap::const_iterator it = m_metadata.indexe s.begin(); it != m_metadata.indexes.end(); ++it) { 213 for (IDBObjectStoreMetadata::IndexMap::const_iterator it = m_metadata.indexe s.begin(); it != m_metadata.indexes.end(); ++it) {
214 IndexKeys keys; 214 IndexKeys keys;
215 generateIndexKeysForValue(&requestState, it->value, value, &keys); 215 generateIndexKeysForValue(&requestState, it->value, value, &keys);
216 indexIds.append(it->key); 216 indexIds.append(it->key);
217 indexKeys.append(keys); 217 indexKeys.append(keys);
218 } 218 }
219 219
220 RefPtr<IDBRequest> request = IDBRequest::create(context, source, m_transacti on.get()); 220 IDBRequest* request = IDBRequest::create(context, source, m_transaction.get( ));
221 Vector<uint8_t> valueBytes = serializedValue->toWireBytes(); 221 Vector<uint8_t> valueBytes = serializedValue->toWireBytes();
222 // This is a hack to account for disagreements about whether SerializedScrip tValue should deal in Vector<uint8_t> or Vector<char>. 222 // This is a hack to account for disagreements about whether SerializedScrip tValue should deal in Vector<uint8_t> or Vector<char>.
223 // See https://lists.webkit.org/pipermail/webkit-dev/2013-February/023682.ht ml 223 // See https://lists.webkit.org/pipermail/webkit-dev/2013-February/023682.ht ml
224 Vector<char>* valueBytesSigned = reinterpret_cast<Vector<char>*>(&valueBytes ); 224 Vector<char>* valueBytesSigned = reinterpret_cast<Vector<char>*>(&valueBytes );
225 RefPtr<SharedBuffer> valueBuffer = SharedBuffer::adoptVector(*valueBytesSign ed); 225 RefPtr<SharedBuffer> valueBuffer = SharedBuffer::adoptVector(*valueBytesSign ed);
226 backendDB()->put(m_transaction->id(), id(), valueBuffer, key.release(), stat ic_cast<IDBDatabaseBackendInterface::PutMode>(putMode), request, indexIds, index Keys); 226 backendDB()->put(m_transaction->id(), id(), valueBuffer, key.release(), stat ic_cast<IDBDatabaseBackendInterface::PutMode>(putMode), request, indexIds, index Keys);
227 return request.release(); 227 return request;
228 } 228 }
229 229
230 PassRefPtr<IDBRequest> IDBObjectStore::deleteFunction(ScriptExecutionContext* co ntext, PassRefPtr<IDBKeyRange> keyRange, ExceptionCode& ec) 230 IDBRequest* IDBObjectStore::deleteFunction(ScriptExecutionContext* context, Pass RefPtr<IDBKeyRange> keyRange, ExceptionCode& ec)
231 { 231 {
232 IDB_TRACE("IDBObjectStore::delete"); 232 IDB_TRACE("IDBObjectStore::delete");
233 if (isDeleted()) { 233 if (isDeleted()) {
234 ec = IDBDatabaseException::InvalidStateError; 234 ec = IDBDatabaseException::InvalidStateError;
235 return 0; 235 return 0;
236 } 236 }
237 if (!m_transaction->isActive()) { 237 if (!m_transaction->isActive()) {
238 ec = IDBDatabaseException::TransactionInactiveError; 238 ec = IDBDatabaseException::TransactionInactiveError;
239 return 0; 239 return 0;
240 } 240 }
241 if (m_transaction->isReadOnly()) { 241 if (m_transaction->isReadOnly()) {
242 ec = IDBDatabaseException::ReadOnlyError; 242 ec = IDBDatabaseException::ReadOnlyError;
243 return 0; 243 return 0;
244 } 244 }
245 if (!keyRange) { 245 if (!keyRange) {
246 ec = IDBDatabaseException::DataError; 246 ec = IDBDatabaseException::DataError;
247 return 0; 247 return 0;
248 } 248 }
249 249
250 RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this ), m_transaction.get()); 250 IDBRequest* request = IDBRequest::create(context, IDBAny::create(this), m_tr ansaction.get());
251 backendDB()->deleteRange(m_transaction->id(), id(), keyRange, request); 251 backendDB()->deleteRange(m_transaction->id(), id(), keyRange, request);
252 return request.release(); 252 return request;
253 } 253 }
254 254
255 PassRefPtr<IDBRequest> IDBObjectStore::deleteFunction(ScriptExecutionContext* co ntext, const ScriptValue& key, ExceptionCode& ec) 255 IDBRequest* IDBObjectStore::deleteFunction(ScriptExecutionContext* context, cons t ScriptValue& key, ExceptionCode& ec)
256 { 256 {
257 RefPtr<IDBKeyRange> keyRange = IDBKeyRange::only(context, key, ec); 257 RefPtr<IDBKeyRange> keyRange = IDBKeyRange::only(context, key, ec);
258 if (ec) 258 if (ec)
259 return 0; 259 return 0;
260 return deleteFunction(context, keyRange.release(), ec); 260 return deleteFunction(context, keyRange.release(), ec);
261 } 261 }
262 262
263 PassRefPtr<IDBRequest> IDBObjectStore::clear(ScriptExecutionContext* context, Ex ceptionCode& ec) 263 IDBRequest* IDBObjectStore::clear(ScriptExecutionContext* context, ExceptionCode & ec)
264 { 264 {
265 IDB_TRACE("IDBObjectStore::clear"); 265 IDB_TRACE("IDBObjectStore::clear");
266 if (isDeleted()) { 266 if (isDeleted()) {
267 ec = IDBDatabaseException::InvalidStateError; 267 ec = IDBDatabaseException::InvalidStateError;
268 return 0; 268 return 0;
269 } 269 }
270 if (!m_transaction->isActive()) { 270 if (!m_transaction->isActive()) {
271 ec = IDBDatabaseException::TransactionInactiveError; 271 ec = IDBDatabaseException::TransactionInactiveError;
272 return 0; 272 return 0;
273 } 273 }
274 if (m_transaction->isReadOnly()) { 274 if (m_transaction->isReadOnly()) {
275 ec = IDBDatabaseException::ReadOnlyError; 275 ec = IDBDatabaseException::ReadOnlyError;
276 return 0; 276 return 0;
277 } 277 }
278 278
279 RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this ), m_transaction.get()); 279 IDBRequest* request = IDBRequest::create(context, IDBAny::create(this), m_tr ansaction.get());
280 backendDB()->clear(m_transaction->id(), id(), request); 280 backendDB()->clear(m_transaction->id(), id(), request);
281 return request.release(); 281 return request;
282 } 282 }
283 283
284 namespace { 284 namespace {
285 // This class creates the index keys for a given index by extracting 285 // This class creates the index keys for a given index by extracting
286 // them from the SerializedScriptValue, for all the existing values in 286 // them from the SerializedScriptValue, for all the existing values in
287 // the objectStore. It only needs to be kept alive by virtue of being 287 // the objectStore. It only needs to be kept alive by virtue of being
288 // a listener on an IDBRequest object, in the same way that JavaScript 288 // a listener on an IDBRequest object, in the same way that JavaScript
289 // cursor success handlers are kept alive. 289 // cursor success handlers are kept alive.
290 class IndexPopulator : public EventListener { 290 class IndexPopulator : public EventListener {
291 public: 291 public:
292 static PassRefPtr<IndexPopulator> create(PassRefPtr<IDBDatabaseBackendInterf ace> backend, int64_t transactionId, int64_t objectStoreId, const IDBIndexMetada ta& indexMetadata) 292 static PassRefPtr<IndexPopulator> create(IDBDatabaseBackendInterface* backen d, int64_t transactionId, int64_t objectStoreId, const IDBIndexMetadata& indexMe tadata)
293 { 293 {
294 return adoptRef(new IndexPopulator(backend, transactionId, objectStoreId , indexMetadata)); 294 return adoptRef(new IndexPopulator(backend, transactionId, objectStoreId , indexMetadata));
295 } 295 }
296 296
297 virtual bool operator==(const EventListener& other) 297 virtual bool operator==(const EventListener& other)
298 { 298 {
299 return this == &other; 299 return this == &other;
300 } 300 }
301 301
302 private: 302 private:
303 IndexPopulator(PassRefPtr<IDBDatabaseBackendInterface> backend, int64_t tran sactionId, int64_t objectStoreId, const IDBIndexMetadata& indexMetadata) 303 IndexPopulator(IDBDatabaseBackendInterface* backend, int64_t transactionId, int64_t objectStoreId, const IDBIndexMetadata& indexMetadata)
304 : EventListener(CPPEventListenerType) 304 : EventListener(CPPEventListenerType)
305 , m_databaseBackend(backend) 305 , m_databaseBackend(backend)
306 , m_transactionId(transactionId) 306 , m_transactionId(transactionId)
307 , m_objectStoreId(objectStoreId) 307 , m_objectStoreId(objectStoreId)
308 , m_indexMetadata(indexMetadata) 308 , m_indexMetadata(indexMetadata)
309 { 309 {
310 } 310 }
311 311
312 virtual void handleEvent(ScriptExecutionContext*, Event* event) 312 virtual void handleEvent(ScriptExecutionContext*, Event* event)
313 { 313 {
(...skipping 23 matching lines...) Expand all
337 m_databaseBackend->setIndexKeys(m_transactionId, m_objectStoreId, pr imaryKey, indexIds, indexKeysList); 337 m_databaseBackend->setIndexKeys(m_transactionId, m_objectStoreId, pr imaryKey, indexIds, indexKeysList);
338 } else { 338 } else {
339 // Now that we are done indexing, tell the backend to go 339 // Now that we are done indexing, tell the backend to go
340 // back to processing tasks of type NormalTask. 340 // back to processing tasks of type NormalTask.
341 m_databaseBackend->setIndexesReady(m_transactionId, m_objectStoreId, indexIds); 341 m_databaseBackend->setIndexesReady(m_transactionId, m_objectStoreId, indexIds);
342 m_databaseBackend.clear(); 342 m_databaseBackend.clear();
343 } 343 }
344 344
345 } 345 }
346 346
347 RefPtr<IDBDatabaseBackendInterface> m_databaseBackend; 347 Persistent<IDBDatabaseBackendInterface> m_databaseBackend;
348 const int64_t m_transactionId; 348 const int64_t m_transactionId;
349 const int64_t m_objectStoreId; 349 const int64_t m_objectStoreId;
350 const IDBIndexMetadata m_indexMetadata; 350 const IDBIndexMetadata m_indexMetadata;
351 }; 351 };
352 } 352 }
353 353
354 PassRefPtr<IDBIndex> IDBObjectStore::createIndex(ScriptExecutionContext* context , const String& name, const IDBKeyPath& keyPath, const Dictionary& options, Exce ptionCode& ec) 354 PassRefPtr<IDBIndex> IDBObjectStore::createIndex(ScriptExecutionContext* context , const String& name, const IDBKeyPath& keyPath, const Dictionary& options, Exce ptionCode& ec)
355 { 355 {
356 bool unique = false; 356 bool unique = false;
357 options.get("unique", unique); 357 options.get("unique", unique);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 IDBIndexMetadata metadata(name, indexId, keyPath, unique, multiEntry); 399 IDBIndexMetadata metadata(name, indexId, keyPath, unique, multiEntry);
400 RefPtr<IDBIndex> index = IDBIndex::create(metadata, this, m_transaction.get( )); 400 RefPtr<IDBIndex> index = IDBIndex::create(metadata, this, m_transaction.get( ));
401 m_indexMap.set(name, index); 401 m_indexMap.set(name, index);
402 m_metadata.indexes.set(indexId, metadata); 402 m_metadata.indexes.set(indexId, metadata);
403 m_transaction->db()->indexCreated(id(), metadata); 403 m_transaction->db()->indexCreated(id(), metadata);
404 404
405 ASSERT(!ec); 405 ASSERT(!ec);
406 if (ec) 406 if (ec)
407 return 0; 407 return 0;
408 408
409 RefPtr<IDBRequest> indexRequest = openCursor(context, static_cast<IDBKeyRang e*>(0), IDBCursor::directionNext(), IDBDatabaseBackendInterface::PreemptiveTask, ec); 409 IDBRequest* indexRequest = openCursor(context, static_cast<IDBKeyRange*>(0), IDBCursor::directionNext(), IDBDatabaseBackendInterface::PreemptiveTask, ec);
410 ASSERT(!ec); 410 ASSERT(!ec);
411 if (ec) 411 if (ec)
412 return 0; 412 return 0;
413 indexRequest->preventPropagation(); 413 indexRequest->preventPropagation();
414 414
415 // 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.
416 RefPtr<IndexPopulator> indexPopulator = IndexPopulator::create(backendDB(), m_transaction->id(), id(), metadata); 416 RefPtr<IndexPopulator> indexPopulator = IndexPopulator::create(backendDB(), m_transaction->id(), id(), metadata);
417 indexRequest->setOnsuccess(indexPopulator); 417 indexRequest->setOnsuccess(indexPopulator);
418 418
419 return index.release(); 419 return index.release();
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 477
478 m_metadata.indexes.remove(indexId); 478 m_metadata.indexes.remove(indexId);
479 m_transaction->db()->indexDeleted(id(), indexId); 479 m_transaction->db()->indexDeleted(id(), indexId);
480 IDBIndexMap::iterator it = m_indexMap.find(name); 480 IDBIndexMap::iterator it = m_indexMap.find(name);
481 if (it != m_indexMap.end()) { 481 if (it != m_indexMap.end()) {
482 it->value->markDeleted(); 482 it->value->markDeleted();
483 m_indexMap.remove(name); 483 m_indexMap.remove(name);
484 } 484 }
485 } 485 }
486 486
487 PassRefPtr<IDBRequest> IDBObjectStore::openCursor(ScriptExecutionContext* contex t, PassRefPtr<IDBKeyRange> range, const String& directionString, IDBDatabaseBack endInterface::TaskType taskType, ExceptionCode& ec) 487 IDBRequest* IDBObjectStore::openCursor(ScriptExecutionContext* context, PassRefP tr<IDBKeyRange> range, const String& directionString, IDBDatabaseBackendInterfac e::TaskType taskType, ExceptionCode& ec)
488 { 488 {
489 IDB_TRACE("IDBObjectStore::openCursor"); 489 IDB_TRACE("IDBObjectStore::openCursor");
490 if (isDeleted()) { 490 if (isDeleted()) {
491 ec = IDBDatabaseException::InvalidStateError; 491 ec = IDBDatabaseException::InvalidStateError;
492 return 0; 492 return 0;
493 } 493 }
494 if (!m_transaction->isActive()) { 494 if (!m_transaction->isActive()) {
495 ec = IDBDatabaseException::TransactionInactiveError; 495 ec = IDBDatabaseException::TransactionInactiveError;
496 return 0; 496 return 0;
497 } 497 }
498 IndexedDB::CursorDirection direction = IDBCursor::stringToDirection(directio nString, ec); 498 IndexedDB::CursorDirection direction = IDBCursor::stringToDirection(directio nString, ec);
499 if (ec) 499 if (ec)
500 return 0; 500 return 0;
501 501
502 RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this ), m_transaction.get()); 502 IDBRequest* request = IDBRequest::create(context, IDBAny::create(this), m_tr ansaction.get());
503 request->setCursorDetails(IndexedDB::CursorKeyAndValue, direction); 503 request->setCursorDetails(IndexedDB::CursorKeyAndValue, direction);
504 504
505 backendDB()->openCursor(m_transaction->id(), id(), IDBIndexMetadata::Invalid Id, range, direction, false, static_cast<IDBDatabaseBackendInterface::TaskType>( taskType), request); 505 backendDB()->openCursor(m_transaction->id(), id(), IDBIndexMetadata::Invalid Id, range, direction, false, static_cast<IDBDatabaseBackendInterface::TaskType>( taskType), request);
506 return request.release(); 506 return request;
507 } 507 }
508 508
509 PassRefPtr<IDBRequest> IDBObjectStore::openCursor(ScriptExecutionContext* contex t, const ScriptValue& key, const String& direction, ExceptionCode& ec) 509 IDBRequest* IDBObjectStore::openCursor(ScriptExecutionContext* context, const Sc riptValue& key, const String& direction, ExceptionCode& ec)
510 { 510 {
511 RefPtr<IDBKeyRange> keyRange = IDBKeyRange::only(context, key, ec); 511 RefPtr<IDBKeyRange> keyRange = IDBKeyRange::only(context, key, ec);
512 if (ec) 512 if (ec)
513 return 0; 513 return 0;
514 return openCursor(context, keyRange.release(), direction, ec); 514 return openCursor(context, keyRange.release(), direction, ec);
515 } 515 }
516 516
517 PassRefPtr<IDBRequest> IDBObjectStore::count(ScriptExecutionContext* context, Pa ssRefPtr<IDBKeyRange> range, ExceptionCode& ec) 517 IDBRequest* IDBObjectStore::count(ScriptExecutionContext* context, PassRefPtr<ID BKeyRange> range, ExceptionCode& ec)
518 { 518 {
519 IDB_TRACE("IDBObjectStore::count"); 519 IDB_TRACE("IDBObjectStore::count");
520 if (isDeleted()) { 520 if (isDeleted()) {
521 ec = IDBDatabaseException::InvalidStateError; 521 ec = IDBDatabaseException::InvalidStateError;
522 return 0; 522 return 0;
523 } 523 }
524 if (!m_transaction->isActive()) { 524 if (!m_transaction->isActive()) {
525 ec = IDBDatabaseException::TransactionInactiveError; 525 ec = IDBDatabaseException::TransactionInactiveError;
526 return 0; 526 return 0;
527 } 527 }
528 RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this ), m_transaction.get()); 528 IDBRequest* request = IDBRequest::create(context, IDBAny::create(this), m_tr ansaction.get());
529 backendDB()->count(m_transaction->id(), id(), IDBIndexMetadata::InvalidId, r ange, request); 529 backendDB()->count(m_transaction->id(), id(), IDBIndexMetadata::InvalidId, r ange, request);
530 return request.release(); 530 return request;
531 } 531 }
532 532
533 PassRefPtr<IDBRequest> IDBObjectStore::count(ScriptExecutionContext* context, co nst ScriptValue& key, ExceptionCode& ec) 533 IDBRequest* IDBObjectStore::count(ScriptExecutionContext* context, const ScriptV alue& key, ExceptionCode& ec)
534 { 534 {
535 RefPtr<IDBKeyRange> keyRange = IDBKeyRange::only(context, key, ec); 535 RefPtr<IDBKeyRange> keyRange = IDBKeyRange::only(context, key, ec);
536 if (ec) 536 if (ec)
537 return 0; 537 return 0;
538 return count(context, keyRange.release(), ec); 538 return count(context, keyRange.release(), ec);
539 } 539 }
540 540
541 void IDBObjectStore::transactionFinished() 541 void IDBObjectStore::transactionFinished()
542 { 542 {
543 ASSERT(m_transaction->isFinished()); 543 ASSERT(m_transaction->isFinished());
(...skipping 12 matching lines...) Expand all
556 } 556 }
557 return IDBIndexMetadata::InvalidId; 557 return IDBIndexMetadata::InvalidId;
558 } 558 }
559 559
560 IDBDatabaseBackendInterface* IDBObjectStore::backendDB() const 560 IDBDatabaseBackendInterface* IDBObjectStore::backendDB() const
561 { 561 {
562 return m_transaction->backendDB(); 562 return m_transaction->backendDB();
563 } 563 }
564 564
565 } // namespace WebCore 565 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/modules/indexeddb/IDBObjectStore.h ('k') | Source/modules/indexeddb/IDBOpenDBRequest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698