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