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

Side by Side Diff: third_party/WebKit/Source/modules/indexeddb/IDBIndex.cpp

Issue 2370643004: Port messages sent by WebIDBFactoryImpl to Mojo. (Closed)
Patch Set: Address last nits and fix leaks in unit tests. Created 4 years, 2 months 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
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 17 matching lines...) Expand all
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(RefPtr<IDBIndexMetadata> metadata, 47 IDBIndex::IDBIndex(RefPtr<IDBIndexMetadata> metadata,
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 } 155 }
157 156
158 IDBRequest* IDBIndex::openCursor(ScriptState* scriptState, 157 IDBRequest* IDBIndex::openCursor(ScriptState* scriptState,
159 IDBKeyRange* keyRange, 158 IDBKeyRange* keyRange,
160 WebIDBCursorDirection direction) { 159 WebIDBCursorDirection direction) {
161 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this), 160 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this),
162 m_transaction.get()); 161 m_transaction.get());
163 request->setCursorDetails(IndexedDB::CursorKeyAndValue, direction); 162 request->setCursorDetails(IndexedDB::CursorKeyAndValue, direction);
164 backendDB()->openCursor(m_transaction->id(), m_objectStore->id(), id(), 163 backendDB()->openCursor(m_transaction->id(), m_objectStore->id(), id(),
165 keyRange, direction, false, WebIDBTaskTypeNormal, 164 keyRange, direction, false, WebIDBTaskTypeNormal,
166 WebIDBCallbacksImpl::create(request).release()); 165 request->createWebCallbacks().release());
167 return request; 166 return request;
168 } 167 }
169 168
170 IDBRequest* IDBIndex::count(ScriptState* scriptState, 169 IDBRequest* IDBIndex::count(ScriptState* scriptState,
171 const ScriptValue& range, 170 const ScriptValue& range,
172 ExceptionState& exceptionState) { 171 ExceptionState& exceptionState) {
173 IDB_TRACE("IDBIndex::count"); 172 IDB_TRACE("IDBIndex::count");
174 if (isDeleted()) { 173 if (isDeleted()) {
175 exceptionState.throwDOMException(InvalidStateError, 174 exceptionState.throwDOMException(InvalidStateError,
176 IDBDatabase::indexDeletedErrorMessage); 175 IDBDatabase::indexDeletedErrorMessage);
(...skipping 17 matching lines...) Expand all
194 193
195 if (!backendDB()) { 194 if (!backendDB()) {
196 exceptionState.throwDOMException(InvalidStateError, 195 exceptionState.throwDOMException(InvalidStateError,
197 IDBDatabase::databaseClosedErrorMessage); 196 IDBDatabase::databaseClosedErrorMessage);
198 return nullptr; 197 return nullptr;
199 } 198 }
200 199
201 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this), 200 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this),
202 m_transaction.get()); 201 m_transaction.get());
203 backendDB()->count(m_transaction->id(), m_objectStore->id(), id(), keyRange, 202 backendDB()->count(m_transaction->id(), m_objectStore->id(), id(), keyRange,
204 WebIDBCallbacksImpl::create(request).release()); 203 request->createWebCallbacks().release());
205 return request; 204 return request;
206 } 205 }
207 206
208 IDBRequest* IDBIndex::openKeyCursor(ScriptState* scriptState, 207 IDBRequest* IDBIndex::openKeyCursor(ScriptState* scriptState,
209 const ScriptValue& range, 208 const ScriptValue& range,
210 const String& directionString, 209 const String& directionString,
211 ExceptionState& exceptionState) { 210 ExceptionState& exceptionState) {
212 IDB_TRACE("IDBIndex::openKeyCursor"); 211 IDB_TRACE("IDBIndex::openKeyCursor");
213 if (isDeleted()) { 212 if (isDeleted()) {
214 exceptionState.throwDOMException(InvalidStateError, 213 exceptionState.throwDOMException(InvalidStateError,
(...skipping 20 matching lines...) Expand all
235 exceptionState.throwDOMException(InvalidStateError, 234 exceptionState.throwDOMException(InvalidStateError,
236 IDBDatabase::databaseClosedErrorMessage); 235 IDBDatabase::databaseClosedErrorMessage);
237 return nullptr; 236 return nullptr;
238 } 237 }
239 238
240 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this), 239 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this),
241 m_transaction.get()); 240 m_transaction.get());
242 request->setCursorDetails(IndexedDB::CursorKeyOnly, direction); 241 request->setCursorDetails(IndexedDB::CursorKeyOnly, direction);
243 backendDB()->openCursor(m_transaction->id(), m_objectStore->id(), id(), 242 backendDB()->openCursor(m_transaction->id(), m_objectStore->id(), id(),
244 keyRange, direction, true, WebIDBTaskTypeNormal, 243 keyRange, direction, true, WebIDBTaskTypeNormal,
245 WebIDBCallbacksImpl::create(request).release()); 244 request->createWebCallbacks().release());
246 return request; 245 return request;
247 } 246 }
248 247
249 IDBRequest* IDBIndex::get(ScriptState* scriptState, 248 IDBRequest* IDBIndex::get(ScriptState* scriptState,
250 const ScriptValue& key, 249 const ScriptValue& key,
251 ExceptionState& exceptionState) { 250 ExceptionState& exceptionState) {
252 IDB_TRACE("IDBIndex::get"); 251 IDB_TRACE("IDBIndex::get");
253 return getInternal(scriptState, key, exceptionState, false); 252 return getInternal(scriptState, key, exceptionState, false);
254 } 253 }
255 254
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 } 321 }
323 if (!backendDB()) { 322 if (!backendDB()) {
324 exceptionState.throwDOMException(InvalidStateError, 323 exceptionState.throwDOMException(InvalidStateError,
325 IDBDatabase::databaseClosedErrorMessage); 324 IDBDatabase::databaseClosedErrorMessage);
326 return nullptr; 325 return nullptr;
327 } 326 }
328 327
329 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this), 328 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this),
330 m_transaction.get()); 329 m_transaction.get());
331 backendDB()->get(m_transaction->id(), m_objectStore->id(), id(), keyRange, 330 backendDB()->get(m_transaction->id(), m_objectStore->id(), id(), keyRange,
332 keyOnly, WebIDBCallbacksImpl::create(request).release()); 331 keyOnly, request->createWebCallbacks().release());
333 return request; 332 return request;
334 } 333 }
335 334
336 IDBRequest* IDBIndex::getAllInternal(ScriptState* scriptState, 335 IDBRequest* IDBIndex::getAllInternal(ScriptState* scriptState,
337 const ScriptValue& range, 336 const ScriptValue& range,
338 unsigned long maxCount, 337 unsigned long maxCount,
339 ExceptionState& exceptionState, 338 ExceptionState& exceptionState,
340 bool keyOnly) { 339 bool keyOnly) {
341 if (!maxCount) 340 if (!maxCount)
342 maxCount = std::numeric_limits<uint32_t>::max(); 341 maxCount = std::numeric_limits<uint32_t>::max();
(...skipping 21 matching lines...) Expand all
364 if (!backendDB()) { 363 if (!backendDB()) {
365 exceptionState.throwDOMException(InvalidStateError, 364 exceptionState.throwDOMException(InvalidStateError,
366 IDBDatabase::databaseClosedErrorMessage); 365 IDBDatabase::databaseClosedErrorMessage);
367 return nullptr; 366 return nullptr;
368 } 367 }
369 368
370 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this), 369 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this),
371 m_transaction.get()); 370 m_transaction.get());
372 backendDB()->getAll(m_transaction->id(), m_objectStore->id(), id(), keyRange, 371 backendDB()->getAll(m_transaction->id(), m_objectStore->id(), id(), keyRange,
373 maxCount, keyOnly, 372 maxCount, keyOnly,
374 WebIDBCallbacksImpl::create(request).release()); 373 request->createWebCallbacks().release());
375 return request; 374 return request;
376 } 375 }
377 376
378 WebIDBDatabase* IDBIndex::backendDB() const { 377 WebIDBDatabase* IDBIndex::backendDB() const {
379 return m_transaction->backendDB(); 378 return m_transaction->backendDB();
380 } 379 }
381 380
382 } // namespace blink 381 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698