| 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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 else | 182 else |
| 183 result.setUnsignedLongLong(m_metadata.intVersion); | 183 result.setUnsignedLongLong(m_metadata.intVersion); |
| 184 } | 184 } |
| 185 | 185 |
| 186 IDBObjectStore* IDBDatabase::createObjectStore(const String& name, const IDBKeyP
ath& keyPath, bool autoIncrement, ExceptionState& exceptionState) | 186 IDBObjectStore* IDBDatabase::createObjectStore(const String& name, const IDBKeyP
ath& keyPath, bool autoIncrement, ExceptionState& exceptionState) |
| 187 { | 187 { |
| 188 IDB_TRACE("IDBDatabase::createObjectStore"); | 188 IDB_TRACE("IDBDatabase::createObjectStore"); |
| 189 Platform::current()->histogramEnumeration("WebCore.IndexedDB.FrontEndAPICall
s", IDBCreateObjectStoreCall, IDBMethodsMax); | 189 Platform::current()->histogramEnumeration("WebCore.IndexedDB.FrontEndAPICall
s", IDBCreateObjectStoreCall, IDBMethodsMax); |
| 190 if (!m_versionChangeTransaction) { | 190 if (!m_versionChangeTransaction) { |
| 191 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::notVers
ionChangeTransactionErrorMessage); | 191 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::notVers
ionChangeTransactionErrorMessage); |
| 192 return 0; | 192 return nullptr; |
| 193 } | 193 } |
| 194 if (m_versionChangeTransaction->isFinished() || m_versionChangeTransaction->
isFinishing()) { | 194 if (m_versionChangeTransaction->isFinished() || m_versionChangeTransaction->
isFinishing()) { |
| 195 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionFinishedErrorMessage); | 195 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionFinishedErrorMessage); |
| 196 return 0; | 196 return nullptr; |
| 197 } | 197 } |
| 198 if (!m_versionChangeTransaction->isActive()) { | 198 if (!m_versionChangeTransaction->isActive()) { |
| 199 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionInactiveErrorMessage); | 199 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionInactiveErrorMessage); |
| 200 return 0; | 200 return nullptr; |
| 201 } | 201 } |
| 202 | 202 |
| 203 if (containsObjectStore(name)) { | 203 if (containsObjectStore(name)) { |
| 204 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."); |
| 205 return 0; | 205 return nullptr; |
| 206 } | 206 } |
| 207 | 207 |
| 208 if (!keyPath.isNull() && !keyPath.isValid()) { | 208 if (!keyPath.isNull() && !keyPath.isValid()) { |
| 209 exceptionState.throwDOMException(SyntaxError, "The keyPath option is not
a valid key path."); | 209 exceptionState.throwDOMException(SyntaxError, "The keyPath option is not
a valid key path."); |
| 210 return 0; | 210 return nullptr; |
| 211 } | 211 } |
| 212 | 212 |
| 213 if (autoIncrement && ((keyPath.type() == IDBKeyPath::StringType && keyPath.s
tring().isEmpty()) || keyPath.type() == IDBKeyPath::ArrayType)) { | 213 if (autoIncrement && ((keyPath.type() == IDBKeyPath::StringType && keyPath.s
tring().isEmpty()) || keyPath.type() == IDBKeyPath::ArrayType)) { |
| 214 exceptionState.throwDOMException(InvalidAccessError, "The autoIncrement
option was set but the keyPath option was empty or an array."); | 214 exceptionState.throwDOMException(InvalidAccessError, "The autoIncrement
option was set but the keyPath option was empty or an array."); |
| 215 return 0; | 215 return nullptr; |
| 216 } | 216 } |
| 217 | 217 |
| 218 if (!m_backend) { | 218 if (!m_backend) { |
| 219 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas
eClosedErrorMessage); | 219 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas
eClosedErrorMessage); |
| 220 return 0; | 220 return nullptr; |
| 221 } | 221 } |
| 222 | 222 |
| 223 int64_t objectStoreId = m_metadata.maxObjectStoreId + 1; | 223 int64_t objectStoreId = m_metadata.maxObjectStoreId + 1; |
| 224 m_backend->createObjectStore(m_versionChangeTransaction->id(), objectStoreId
, name, keyPath, autoIncrement); | 224 m_backend->createObjectStore(m_versionChangeTransaction->id(), objectStoreId
, name, keyPath, autoIncrement); |
| 225 | 225 |
| 226 IDBObjectStoreMetadata metadata(name, objectStoreId, keyPath, autoIncrement,
WebIDBDatabase::minimumIndexId); | 226 IDBObjectStoreMetadata metadata(name, objectStoreId, keyPath, autoIncrement,
WebIDBDatabase::minimumIndexId); |
| 227 IDBObjectStore* objectStore = IDBObjectStore::create(metadata, m_versionChan
geTransaction.get()); | 227 IDBObjectStore* objectStore = IDBObjectStore::create(metadata, m_versionChan
geTransaction.get()); |
| 228 m_metadata.objectStores.set(metadata.id, metadata); | 228 m_metadata.objectStores.set(metadata.id, metadata); |
| 229 ++m_metadata.maxObjectStoreId; | 229 ++m_metadata.maxObjectStoreId; |
| 230 | 230 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 } else if (storeNames.isDOMStringList()) { | 279 } else if (storeNames.isDOMStringList()) { |
| 280 const Vector<String>& list = *storeNames.getAsDOMStringList(); | 280 const Vector<String>& list = *storeNames.getAsDOMStringList(); |
| 281 for (const String& name : list) | 281 for (const String& name : list) |
| 282 scope.add(name); | 282 scope.add(name); |
| 283 } else { | 283 } else { |
| 284 ASSERT_NOT_REACHED(); | 284 ASSERT_NOT_REACHED(); |
| 285 } | 285 } |
| 286 | 286 |
| 287 if (scope.isEmpty()) { | 287 if (scope.isEmpty()) { |
| 288 exceptionState.throwDOMException(InvalidAccessError, "The storeNames par
ameter was empty."); | 288 exceptionState.throwDOMException(InvalidAccessError, "The storeNames par
ameter was empty."); |
| 289 return 0; | 289 return nullptr; |
| 290 } | 290 } |
| 291 | 291 |
| 292 WebIDBTransactionMode mode = IDBTransaction::stringToMode(modeString, except
ionState); | 292 WebIDBTransactionMode mode = IDBTransaction::stringToMode(modeString, except
ionState); |
| 293 if (exceptionState.hadException()) | 293 if (exceptionState.hadException()) |
| 294 return 0; | 294 return nullptr; |
| 295 | 295 |
| 296 if (m_versionChangeTransaction) { | 296 if (m_versionChangeTransaction) { |
| 297 exceptionState.throwDOMException(InvalidStateError, "A version change tr
ansaction is running."); | 297 exceptionState.throwDOMException(InvalidStateError, "A version change tr
ansaction is running."); |
| 298 return 0; | 298 return nullptr; |
| 299 } | 299 } |
| 300 | 300 |
| 301 if (m_closePending) { | 301 if (m_closePending) { |
| 302 exceptionState.throwDOMException(InvalidStateError, "The database connec
tion is closing."); | 302 exceptionState.throwDOMException(InvalidStateError, "The database connec
tion is closing."); |
| 303 return 0; | 303 return nullptr; |
| 304 } | 304 } |
| 305 | 305 |
| 306 Vector<int64_t> objectStoreIds; | 306 Vector<int64_t> objectStoreIds; |
| 307 for (const String& name : scope) { | 307 for (const String& name : scope) { |
| 308 int64_t objectStoreId = findObjectStoreId(name); | 308 int64_t objectStoreId = findObjectStoreId(name); |
| 309 if (objectStoreId == IDBObjectStoreMetadata::InvalidId) { | 309 if (objectStoreId == IDBObjectStoreMetadata::InvalidId) { |
| 310 exceptionState.throwDOMException(NotFoundError, "One of the specifie
d object stores was not found."); | 310 exceptionState.throwDOMException(NotFoundError, "One of the specifie
d object stores was not found."); |
| 311 return 0; | 311 return nullptr; |
| 312 } | 312 } |
| 313 objectStoreIds.append(objectStoreId); | 313 objectStoreIds.append(objectStoreId); |
| 314 } | 314 } |
| 315 | 315 |
| 316 if (!m_backend) { | 316 if (!m_backend) { |
| 317 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas
eClosedErrorMessage); | 317 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas
eClosedErrorMessage); |
| 318 return 0; | 318 return nullptr; |
| 319 } | 319 } |
| 320 | 320 |
| 321 int64_t transactionId = nextTransactionId(); | 321 int64_t transactionId = nextTransactionId(); |
| 322 m_backend->createTransaction(transactionId, WebIDBDatabaseCallbacksImpl::cre
ate(m_databaseCallbacks).leakPtr(), objectStoreIds, mode); | 322 m_backend->createTransaction(transactionId, WebIDBDatabaseCallbacksImpl::cre
ate(m_databaseCallbacks).leakPtr(), objectStoreIds, mode); |
| 323 | 323 |
| 324 return IDBTransaction::create(scriptState, transactionId, scope, mode, this)
; | 324 return IDBTransaction::create(scriptState, transactionId, scope, mode, this)
; |
| 325 } | 325 } |
| 326 | 326 |
| 327 void IDBDatabase::forceClose() | 327 void IDBDatabase::forceClose() |
| 328 { | 328 { |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 { | 448 { |
| 449 return EventTargetNames::IDBDatabase; | 449 return EventTargetNames::IDBDatabase; |
| 450 } | 450 } |
| 451 | 451 |
| 452 ExecutionContext* IDBDatabase::executionContext() const | 452 ExecutionContext* IDBDatabase::executionContext() const |
| 453 { | 453 { |
| 454 return ActiveDOMObject::executionContext(); | 454 return ActiveDOMObject::executionContext(); |
| 455 } | 455 } |
| 456 | 456 |
| 457 } // namespace blink | 457 } // namespace blink |
| OLD | NEW |