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

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

Issue 2370643004: Port messages sent by WebIDBFactoryImpl to Mojo. (Closed)
Patch Set: Addressed most of dcheng@'s feedback. 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 20 matching lines...) Expand all
31 #include "bindings/modules/v8/ToV8ForModules.h" 31 #include "bindings/modules/v8/ToV8ForModules.h"
32 #include "bindings/modules/v8/V8BindingForModules.h" 32 #include "bindings/modules/v8/V8BindingForModules.h"
33 #include "bindings/modules/v8/V8IDBRequest.h" 33 #include "bindings/modules/v8/V8IDBRequest.h"
34 #include "core/dom/ExceptionCode.h" 34 #include "core/dom/ExceptionCode.h"
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"
42 #include "public/platform/modules/indexeddb/WebIDBDatabase.h" 41 #include "public/platform/modules/indexeddb/WebIDBDatabase.h"
43 #include "public/platform/modules/indexeddb/WebIDBKeyRange.h" 42 #include "public/platform/modules/indexeddb/WebIDBKeyRange.h"
44 #include <limits> 43 #include <limits>
45 #include <memory> 44 #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
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 return; 166 return;
168 } 167 }
169 if (!m_gotValue) { 168 if (!m_gotValue) {
170 exceptionState.throwDOMException(InvalidStateError, 169 exceptionState.throwDOMException(InvalidStateError,
171 IDBDatabase::noValueErrorMessage); 170 IDBDatabase::noValueErrorMessage);
172 return; 171 return;
173 } 172 }
174 173
175 m_request->setPendingCursor(this); 174 m_request->setPendingCursor(this);
176 m_gotValue = false; 175 m_gotValue = false;
177 m_backend->advance(count, WebIDBCallbacksImpl::create(m_request).release()); 176 m_backend->advance(count, m_request->createWebCallbacks().release());
178 } 177 }
179 178
180 void IDBCursor::continueFunction(ScriptState* scriptState, 179 void IDBCursor::continueFunction(ScriptState* scriptState,
181 const ScriptValue& keyValue, 180 const ScriptValue& keyValue,
182 ExceptionState& exceptionState) { 181 ExceptionState& exceptionState) {
183 IDB_TRACE("IDBCursor::continue"); 182 IDB_TRACE("IDBCursor::continue");
184 183
185 if (m_transaction->isFinished() || m_transaction->isFinishing()) { 184 if (m_transaction->isFinished() || m_transaction->isFinishing()) {
186 exceptionState.throwDOMException( 185 exceptionState.throwDOMException(
187 TransactionInactiveError, IDBDatabase::transactionFinishedErrorMessage); 186 TransactionInactiveError, IDBDatabase::transactionFinishedErrorMessage);
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 return; 311 return;
313 } 312 }
314 } 313 }
315 } 314 }
316 315
317 // FIXME: We're not using the context from when continue was called, which mea ns the callback 316 // FIXME: We're not using the context from when continue was called, which mea ns the callback
318 // will be on the original context openCursor was called on. Is this ri ght? 317 // will be on the original context openCursor was called on. Is this ri ght?
319 m_request->setPendingCursor(this); 318 m_request->setPendingCursor(this);
320 m_gotValue = false; 319 m_gotValue = false;
321 m_backend->continueFunction(key, primaryKey, 320 m_backend->continueFunction(key, primaryKey,
322 WebIDBCallbacksImpl::create(m_request).release()); 321 m_request->createWebCallbacks().release());
323 } 322 }
324 323
325 IDBRequest* IDBCursor::deleteFunction(ScriptState* scriptState, 324 IDBRequest* IDBCursor::deleteFunction(ScriptState* scriptState,
326 ExceptionState& exceptionState) { 325 ExceptionState& exceptionState) {
327 IDB_TRACE("IDBCursor::delete"); 326 IDB_TRACE("IDBCursor::delete");
328 if (m_transaction->isFinished() || m_transaction->isFinishing()) { 327 if (m_transaction->isFinished() || m_transaction->isFinishing()) {
329 exceptionState.throwDOMException( 328 exceptionState.throwDOMException(
330 TransactionInactiveError, IDBDatabase::transactionFinishedErrorMessage); 329 TransactionInactiveError, IDBDatabase::transactionFinishedErrorMessage);
331 return nullptr; 330 return nullptr;
332 } 331 }
(...skipping 29 matching lines...) Expand all
362 return nullptr; 361 return nullptr;
363 } 362 }
364 363
365 IDBKeyRange* keyRange = IDBKeyRange::only(m_primaryKey, exceptionState); 364 IDBKeyRange* keyRange = IDBKeyRange::only(m_primaryKey, exceptionState);
366 DCHECK(!exceptionState.hadException()); 365 DCHECK(!exceptionState.hadException());
367 366
368 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this), 367 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this),
369 m_transaction.get()); 368 m_transaction.get());
370 m_transaction->backendDB()->deleteRange( 369 m_transaction->backendDB()->deleteRange(
371 m_transaction->id(), effectiveObjectStore()->id(), keyRange, 370 m_transaction->id(), effectiveObjectStore()->id(), keyRange,
372 WebIDBCallbacksImpl::create(request).release()); 371 request->createWebCallbacks().release());
373 return request; 372 return request;
374 } 373 }
375 374
376 void IDBCursor::postSuccessHandlerCallback() { 375 void IDBCursor::postSuccessHandlerCallback() {
377 if (m_backend) 376 if (m_backend)
378 m_backend->postSuccessHandlerCallback(); 377 m_backend->postSuccessHandlerCallback();
379 } 378 }
380 379
381 void IDBCursor::close() { 380 void IDBCursor::close() {
382 m_value.clear(); 381 m_value.clear();
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 case WebIDBCursorDirectionPrevNoDuplicate: 479 case WebIDBCursorDirectionPrevNoDuplicate:
481 return IndexedDBNames::prevunique; 480 return IndexedDBNames::prevunique;
482 481
483 default: 482 default:
484 NOTREACHED(); 483 NOTREACHED();
485 return IndexedDBNames::next; 484 return IndexedDBNames::next;
486 } 485 }
487 } 486 }
488 487
489 } // namespace blink 488 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698