| 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 24 matching lines...) Expand all Loading... |
| 35 #include "modules/IndexedDBNames.h" | 35 #include "modules/IndexedDBNames.h" |
| 36 #include "modules/indexeddb/IDBAny.h" | 36 #include "modules/indexeddb/IDBAny.h" |
| 37 #include "modules/indexeddb/IDBDatabase.h" | 37 #include "modules/indexeddb/IDBDatabase.h" |
| 38 #include "modules/indexeddb/IDBObjectStore.h" | 38 #include "modules/indexeddb/IDBObjectStore.h" |
| 39 #include "modules/indexeddb/IDBTracing.h" | 39 #include "modules/indexeddb/IDBTracing.h" |
| 40 #include "modules/indexeddb/IDBTransaction.h" | 40 #include "modules/indexeddb/IDBTransaction.h" |
| 41 #include "modules/indexeddb/WebIDBCallbacksImpl.h" | 41 #include "modules/indexeddb/WebIDBCallbacksImpl.h" |
| 42 #include "public/platform/modules/indexeddb/WebIDBDatabase.h" | 42 #include "public/platform/modules/indexeddb/WebIDBDatabase.h" |
| 43 #include "public/platform/modules/indexeddb/WebIDBKeyRange.h" | 43 #include "public/platform/modules/indexeddb/WebIDBKeyRange.h" |
| 44 #include <limits> | 44 #include <limits> |
| 45 #include <memory> |
| 45 | 46 |
| 46 using blink::WebIDBCursor; | 47 using blink::WebIDBCursor; |
| 47 using blink::WebIDBDatabase; | 48 using blink::WebIDBDatabase; |
| 48 | 49 |
| 49 namespace blink { | 50 namespace blink { |
| 50 | 51 |
| 51 IDBCursor* IDBCursor::create(PassOwnPtr<WebIDBCursor> backend, WebIDBCursorDirec
tion direction, IDBRequest* request, IDBAny* source, IDBTransaction* transaction
) | 52 IDBCursor* IDBCursor::create(std::unique_ptr<WebIDBCursor> backend, WebIDBCursor
Direction direction, IDBRequest* request, IDBAny* source, IDBTransaction* transa
ction) |
| 52 { | 53 { |
| 53 return new IDBCursor(std::move(backend), direction, request, source, transac
tion); | 54 return new IDBCursor(std::move(backend), direction, request, source, transac
tion); |
| 54 } | 55 } |
| 55 | 56 |
| 56 IDBCursor::IDBCursor(PassOwnPtr<WebIDBCursor> backend, WebIDBCursorDirection dir
ection, IDBRequest* request, IDBAny* source, IDBTransaction* transaction) | 57 IDBCursor::IDBCursor(std::unique_ptr<WebIDBCursor> backend, WebIDBCursorDirectio
n direction, IDBRequest* request, IDBAny* source, IDBTransaction* transaction) |
| 57 : m_backend(std::move(backend)) | 58 : m_backend(std::move(backend)) |
| 58 , m_request(request) | 59 , m_request(request) |
| 59 , m_direction(direction) | 60 , m_direction(direction) |
| 60 , m_source(source) | 61 , m_source(source) |
| 61 , m_transaction(transaction) | 62 , m_transaction(transaction) |
| 62 { | 63 { |
| 63 ASSERT(m_backend); | 64 ASSERT(m_backend); |
| 64 ASSERT(m_request); | 65 ASSERT(m_request); |
| 65 ASSERT(m_source->getType() == IDBAny::IDBObjectStoreType || m_source->getTyp
e() == IDBAny::IDBIndexType); | 66 ASSERT(m_source->getType() == IDBAny::IDBObjectStoreType || m_source->getTyp
e() == IDBAny::IDBIndexType); |
| 66 ASSERT(m_transaction); | 67 ASSERT(m_transaction); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::noValue
ErrorMessage); | 142 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::noValue
ErrorMessage); |
| 142 return; | 143 return; |
| 143 } | 144 } |
| 144 if (isDeleted()) { | 145 if (isDeleted()) { |
| 145 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::sourceD
eletedErrorMessage); | 146 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::sourceD
eletedErrorMessage); |
| 146 return; | 147 return; |
| 147 } | 148 } |
| 148 | 149 |
| 149 m_request->setPendingCursor(this); | 150 m_request->setPendingCursor(this); |
| 150 m_gotValue = false; | 151 m_gotValue = false; |
| 151 m_backend->advance(count, WebIDBCallbacksImpl::create(m_request).leakPtr()); | 152 m_backend->advance(count, WebIDBCallbacksImpl::create(m_request).release()); |
| 152 } | 153 } |
| 153 | 154 |
| 154 void IDBCursor::continueFunction(ScriptState* scriptState, const ScriptValue& ke
yValue, ExceptionState& exceptionState) | 155 void IDBCursor::continueFunction(ScriptState* scriptState, const ScriptValue& ke
yValue, ExceptionState& exceptionState) |
| 155 { | 156 { |
| 156 IDB_TRACE("IDBCursor::continue"); | 157 IDB_TRACE("IDBCursor::continue"); |
| 157 IDBKey* key = keyValue.isUndefined() || keyValue.isNull() ? nullptr : Script
Value::to<IDBKey*>(scriptState->isolate(), keyValue, exceptionState); | 158 IDBKey* key = keyValue.isUndefined() || keyValue.isNull() ? nullptr : Script
Value::to<IDBKey*>(scriptState->isolate(), keyValue, exceptionState); |
| 158 if (exceptionState.hadException()) | 159 if (exceptionState.hadException()) |
| 159 return; | 160 return; |
| 160 if (key && !key->isValid()) { | 161 if (key && !key->isValid()) { |
| 161 exceptionState.throwDOMException(DataError, IDBDatabase::notValidKeyErro
rMessage); | 162 exceptionState.throwDOMException(DataError, IDBDatabase::notValidKeyErro
rMessage); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 exceptionState.throwDOMException(DataError, "The parameter is gr
eater than or equal to this cursor's position."); | 236 exceptionState.throwDOMException(DataError, "The parameter is gr
eater than or equal to this cursor's position."); |
| 236 return; | 237 return; |
| 237 } | 238 } |
| 238 } | 239 } |
| 239 } | 240 } |
| 240 | 241 |
| 241 // FIXME: We're not using the context from when continue was called, which m
eans the callback | 242 // FIXME: We're not using the context from when continue was called, which m
eans the callback |
| 242 // will be on the original context openCursor was called on. Is this
right? | 243 // will be on the original context openCursor was called on. Is this
right? |
| 243 m_request->setPendingCursor(this); | 244 m_request->setPendingCursor(this); |
| 244 m_gotValue = false; | 245 m_gotValue = false; |
| 245 m_backend->continueFunction(key, primaryKey, WebIDBCallbacksImpl::create(m_r
equest).leakPtr()); | 246 m_backend->continueFunction(key, primaryKey, WebIDBCallbacksImpl::create(m_r
equest).release()); |
| 246 } | 247 } |
| 247 | 248 |
| 248 IDBRequest* IDBCursor::deleteFunction(ScriptState* scriptState, ExceptionState&
exceptionState) | 249 IDBRequest* IDBCursor::deleteFunction(ScriptState* scriptState, ExceptionState&
exceptionState) |
| 249 { | 250 { |
| 250 IDB_TRACE("IDBCursor::delete"); | 251 IDB_TRACE("IDBCursor::delete"); |
| 251 if (m_transaction->isFinished() || m_transaction->isFinishing()) { | 252 if (m_transaction->isFinished() || m_transaction->isFinishing()) { |
| 252 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionFinishedErrorMessage); | 253 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionFinishedErrorMessage); |
| 253 return nullptr; | 254 return nullptr; |
| 254 } | 255 } |
| 255 if (!m_transaction->isActive()) { | 256 if (!m_transaction->isActive()) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 275 } | 276 } |
| 276 if (!m_transaction->backendDB()) { | 277 if (!m_transaction->backendDB()) { |
| 277 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas
eClosedErrorMessage); | 278 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas
eClosedErrorMessage); |
| 278 return nullptr; | 279 return nullptr; |
| 279 } | 280 } |
| 280 | 281 |
| 281 IDBKeyRange* keyRange = IDBKeyRange::only(m_primaryKey, exceptionState); | 282 IDBKeyRange* keyRange = IDBKeyRange::only(m_primaryKey, exceptionState); |
| 282 ASSERT(!exceptionState.hadException()); | 283 ASSERT(!exceptionState.hadException()); |
| 283 | 284 |
| 284 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this),
m_transaction.get()); | 285 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this),
m_transaction.get()); |
| 285 m_transaction->backendDB()->deleteRange(m_transaction->id(), effectiveObject
Store()->id(), keyRange, WebIDBCallbacksImpl::create(request).leakPtr()); | 286 m_transaction->backendDB()->deleteRange(m_transaction->id(), effectiveObject
Store()->id(), keyRange, WebIDBCallbacksImpl::create(request).release()); |
| 286 return request; | 287 return request; |
| 287 } | 288 } |
| 288 | 289 |
| 289 void IDBCursor::postSuccessHandlerCallback() | 290 void IDBCursor::postSuccessHandlerCallback() |
| 290 { | 291 { |
| 291 if (m_backend) | 292 if (m_backend) |
| 292 m_backend->postSuccessHandlerCallback(); | 293 m_backend->postSuccessHandlerCallback(); |
| 293 } | 294 } |
| 294 | 295 |
| 295 void IDBCursor::close() | 296 void IDBCursor::close() |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 case WebIDBCursorDirectionPrevNoDuplicate: | 401 case WebIDBCursorDirectionPrevNoDuplicate: |
| 401 return IndexedDBNames::prevunique; | 402 return IndexedDBNames::prevunique; |
| 402 | 403 |
| 403 default: | 404 default: |
| 404 ASSERT_NOT_REACHED(); | 405 ASSERT_NOT_REACHED(); |
| 405 return IndexedDBNames::next; | 406 return IndexedDBNames::next; |
| 406 } | 407 } |
| 407 } | 408 } |
| 408 | 409 |
| 409 } // namespace blink | 410 } // namespace blink |
| OLD | NEW |