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

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

Issue 18548003: Rename ExceptionCode constants to use the names in the spec (2/3) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 5 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.cpp ('k') | Source/modules/indexeddb/IDBFactory.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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 } 167 }
168 168
169 return createObjectStore(name, keyPath, autoIncrement, ec); 169 return createObjectStore(name, keyPath, autoIncrement, ec);
170 } 170 }
171 171
172 PassRefPtr<IDBObjectStore> IDBDatabase::createObjectStore(const String& name, co nst IDBKeyPath& keyPath, bool autoIncrement, ExceptionCode& ec) 172 PassRefPtr<IDBObjectStore> IDBDatabase::createObjectStore(const String& name, co nst IDBKeyPath& keyPath, bool autoIncrement, ExceptionCode& ec)
173 { 173 {
174 IDB_TRACE("IDBDatabase::createObjectStore"); 174 IDB_TRACE("IDBDatabase::createObjectStore");
175 HistogramSupport::histogramEnumeration("WebCore.IndexedDB.FrontEndAPICalls", IDBCreateObjectStoreCall, IDBMethodsMax); 175 HistogramSupport::histogramEnumeration("WebCore.IndexedDB.FrontEndAPICalls", IDBCreateObjectStoreCall, IDBMethodsMax);
176 if (!m_versionChangeTransaction) { 176 if (!m_versionChangeTransaction) {
177 ec = INVALID_STATE_ERR; 177 ec = InvalidStateError;
178 return 0; 178 return 0;
179 } 179 }
180 if (!m_versionChangeTransaction->isActive()) { 180 if (!m_versionChangeTransaction->isActive()) {
181 ec = TransactionInactiveError; 181 ec = TransactionInactiveError;
182 return 0; 182 return 0;
183 } 183 }
184 184
185 if (containsObjectStore(name)) { 185 if (containsObjectStore(name)) {
186 ec = ConstraintError; 186 ec = ConstraintError;
187 return 0; 187 return 0;
188 } 188 }
189 189
190 if (!keyPath.isNull() && !keyPath.isValid()) { 190 if (!keyPath.isNull() && !keyPath.isValid()) {
191 ec = SYNTAX_ERR; 191 ec = SyntaxError;
192 return 0; 192 return 0;
193 } 193 }
194 194
195 if (autoIncrement && ((keyPath.type() == IDBKeyPath::StringType && keyPath.s tring().isEmpty()) || keyPath.type() == IDBKeyPath::ArrayType)) { 195 if (autoIncrement && ((keyPath.type() == IDBKeyPath::StringType && keyPath.s tring().isEmpty()) || keyPath.type() == IDBKeyPath::ArrayType)) {
196 ec = INVALID_ACCESS_ERR; 196 ec = InvalidAccessError;
197 return 0; 197 return 0;
198 } 198 }
199 199
200 int64_t objectStoreId = m_metadata.maxObjectStoreId + 1; 200 int64_t objectStoreId = m_metadata.maxObjectStoreId + 1;
201 m_backend->createObjectStore(m_versionChangeTransaction->id(), objectStoreId , name, keyPath, autoIncrement); 201 m_backend->createObjectStore(m_versionChangeTransaction->id(), objectStoreId , name, keyPath, autoIncrement);
202 202
203 IDBObjectStoreMetadata metadata(name, objectStoreId, keyPath, autoIncrement, IDBDatabaseBackendInterface::MinimumIndexId); 203 IDBObjectStoreMetadata metadata(name, objectStoreId, keyPath, autoIncrement, IDBDatabaseBackendInterface::MinimumIndexId);
204 RefPtr<IDBObjectStore> objectStore = IDBObjectStore::create(metadata, m_vers ionChangeTransaction.get()); 204 RefPtr<IDBObjectStore> objectStore = IDBObjectStore::create(metadata, m_vers ionChangeTransaction.get());
205 m_metadata.objectStores.set(metadata.id, metadata); 205 m_metadata.objectStores.set(metadata.id, metadata);
206 ++m_metadata.maxObjectStoreId; 206 ++m_metadata.maxObjectStoreId;
207 207
208 m_versionChangeTransaction->objectStoreCreated(name, objectStore); 208 m_versionChangeTransaction->objectStoreCreated(name, objectStore);
209 return objectStore.release(); 209 return objectStore.release();
210 } 210 }
211 211
212 void IDBDatabase::deleteObjectStore(const String& name, ExceptionCode& ec) 212 void IDBDatabase::deleteObjectStore(const String& name, ExceptionCode& ec)
213 { 213 {
214 IDB_TRACE("IDBDatabase::deleteObjectStore"); 214 IDB_TRACE("IDBDatabase::deleteObjectStore");
215 HistogramSupport::histogramEnumeration("WebCore.IndexedDB.FrontEndAPICalls", IDBDeleteObjectStoreCall, IDBMethodsMax); 215 HistogramSupport::histogramEnumeration("WebCore.IndexedDB.FrontEndAPICalls", IDBDeleteObjectStoreCall, IDBMethodsMax);
216 if (!m_versionChangeTransaction) { 216 if (!m_versionChangeTransaction) {
217 ec = INVALID_STATE_ERR; 217 ec = InvalidStateError;
218 return; 218 return;
219 } 219 }
220 if (!m_versionChangeTransaction->isActive()) { 220 if (!m_versionChangeTransaction->isActive()) {
221 ec = TransactionInactiveError; 221 ec = TransactionInactiveError;
222 return; 222 return;
223 } 223 }
224 224
225 int64_t objectStoreId = findObjectStoreId(name); 225 int64_t objectStoreId = findObjectStoreId(name);
226 if (objectStoreId == IDBObjectStoreMetadata::InvalidId) { 226 if (objectStoreId == IDBObjectStoreMetadata::InvalidId) {
227 // FIXME: Should use (NotFoundError, "..."). 227 // FIXME: Should use (NotFoundError, "...").
228 ec = IDBNotFoundError; 228 ec = IDBNotFoundError;
229 return; 229 return;
230 } 230 }
231 231
232 m_backend->deleteObjectStore(m_versionChangeTransaction->id(), objectStoreId ); 232 m_backend->deleteObjectStore(m_versionChangeTransaction->id(), objectStoreId );
233 m_versionChangeTransaction->objectStoreDeleted(name); 233 m_versionChangeTransaction->objectStoreDeleted(name);
234 m_metadata.objectStores.remove(objectStoreId); 234 m_metadata.objectStores.remove(objectStoreId);
235 } 235 }
236 236
237 PassRefPtr<IDBTransaction> IDBDatabase::transaction(ScriptExecutionContext* cont ext, const Vector<String>& scope, const String& modeString, ExceptionCode& ec) 237 PassRefPtr<IDBTransaction> IDBDatabase::transaction(ScriptExecutionContext* cont ext, const Vector<String>& scope, const String& modeString, ExceptionCode& ec)
238 { 238 {
239 IDB_TRACE("IDBDatabase::transaction"); 239 IDB_TRACE("IDBDatabase::transaction");
240 HistogramSupport::histogramEnumeration("WebCore.IndexedDB.FrontEndAPICalls", IDBTransactionCall, IDBMethodsMax); 240 HistogramSupport::histogramEnumeration("WebCore.IndexedDB.FrontEndAPICalls", IDBTransactionCall, IDBMethodsMax);
241 if (!scope.size()) { 241 if (!scope.size()) {
242 ec = INVALID_ACCESS_ERR; 242 ec = InvalidAccessError;
243 return 0; 243 return 0;
244 } 244 }
245 245
246 IndexedDB::TransactionMode mode = IDBTransaction::stringToMode(modeString, e c); 246 IndexedDB::TransactionMode mode = IDBTransaction::stringToMode(modeString, e c);
247 if (ec) 247 if (ec)
248 return 0; 248 return 0;
249 249
250 if (m_versionChangeTransaction || m_closePending) { 250 if (m_versionChangeTransaction || m_closePending) {
251 ec = INVALID_STATE_ERR; 251 ec = InvalidStateError;
252 return 0; 252 return 0;
253 } 253 }
254 254
255 Vector<int64_t> objectStoreIds; 255 Vector<int64_t> objectStoreIds;
256 for (size_t i = 0; i < scope.size(); ++i) { 256 for (size_t i = 0; i < scope.size(); ++i) {
257 int64_t objectStoreId = findObjectStoreId(scope[i]); 257 int64_t objectStoreId = findObjectStoreId(scope[i]);
258 if (objectStoreId == IDBObjectStoreMetadata::InvalidId) { 258 if (objectStoreId == IDBObjectStoreMetadata::InvalidId) {
259 // FIXME: Should use (NotFoundError, "..."). 259 // FIXME: Should use (NotFoundError, "...").
260 ec = IDBNotFoundError; 260 ec = IDBNotFoundError;
261 return 0; 261 return 0;
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 { 391 {
392 return &m_eventTargetData; 392 return &m_eventTargetData;
393 } 393 }
394 394
395 EventTargetData* IDBDatabase::ensureEventTargetData() 395 EventTargetData* IDBDatabase::ensureEventTargetData()
396 { 396 {
397 return &m_eventTargetData; 397 return &m_eventTargetData;
398 } 398 }
399 399
400 } // namespace WebCore 400 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/modules/indexeddb/IDBCursor.cpp ('k') | Source/modules/indexeddb/IDBFactory.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698