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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 | 125 |
126 void IDBDatabase::transactionFinished(const IDBTransaction* transaction) | 126 void IDBDatabase::transactionFinished(const IDBTransaction* transaction) |
127 { | 127 { |
128 ASSERT(transaction); | 128 ASSERT(transaction); |
129 ASSERT(m_transactions.contains(transaction->id())); | 129 ASSERT(m_transactions.contains(transaction->id())); |
130 ASSERT(m_transactions.get(transaction->id()) == transaction); | 130 ASSERT(m_transactions.get(transaction->id()) == transaction); |
131 m_transactions.remove(transaction->id()); | 131 m_transactions.remove(transaction->id()); |
132 | 132 |
133 if (transaction->isVersionChange()) { | 133 if (transaction->isVersionChange()) { |
134 ASSERT(m_versionChangeTransaction == transaction); | 134 ASSERT(m_versionChangeTransaction == transaction); |
135 m_versionChangeTransaction = 0; | 135 m_versionChangeTransaction = nullptr; |
136 } | 136 } |
137 | 137 |
138 if (m_closePending && m_transactions.isEmpty()) | 138 if (m_closePending && m_transactions.isEmpty()) |
139 closeConnection(); | 139 closeConnection(); |
140 } | 140 } |
141 | 141 |
142 void IDBDatabase::onAbort(int64_t transactionId, PassRefPtr<DOMError> error) | 142 void IDBDatabase::onAbort(int64_t transactionId, PassRefPtr<DOMError> error) |
143 { | 143 { |
144 ASSERT(m_transactions.contains(transactionId)); | 144 ASSERT(m_transactions.contains(transactionId)); |
145 m_transactions.get(transactionId)->onAbort(error); | 145 m_transactions.get(transactionId)->onAbort(error); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 | 187 |
188 return createObjectStore(name, keyPath, autoIncrement, exceptionState); | 188 return createObjectStore(name, keyPath, autoIncrement, exceptionState); |
189 } | 189 } |
190 | 190 |
191 PassRefPtr<IDBObjectStore> IDBDatabase::createObjectStore(const String& name, co
nst IDBKeyPath& keyPath, bool autoIncrement, ExceptionState& exceptionState) | 191 PassRefPtr<IDBObjectStore> IDBDatabase::createObjectStore(const String& name, co
nst IDBKeyPath& keyPath, bool autoIncrement, ExceptionState& exceptionState) |
192 { | 192 { |
193 IDB_TRACE("IDBDatabase::createObjectStore"); | 193 IDB_TRACE("IDBDatabase::createObjectStore"); |
194 blink::Platform::current()->histogramEnumeration("WebCore.IndexedDB.FrontEnd
APICalls", IDBCreateObjectStoreCall, IDBMethodsMax); | 194 blink::Platform::current()->histogramEnumeration("WebCore.IndexedDB.FrontEnd
APICalls", IDBCreateObjectStoreCall, IDBMethodsMax); |
195 if (!m_versionChangeTransaction) { | 195 if (!m_versionChangeTransaction) { |
196 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::notVers
ionChangeTransactionErrorMessage); | 196 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::notVers
ionChangeTransactionErrorMessage); |
197 return 0; | 197 return nullptr; |
198 } | 198 } |
199 if (m_versionChangeTransaction->isFinished()) { | 199 if (m_versionChangeTransaction->isFinished()) { |
200 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionFinishedErrorMessage); | 200 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionFinishedErrorMessage); |
201 return 0; | 201 return nullptr; |
202 } | 202 } |
203 if (!m_versionChangeTransaction->isActive()) { | 203 if (!m_versionChangeTransaction->isActive()) { |
204 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionInactiveErrorMessage); | 204 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionInactiveErrorMessage); |
205 return 0; | 205 return nullptr; |
206 } | 206 } |
207 | 207 |
208 if (containsObjectStore(name)) { | 208 if (containsObjectStore(name)) { |
209 exceptionState.throwDOMException(ConstraintError, "An object store with
the specified name already exists."); | 209 exceptionState.throwDOMException(ConstraintError, "An object store with
the specified name already exists."); |
210 return 0; | 210 return nullptr; |
211 } | 211 } |
212 | 212 |
213 if (!keyPath.isNull() && !keyPath.isValid()) { | 213 if (!keyPath.isNull() && !keyPath.isValid()) { |
214 exceptionState.throwDOMException(SyntaxError, "The keyPath option is not
a valid key path."); | 214 exceptionState.throwDOMException(SyntaxError, "The keyPath option is not
a valid key path."); |
215 return 0; | 215 return nullptr; |
216 } | 216 } |
217 | 217 |
218 if (autoIncrement && ((keyPath.type() == IDBKeyPath::StringType && keyPath.s
tring().isEmpty()) || keyPath.type() == IDBKeyPath::ArrayType)) { | 218 if (autoIncrement && ((keyPath.type() == IDBKeyPath::StringType && keyPath.s
tring().isEmpty()) || keyPath.type() == IDBKeyPath::ArrayType)) { |
219 exceptionState.throwDOMException(InvalidAccessError, "The autoIncrement
option was set but the keyPath option was empty or an array."); | 219 exceptionState.throwDOMException(InvalidAccessError, "The autoIncrement
option was set but the keyPath option was empty or an array."); |
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 RefPtr<IDBObjectStore> objectStore = IDBObjectStore::create(metadata, m_vers
ionChangeTransaction.get()); | 227 RefPtr<IDBObjectStore> objectStore = IDBObjectStore::create(metadata, m_vers
ionChangeTransaction.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 28 matching lines...) Expand all Loading... |
259 m_versionChangeTransaction->objectStoreDeleted(name); | 259 m_versionChangeTransaction->objectStoreDeleted(name); |
260 m_metadata.objectStores.remove(objectStoreId); | 260 m_metadata.objectStores.remove(objectStoreId); |
261 } | 261 } |
262 | 262 |
263 PassRefPtr<IDBTransaction> IDBDatabase::transaction(ExecutionContext* context, c
onst Vector<String>& scope, const String& modeString, ExceptionState& exceptionS
tate) | 263 PassRefPtr<IDBTransaction> IDBDatabase::transaction(ExecutionContext* context, c
onst Vector<String>& scope, const String& modeString, ExceptionState& exceptionS
tate) |
264 { | 264 { |
265 IDB_TRACE("IDBDatabase::transaction"); | 265 IDB_TRACE("IDBDatabase::transaction"); |
266 blink::Platform::current()->histogramEnumeration("WebCore.IndexedDB.FrontEnd
APICalls", IDBTransactionCall, IDBMethodsMax); | 266 blink::Platform::current()->histogramEnumeration("WebCore.IndexedDB.FrontEnd
APICalls", IDBTransactionCall, IDBMethodsMax); |
267 if (!scope.size()) { | 267 if (!scope.size()) { |
268 exceptionState.throwDOMException(InvalidAccessError, "The storeNames par
ameter was empty."); | 268 exceptionState.throwDOMException(InvalidAccessError, "The storeNames par
ameter was empty."); |
269 return 0; | 269 return nullptr; |
270 } | 270 } |
271 | 271 |
272 blink::WebIDBDatabase::TransactionMode mode = IDBTransaction::stringToMode(m
odeString, exceptionState); | 272 blink::WebIDBDatabase::TransactionMode mode = IDBTransaction::stringToMode(m
odeString, exceptionState); |
273 if (exceptionState.hadException()) | 273 if (exceptionState.hadException()) |
274 return 0; | 274 return nullptr; |
275 | 275 |
276 if (m_versionChangeTransaction) { | 276 if (m_versionChangeTransaction) { |
277 exceptionState.throwDOMException(InvalidStateError, "A version change tr
ansaction is running."); | 277 exceptionState.throwDOMException(InvalidStateError, "A version change tr
ansaction is running."); |
278 return 0; | 278 return nullptr; |
279 } | 279 } |
280 | 280 |
281 if (m_closePending) { | 281 if (m_closePending) { |
282 exceptionState.throwDOMException(InvalidStateError, "The database connec
tion is closing."); | 282 exceptionState.throwDOMException(InvalidStateError, "The database connec
tion is closing."); |
283 return 0; | 283 return nullptr; |
284 } | 284 } |
285 | 285 |
286 Vector<int64_t> objectStoreIds; | 286 Vector<int64_t> objectStoreIds; |
287 for (size_t i = 0; i < scope.size(); ++i) { | 287 for (size_t i = 0; i < scope.size(); ++i) { |
288 int64_t objectStoreId = findObjectStoreId(scope[i]); | 288 int64_t objectStoreId = findObjectStoreId(scope[i]); |
289 if (objectStoreId == IDBObjectStoreMetadata::InvalidId) { | 289 if (objectStoreId == IDBObjectStoreMetadata::InvalidId) { |
290 exceptionState.throwDOMException(NotFoundError, "One of the specifie
d object stores was not found."); | 290 exceptionState.throwDOMException(NotFoundError, "One of the specifie
d object stores was not found."); |
291 return 0; | 291 return nullptr; |
292 } | 292 } |
293 objectStoreIds.append(objectStoreId); | 293 objectStoreIds.append(objectStoreId); |
294 } | 294 } |
295 | 295 |
296 int64_t transactionId = nextTransactionId(); | 296 int64_t transactionId = nextTransactionId(); |
297 m_backend->createTransaction(transactionId, WebIDBDatabaseCallbacksImpl::cre
ate(m_databaseCallbacks).leakPtr(), objectStoreIds, mode); | 297 m_backend->createTransaction(transactionId, WebIDBDatabaseCallbacksImpl::cre
ate(m_databaseCallbacks).leakPtr(), objectStoreIds, mode); |
298 | 298 |
299 RefPtr<IDBTransaction> transaction = IDBTransaction::create(context, transac
tionId, scope, mode, this); | 299 RefPtr<IDBTransaction> transaction = IDBTransaction::create(context, transac
tionId, scope, mode, this); |
300 return transaction.release(); | 300 return transaction.release(); |
301 } | 301 } |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 { | 420 { |
421 return EventTargetNames::IDBDatabase; | 421 return EventTargetNames::IDBDatabase; |
422 } | 422 } |
423 | 423 |
424 ExecutionContext* IDBDatabase::executionContext() const | 424 ExecutionContext* IDBDatabase::executionContext() const |
425 { | 425 { |
426 return ActiveDOMObject::executionContext(); | 426 return ActiveDOMObject::executionContext(); |
427 } | 427 } |
428 | 428 |
429 } // namespace WebCore | 429 } // namespace WebCore |
OLD | NEW |