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

Side by Side Diff: Source/modules/indexeddb/IDBCursor.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
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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 visitor->trace(m_key); 82 visitor->trace(m_key);
83 visitor->trace(m_primaryKey); 83 visitor->trace(m_primaryKey);
84 } 84 }
85 85
86 IDBRequest* IDBCursor::update(ScriptState* scriptState, const ScriptValue& value , ExceptionState& exceptionState) 86 IDBRequest* IDBCursor::update(ScriptState* scriptState, const ScriptValue& value , ExceptionState& exceptionState)
87 { 87 {
88 IDB_TRACE("IDBCursor::update"); 88 IDB_TRACE("IDBCursor::update");
89 89
90 if (!m_gotValue) { 90 if (!m_gotValue) {
91 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::noValue ErrorMessage); 91 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::noValue ErrorMessage);
92 return 0; 92 return nullptr;
93 } 93 }
94 if (isKeyCursor()) { 94 if (isKeyCursor()) {
95 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::isKeyCu rsorErrorMessage); 95 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::isKeyCu rsorErrorMessage);
96 return 0; 96 return nullptr;
97 } 97 }
98 if (isDeleted()) { 98 if (isDeleted()) {
99 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::sourceD eletedErrorMessage); 99 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::sourceD eletedErrorMessage);
100 return 0; 100 return nullptr;
101 } 101 }
102 if (m_transaction->isFinished() || m_transaction->isFinishing()) { 102 if (m_transaction->isFinished() || m_transaction->isFinishing()) {
103 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionFinishedErrorMessage); 103 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionFinishedErrorMessage);
104 return 0; 104 return nullptr;
105 } 105 }
106 if (!m_transaction->isActive()) { 106 if (!m_transaction->isActive()) {
107 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionInactiveErrorMessage); 107 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionInactiveErrorMessage);
108 return 0; 108 return nullptr;
109 } 109 }
110 if (m_transaction->isReadOnly()) { 110 if (m_transaction->isReadOnly()) {
111 exceptionState.throwDOMException(ReadOnlyError, "The record may not be u pdated inside a read-only transaction."); 111 exceptionState.throwDOMException(ReadOnlyError, "The record may not be u pdated inside a read-only transaction.");
112 return 0; 112 return nullptr;
113 } 113 }
114 114
115 IDBObjectStore* objectStore = effectiveObjectStore(); 115 IDBObjectStore* objectStore = effectiveObjectStore();
116 return objectStore->put(scriptState, WebIDBPutModeCursorUpdate, IDBAny::crea te(this), value, m_primaryKey, exceptionState); 116 return objectStore->put(scriptState, WebIDBPutModeCursorUpdate, IDBAny::crea te(this), value, m_primaryKey, exceptionState);
117 } 117 }
118 118
119 void IDBCursor::advance(unsigned count, ExceptionState& exceptionState) 119 void IDBCursor::advance(unsigned count, ExceptionState& exceptionState)
120 { 120 {
121 IDB_TRACE("IDBCursor::advance"); 121 IDB_TRACE("IDBCursor::advance");
122 if (!count) { 122 if (!count) {
(...skipping 26 matching lines...) Expand all
149 void IDBCursor::continueFunction(ScriptState* scriptState, const ScriptValue& ke yValue, ExceptionState& exceptionState) 149 void IDBCursor::continueFunction(ScriptState* scriptState, const ScriptValue& ke yValue, ExceptionState& exceptionState)
150 { 150 {
151 IDB_TRACE("IDBCursor::continue"); 151 IDB_TRACE("IDBCursor::continue");
152 IDBKey* key = keyValue.isUndefined() || keyValue.isNull() ? nullptr : Script Value::to<IDBKey*>(scriptState->isolate(), keyValue, exceptionState); 152 IDBKey* key = keyValue.isUndefined() || keyValue.isNull() ? nullptr : Script Value::to<IDBKey*>(scriptState->isolate(), keyValue, exceptionState);
153 if (exceptionState.hadException()) 153 if (exceptionState.hadException())
154 return; 154 return;
155 if (key && !key->isValid()) { 155 if (key && !key->isValid()) {
156 exceptionState.throwDOMException(DataError, IDBDatabase::notValidKeyErro rMessage); 156 exceptionState.throwDOMException(DataError, IDBDatabase::notValidKeyErro rMessage);
157 return; 157 return;
158 } 158 }
159 continueFunction(key, 0, exceptionState); 159 continueFunction(key, nullptr, exceptionState);
160 } 160 }
161 161
162 void IDBCursor::continuePrimaryKey(ScriptState* scriptState, const ScriptValue& keyValue, const ScriptValue& primaryKeyValue, ExceptionState& exceptionState) 162 void IDBCursor::continuePrimaryKey(ScriptState* scriptState, const ScriptValue& keyValue, const ScriptValue& primaryKeyValue, ExceptionState& exceptionState)
163 { 163 {
164 IDB_TRACE("IDBCursor::continuePrimaryKey"); 164 IDB_TRACE("IDBCursor::continuePrimaryKey");
165 if (m_source->type() != IDBAny::IDBIndexType) { 165 if (m_source->type() != IDBAny::IDBIndexType) {
166 exceptionState.throwDOMException(InvalidAccessError, "The cursor's sourc e is not an index."); 166 exceptionState.throwDOMException(InvalidAccessError, "The cursor's sourc e is not an index.");
167 return; 167 return;
168 } 168 }
169 169
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 m_request->setPendingCursor(this); 234 m_request->setPendingCursor(this);
235 m_gotValue = false; 235 m_gotValue = false;
236 m_backend->continueFunction(key, primaryKey, WebIDBCallbacksImpl::create(m_r equest).leakPtr()); 236 m_backend->continueFunction(key, primaryKey, WebIDBCallbacksImpl::create(m_r equest).leakPtr());
237 } 237 }
238 238
239 IDBRequest* IDBCursor::deleteFunction(ScriptState* scriptState, ExceptionState& exceptionState) 239 IDBRequest* IDBCursor::deleteFunction(ScriptState* scriptState, ExceptionState& exceptionState)
240 { 240 {
241 IDB_TRACE("IDBCursor::delete"); 241 IDB_TRACE("IDBCursor::delete");
242 if (m_transaction->isFinished() || m_transaction->isFinishing()) { 242 if (m_transaction->isFinished() || m_transaction->isFinishing()) {
243 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionFinishedErrorMessage); 243 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionFinishedErrorMessage);
244 return 0; 244 return nullptr;
245 } 245 }
246 if (!m_transaction->isActive()) { 246 if (!m_transaction->isActive()) {
247 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionInactiveErrorMessage); 247 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionInactiveErrorMessage);
248 return 0; 248 return nullptr;
249 } 249 }
250 if (m_transaction->isReadOnly()) { 250 if (m_transaction->isReadOnly()) {
251 exceptionState.throwDOMException(ReadOnlyError, "The record may not be d eleted inside a read-only transaction."); 251 exceptionState.throwDOMException(ReadOnlyError, "The record may not be d eleted inside a read-only transaction.");
252 return 0; 252 return nullptr;
253 } 253 }
254 254
255 if (!m_gotValue) { 255 if (!m_gotValue) {
256 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::noValue ErrorMessage); 256 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::noValue ErrorMessage);
257 return 0; 257 return nullptr;
258 } 258 }
259 if (isKeyCursor()) { 259 if (isKeyCursor()) {
260 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::isKeyCu rsorErrorMessage); 260 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::isKeyCu rsorErrorMessage);
261 return 0; 261 return nullptr;
262 } 262 }
263 if (isDeleted()) { 263 if (isDeleted()) {
264 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::sourceD eletedErrorMessage); 264 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::sourceD eletedErrorMessage);
265 return 0; 265 return nullptr;
266 } 266 }
267 if (!m_transaction->backendDB()) { 267 if (!m_transaction->backendDB()) {
268 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas eClosedErrorMessage); 268 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas eClosedErrorMessage);
269 return 0; 269 return nullptr;
270 } 270 }
271 271
272 IDBKeyRange* keyRange = IDBKeyRange::only(m_primaryKey, exceptionState); 272 IDBKeyRange* keyRange = IDBKeyRange::only(m_primaryKey, exceptionState);
273 ASSERT(!exceptionState.hadException()); 273 ASSERT(!exceptionState.hadException());
274 274
275 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this), m_transaction.get()); 275 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this), m_transaction.get());
276 m_transaction->backendDB()->deleteRange(m_transaction->id(), effectiveObject Store()->id(), keyRange, WebIDBCallbacksImpl::create(request).leakPtr()); 276 m_transaction->backendDB()->deleteRange(m_transaction->id(), effectiveObject Store()->id(), keyRange, WebIDBCallbacksImpl::create(request).leakPtr());
277 return request; 277 return request;
278 } 278 }
279 279
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 case WebIDBCursorDirectionPrevNoDuplicate: 389 case WebIDBCursorDirectionPrevNoDuplicate:
390 return IndexedDBNames::prevunique; 390 return IndexedDBNames::prevunique;
391 391
392 default: 392 default:
393 ASSERT_NOT_REACHED(); 393 ASSERT_NOT_REACHED();
394 return IndexedDBNames::next; 394 return IndexedDBNames::next;
395 } 395 }
396 } 396 }
397 397
398 } // namespace blink 398 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/indexeddb/DOMWindowIndexedDatabase.cpp ('k') | Source/modules/indexeddb/IDBDatabase.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698