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

Side by Side Diff: Source/modules/indexeddb/IDBIndex.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/IDBIndex.h ('k') | Source/modules/indexeddb/IDBIndex.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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 { 64 {
65 visitor->trace(m_objectStore); 65 visitor->trace(m_objectStore);
66 visitor->trace(m_transaction); 66 visitor->trace(m_transaction);
67 } 67 }
68 68
69 ScriptValue IDBIndex::keyPath(ScriptState* scriptState) const 69 ScriptValue IDBIndex::keyPath(ScriptState* scriptState) const
70 { 70 {
71 return idbAnyToScriptValue(scriptState, IDBAny::create(m_metadata.keyPath)); 71 return idbAnyToScriptValue(scriptState, IDBAny::create(m_metadata.keyPath));
72 } 72 }
73 73
74 IDBRequest* IDBIndex::openCursor(ExecutionContext* context, const ScriptValue& r ange, const String& directionString, ExceptionState& exceptionState) 74 IDBRequest* IDBIndex::openCursor(ScriptState* scriptState, const ScriptValue& ra nge, const String& directionString, ExceptionState& exceptionState)
75 { 75 {
76 IDB_TRACE("IDBIndex::openCursor"); 76 IDB_TRACE("IDBIndex::openCursor");
77 if (isDeleted()) { 77 if (isDeleted()) {
78 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::indexDe letedErrorMessage); 78 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::indexDe letedErrorMessage);
79 return 0; 79 return 0;
80 } 80 }
81 if (m_transaction->isFinished() || m_transaction->isFinishing()) { 81 if (m_transaction->isFinished() || m_transaction->isFinishing()) {
82 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionFinishedErrorMessage); 82 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionFinishedErrorMessage);
83 return 0; 83 return 0;
84 } 84 }
85 if (!m_transaction->isActive()) { 85 if (!m_transaction->isActive()) {
86 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionInactiveErrorMessage); 86 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionInactiveErrorMessage);
87 return 0; 87 return 0;
88 } 88 }
89 WebIDBCursor::Direction direction = IDBCursor::stringToDirection(directionSt ring, exceptionState); 89 WebIDBCursor::Direction direction = IDBCursor::stringToDirection(directionSt ring, exceptionState);
90 if (exceptionState.hadException()) 90 if (exceptionState.hadException())
91 return 0; 91 return 0;
92 92
93 IDBKeyRange* keyRange = IDBKeyRange::fromScriptValue(context, range, excepti onState); 93 IDBKeyRange* keyRange = IDBKeyRange::fromScriptValue(scriptState->executionC ontext(), range, exceptionState);
94 if (exceptionState.hadException()) 94 if (exceptionState.hadException())
95 return 0; 95 return 0;
96 96
97 if (!backendDB()) { 97 if (!backendDB()) {
98 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas eClosedErrorMessage); 98 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas eClosedErrorMessage);
99 return 0; 99 return 0;
100 } 100 }
101 101
102 return openCursor(context, keyRange, direction); 102 return openCursor(scriptState, keyRange, direction);
103 } 103 }
104 104
105 IDBRequest* IDBIndex::openCursor(ExecutionContext* context, IDBKeyRange* keyRang e, WebIDBCursor::Direction direction) 105 IDBRequest* IDBIndex::openCursor(ScriptState* scriptState, IDBKeyRange* keyRange , WebIDBCursor::Direction direction)
106 { 106 {
107 IDBRequest* request = IDBRequest::create(context, IDBAny::create(this), m_tr ansaction.get()); 107 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this), m_transaction.get());
108 request->setCursorDetails(IndexedDB::CursorKeyAndValue, direction); 108 request->setCursorDetails(IndexedDB::CursorKeyAndValue, direction);
109 backendDB()->openCursor(m_transaction->id(), m_objectStore->id(), m_metadata .id, keyRange, direction, false, WebIDBDatabase::NormalTask, WebIDBCallbacksImpl ::create(request).leakPtr()); 109 backendDB()->openCursor(m_transaction->id(), m_objectStore->id(), m_metadata .id, keyRange, direction, false, WebIDBDatabase::NormalTask, WebIDBCallbacksImpl ::create(request).leakPtr());
110 return request; 110 return request;
111 } 111 }
112 112
113 IDBRequest* IDBIndex::count(ExecutionContext* context, const ScriptValue& range, ExceptionState& exceptionState) 113 IDBRequest* IDBIndex::count(ScriptState* scriptState, const ScriptValue& range, ExceptionState& exceptionState)
114 { 114 {
115 IDB_TRACE("IDBIndex::count"); 115 IDB_TRACE("IDBIndex::count");
116 if (isDeleted()) { 116 if (isDeleted()) {
117 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::indexDe letedErrorMessage); 117 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::indexDe letedErrorMessage);
118 return 0; 118 return 0;
119 } 119 }
120 if (m_transaction->isFinished() || m_transaction->isFinishing()) { 120 if (m_transaction->isFinished() || m_transaction->isFinishing()) {
121 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionFinishedErrorMessage); 121 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionFinishedErrorMessage);
122 return 0; 122 return 0;
123 } 123 }
124 if (!m_transaction->isActive()) { 124 if (!m_transaction->isActive()) {
125 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionInactiveErrorMessage); 125 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionInactiveErrorMessage);
126 return 0; 126 return 0;
127 } 127 }
128 128
129 IDBKeyRange* keyRange = IDBKeyRange::fromScriptValue(context, range, excepti onState); 129 IDBKeyRange* keyRange = IDBKeyRange::fromScriptValue(scriptState->executionC ontext(), range, exceptionState);
130 if (exceptionState.hadException()) 130 if (exceptionState.hadException())
131 return 0; 131 return 0;
132 132
133 if (!backendDB()) { 133 if (!backendDB()) {
134 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas eClosedErrorMessage); 134 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas eClosedErrorMessage);
135 return 0; 135 return 0;
136 } 136 }
137 137
138 IDBRequest* request = IDBRequest::create(context, IDBAny::create(this), m_tr ansaction.get()); 138 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this), m_transaction.get());
139 backendDB()->count(m_transaction->id(), m_objectStore->id(), m_metadata.id, keyRange, WebIDBCallbacksImpl::create(request).leakPtr()); 139 backendDB()->count(m_transaction->id(), m_objectStore->id(), m_metadata.id, keyRange, WebIDBCallbacksImpl::create(request).leakPtr());
140 return request; 140 return request;
141 } 141 }
142 142
143 IDBRequest* IDBIndex::openKeyCursor(ExecutionContext* context, const ScriptValue & range, const String& directionString, ExceptionState& exceptionState) 143 IDBRequest* IDBIndex::openKeyCursor(ScriptState* scriptState, const ScriptValue& range, const String& directionString, ExceptionState& exceptionState)
144 { 144 {
145 IDB_TRACE("IDBIndex::openKeyCursor"); 145 IDB_TRACE("IDBIndex::openKeyCursor");
146 if (isDeleted()) { 146 if (isDeleted()) {
147 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::indexDe letedErrorMessage); 147 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::indexDe letedErrorMessage);
148 return 0; 148 return 0;
149 } 149 }
150 if (m_transaction->isFinished() || m_transaction->isFinishing()) { 150 if (m_transaction->isFinished() || m_transaction->isFinishing()) {
151 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionFinishedErrorMessage); 151 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionFinishedErrorMessage);
152 return 0; 152 return 0;
153 } 153 }
154 if (!m_transaction->isActive()) { 154 if (!m_transaction->isActive()) {
155 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionInactiveErrorMessage); 155 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionInactiveErrorMessage);
156 return 0; 156 return 0;
157 } 157 }
158 WebIDBCursor::Direction direction = IDBCursor::stringToDirection(directionSt ring, exceptionState); 158 WebIDBCursor::Direction direction = IDBCursor::stringToDirection(directionSt ring, exceptionState);
159 if (exceptionState.hadException()) 159 if (exceptionState.hadException())
160 return 0; 160 return 0;
161 161
162 IDBKeyRange* keyRange = IDBKeyRange::fromScriptValue(context, range, excepti onState); 162 IDBKeyRange* keyRange = IDBKeyRange::fromScriptValue(scriptState->executionC ontext(), range, exceptionState);
163 if (exceptionState.hadException()) 163 if (exceptionState.hadException())
164 return 0; 164 return 0;
165 if (!backendDB()) { 165 if (!backendDB()) {
166 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas eClosedErrorMessage); 166 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas eClosedErrorMessage);
167 return 0; 167 return 0;
168 } 168 }
169 169
170 IDBRequest* request = IDBRequest::create(context, IDBAny::create(this), m_tr ansaction.get()); 170 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this), m_transaction.get());
171 request->setCursorDetails(IndexedDB::CursorKeyOnly, direction); 171 request->setCursorDetails(IndexedDB::CursorKeyOnly, direction);
172 backendDB()->openCursor(m_transaction->id(), m_objectStore->id(), m_metadata .id, keyRange, direction, true, WebIDBDatabase::NormalTask, WebIDBCallbacksImpl: :create(request).leakPtr()); 172 backendDB()->openCursor(m_transaction->id(), m_objectStore->id(), m_metadata .id, keyRange, direction, true, WebIDBDatabase::NormalTask, WebIDBCallbacksImpl: :create(request).leakPtr());
173 return request; 173 return request;
174 } 174 }
175 175
176 IDBRequest* IDBIndex::get(ExecutionContext* context, const ScriptValue& key, Exc eptionState& exceptionState) 176 IDBRequest* IDBIndex::get(ScriptState* scriptState, const ScriptValue& key, Exce ptionState& exceptionState)
177 { 177 {
178 IDB_TRACE("IDBIndex::get"); 178 IDB_TRACE("IDBIndex::get");
179 return getInternal(context, key, exceptionState, false); 179 return getInternal(scriptState, key, exceptionState, false);
180 } 180 }
181 181
182 IDBRequest* IDBIndex::getKey(ExecutionContext* context, const ScriptValue& key, ExceptionState& exceptionState) 182 IDBRequest* IDBIndex::getKey(ScriptState* scriptState, const ScriptValue& key, E xceptionState& exceptionState)
183 { 183 {
184 IDB_TRACE("IDBIndex::getKey"); 184 IDB_TRACE("IDBIndex::getKey");
185 return getInternal(context, key, exceptionState, true); 185 return getInternal(scriptState, key, exceptionState, true);
186 } 186 }
187 187
188 IDBRequest* IDBIndex::getInternal(ExecutionContext* context, const ScriptValue& key, ExceptionState& exceptionState, bool keyOnly) 188 IDBRequest* IDBIndex::getInternal(ScriptState* scriptState, const ScriptValue& k ey, ExceptionState& exceptionState, bool keyOnly)
189 { 189 {
190 if (isDeleted()) { 190 if (isDeleted()) {
191 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::indexDe letedErrorMessage); 191 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::indexDe letedErrorMessage);
192 return 0; 192 return 0;
193 } 193 }
194 if (m_transaction->isFinished() || m_transaction->isFinishing()) { 194 if (m_transaction->isFinished() || m_transaction->isFinishing()) {
195 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionFinishedErrorMessage); 195 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionFinishedErrorMessage);
196 return 0; 196 return 0;
197 } 197 }
198 if (!m_transaction->isActive()) { 198 if (!m_transaction->isActive()) {
199 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionInactiveErrorMessage); 199 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionInactiveErrorMessage);
200 return 0; 200 return 0;
201 } 201 }
202 202
203 IDBKeyRange* keyRange = IDBKeyRange::fromScriptValue(context, key, exception State); 203 IDBKeyRange* keyRange = IDBKeyRange::fromScriptValue(scriptState->executionC ontext(), key, exceptionState);
204 if (exceptionState.hadException()) 204 if (exceptionState.hadException())
205 return 0; 205 return 0;
206 if (!keyRange) { 206 if (!keyRange) {
207 exceptionState.throwDOMException(DataError, IDBDatabase::noKeyOrKeyRange ErrorMessage); 207 exceptionState.throwDOMException(DataError, IDBDatabase::noKeyOrKeyRange ErrorMessage);
208 return 0; 208 return 0;
209 } 209 }
210 if (!backendDB()) { 210 if (!backendDB()) {
211 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas eClosedErrorMessage); 211 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas eClosedErrorMessage);
212 return 0; 212 return 0;
213 } 213 }
214 214
215 IDBRequest* request = IDBRequest::create(context, IDBAny::create(this), m_tr ansaction.get()); 215 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this), m_transaction.get());
216 backendDB()->get(m_transaction->id(), m_objectStore->id(), m_metadata.id, ke yRange, keyOnly, WebIDBCallbacksImpl::create(request).leakPtr()); 216 backendDB()->get(m_transaction->id(), m_objectStore->id(), m_metadata.id, ke yRange, keyOnly, WebIDBCallbacksImpl::create(request).leakPtr());
217 return request; 217 return request;
218 } 218 }
219 219
220 WebIDBDatabase* IDBIndex::backendDB() const 220 WebIDBDatabase* IDBIndex::backendDB() const
221 { 221 {
222 return m_transaction->backendDB(); 222 return m_transaction->backendDB();
223 } 223 }
224 224
225 bool IDBIndex::isDeleted() const 225 bool IDBIndex::isDeleted() const
226 { 226 {
227 return m_deleted || m_objectStore->isDeleted(); 227 return m_deleted || m_objectStore->isDeleted();
228 } 228 }
229 229
230 } // namespace WebCore 230 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/modules/indexeddb/IDBIndex.h ('k') | Source/modules/indexeddb/IDBIndex.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698