| OLD | NEW |
| 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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 } | 180 } |
| 181 if (m_versionChangeTransaction->isFinished() || m_versionChangeTransaction->
isFinishing()) { | 181 if (m_versionChangeTransaction->isFinished() || m_versionChangeTransaction->
isFinishing()) { |
| 182 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionFinishedErrorMessage); | 182 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionFinishedErrorMessage); |
| 183 return nullptr; | 183 return nullptr; |
| 184 } | 184 } |
| 185 if (!m_versionChangeTransaction->isActive()) { | 185 if (!m_versionChangeTransaction->isActive()) { |
| 186 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionInactiveErrorMessage); | 186 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionInactiveErrorMessage); |
| 187 return nullptr; | 187 return nullptr; |
| 188 } | 188 } |
| 189 | 189 |
| 190 if (!keyPath.isNull() && !keyPath.isValid()) { |
| 191 exceptionState.throwDOMException(SyntaxError, "The keyPath option is not
a valid key path."); |
| 192 return nullptr; |
| 193 } |
| 194 |
| 190 if (containsObjectStore(name)) { | 195 if (containsObjectStore(name)) { |
| 191 exceptionState.throwDOMException(ConstraintError, "An object store with
the specified name already exists."); | 196 exceptionState.throwDOMException(ConstraintError, "An object store with
the specified name already exists."); |
| 192 return nullptr; | 197 return nullptr; |
| 193 } | 198 } |
| 194 | 199 |
| 195 if (!keyPath.isNull() && !keyPath.isValid()) { | |
| 196 exceptionState.throwDOMException(SyntaxError, "The keyPath option is not
a valid key path."); | |
| 197 return nullptr; | |
| 198 } | |
| 199 | |
| 200 if (autoIncrement && ((keyPath.getType() == IDBKeyPath::StringType && keyPat
h.string().isEmpty()) || keyPath.getType() == IDBKeyPath::ArrayType)) { | 200 if (autoIncrement && ((keyPath.getType() == IDBKeyPath::StringType && keyPat
h.string().isEmpty()) || keyPath.getType() == IDBKeyPath::ArrayType)) { |
| 201 exceptionState.throwDOMException(InvalidAccessError, "The autoIncrement
option was set but the keyPath option was empty or an array."); | 201 exceptionState.throwDOMException(InvalidAccessError, "The autoIncrement
option was set but the keyPath option was empty or an array."); |
| 202 return nullptr; | 202 return nullptr; |
| 203 } | 203 } |
| 204 | 204 |
| 205 if (!m_backend) { | 205 if (!m_backend) { |
| 206 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas
eClosedErrorMessage); | 206 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas
eClosedErrorMessage); |
| 207 return nullptr; | 207 return nullptr; |
| 208 } | 208 } |
| 209 | 209 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 for (const String& name : storeNames.getAsStringSequence()) | 264 for (const String& name : storeNames.getAsStringSequence()) |
| 265 scope.add(name); | 265 scope.add(name); |
| 266 } else if (storeNames.isDOMStringList()) { | 266 } else if (storeNames.isDOMStringList()) { |
| 267 const Vector<String>& list = *storeNames.getAsDOMStringList(); | 267 const Vector<String>& list = *storeNames.getAsDOMStringList(); |
| 268 for (const String& name : list) | 268 for (const String& name : list) |
| 269 scope.add(name); | 269 scope.add(name); |
| 270 } else { | 270 } else { |
| 271 ASSERT_NOT_REACHED(); | 271 ASSERT_NOT_REACHED(); |
| 272 } | 272 } |
| 273 | 273 |
| 274 if (scope.isEmpty()) { | |
| 275 exceptionState.throwDOMException(InvalidAccessError, "The storeNames par
ameter was empty."); | |
| 276 return nullptr; | |
| 277 } | |
| 278 | |
| 279 WebIDBTransactionMode mode = IDBTransaction::stringToMode(modeString); | |
| 280 if (mode != WebIDBTransactionModeReadOnly && mode != WebIDBTransactionModeRe
adWrite) { | |
| 281 exceptionState.throwTypeError("The mode provided ('" + modeString + "')
is not one of 'readonly' or 'readwrite'."); | |
| 282 return nullptr; | |
| 283 } | |
| 284 | |
| 285 if (exceptionState.hadException()) | |
| 286 return nullptr; | |
| 287 | |
| 288 if (m_versionChangeTransaction) { | 274 if (m_versionChangeTransaction) { |
| 289 exceptionState.throwDOMException(InvalidStateError, "A version change tr
ansaction is running."); | 275 exceptionState.throwDOMException(InvalidStateError, "A version change tr
ansaction is running."); |
| 290 return nullptr; | 276 return nullptr; |
| 291 } | 277 } |
| 292 | 278 |
| 293 if (m_closePending) { | 279 if (m_closePending) { |
| 294 exceptionState.throwDOMException(InvalidStateError, "The database connec
tion is closing."); | 280 exceptionState.throwDOMException(InvalidStateError, "The database connec
tion is closing."); |
| 295 return nullptr; | 281 return nullptr; |
| 296 } | 282 } |
| 297 | 283 |
| 284 if (!m_backend) { |
| 285 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas
eClosedErrorMessage); |
| 286 return nullptr; |
| 287 } |
| 288 |
| 289 |
| 290 if (scope.isEmpty()) { |
| 291 exceptionState.throwDOMException(InvalidAccessError, "The storeNames par
ameter was empty."); |
| 292 return nullptr; |
| 293 } |
| 294 |
| 298 Vector<int64_t> objectStoreIds; | 295 Vector<int64_t> objectStoreIds; |
| 299 for (const String& name : scope) { | 296 for (const String& name : scope) { |
| 300 int64_t objectStoreId = findObjectStoreId(name); | 297 int64_t objectStoreId = findObjectStoreId(name); |
| 301 if (objectStoreId == IDBObjectStoreMetadata::InvalidId) { | 298 if (objectStoreId == IDBObjectStoreMetadata::InvalidId) { |
| 302 exceptionState.throwDOMException(NotFoundError, "One of the specifie
d object stores was not found."); | 299 exceptionState.throwDOMException(NotFoundError, "One of the specifie
d object stores was not found."); |
| 303 return nullptr; | 300 return nullptr; |
| 304 } | 301 } |
| 305 objectStoreIds.append(objectStoreId); | 302 objectStoreIds.append(objectStoreId); |
| 306 } | 303 } |
| 307 | 304 |
| 308 if (!m_backend) { | 305 WebIDBTransactionMode mode = IDBTransaction::stringToMode(modeString); |
| 309 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas
eClosedErrorMessage); | 306 if (mode != WebIDBTransactionModeReadOnly && mode != WebIDBTransactionModeRe
adWrite) { |
| 307 exceptionState.throwTypeError("The mode provided ('" + modeString + "')
is not one of 'readonly' or 'readwrite'."); |
| 310 return nullptr; | 308 return nullptr; |
| 311 } | 309 } |
| 312 | 310 |
| 313 int64_t transactionId = nextTransactionId(); | 311 int64_t transactionId = nextTransactionId(); |
| 314 m_backend->createTransaction(transactionId, WebIDBDatabaseCallbacksImpl::cre
ate(m_databaseCallbacks).leakPtr(), objectStoreIds, mode); | 312 m_backend->createTransaction(transactionId, WebIDBDatabaseCallbacksImpl::cre
ate(m_databaseCallbacks).leakPtr(), objectStoreIds, mode); |
| 315 | 313 |
| 316 return IDBTransaction::create(scriptState, transactionId, scope, mode, this)
; | 314 return IDBTransaction::create(scriptState, transactionId, scope, mode, this)
; |
| 317 } | 315 } |
| 318 | 316 |
| 319 void IDBDatabase::forceClose() | 317 void IDBDatabase::forceClose() |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 return ActiveDOMObject::getExecutionContext(); | 444 return ActiveDOMObject::getExecutionContext(); |
| 447 } | 445 } |
| 448 | 446 |
| 449 void IDBDatabase::recordApiCallsHistogram(IndexedDatabaseMethods method) | 447 void IDBDatabase::recordApiCallsHistogram(IndexedDatabaseMethods method) |
| 450 { | 448 { |
| 451 DEFINE_THREAD_SAFE_STATIC_LOCAL(EnumerationHistogram, apiCallsHistogram, new
EnumerationHistogram("WebCore.IndexedDB.FrontEndAPICalls", IDBMethodsMax)); | 449 DEFINE_THREAD_SAFE_STATIC_LOCAL(EnumerationHistogram, apiCallsHistogram, new
EnumerationHistogram("WebCore.IndexedDB.FrontEndAPICalls", IDBMethodsMax)); |
| 452 apiCallsHistogram.count(method); | 450 apiCallsHistogram.count(method); |
| 453 } | 451 } |
| 454 | 452 |
| 455 } // namespace blink | 453 } // namespace blink |
| OLD | NEW |