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

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

Issue 2370643004: Port messages sent by WebIDBFactoryImpl to Mojo. (Closed)
Patch Set: Allow cpp_only to be set by the invoker. 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(const IDBIndexMetadata& metadata, IDBObjectStore* objectStore , IDBTransaction* transaction) 47 IDBIndex::IDBIndex(const IDBIndexMetadata& metadata, IDBObjectStore* objectStore , IDBTransaction* transaction)
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 return nullptr; 134 return nullptr;
136 } 135 }
137 136
138 return openCursor(scriptState, keyRange, direction); 137 return openCursor(scriptState, keyRange, direction);
139 } 138 }
140 139
141 IDBRequest* IDBIndex::openCursor(ScriptState* scriptState, IDBKeyRange* keyRange , WebIDBCursorDirection direction) 140 IDBRequest* IDBIndex::openCursor(ScriptState* scriptState, IDBKeyRange* keyRange , WebIDBCursorDirection direction)
142 { 141 {
143 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this), m_transaction.get()); 142 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this), m_transaction.get());
144 request->setCursorDetails(IndexedDB::CursorKeyAndValue, direction); 143 request->setCursorDetails(IndexedDB::CursorKeyAndValue, direction);
145 backendDB()->openCursor(m_transaction->id(), m_objectStore->id(), id(), keyR ange, direction, false, WebIDBTaskTypeNormal, WebIDBCallbacksImpl::create(reques t).release()); 144 backendDB()->openCursor(m_transaction->id(), m_objectStore->id(), id(), keyR ange, direction, false, WebIDBTaskTypeNormal, request->createWebCallbacks().rele ase());
146 return request; 145 return request;
147 } 146 }
148 147
149 IDBRequest* IDBIndex::count(ScriptState* scriptState, const ScriptValue& range, ExceptionState& exceptionState) 148 IDBRequest* IDBIndex::count(ScriptState* scriptState, const ScriptValue& range, ExceptionState& exceptionState)
150 { 149 {
151 IDB_TRACE("IDBIndex::count"); 150 IDB_TRACE("IDBIndex::count");
152 if (isDeleted()) { 151 if (isDeleted()) {
153 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::indexDe letedErrorMessage); 152 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::indexDe letedErrorMessage);
154 return nullptr; 153 return nullptr;
155 } 154 }
156 if (m_transaction->isFinished() || m_transaction->isFinishing()) { 155 if (m_transaction->isFinished() || m_transaction->isFinishing()) {
157 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionFinishedErrorMessage); 156 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionFinishedErrorMessage);
158 return nullptr; 157 return nullptr;
159 } 158 }
160 if (!m_transaction->isActive()) { 159 if (!m_transaction->isActive()) {
161 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionInactiveErrorMessage); 160 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionInactiveErrorMessage);
162 return nullptr; 161 return nullptr;
163 } 162 }
164 163
165 IDBKeyRange* keyRange = IDBKeyRange::fromScriptValue(scriptState->getExecuti onContext(), range, exceptionState); 164 IDBKeyRange* keyRange = IDBKeyRange::fromScriptValue(scriptState->getExecuti onContext(), range, exceptionState);
166 if (exceptionState.hadException()) 165 if (exceptionState.hadException())
167 return nullptr; 166 return nullptr;
168 167
169 if (!backendDB()) { 168 if (!backendDB()) {
170 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas eClosedErrorMessage); 169 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas eClosedErrorMessage);
171 return nullptr; 170 return nullptr;
172 } 171 }
173 172
174 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this), m_transaction.get()); 173 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this), m_transaction.get());
175 backendDB()->count(m_transaction->id(), m_objectStore->id(), id(), keyRange, WebIDBCallbacksImpl::create(request).release()); 174 backendDB()->count(m_transaction->id(), m_objectStore->id(), id(), keyRange, request->createWebCallbacks().release());
176 return request; 175 return request;
177 } 176 }
178 177
179 IDBRequest* IDBIndex::openKeyCursor(ScriptState* scriptState, const ScriptValue& range, const String& directionString, ExceptionState& exceptionState) 178 IDBRequest* IDBIndex::openKeyCursor(ScriptState* scriptState, const ScriptValue& range, const String& directionString, ExceptionState& exceptionState)
180 { 179 {
181 IDB_TRACE("IDBIndex::openKeyCursor"); 180 IDB_TRACE("IDBIndex::openKeyCursor");
182 if (isDeleted()) { 181 if (isDeleted()) {
183 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::indexDe letedErrorMessage); 182 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::indexDe letedErrorMessage);
184 return nullptr; 183 return nullptr;
185 } 184 }
186 if (m_transaction->isFinished() || m_transaction->isFinishing()) { 185 if (m_transaction->isFinished() || m_transaction->isFinishing()) {
187 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionFinishedErrorMessage); 186 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionFinishedErrorMessage);
188 return nullptr; 187 return nullptr;
189 } 188 }
190 if (!m_transaction->isActive()) { 189 if (!m_transaction->isActive()) {
191 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionInactiveErrorMessage); 190 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionInactiveErrorMessage);
192 return nullptr; 191 return nullptr;
193 } 192 }
194 WebIDBCursorDirection direction = IDBCursor::stringToDirection(directionStri ng); 193 WebIDBCursorDirection direction = IDBCursor::stringToDirection(directionStri ng);
195 IDBKeyRange* keyRange = IDBKeyRange::fromScriptValue(scriptState->getExecuti onContext(), range, exceptionState); 194 IDBKeyRange* keyRange = IDBKeyRange::fromScriptValue(scriptState->getExecuti onContext(), range, exceptionState);
196 if (exceptionState.hadException()) 195 if (exceptionState.hadException())
197 return nullptr; 196 return nullptr;
198 if (!backendDB()) { 197 if (!backendDB()) {
199 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas eClosedErrorMessage); 198 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas eClosedErrorMessage);
200 return nullptr; 199 return nullptr;
201 } 200 }
202 201
203 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this), m_transaction.get()); 202 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this), m_transaction.get());
204 request->setCursorDetails(IndexedDB::CursorKeyOnly, direction); 203 request->setCursorDetails(IndexedDB::CursorKeyOnly, direction);
205 backendDB()->openCursor(m_transaction->id(), m_objectStore->id(), id(), keyR ange, direction, true, WebIDBTaskTypeNormal, WebIDBCallbacksImpl::create(request ).release()); 204 backendDB()->openCursor(m_transaction->id(), m_objectStore->id(), id(), keyR ange, direction, true, WebIDBTaskTypeNormal, request->createWebCallbacks().relea se());
206 return request; 205 return request;
207 } 206 }
208 207
209 IDBRequest* IDBIndex::get(ScriptState* scriptState, const ScriptValue& key, Exce ptionState& exceptionState) 208 IDBRequest* IDBIndex::get(ScriptState* scriptState, const ScriptValue& key, Exce ptionState& exceptionState)
210 { 209 {
211 IDB_TRACE("IDBIndex::get"); 210 IDB_TRACE("IDBIndex::get");
212 return getInternal(scriptState, key, exceptionState, false); 211 return getInternal(scriptState, key, exceptionState, false);
213 } 212 }
214 213
215 IDBRequest* IDBIndex::getAll(ScriptState* scriptState, const ScriptValue& range, ExceptionState& exceptionState) 214 IDBRequest* IDBIndex::getAll(ScriptState* scriptState, const ScriptValue& range, ExceptionState& exceptionState)
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 if (!keyRange) { 260 if (!keyRange) {
262 exceptionState.throwDOMException(DataError, IDBDatabase::noKeyOrKeyRange ErrorMessage); 261 exceptionState.throwDOMException(DataError, IDBDatabase::noKeyOrKeyRange ErrorMessage);
263 return nullptr; 262 return nullptr;
264 } 263 }
265 if (!backendDB()) { 264 if (!backendDB()) {
266 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas eClosedErrorMessage); 265 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas eClosedErrorMessage);
267 return nullptr; 266 return nullptr;
268 } 267 }
269 268
270 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this), m_transaction.get()); 269 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this), m_transaction.get());
271 backendDB()->get(m_transaction->id(), m_objectStore->id(), id(), keyRange, k eyOnly, WebIDBCallbacksImpl::create(request).release()); 270 backendDB()->get(m_transaction->id(), m_objectStore->id(), id(), keyRange, k eyOnly, request->createWebCallbacks().release());
272 return request; 271 return request;
273 } 272 }
274 273
275 IDBRequest* IDBIndex::getAllInternal(ScriptState* scriptState, const ScriptValue & range, unsigned long maxCount, ExceptionState& exceptionState, bool keyOnly) 274 IDBRequest* IDBIndex::getAllInternal(ScriptState* scriptState, const ScriptValue & range, unsigned long maxCount, ExceptionState& exceptionState, bool keyOnly)
276 { 275 {
277 if (!maxCount) 276 if (!maxCount)
278 maxCount = std::numeric_limits<uint32_t>::max(); 277 maxCount = std::numeric_limits<uint32_t>::max();
279 278
280 if (isDeleted()) { 279 if (isDeleted()) {
281 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::indexDe letedErrorMessage); 280 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::indexDe letedErrorMessage);
(...skipping 10 matching lines...) Expand all
292 291
293 IDBKeyRange* keyRange = IDBKeyRange::fromScriptValue(scriptState->getExecuti onContext(), range, exceptionState); 292 IDBKeyRange* keyRange = IDBKeyRange::fromScriptValue(scriptState->getExecuti onContext(), range, exceptionState);
294 if (exceptionState.hadException()) 293 if (exceptionState.hadException())
295 return nullptr; 294 return nullptr;
296 if (!backendDB()) { 295 if (!backendDB()) {
297 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas eClosedErrorMessage); 296 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas eClosedErrorMessage);
298 return nullptr; 297 return nullptr;
299 } 298 }
300 299
301 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this), m_transaction.get()); 300 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this), m_transaction.get());
302 backendDB()->getAll(m_transaction->id(), m_objectStore->id(), id(), keyRange , maxCount, keyOnly, WebIDBCallbacksImpl::create(request).release()); 301 backendDB()->getAll(m_transaction->id(), m_objectStore->id(), id(), keyRange , maxCount, keyOnly, request->createWebCallbacks().release());
303 return request; 302 return request;
304 } 303 }
305 304
306 WebIDBDatabase* IDBIndex::backendDB() const 305 WebIDBDatabase* IDBIndex::backendDB() const
307 { 306 {
308 return m_transaction->backendDB(); 307 return m_transaction->backendDB();
309 } 308 }
310 309
311 bool IDBIndex::isDeleted() const 310 bool IDBIndex::isDeleted() const
312 { 311 {
313 return m_deleted || m_objectStore->isDeleted(); 312 return m_deleted || m_objectStore->isDeleted();
314 } 313 }
315 314
316 } // namespace blink 315 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698