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