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

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

Issue 295163005: Remove ScriptState::current() from IDBRequest (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « Source/modules/indexeddb/IDBCursor.h ('k') | Source/modules/indexeddb/IDBCursor.idl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 102
103 void IDBCursor::trace(Visitor* visitor) 103 void IDBCursor::trace(Visitor* visitor)
104 { 104 {
105 visitor->trace(m_request); 105 visitor->trace(m_request);
106 visitor->trace(m_source); 106 visitor->trace(m_source);
107 visitor->trace(m_transaction); 107 visitor->trace(m_transaction);
108 visitor->trace(m_key); 108 visitor->trace(m_key);
109 visitor->trace(m_primaryKey); 109 visitor->trace(m_primaryKey);
110 } 110 }
111 111
112 IDBRequest* IDBCursor::update(ExecutionContext* executionContext, ScriptValue& v alue, ExceptionState& exceptionState) 112 IDBRequest* IDBCursor::update(ScriptState* scriptState, ScriptValue& value, Exce ptionState& exceptionState)
113 { 113 {
114 IDB_TRACE("IDBCursor::update"); 114 IDB_TRACE("IDBCursor::update");
115 115
116 if (!m_gotValue) { 116 if (!m_gotValue) {
117 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::noValue ErrorMessage); 117 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::noValue ErrorMessage);
118 return 0; 118 return 0;
119 } 119 }
120 if (isKeyCursor()) { 120 if (isKeyCursor()) {
121 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::isKeyCu rsorErrorMessage); 121 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::isKeyCu rsorErrorMessage);
122 return 0; 122 return 0;
(...skipping 12 matching lines...) Expand all
135 } 135 }
136 if (m_transaction->isReadOnly()) { 136 if (m_transaction->isReadOnly()) {
137 exceptionState.throwDOMException(ReadOnlyError, "The record may not be u pdated inside a read-only transaction."); 137 exceptionState.throwDOMException(ReadOnlyError, "The record may not be u pdated inside a read-only transaction.");
138 return 0; 138 return 0;
139 } 139 }
140 140
141 IDBObjectStore* objectStore = effectiveObjectStore(); 141 IDBObjectStore* objectStore = effectiveObjectStore();
142 const IDBKeyPath& keyPath = objectStore->metadata().keyPath; 142 const IDBKeyPath& keyPath = objectStore->metadata().keyPath;
143 const bool usesInLineKeys = !keyPath.isNull(); 143 const bool usesInLineKeys = !keyPath.isNull();
144 if (usesInLineKeys) { 144 if (usesInLineKeys) {
145 IDBKey* keyPathKey = createIDBKeyFromScriptValueAndKeyPath(toIsolate(exe cutionContext), value, keyPath); 145 IDBKey* keyPathKey = createIDBKeyFromScriptValueAndKeyPath(scriptState-> isolate(), value, keyPath);
146 if (!keyPathKey || !keyPathKey->isEqual(m_primaryKey.get())) { 146 if (!keyPathKey || !keyPathKey->isEqual(m_primaryKey.get())) {
147 exceptionState.throwDOMException(DataError, "The effective object st ore of this cursor uses in-line keys and evaluating the key path of the value pa rameter results in a different value than the cursor's effective key."); 147 exceptionState.throwDOMException(DataError, "The effective object st ore of this cursor uses in-line keys and evaluating the key path of the value pa rameter results in a different value than the cursor's effective key.");
148 return 0; 148 return 0;
149 } 149 }
150 } 150 }
151 151
152 return objectStore->put(executionContext, WebIDBDatabase::CursorUpdate, IDBA ny::create(this), value, m_primaryKey, exceptionState); 152 return objectStore->put(scriptState, WebIDBDatabase::CursorUpdate, IDBAny::c reate(this), value, m_primaryKey, exceptionState);
153 } 153 }
154 154
155 void IDBCursor::advance(unsigned long count, ExceptionState& exceptionState) 155 void IDBCursor::advance(unsigned long count, ExceptionState& exceptionState)
156 { 156 {
157 IDB_TRACE("IDBCursor::advance"); 157 IDB_TRACE("IDBCursor::advance");
158 if (!count) { 158 if (!count) {
159 exceptionState.throwTypeError("A count argument with value 0 (zero) was supplied, must be greater than 0."); 159 exceptionState.throwTypeError("A count argument with value 0 (zero) was supplied, must be greater than 0.");
160 return; 160 return;
161 } 161 }
162 if (!m_gotValue) { 162 if (!m_gotValue) {
(...skipping 12 matching lines...) Expand all
175 if (!m_transaction->isActive()) { 175 if (!m_transaction->isActive()) {
176 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionInactiveErrorMessage); 176 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionInactiveErrorMessage);
177 return; 177 return;
178 } 178 }
179 179
180 m_request->setPendingCursor(this); 180 m_request->setPendingCursor(this);
181 m_gotValue = false; 181 m_gotValue = false;
182 m_backend->advance(count, WebIDBCallbacksImpl::create(m_request).leakPtr()); 182 m_backend->advance(count, WebIDBCallbacksImpl::create(m_request).leakPtr());
183 } 183 }
184 184
185 void IDBCursor::continueFunction(ExecutionContext* context, const ScriptValue& k eyValue, ExceptionState& exceptionState) 185 void IDBCursor::continueFunction(ScriptState* scriptState, const ScriptValue& ke yValue, ExceptionState& exceptionState)
186 { 186 {
187 IDB_TRACE("IDBCursor::continue"); 187 IDB_TRACE("IDBCursor::continue");
188 IDBKey* key = keyValue.isUndefined() || keyValue.isNull() ? 0 : scriptValueT oIDBKey(toIsolate(context), keyValue); 188 IDBKey* key = keyValue.isUndefined() || keyValue.isNull() ? nullptr : script ValueToIDBKey(scriptState->isolate(), keyValue);
189 if (key && !key->isValid()) { 189 if (key && !key->isValid()) {
190 exceptionState.throwDOMException(DataError, IDBDatabase::notValidKeyErro rMessage); 190 exceptionState.throwDOMException(DataError, IDBDatabase::notValidKeyErro rMessage);
191 return; 191 return;
192 } 192 }
193 continueFunction(key, 0, exceptionState); 193 continueFunction(key, 0, exceptionState);
194 } 194 }
195 195
196 void IDBCursor::continuePrimaryKey(ExecutionContext* context, const ScriptValue& keyValue, const ScriptValue& primaryKeyValue, ExceptionState& exceptionState) 196 void IDBCursor::continuePrimaryKey(ScriptState* scriptState, const ScriptValue& keyValue, const ScriptValue& primaryKeyValue, ExceptionState& exceptionState)
197 { 197 {
198 IDB_TRACE("IDBCursor::continuePrimaryKey"); 198 IDB_TRACE("IDBCursor::continuePrimaryKey");
199 IDBKey* key = scriptValueToIDBKey(toIsolate(context), keyValue); 199 IDBKey* key = scriptValueToIDBKey(scriptState->isolate(), keyValue);
200 IDBKey* primaryKey = scriptValueToIDBKey(toIsolate(context), primaryKeyValue ); 200 IDBKey* primaryKey = scriptValueToIDBKey(scriptState->isolate(), primaryKeyV alue);
201 if (!key->isValid() || !primaryKey->isValid()) { 201 if (!key->isValid() || !primaryKey->isValid()) {
202 exceptionState.throwDOMException(DataError, IDBDatabase::notValidKeyErro rMessage); 202 exceptionState.throwDOMException(DataError, IDBDatabase::notValidKeyErro rMessage);
203 return; 203 return;
204 } 204 }
205 continueFunction(key, primaryKey, exceptionState); 205 continueFunction(key, primaryKey, exceptionState);
206 } 206 }
207 207
208 void IDBCursor::continueFunction(IDBKey* key, IDBKey* primaryKey, ExceptionState & exceptionState) 208 void IDBCursor::continueFunction(IDBKey* key, IDBKey* primaryKey, ExceptionState & exceptionState)
209 { 209 {
210 ASSERT(!primaryKey || (key && primaryKey)); 210 ASSERT(!primaryKey || (key && primaryKey));
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 } 248 }
249 } 249 }
250 250
251 // FIXME: We're not using the context from when continue was called, which m eans the callback 251 // FIXME: We're not using the context from when continue was called, which m eans the callback
252 // will be on the original context openCursor was called on. Is this right? 252 // will be on the original context openCursor was called on. Is this right?
253 m_request->setPendingCursor(this); 253 m_request->setPendingCursor(this);
254 m_gotValue = false; 254 m_gotValue = false;
255 m_backend->continueFunction(key, primaryKey, WebIDBCallbacksImpl::create(m_r equest).leakPtr()); 255 m_backend->continueFunction(key, primaryKey, WebIDBCallbacksImpl::create(m_r equest).leakPtr());
256 } 256 }
257 257
258 IDBRequest* IDBCursor::deleteFunction(ExecutionContext* context, ExceptionState& exceptionState) 258 IDBRequest* IDBCursor::deleteFunction(ScriptState* scriptState, ExceptionState& exceptionState)
259 { 259 {
260 IDB_TRACE("IDBCursor::delete"); 260 IDB_TRACE("IDBCursor::delete");
261 if (m_transaction->isFinished() || m_transaction->isFinishing()) { 261 if (m_transaction->isFinished() || m_transaction->isFinishing()) {
262 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionFinishedErrorMessage); 262 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionFinishedErrorMessage);
263 return 0; 263 return 0;
264 } 264 }
265 if (!m_transaction->isActive()) { 265 if (!m_transaction->isActive()) {
266 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionInactiveErrorMessage); 266 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionInactiveErrorMessage);
267 return 0; 267 return 0;
268 } 268 }
(...skipping 15 matching lines...) Expand all
284 return 0; 284 return 0;
285 } 285 }
286 if (!m_transaction->backendDB()) { 286 if (!m_transaction->backendDB()) {
287 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas eClosedErrorMessage); 287 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas eClosedErrorMessage);
288 return 0; 288 return 0;
289 } 289 }
290 290
291 IDBKeyRange* keyRange = IDBKeyRange::only(m_primaryKey, exceptionState); 291 IDBKeyRange* keyRange = IDBKeyRange::only(m_primaryKey, exceptionState);
292 ASSERT(!exceptionState.hadException()); 292 ASSERT(!exceptionState.hadException());
293 293
294 IDBRequest* request = IDBRequest::create(context, IDBAny::create(this), m_tr ansaction.get()); 294 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this), m_transaction.get());
295 m_transaction->backendDB()->deleteRange(m_transaction->id(), effectiveObject Store()->id(), keyRange, WebIDBCallbacksImpl::create(request).leakPtr()); 295 m_transaction->backendDB()->deleteRange(m_transaction->id(), effectiveObject Store()->id(), keyRange, WebIDBCallbacksImpl::create(request).leakPtr());
296 return request; 296 return request;
297 } 297 }
298 298
299 void IDBCursor::postSuccessHandlerCallback() 299 void IDBCursor::postSuccessHandlerCallback()
300 { 300 {
301 if (m_backend) 301 if (m_backend)
302 m_backend->postSuccessHandlerCallback(); 302 m_backend->postSuccessHandlerCallback();
303 } 303 }
304 304
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 case WebIDBCursor::PrevNoDuplicate: 420 case WebIDBCursor::PrevNoDuplicate:
421 return IDBCursor::directionPrevUnique(); 421 return IDBCursor::directionPrevUnique();
422 422
423 default: 423 default:
424 ASSERT_NOT_REACHED(); 424 ASSERT_NOT_REACHED();
425 return IDBCursor::directionNext(); 425 return IDBCursor::directionNext();
426 } 426 }
427 } 427 }
428 428
429 } // namespace WebCore 429 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/modules/indexeddb/IDBCursor.h ('k') | Source/modules/indexeddb/IDBCursor.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698