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 21 matching lines...) Expand all Loading... |
32 #include "bindings/core/v8/ExceptionStatePlaceholder.h" | 32 #include "bindings/core/v8/ExceptionStatePlaceholder.h" |
33 #include "bindings/modules/v8/ToV8ForModules.h" | 33 #include "bindings/modules/v8/ToV8ForModules.h" |
34 #include "bindings/modules/v8/V8BindingForModules.h" | 34 #include "bindings/modules/v8/V8BindingForModules.h" |
35 #include "core/dom/DOMException.h" | 35 #include "core/dom/DOMException.h" |
36 #include "core/dom/ExceptionCode.h" | 36 #include "core/dom/ExceptionCode.h" |
37 #include "core/dom/ExecutionContext.h" | 37 #include "core/dom/ExecutionContext.h" |
38 #include "core/events/EventQueue.h" | 38 #include "core/events/EventQueue.h" |
39 #include "modules/IndexedDBNames.h" | 39 #include "modules/IndexedDBNames.h" |
40 #include "modules/indexeddb/IDBCursorWithValue.h" | 40 #include "modules/indexeddb/IDBCursorWithValue.h" |
41 #include "modules/indexeddb/IDBDatabase.h" | 41 #include "modules/indexeddb/IDBDatabase.h" |
| 42 #include "modules/indexeddb/IDBDatabaseProxy.h" |
42 #include "modules/indexeddb/IDBEventDispatcher.h" | 43 #include "modules/indexeddb/IDBEventDispatcher.h" |
43 #include "modules/indexeddb/IDBTracing.h" | 44 #include "modules/indexeddb/IDBTracing.h" |
44 #include "modules/indexeddb/IDBValue.h" | 45 #include "modules/indexeddb/IDBValue.h" |
45 #include "platform/SharedBuffer.h" | 46 #include "platform/SharedBuffer.h" |
46 #include "public/platform/WebBlobInfo.h" | 47 #include "public/platform/WebBlobInfo.h" |
47 #include <memory> | 48 #include <memory> |
48 | 49 |
49 using blink::WebIDBCursor; | |
50 | |
51 namespace blink { | 50 namespace blink { |
52 | 51 |
53 IDBRequest* IDBRequest::create(ScriptState* scriptState, IDBAny* source, IDBTran
saction* transaction) | 52 IDBRequest* IDBRequest::create(ScriptState* scriptState, IDBAny* source, IDBTran
saction* transaction) |
54 { | 53 { |
55 IDBRequest* request = new IDBRequest(scriptState, source, transaction); | 54 IDBRequest* request = new IDBRequest(scriptState, source, transaction); |
56 request->suspendIfNeeded(); | 55 request->suspendIfNeeded(); |
57 // Requests associated with IDBFactory (open/deleteDatabase/getDatabaseNames
) are not associated with transactions. | 56 // Requests associated with IDBFactory (open/deleteDatabase/getDatabaseNames
) are not associated with transactions. |
58 if (transaction) | 57 if (transaction) |
59 transaction->registerRequest(request); | 58 transaction->registerRequest(request); |
60 return request; | 59 return request; |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 ASSERT_UNUSED(removed, removed); | 145 ASSERT_UNUSED(removed, removed); |
147 } | 146 } |
148 m_enqueuedEvents.clear(); | 147 m_enqueuedEvents.clear(); |
149 | 148 |
150 m_error.clear(); | 149 m_error.clear(); |
151 m_result.clear(); | 150 m_result.clear(); |
152 onError(DOMException::create(AbortError, "The transaction was aborted, so th
e request cannot be fulfilled.")); | 151 onError(DOMException::create(AbortError, "The transaction was aborted, so th
e request cannot be fulfilled.")); |
153 m_requestAborted = true; | 152 m_requestAborted = true; |
154 } | 153 } |
155 | 154 |
156 void IDBRequest::setCursorDetails(IndexedDB::CursorType cursorType, WebIDBCursor
Direction direction) | 155 void IDBRequest::setCursorDetails(IndexedDB::CursorType cursorType, indexed_db::
mojom::blink::CursorDirection direction) |
157 { | 156 { |
158 ASSERT(m_readyState == PENDING); | 157 ASSERT(m_readyState == PENDING); |
159 ASSERT(!m_pendingCursor); | 158 ASSERT(!m_pendingCursor); |
160 m_cursorType = cursorType; | 159 m_cursorType = cursorType; |
161 m_cursorDirection = direction; | 160 m_cursorDirection = direction; |
162 } | 161 } |
163 | 162 |
164 void IDBRequest::setPendingCursor(IDBCursor* cursor) | 163 void IDBRequest::setPendingCursor(IDBCursor* cursor) |
165 { | 164 { |
166 ASSERT(m_readyState == DONE); | 165 ASSERT(m_readyState == DONE); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 | 197 |
199 onSuccessInternal(IDBAny::create(cursor)); | 198 onSuccessInternal(IDBAny::create(cursor)); |
200 } | 199 } |
201 | 200 |
202 void IDBRequest::ackReceivedBlobs(const IDBValue* value) | 201 void IDBRequest::ackReceivedBlobs(const IDBValue* value) |
203 { | 202 { |
204 if (!m_transaction || !m_transaction->backendDB()) | 203 if (!m_transaction || !m_transaction->backendDB()) |
205 return; | 204 return; |
206 Vector<String> uuids = value->getUUIDs(); | 205 Vector<String> uuids = value->getUUIDs(); |
207 if (!uuids.isEmpty()) | 206 if (!uuids.isEmpty()) |
208 m_transaction->backendDB()->ackReceivedBlobs(uuids); | 207 m_transaction->backendDB()->AckReceivedBlobs(std::move(uuids)); |
209 } | 208 } |
210 | 209 |
211 void IDBRequest::ackReceivedBlobs(const Vector<RefPtr<IDBValue>>& values) | 210 void IDBRequest::ackReceivedBlobs(const Vector<RefPtr<IDBValue>>& values) |
212 { | 211 { |
213 for (size_t i = 0; i < values.size(); ++i) | 212 for (size_t i = 0; i < values.size(); ++i) |
214 ackReceivedBlobs(values[i].get()); | 213 ackReceivedBlobs(values[i].get()); |
215 } | 214 } |
216 | 215 |
217 bool IDBRequest::shouldEnqueueEvent() const | 216 bool IDBRequest::shouldEnqueueEvent() const |
218 { | 217 { |
(...skipping 24 matching lines...) Expand all Loading... |
243 IDB_TRACE("IDBRequest::onSuccess(StringList)"); | 242 IDB_TRACE("IDBRequest::onSuccess(StringList)"); |
244 if (!shouldEnqueueEvent()) | 243 if (!shouldEnqueueEvent()) |
245 return; | 244 return; |
246 | 245 |
247 DOMStringList* domStringList = DOMStringList::create(DOMStringList::IndexedD
B); | 246 DOMStringList* domStringList = DOMStringList::create(DOMStringList::IndexedD
B); |
248 for (size_t i = 0; i < stringList.size(); ++i) | 247 for (size_t i = 0; i < stringList.size(); ++i) |
249 domStringList->append(stringList[i]); | 248 domStringList->append(stringList[i]); |
250 onSuccessInternal(IDBAny::create(domStringList)); | 249 onSuccessInternal(IDBAny::create(domStringList)); |
251 } | 250 } |
252 | 251 |
253 void IDBRequest::onSuccess(std::unique_ptr<WebIDBCursor> backend, IDBKey* key, I
DBKey* primaryKey, PassRefPtr<IDBValue> value) | 252 void IDBRequest::onSuccess(std::unique_ptr<IDBCursorProxy> backend, IDBKey* key,
IDBKey* primaryKey, PassRefPtr<IDBValue> value) |
254 { | 253 { |
255 IDB_TRACE("IDBRequest::onSuccess(IDBCursor)"); | 254 IDB_TRACE("IDBRequest::onSuccess(IDBCursor)"); |
256 if (!shouldEnqueueEvent()) | 255 if (!shouldEnqueueEvent()) |
257 return; | 256 return; |
258 | 257 |
259 ASSERT(!m_pendingCursor); | 258 ASSERT(!m_pendingCursor); |
260 IDBCursor* cursor = nullptr; | 259 IDBCursor* cursor = nullptr; |
261 switch (m_cursorType) { | 260 switch (m_cursorType) { |
262 case IndexedDB::CursorKeyOnly: | 261 case IndexedDB::CursorKeyOnly: |
263 cursor = IDBCursor::create(std::move(backend), m_cursorDirection, this,
m_source.get(), m_transaction.get()); | 262 cursor = IDBCursor::create(std::move(backend), m_cursorDirection, this,
m_source.get(), m_transaction.get()); |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 } | 533 } |
535 | 534 |
536 void IDBRequest::dequeueEvent(Event* event) | 535 void IDBRequest::dequeueEvent(Event* event) |
537 { | 536 { |
538 for (size_t i = 0; i < m_enqueuedEvents.size(); ++i) { | 537 for (size_t i = 0; i < m_enqueuedEvents.size(); ++i) { |
539 if (m_enqueuedEvents[i].get() == event) | 538 if (m_enqueuedEvents[i].get() == event) |
540 m_enqueuedEvents.remove(i); | 539 m_enqueuedEvents.remove(i); |
541 } | 540 } |
542 } | 541 } |
543 | 542 |
| 543 void IDBRequest::onGetResult(indexed_db::mojom::blink::GetResultPtr result) |
| 544 { |
| 545 // Implement me. |
| 546 NOTREACHED(); |
| 547 } |
| 548 |
544 } // namespace blink | 549 } // namespace blink |
OLD | NEW |