| OLD | NEW |
| 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 17 matching lines...) Expand all Loading... |
| 28 #include "bindings/core/v8/ExceptionState.h" | 28 #include "bindings/core/v8/ExceptionState.h" |
| 29 #include "bindings/modules/v8/ToV8ForModules.h" | 29 #include "bindings/modules/v8/ToV8ForModules.h" |
| 30 #include "bindings/modules/v8/V8BindingForModules.h" | 30 #include "bindings/modules/v8/V8BindingForModules.h" |
| 31 #include "core/dom/ExceptionCode.h" | 31 #include "core/dom/ExceptionCode.h" |
| 32 #include "core/dom/ExecutionContext.h" | 32 #include "core/dom/ExecutionContext.h" |
| 33 #include "modules/indexeddb/IDBDatabase.h" | 33 #include "modules/indexeddb/IDBDatabase.h" |
| 34 #include "modules/indexeddb/IDBKey.h" | 34 #include "modules/indexeddb/IDBKey.h" |
| 35 #include "modules/indexeddb/IDBObjectStore.h" | 35 #include "modules/indexeddb/IDBObjectStore.h" |
| 36 #include "modules/indexeddb/IDBTracing.h" | 36 #include "modules/indexeddb/IDBTracing.h" |
| 37 #include "modules/indexeddb/IDBTransaction.h" | 37 #include "modules/indexeddb/IDBTransaction.h" |
| 38 #include "modules/indexeddb/WebIDBCallbacksImpl.h" | |
| 39 #include "public/platform/modules/indexeddb/WebIDBKeyRange.h" | 38 #include "public/platform/modules/indexeddb/WebIDBKeyRange.h" |
| 40 #include <memory> | 39 #include <memory> |
| 41 | 40 |
| 42 using blink::WebIDBCallbacks; | 41 using blink::WebIDBCallbacks; |
| 43 using blink::WebIDBCursor; | 42 using blink::WebIDBCursor; |
| 44 using blink::WebIDBDatabase; | 43 using blink::WebIDBDatabase; |
| 45 | 44 |
| 46 namespace blink { | 45 namespace blink { |
| 47 | 46 |
| 48 IDBIndex::IDBIndex(const IDBIndexMetadata& metadata, | 47 IDBIndex::IDBIndex(const IDBIndexMetadata& metadata, |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 } | 150 } |
| 152 | 151 |
| 153 IDBRequest* IDBIndex::openCursor(ScriptState* scriptState, | 152 IDBRequest* IDBIndex::openCursor(ScriptState* scriptState, |
| 154 IDBKeyRange* keyRange, | 153 IDBKeyRange* keyRange, |
| 155 WebIDBCursorDirection direction) { | 154 WebIDBCursorDirection direction) { |
| 156 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this), | 155 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this), |
| 157 m_transaction.get()); | 156 m_transaction.get()); |
| 158 request->setCursorDetails(IndexedDB::CursorKeyAndValue, direction); | 157 request->setCursorDetails(IndexedDB::CursorKeyAndValue, direction); |
| 159 backendDB()->openCursor(m_transaction->id(), m_objectStore->id(), id(), | 158 backendDB()->openCursor(m_transaction->id(), m_objectStore->id(), id(), |
| 160 keyRange, direction, false, WebIDBTaskTypeNormal, | 159 keyRange, direction, false, WebIDBTaskTypeNormal, |
| 161 WebIDBCallbacksImpl::create(request).release()); | 160 request->createWebCallbacks().release()); |
| 162 return request; | 161 return request; |
| 163 } | 162 } |
| 164 | 163 |
| 165 IDBRequest* IDBIndex::count(ScriptState* scriptState, | 164 IDBRequest* IDBIndex::count(ScriptState* scriptState, |
| 166 const ScriptValue& range, | 165 const ScriptValue& range, |
| 167 ExceptionState& exceptionState) { | 166 ExceptionState& exceptionState) { |
| 168 IDB_TRACE("IDBIndex::count"); | 167 IDB_TRACE("IDBIndex::count"); |
| 169 if (isDeleted()) { | 168 if (isDeleted()) { |
| 170 exceptionState.throwDOMException(InvalidStateError, | 169 exceptionState.throwDOMException(InvalidStateError, |
| 171 IDBDatabase::indexDeletedErrorMessage); | 170 IDBDatabase::indexDeletedErrorMessage); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 189 | 188 |
| 190 if (!backendDB()) { | 189 if (!backendDB()) { |
| 191 exceptionState.throwDOMException(InvalidStateError, | 190 exceptionState.throwDOMException(InvalidStateError, |
| 192 IDBDatabase::databaseClosedErrorMessage); | 191 IDBDatabase::databaseClosedErrorMessage); |
| 193 return nullptr; | 192 return nullptr; |
| 194 } | 193 } |
| 195 | 194 |
| 196 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this), | 195 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this), |
| 197 m_transaction.get()); | 196 m_transaction.get()); |
| 198 backendDB()->count(m_transaction->id(), m_objectStore->id(), id(), keyRange, | 197 backendDB()->count(m_transaction->id(), m_objectStore->id(), id(), keyRange, |
| 199 WebIDBCallbacksImpl::create(request).release()); | 198 request->createWebCallbacks().release()); |
| 200 return request; | 199 return request; |
| 201 } | 200 } |
| 202 | 201 |
| 203 IDBRequest* IDBIndex::openKeyCursor(ScriptState* scriptState, | 202 IDBRequest* IDBIndex::openKeyCursor(ScriptState* scriptState, |
| 204 const ScriptValue& range, | 203 const ScriptValue& range, |
| 205 const String& directionString, | 204 const String& directionString, |
| 206 ExceptionState& exceptionState) { | 205 ExceptionState& exceptionState) { |
| 207 IDB_TRACE("IDBIndex::openKeyCursor"); | 206 IDB_TRACE("IDBIndex::openKeyCursor"); |
| 208 if (isDeleted()) { | 207 if (isDeleted()) { |
| 209 exceptionState.throwDOMException(InvalidStateError, | 208 exceptionState.throwDOMException(InvalidStateError, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 230 exceptionState.throwDOMException(InvalidStateError, | 229 exceptionState.throwDOMException(InvalidStateError, |
| 231 IDBDatabase::databaseClosedErrorMessage); | 230 IDBDatabase::databaseClosedErrorMessage); |
| 232 return nullptr; | 231 return nullptr; |
| 233 } | 232 } |
| 234 | 233 |
| 235 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this), | 234 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this), |
| 236 m_transaction.get()); | 235 m_transaction.get()); |
| 237 request->setCursorDetails(IndexedDB::CursorKeyOnly, direction); | 236 request->setCursorDetails(IndexedDB::CursorKeyOnly, direction); |
| 238 backendDB()->openCursor(m_transaction->id(), m_objectStore->id(), id(), | 237 backendDB()->openCursor(m_transaction->id(), m_objectStore->id(), id(), |
| 239 keyRange, direction, true, WebIDBTaskTypeNormal, | 238 keyRange, direction, true, WebIDBTaskTypeNormal, |
| 240 WebIDBCallbacksImpl::create(request).release()); | 239 request->createWebCallbacks().release()); |
| 241 return request; | 240 return request; |
| 242 } | 241 } |
| 243 | 242 |
| 244 IDBRequest* IDBIndex::get(ScriptState* scriptState, | 243 IDBRequest* IDBIndex::get(ScriptState* scriptState, |
| 245 const ScriptValue& key, | 244 const ScriptValue& key, |
| 246 ExceptionState& exceptionState) { | 245 ExceptionState& exceptionState) { |
| 247 IDB_TRACE("IDBIndex::get"); | 246 IDB_TRACE("IDBIndex::get"); |
| 248 return getInternal(scriptState, key, exceptionState, false); | 247 return getInternal(scriptState, key, exceptionState, false); |
| 249 } | 248 } |
| 250 | 249 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 } | 316 } |
| 318 if (!backendDB()) { | 317 if (!backendDB()) { |
| 319 exceptionState.throwDOMException(InvalidStateError, | 318 exceptionState.throwDOMException(InvalidStateError, |
| 320 IDBDatabase::databaseClosedErrorMessage); | 319 IDBDatabase::databaseClosedErrorMessage); |
| 321 return nullptr; | 320 return nullptr; |
| 322 } | 321 } |
| 323 | 322 |
| 324 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this), | 323 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this), |
| 325 m_transaction.get()); | 324 m_transaction.get()); |
| 326 backendDB()->get(m_transaction->id(), m_objectStore->id(), id(), keyRange, | 325 backendDB()->get(m_transaction->id(), m_objectStore->id(), id(), keyRange, |
| 327 keyOnly, WebIDBCallbacksImpl::create(request).release()); | 326 keyOnly, request->createWebCallbacks().release()); |
| 328 return request; | 327 return request; |
| 329 } | 328 } |
| 330 | 329 |
| 331 IDBRequest* IDBIndex::getAllInternal(ScriptState* scriptState, | 330 IDBRequest* IDBIndex::getAllInternal(ScriptState* scriptState, |
| 332 const ScriptValue& range, | 331 const ScriptValue& range, |
| 333 unsigned long maxCount, | 332 unsigned long maxCount, |
| 334 ExceptionState& exceptionState, | 333 ExceptionState& exceptionState, |
| 335 bool keyOnly) { | 334 bool keyOnly) { |
| 336 if (!maxCount) | 335 if (!maxCount) |
| 337 maxCount = std::numeric_limits<uint32_t>::max(); | 336 maxCount = std::numeric_limits<uint32_t>::max(); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 359 if (!backendDB()) { | 358 if (!backendDB()) { |
| 360 exceptionState.throwDOMException(InvalidStateError, | 359 exceptionState.throwDOMException(InvalidStateError, |
| 361 IDBDatabase::databaseClosedErrorMessage); | 360 IDBDatabase::databaseClosedErrorMessage); |
| 362 return nullptr; | 361 return nullptr; |
| 363 } | 362 } |
| 364 | 363 |
| 365 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this), | 364 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this), |
| 366 m_transaction.get()); | 365 m_transaction.get()); |
| 367 backendDB()->getAll(m_transaction->id(), m_objectStore->id(), id(), keyRange, | 366 backendDB()->getAll(m_transaction->id(), m_objectStore->id(), id(), keyRange, |
| 368 maxCount, keyOnly, | 367 maxCount, keyOnly, |
| 369 WebIDBCallbacksImpl::create(request).release()); | 368 request->createWebCallbacks().release()); |
| 370 return request; | 369 return request; |
| 371 } | 370 } |
| 372 | 371 |
| 373 WebIDBDatabase* IDBIndex::backendDB() const { | 372 WebIDBDatabase* IDBIndex::backendDB() const { |
| 374 return m_transaction->backendDB(); | 373 return m_transaction->backendDB(); |
| 375 } | 374 } |
| 376 | 375 |
| 377 bool IDBIndex::isDeleted() const { | 376 bool IDBIndex::isDeleted() const { |
| 378 return m_deleted || m_objectStore->isDeleted(); | 377 return m_deleted || m_objectStore->isDeleted(); |
| 379 } | 378 } |
| 380 | 379 |
| 381 } // namespace blink | 380 } // namespace blink |
| OLD | NEW |