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

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

Issue 1166553004: IndexedDB: Replace 0 with nullptr where appropriate (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: MOAR Created 5 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/IDBFactory.cpp ('k') | Source/modules/indexeddb/IDBKeyRange.cpp » ('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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 ScriptValue IDBIndex::keyPath(ScriptState* scriptState) const 69 ScriptValue IDBIndex::keyPath(ScriptState* scriptState) const
70 { 70 {
71 return ScriptValue::from(scriptState, m_metadata.keyPath); 71 return ScriptValue::from(scriptState, m_metadata.keyPath);
72 } 72 }
73 73
74 IDBRequest* IDBIndex::openCursor(ScriptState* scriptState, const ScriptValue& ra nge, 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 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 0; 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 0; 87 return nullptr;
88 } 88 }
89 WebIDBCursorDirection direction = IDBCursor::stringToDirection(directionStri ng, exceptionState); 89 WebIDBCursorDirection direction = IDBCursor::stringToDirection(directionStri ng, exceptionState);
90 if (exceptionState.hadException()) 90 if (exceptionState.hadException())
91 return 0; 91 return nullptr;
92 92
93 IDBKeyRange* keyRange = IDBKeyRange::fromScriptValue(scriptState->executionC ontext(), range, exceptionState); 93 IDBKeyRange* keyRange = IDBKeyRange::fromScriptValue(scriptState->executionC ontext(), range, exceptionState);
94 if (exceptionState.hadException()) 94 if (exceptionState.hadException())
95 return 0; 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 0; 99 return nullptr;
100 } 100 }
101 101
102 return openCursor(scriptState, keyRange, direction); 102 return openCursor(scriptState, keyRange, direction);
103 } 103 }
104 104
105 IDBRequest* IDBIndex::openCursor(ScriptState* scriptState, IDBKeyRange* keyRange , WebIDBCursorDirection direction) 105 IDBRequest* IDBIndex::openCursor(ScriptState* scriptState, IDBKeyRange* keyRange , WebIDBCursorDirection direction)
106 { 106 {
107 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this), m_transaction.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, WebIDBTaskTypeNormal, WebIDBCallbacksImpl::crea te(request).leakPtr()); 109 backendDB()->openCursor(m_transaction->id(), m_objectStore->id(), m_metadata .id, keyRange, direction, false, WebIDBTaskTypeNormal, WebIDBCallbacksImpl::crea te(request).leakPtr());
110 return request; 110 return request;
111 } 111 }
112 112
113 IDBRequest* IDBIndex::count(ScriptState* scriptState, 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 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 0; 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 0; 126 return nullptr;
127 } 127 }
128 128
129 IDBKeyRange* keyRange = IDBKeyRange::fromScriptValue(scriptState->executionC ontext(), range, exceptionState); 129 IDBKeyRange* keyRange = IDBKeyRange::fromScriptValue(scriptState->executionC ontext(), range, exceptionState);
130 if (exceptionState.hadException()) 130 if (exceptionState.hadException())
131 return 0; 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 0; 135 return nullptr;
136 } 136 }
137 137
138 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this), m_transaction.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(ScriptState* scriptState, 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 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 0; 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 0; 156 return nullptr;
157 } 157 }
158 WebIDBCursorDirection direction = IDBCursor::stringToDirection(directionStri ng, exceptionState); 158 WebIDBCursorDirection direction = IDBCursor::stringToDirection(directionStri ng, exceptionState);
159 if (exceptionState.hadException()) 159 if (exceptionState.hadException())
160 return 0; 160 return nullptr;
161 161
162 IDBKeyRange* keyRange = IDBKeyRange::fromScriptValue(scriptState->executionC ontext(), range, exceptionState); 162 IDBKeyRange* keyRange = IDBKeyRange::fromScriptValue(scriptState->executionC ontext(), range, exceptionState);
163 if (exceptionState.hadException()) 163 if (exceptionState.hadException())
164 return 0; 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 0; 167 return nullptr;
168 } 168 }
169 169
170 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this), m_transaction.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, WebIDBTaskTypeNormal, WebIDBCallbacksImpl::creat e(request).leakPtr()); 172 backendDB()->openCursor(m_transaction->id(), m_objectStore->id(), m_metadata .id, keyRange, direction, true, WebIDBTaskTypeNormal, WebIDBCallbacksImpl::creat e(request).leakPtr());
173 return request; 173 return request;
174 } 174 }
175 175
176 IDBRequest* IDBIndex::get(ScriptState* scriptState, const ScriptValue& key, Exce ptionState& exceptionState) 176 IDBRequest* IDBIndex::get(ScriptState* scriptState, const ScriptValue& key, Exce ptionState& exceptionState)
177 { 177 {
(...skipping 15 matching lines...) Expand all
193 IDBRequest* IDBIndex::getKey(ScriptState* scriptState, const ScriptValue& key, E xceptionState& exceptionState) 193 IDBRequest* IDBIndex::getKey(ScriptState* scriptState, const ScriptValue& key, E xceptionState& exceptionState)
194 { 194 {
195 IDB_TRACE("IDBIndex::getKey"); 195 IDB_TRACE("IDBIndex::getKey");
196 return getInternal(scriptState, key, exceptionState, true); 196 return getInternal(scriptState, key, exceptionState, true);
197 } 197 }
198 198
199 IDBRequest* IDBIndex::getInternal(ScriptState* scriptState, const ScriptValue& k ey, ExceptionState& exceptionState, bool keyOnly) 199 IDBRequest* IDBIndex::getInternal(ScriptState* scriptState, const ScriptValue& k ey, ExceptionState& exceptionState, bool keyOnly)
200 { 200 {
201 if (isDeleted()) { 201 if (isDeleted()) {
202 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::indexDe letedErrorMessage); 202 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::indexDe letedErrorMessage);
203 return 0; 203 return nullptr;
204 } 204 }
205 if (m_transaction->isFinished() || m_transaction->isFinishing()) { 205 if (m_transaction->isFinished() || m_transaction->isFinishing()) {
206 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionFinishedErrorMessage); 206 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionFinishedErrorMessage);
207 return 0; 207 return nullptr;
208 } 208 }
209 if (!m_transaction->isActive()) { 209 if (!m_transaction->isActive()) {
210 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionInactiveErrorMessage); 210 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionInactiveErrorMessage);
211 return 0; 211 return nullptr;
212 } 212 }
213 213
214 IDBKeyRange* keyRange = IDBKeyRange::fromScriptValue(scriptState->executionC ontext(), key, exceptionState); 214 IDBKeyRange* keyRange = IDBKeyRange::fromScriptValue(scriptState->executionC ontext(), key, exceptionState);
215 if (exceptionState.hadException()) 215 if (exceptionState.hadException())
216 return 0; 216 return nullptr;
217 if (!keyRange) { 217 if (!keyRange) {
218 exceptionState.throwDOMException(DataError, IDBDatabase::noKeyOrKeyRange ErrorMessage); 218 exceptionState.throwDOMException(DataError, IDBDatabase::noKeyOrKeyRange ErrorMessage);
219 return 0; 219 return nullptr;
220 } 220 }
221 if (!backendDB()) { 221 if (!backendDB()) {
222 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas eClosedErrorMessage); 222 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas eClosedErrorMessage);
223 return 0; 223 return nullptr;
224 } 224 }
225 225
226 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this), m_transaction.get()); 226 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this), m_transaction.get());
227 backendDB()->get(m_transaction->id(), m_objectStore->id(), m_metadata.id, ke yRange, keyOnly, WebIDBCallbacksImpl::create(request).leakPtr()); 227 backendDB()->get(m_transaction->id(), m_objectStore->id(), m_metadata.id, ke yRange, keyOnly, WebIDBCallbacksImpl::create(request).leakPtr());
228 return request; 228 return request;
229 } 229 }
230 230
231 IDBRequest* IDBIndex::getAllInternal(ScriptState* scriptState, const ScriptValue & range, unsigned long maxCount, ExceptionState& exceptionState, bool keyOnly) 231 IDBRequest* IDBIndex::getAllInternal(ScriptState* scriptState, const ScriptValue & range, unsigned long maxCount, ExceptionState& exceptionState, bool keyOnly)
232 { 232 {
233 if (!maxCount) { 233 if (!maxCount) {
234 exceptionState.throwTypeError(IDBDatabase::notValidMaxCountErrorMessage) ; 234 exceptionState.throwTypeError(IDBDatabase::notValidMaxCountErrorMessage) ;
235 return 0; 235 return nullptr;
236 } 236 }
237 if (isDeleted()) { 237 if (isDeleted()) {
238 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::indexDe letedErrorMessage); 238 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::indexDe letedErrorMessage);
239 return 0; 239 return nullptr;
240 } 240 }
241 if (m_transaction->isFinished() || m_transaction->isFinishing()) { 241 if (m_transaction->isFinished() || m_transaction->isFinishing()) {
242 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionFinishedErrorMessage); 242 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionFinishedErrorMessage);
243 return 0; 243 return nullptr;
244 } 244 }
245 if (!m_transaction->isActive()) { 245 if (!m_transaction->isActive()) {
246 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionInactiveErrorMessage); 246 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionInactiveErrorMessage);
247 return 0; 247 return nullptr;
248 } 248 }
249 249
250 IDBKeyRange* keyRange = IDBKeyRange::fromScriptValue(scriptState->executionC ontext(), range, exceptionState); 250 IDBKeyRange* keyRange = IDBKeyRange::fromScriptValue(scriptState->executionC ontext(), range, exceptionState);
251 if (exceptionState.hadException()) 251 if (exceptionState.hadException())
252 return 0; 252 return nullptr;
253 if (!backendDB()) { 253 if (!backendDB()) {
254 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas eClosedErrorMessage); 254 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas eClosedErrorMessage);
255 return 0; 255 return nullptr;
256 } 256 }
257 257
258 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this), m_transaction.get()); 258 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this), m_transaction.get());
259 backendDB()->getAll(m_transaction->id(), m_objectStore->id(), m_metadata.id, keyRange, maxCount, keyOnly, WebIDBCallbacksImpl::create(request).leakPtr()); 259 backendDB()->getAll(m_transaction->id(), m_objectStore->id(), m_metadata.id, keyRange, maxCount, keyOnly, WebIDBCallbacksImpl::create(request).leakPtr());
260 return request; 260 return request;
261 } 261 }
262 262
263 WebIDBDatabase* IDBIndex::backendDB() const 263 WebIDBDatabase* IDBIndex::backendDB() const
264 { 264 {
265 return m_transaction->backendDB(); 265 return m_transaction->backendDB();
266 } 266 }
267 267
268 bool IDBIndex::isDeleted() const 268 bool IDBIndex::isDeleted() const
269 { 269 {
270 return m_deleted || m_objectStore->isDeleted(); 270 return m_deleted || m_objectStore->isDeleted();
271 } 271 }
272 272
273 } // namespace blink 273 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/indexeddb/IDBFactory.cpp ('k') | Source/modules/indexeddb/IDBKeyRange.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698