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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 } | 104 } |
105 | 105 |
106 int64_t IDBDatabase::nextTransactionId() | 106 int64_t IDBDatabase::nextTransactionId() |
107 { | 107 { |
108 // Only keep a 32-bit counter to allow ports to use the other 32 | 108 // Only keep a 32-bit counter to allow ports to use the other 32 |
109 // bits of the id. | 109 // bits of the id. |
110 AtomicallyInitializedStatic(int, currentTransactionId = 0); | 110 AtomicallyInitializedStatic(int, currentTransactionId = 0); |
111 return atomicIncrement(¤tTransactionId); | 111 return atomicIncrement(¤tTransactionId); |
112 } | 112 } |
113 | 113 |
114 void IDBDatabase::ackReceivedBlobs(const Vector<blink::WebBlobInfo>* blobInfo) | 114 void IDBDatabase::ackReceivedBlobs(const Vector<WebBlobInfo>* blobInfo) |
115 { | 115 { |
116 ASSERT(blobInfo); | 116 ASSERT(blobInfo); |
117 if (!blobInfo->size() || !m_backend) | 117 if (!blobInfo->size() || !m_backend) |
118 return; | 118 return; |
119 Vector<blink::WebBlobInfo>::const_iterator iter; | 119 Vector<WebBlobInfo>::const_iterator iter; |
120 Vector<String> uuids; | 120 Vector<String> uuids; |
121 uuids.reserveCapacity(blobInfo->size()); | 121 uuids.reserveCapacity(blobInfo->size()); |
122 for (iter = blobInfo->begin(); iter != blobInfo->end(); ++iter) | 122 for (iter = blobInfo->begin(); iter != blobInfo->end(); ++iter) |
123 uuids.append(iter->uuid()); | 123 uuids.append(iter->uuid()); |
124 m_backend->ackReceivedBlobs(uuids); | 124 m_backend->ackReceivedBlobs(uuids); |
125 } | 125 } |
126 | 126 |
127 void IDBDatabase::indexCreated(int64_t objectStoreId, const IDBIndexMetadata& me
tadata) | 127 void IDBDatabase::indexCreated(int64_t objectStoreId, const IDBIndexMetadata& me
tadata) |
128 { | 128 { |
129 IDBDatabaseMetadata::ObjectStoreMap::iterator it = m_metadata.objectStores.f
ind(objectStoreId); | 129 IDBDatabaseMetadata::ObjectStoreMap::iterator it = m_metadata.objectStores.f
ind(objectStoreId); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 | 210 |
211 DictionaryHelper::get(options, "autoIncrement", autoIncrement); | 211 DictionaryHelper::get(options, "autoIncrement", autoIncrement); |
212 } | 212 } |
213 | 213 |
214 return createObjectStore(name, keyPath, autoIncrement, exceptionState); | 214 return createObjectStore(name, keyPath, autoIncrement, exceptionState); |
215 } | 215 } |
216 | 216 |
217 IDBObjectStore* IDBDatabase::createObjectStore(const String& name, const IDBKeyP
ath& keyPath, bool autoIncrement, ExceptionState& exceptionState) | 217 IDBObjectStore* IDBDatabase::createObjectStore(const String& name, const IDBKeyP
ath& keyPath, bool autoIncrement, ExceptionState& exceptionState) |
218 { | 218 { |
219 IDB_TRACE("IDBDatabase::createObjectStore"); | 219 IDB_TRACE("IDBDatabase::createObjectStore"); |
220 blink::Platform::current()->histogramEnumeration("WebCore.IndexedDB.FrontEnd
APICalls", IDBCreateObjectStoreCall, IDBMethodsMax); | 220 Platform::current()->histogramEnumeration("WebCore.IndexedDB.FrontEndAPICall
s", IDBCreateObjectStoreCall, IDBMethodsMax); |
221 if (!m_versionChangeTransaction) { | 221 if (!m_versionChangeTransaction) { |
222 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::notVers
ionChangeTransactionErrorMessage); | 222 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::notVers
ionChangeTransactionErrorMessage); |
223 return 0; | 223 return 0; |
224 } | 224 } |
225 if (m_versionChangeTransaction->isFinished() || m_versionChangeTransaction->
isFinishing()) { | 225 if (m_versionChangeTransaction->isFinished() || m_versionChangeTransaction->
isFinishing()) { |
226 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionFinishedErrorMessage); | 226 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionFinishedErrorMessage); |
227 return 0; | 227 return 0; |
228 } | 228 } |
229 if (!m_versionChangeTransaction->isActive()) { | 229 if (!m_versionChangeTransaction->isActive()) { |
230 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionInactiveErrorMessage); | 230 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionInactiveErrorMessage); |
(...skipping 28 matching lines...) Expand all Loading... |
259 m_metadata.objectStores.set(metadata.id, metadata); | 259 m_metadata.objectStores.set(metadata.id, metadata); |
260 ++m_metadata.maxObjectStoreId; | 260 ++m_metadata.maxObjectStoreId; |
261 | 261 |
262 m_versionChangeTransaction->objectStoreCreated(name, objectStore); | 262 m_versionChangeTransaction->objectStoreCreated(name, objectStore); |
263 return objectStore; | 263 return objectStore; |
264 } | 264 } |
265 | 265 |
266 void IDBDatabase::deleteObjectStore(const String& name, ExceptionState& exceptio
nState) | 266 void IDBDatabase::deleteObjectStore(const String& name, ExceptionState& exceptio
nState) |
267 { | 267 { |
268 IDB_TRACE("IDBDatabase::deleteObjectStore"); | 268 IDB_TRACE("IDBDatabase::deleteObjectStore"); |
269 blink::Platform::current()->histogramEnumeration("WebCore.IndexedDB.FrontEnd
APICalls", IDBDeleteObjectStoreCall, IDBMethodsMax); | 269 Platform::current()->histogramEnumeration("WebCore.IndexedDB.FrontEndAPICall
s", IDBDeleteObjectStoreCall, IDBMethodsMax); |
270 if (!m_versionChangeTransaction) { | 270 if (!m_versionChangeTransaction) { |
271 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::notVers
ionChangeTransactionErrorMessage); | 271 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::notVers
ionChangeTransactionErrorMessage); |
272 return; | 272 return; |
273 } | 273 } |
274 if (m_versionChangeTransaction->isFinished() || m_versionChangeTransaction->
isFinishing()) { | 274 if (m_versionChangeTransaction->isFinished() || m_versionChangeTransaction->
isFinishing()) { |
275 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionFinishedErrorMessage); | 275 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionFinishedErrorMessage); |
276 return; | 276 return; |
277 } | 277 } |
278 if (!m_versionChangeTransaction->isActive()) { | 278 if (!m_versionChangeTransaction->isActive()) { |
279 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionInactiveErrorMessage); | 279 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionInactiveErrorMessage); |
(...skipping 12 matching lines...) Expand all Loading... |
292 } | 292 } |
293 | 293 |
294 m_backend->deleteObjectStore(m_versionChangeTransaction->id(), objectStoreId
); | 294 m_backend->deleteObjectStore(m_versionChangeTransaction->id(), objectStoreId
); |
295 m_versionChangeTransaction->objectStoreDeleted(name); | 295 m_versionChangeTransaction->objectStoreDeleted(name); |
296 m_metadata.objectStores.remove(objectStoreId); | 296 m_metadata.objectStores.remove(objectStoreId); |
297 } | 297 } |
298 | 298 |
299 IDBTransaction* IDBDatabase::transaction(ExecutionContext* context, const Vector
<String>& scope, const String& modeString, ExceptionState& exceptionState) | 299 IDBTransaction* IDBDatabase::transaction(ExecutionContext* context, const Vector
<String>& scope, const String& modeString, ExceptionState& exceptionState) |
300 { | 300 { |
301 IDB_TRACE("IDBDatabase::transaction"); | 301 IDB_TRACE("IDBDatabase::transaction"); |
302 blink::Platform::current()->histogramEnumeration("WebCore.IndexedDB.FrontEnd
APICalls", IDBTransactionCall, IDBMethodsMax); | 302 Platform::current()->histogramEnumeration("WebCore.IndexedDB.FrontEndAPICall
s", IDBTransactionCall, IDBMethodsMax); |
303 if (!scope.size()) { | 303 if (!scope.size()) { |
304 exceptionState.throwDOMException(InvalidAccessError, "The storeNames par
ameter was empty."); | 304 exceptionState.throwDOMException(InvalidAccessError, "The storeNames par
ameter was empty."); |
305 return 0; | 305 return 0; |
306 } | 306 } |
307 | 307 |
308 blink::WebIDBTransactionMode mode = IDBTransaction::stringToMode(modeString,
exceptionState); | 308 WebIDBTransactionMode mode = IDBTransaction::stringToMode(modeString, except
ionState); |
309 if (exceptionState.hadException()) | 309 if (exceptionState.hadException()) |
310 return 0; | 310 return 0; |
311 | 311 |
312 if (m_versionChangeTransaction) { | 312 if (m_versionChangeTransaction) { |
313 exceptionState.throwDOMException(InvalidStateError, "A version change tr
ansaction is running."); | 313 exceptionState.throwDOMException(InvalidStateError, "A version change tr
ansaction is running."); |
314 return 0; | 314 return 0; |
315 } | 315 } |
316 | 316 |
317 if (m_closePending) { | 317 if (m_closePending) { |
318 exceptionState.throwDOMException(InvalidStateError, "The database connec
tion is closing."); | 318 exceptionState.throwDOMException(InvalidStateError, "The database connec
tion is closing."); |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
471 { | 471 { |
472 return EventTargetNames::IDBDatabase; | 472 return EventTargetNames::IDBDatabase; |
473 } | 473 } |
474 | 474 |
475 ExecutionContext* IDBDatabase::executionContext() const | 475 ExecutionContext* IDBDatabase::executionContext() const |
476 { | 476 { |
477 return ActiveDOMObject::executionContext(); | 477 return ActiveDOMObject::executionContext(); |
478 } | 478 } |
479 | 479 |
480 } // namespace blink | 480 } // namespace blink |
OLD | NEW |