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

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, 7 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
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 PassRefPtrWillBeRawPtr<IDBRequest> IDBIndex::openCursor(ExecutionContext* contex t, const ScriptValue& range, const String& directionString, ExceptionState& exce ptionState) 74 PassRefPtrWillBeRawPtr<IDBRequest> IDBIndex::openCursor(ScriptState* scriptState , const ScriptValue& range, const String& directionString, ExceptionState& excep tionState)
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 nullptr; 79 return nullptr;
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 nullptr; 83 return nullptr;
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 nullptr; 87 return nullptr;
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 nullptr; 91 return nullptr;
92 92
93 RefPtrWillBeRawPtr<IDBKeyRange> keyRange = IDBKeyRange::fromScriptValue(cont ext, range, exceptionState); 93 RefPtrWillBeRawPtr<IDBKeyRange> keyRange = IDBKeyRange::fromScriptValue(scri ptState->executionContext(), range, exceptionState);
94 if (exceptionState.hadException()) 94 if (exceptionState.hadException())
95 return nullptr; 95 return nullptr;
96 96
97 if (!backendDB()) { 97 if (!backendDB()) {
98 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas eClosedErrorMessage); 98 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas eClosedErrorMessage);
99 return nullptr; 99 return nullptr;
100 } 100 }
101 101
102 return openCursor(context, keyRange.release(), direction); 102 return openCursor(scriptState, keyRange.release(), direction);
103 } 103 }
104 104
105 PassRefPtrWillBeRawPtr<IDBRequest> IDBIndex::openCursor(ExecutionContext* contex t, PassRefPtrWillBeRawPtr<IDBKeyRange> keyRange, WebIDBCursor::Direction directi on) 105 PassRefPtrWillBeRawPtr<IDBRequest> IDBIndex::openCursor(ScriptState* scriptState , PassRefPtrWillBeRawPtr<IDBKeyRange> keyRange, WebIDBCursor::Direction directio n)
106 { 106 {
107 RefPtrWillBeRawPtr<IDBRequest> request = IDBRequest::create(context, IDBAny: :create(this), m_transaction.get()); 107 RefPtrWillBeRawPtr<IDBRequest> request = IDBRequest::create(scriptState, IDB Any::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 PassRefPtrWillBeRawPtr<IDBRequest> IDBIndex::count(ExecutionContext* context, co nst ScriptValue& range, ExceptionState& exceptionState) 113 PassRefPtrWillBeRawPtr<IDBRequest> IDBIndex::count(ScriptState* scriptState, con st 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 nullptr; 118 return nullptr;
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 nullptr; 122 return nullptr;
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 nullptr; 126 return nullptr;
127 } 127 }
128 128
129 RefPtrWillBeRawPtr<IDBKeyRange> keyRange = IDBKeyRange::fromScriptValue(cont ext, range, exceptionState); 129 RefPtrWillBeRawPtr<IDBKeyRange> keyRange = IDBKeyRange::fromScriptValue(scri ptState->executionContext(), range, exceptionState);
130 if (exceptionState.hadException()) 130 if (exceptionState.hadException())
131 return nullptr; 131 return nullptr;
132 132
133 if (!backendDB()) { 133 if (!backendDB()) {
134 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas eClosedErrorMessage); 134 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas eClosedErrorMessage);
135 return nullptr; 135 return nullptr;
136 } 136 }
137 137
138 RefPtrWillBeRawPtr<IDBRequest> request = IDBRequest::create(context, IDBAny: :create(this), m_transaction.get()); 138 RefPtrWillBeRawPtr<IDBRequest> request = IDBRequest::create(scriptState, IDB Any::create(this), m_transaction.get());
139 backendDB()->count(m_transaction->id(), m_objectStore->id(), m_metadata.id, keyRange.release(), WebIDBCallbacksImpl::create(request).leakPtr()); 139 backendDB()->count(m_transaction->id(), m_objectStore->id(), m_metadata.id, keyRange.release(), WebIDBCallbacksImpl::create(request).leakPtr());
140 return request; 140 return request;
141 } 141 }
142 142
143 PassRefPtrWillBeRawPtr<IDBRequest> IDBIndex::openKeyCursor(ExecutionContext* con text, const ScriptValue& range, const String& directionString, ExceptionState& e xceptionState) 143 PassRefPtrWillBeRawPtr<IDBRequest> IDBIndex::openKeyCursor(ScriptState* scriptSt ate, const ScriptValue& range, const String& directionString, ExceptionState& ex ceptionState)
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 nullptr; 148 return nullptr;
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 nullptr; 152 return nullptr;
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 nullptr; 156 return nullptr;
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 nullptr; 160 return nullptr;
161 161
162 RefPtrWillBeRawPtr<IDBKeyRange> keyRange = IDBKeyRange::fromScriptValue(cont ext, range, exceptionState); 162 RefPtrWillBeRawPtr<IDBKeyRange> keyRange = IDBKeyRange::fromScriptValue(scri ptState->executionContext(), range, exceptionState);
163 if (exceptionState.hadException()) 163 if (exceptionState.hadException())
164 return nullptr; 164 return nullptr;
165 if (!backendDB()) { 165 if (!backendDB()) {
166 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas eClosedErrorMessage); 166 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas eClosedErrorMessage);
167 return nullptr; 167 return nullptr;
168 } 168 }
169 169
170 RefPtrWillBeRawPtr<IDBRequest> request = IDBRequest::create(context, IDBAny: :create(this), m_transaction.get()); 170 RefPtrWillBeRawPtr<IDBRequest> request = IDBRequest::create(scriptState, IDB Any::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.release(), direction, true, WebIDBDatabase::NormalTask, WebIDBCall backsImpl::create(request).leakPtr()); 172 backendDB()->openCursor(m_transaction->id(), m_objectStore->id(), m_metadata .id, keyRange.release(), direction, true, WebIDBDatabase::NormalTask, WebIDBCall backsImpl::create(request).leakPtr());
173 return request; 173 return request;
174 } 174 }
175 175
176 PassRefPtrWillBeRawPtr<IDBRequest> IDBIndex::get(ExecutionContext* context, cons t ScriptValue& key, ExceptionState& exceptionState) 176 PassRefPtrWillBeRawPtr<IDBRequest> IDBIndex::get(ScriptState* scriptState, const ScriptValue& key, ExceptionState& 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 PassRefPtrWillBeRawPtr<IDBRequest> IDBIndex::getKey(ExecutionContext* context, c onst ScriptValue& key, ExceptionState& exceptionState) 182 PassRefPtrWillBeRawPtr<IDBRequest> IDBIndex::getKey(ScriptState* scriptState, co nst ScriptValue& key, ExceptionState& 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 PassRefPtrWillBeRawPtr<IDBRequest> IDBIndex::getInternal(ExecutionContext* conte xt, const ScriptValue& key, ExceptionState& exceptionState, bool keyOnly) 188 PassRefPtrWillBeRawPtr<IDBRequest> IDBIndex::getInternal(ScriptState* scriptStat e, const ScriptValue& key, 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 nullptr; 192 return nullptr;
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 nullptr; 196 return nullptr;
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 nullptr; 200 return nullptr;
201 } 201 }
202 202
203 RefPtrWillBeRawPtr<IDBKeyRange> keyRange = IDBKeyRange::fromScriptValue(cont ext, key, exceptionState); 203 RefPtrWillBeRawPtr<IDBKeyRange> keyRange = IDBKeyRange::fromScriptValue(scri ptState->executionContext(), key, exceptionState);
204 if (exceptionState.hadException()) 204 if (exceptionState.hadException())
205 return nullptr; 205 return nullptr;
206 if (!keyRange) { 206 if (!keyRange) {
207 exceptionState.throwDOMException(DataError, IDBDatabase::noKeyOrKeyRange ErrorMessage); 207 exceptionState.throwDOMException(DataError, IDBDatabase::noKeyOrKeyRange ErrorMessage);
208 return nullptr; 208 return nullptr;
209 } 209 }
210 if (!backendDB()) { 210 if (!backendDB()) {
211 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas eClosedErrorMessage); 211 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas eClosedErrorMessage);
212 return nullptr; 212 return nullptr;
213 } 213 }
214 214
215 RefPtrWillBeRawPtr<IDBRequest> request = IDBRequest::create(context, IDBAny: :create(this), m_transaction.get()); 215 RefPtrWillBeRawPtr<IDBRequest> request = IDBRequest::create(scriptState, IDB Any::create(this), m_transaction.get());
216 backendDB()->get(m_transaction->id(), m_objectStore->id(), m_metadata.id, ke yRange.release(), keyOnly, WebIDBCallbacksImpl::create(request).leakPtr()); 216 backendDB()->get(m_transaction->id(), m_objectStore->id(), m_metadata.id, ke yRange.release(), 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

Powered by Google App Engine
This is Rietveld 408576698