| 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 17 matching lines...) Expand all Loading... |
| 28 #include "bindings/core/v8/ExceptionState.h" | 28 #include "bindings/core/v8/ExceptionState.h" |
| 29 #include "bindings/core/v8/ExceptionStatePlaceholder.h" | 29 #include "bindings/core/v8/ExceptionStatePlaceholder.h" |
| 30 #include "bindings/core/v8/Nullable.h" | 30 #include "bindings/core/v8/Nullable.h" |
| 31 #include "bindings/core/v8/SerializedScriptValue.h" | 31 #include "bindings/core/v8/SerializedScriptValue.h" |
| 32 #include "bindings/modules/v8/V8BindingForModules.h" | 32 #include "bindings/modules/v8/V8BindingForModules.h" |
| 33 #include "core/dom/ExceptionCode.h" | 33 #include "core/dom/ExceptionCode.h" |
| 34 #include "core/dom/ExecutionContext.h" | 34 #include "core/dom/ExecutionContext.h" |
| 35 #include "core/events/EventQueue.h" | 35 #include "core/events/EventQueue.h" |
| 36 #include "modules/indexeddb/IDBAny.h" | 36 #include "modules/indexeddb/IDBAny.h" |
| 37 #include "modules/indexeddb/IDBEventDispatcher.h" | 37 #include "modules/indexeddb/IDBEventDispatcher.h" |
| 38 #include "modules/indexeddb/IDBHistograms.h" | |
| 39 #include "modules/indexeddb/IDBIndex.h" | 38 #include "modules/indexeddb/IDBIndex.h" |
| 40 #include "modules/indexeddb/IDBKeyPath.h" | 39 #include "modules/indexeddb/IDBKeyPath.h" |
| 41 #include "modules/indexeddb/IDBTracing.h" | 40 #include "modules/indexeddb/IDBTracing.h" |
| 42 #include "modules/indexeddb/IDBVersionChangeEvent.h" | 41 #include "modules/indexeddb/IDBVersionChangeEvent.h" |
| 43 #include "modules/indexeddb/WebIDBDatabaseCallbacksImpl.h" | 42 #include "modules/indexeddb/WebIDBDatabaseCallbacksImpl.h" |
| 44 #include "public/platform/Platform.h" | 43 #include "platform/Histogram.h" |
| 45 #include "public/platform/modules/indexeddb/WebIDBKeyPath.h" | 44 #include "public/platform/modules/indexeddb/WebIDBKeyPath.h" |
| 46 #include "public/platform/modules/indexeddb/WebIDBTypes.h" | 45 #include "public/platform/modules/indexeddb/WebIDBTypes.h" |
| 47 #include "wtf/Atomics.h" | 46 #include "wtf/Atomics.h" |
| 48 #include <limits> | 47 #include <limits> |
| 49 | 48 |
| 50 using blink::WebIDBDatabase; | 49 using blink::WebIDBDatabase; |
| 51 | 50 |
| 52 namespace blink { | 51 namespace blink { |
| 53 | 52 |
| 54 const char IDBDatabase::indexDeletedErrorMessage[] = "The index or its object st
ore has been deleted."; | 53 const char IDBDatabase::indexDeletedErrorMessage[] = "The index or its object st
ore has been deleted."; |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 { | 172 { |
| 174 if (m_metadata.intVersion == IDBDatabaseMetadata::NoIntVersion) | 173 if (m_metadata.intVersion == IDBDatabaseMetadata::NoIntVersion) |
| 175 result.setString(m_metadata.version); | 174 result.setString(m_metadata.version); |
| 176 else | 175 else |
| 177 result.setUnsignedLongLong(m_metadata.intVersion); | 176 result.setUnsignedLongLong(m_metadata.intVersion); |
| 178 } | 177 } |
| 179 | 178 |
| 180 IDBObjectStore* IDBDatabase::createObjectStore(const String& name, const IDBKeyP
ath& keyPath, bool autoIncrement, ExceptionState& exceptionState) | 179 IDBObjectStore* IDBDatabase::createObjectStore(const String& name, const IDBKeyP
ath& keyPath, bool autoIncrement, ExceptionState& exceptionState) |
| 181 { | 180 { |
| 182 IDB_TRACE("IDBDatabase::createObjectStore"); | 181 IDB_TRACE("IDBDatabase::createObjectStore"); |
| 183 Platform::current()->histogramEnumeration("WebCore.IndexedDB.FrontEndAPICall
s", IDBCreateObjectStoreCall, IDBMethodsMax); | 182 recordApiCallsHistogram(IDBCreateObjectStoreCall); |
| 183 |
| 184 if (!m_versionChangeTransaction) { | 184 if (!m_versionChangeTransaction) { |
| 185 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::notVers
ionChangeTransactionErrorMessage); | 185 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::notVers
ionChangeTransactionErrorMessage); |
| 186 return nullptr; | 186 return nullptr; |
| 187 } | 187 } |
| 188 if (m_versionChangeTransaction->isFinished() || m_versionChangeTransaction->
isFinishing()) { | 188 if (m_versionChangeTransaction->isFinished() || m_versionChangeTransaction->
isFinishing()) { |
| 189 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionFinishedErrorMessage); | 189 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionFinishedErrorMessage); |
| 190 return nullptr; | 190 return nullptr; |
| 191 } | 191 } |
| 192 if (!m_versionChangeTransaction->isActive()) { | 192 if (!m_versionChangeTransaction->isActive()) { |
| 193 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionInactiveErrorMessage); | 193 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionInactiveErrorMessage); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 222 m_metadata.objectStores.set(metadata.id, metadata); | 222 m_metadata.objectStores.set(metadata.id, metadata); |
| 223 ++m_metadata.maxObjectStoreId; | 223 ++m_metadata.maxObjectStoreId; |
| 224 | 224 |
| 225 m_versionChangeTransaction->objectStoreCreated(name, objectStore); | 225 m_versionChangeTransaction->objectStoreCreated(name, objectStore); |
| 226 return objectStore; | 226 return objectStore; |
| 227 } | 227 } |
| 228 | 228 |
| 229 void IDBDatabase::deleteObjectStore(const String& name, ExceptionState& exceptio
nState) | 229 void IDBDatabase::deleteObjectStore(const String& name, ExceptionState& exceptio
nState) |
| 230 { | 230 { |
| 231 IDB_TRACE("IDBDatabase::deleteObjectStore"); | 231 IDB_TRACE("IDBDatabase::deleteObjectStore"); |
| 232 Platform::current()->histogramEnumeration("WebCore.IndexedDB.FrontEndAPICall
s", IDBDeleteObjectStoreCall, IDBMethodsMax); | 232 recordApiCallsHistogram(IDBDeleteObjectStoreCall); |
| 233 if (!m_versionChangeTransaction) { | 233 if (!m_versionChangeTransaction) { |
| 234 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::notVers
ionChangeTransactionErrorMessage); | 234 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::notVers
ionChangeTransactionErrorMessage); |
| 235 return; | 235 return; |
| 236 } | 236 } |
| 237 if (m_versionChangeTransaction->isFinished() || m_versionChangeTransaction->
isFinishing()) { | 237 if (m_versionChangeTransaction->isFinished() || m_versionChangeTransaction->
isFinishing()) { |
| 238 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionFinishedErrorMessage); | 238 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionFinishedErrorMessage); |
| 239 return; | 239 return; |
| 240 } | 240 } |
| 241 if (!m_versionChangeTransaction->isActive()) { | 241 if (!m_versionChangeTransaction->isActive()) { |
| 242 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionInactiveErrorMessage); | 242 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionInactiveErrorMessage); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 255 } | 255 } |
| 256 | 256 |
| 257 m_backend->deleteObjectStore(m_versionChangeTransaction->id(), objectStoreId
); | 257 m_backend->deleteObjectStore(m_versionChangeTransaction->id(), objectStoreId
); |
| 258 m_versionChangeTransaction->objectStoreDeleted(name); | 258 m_versionChangeTransaction->objectStoreDeleted(name); |
| 259 m_metadata.objectStores.remove(objectStoreId); | 259 m_metadata.objectStores.remove(objectStoreId); |
| 260 } | 260 } |
| 261 | 261 |
| 262 IDBTransaction* IDBDatabase::transaction(ScriptState* scriptState, const StringO
rStringSequenceOrDOMStringList& storeNames, const String& modeString, ExceptionS
tate& exceptionState) | 262 IDBTransaction* IDBDatabase::transaction(ScriptState* scriptState, const StringO
rStringSequenceOrDOMStringList& storeNames, const String& modeString, ExceptionS
tate& exceptionState) |
| 263 { | 263 { |
| 264 IDB_TRACE("IDBDatabase::transaction"); | 264 IDB_TRACE("IDBDatabase::transaction"); |
| 265 Platform::current()->histogramEnumeration("WebCore.IndexedDB.FrontEndAPICall
s", IDBTransactionCall, IDBMethodsMax); | 265 recordApiCallsHistogram(IDBTransactionCall); |
| 266 | 266 |
| 267 HashSet<String> scope; | 267 HashSet<String> scope; |
| 268 if (storeNames.isString()) { | 268 if (storeNames.isString()) { |
| 269 scope.add(storeNames.getAsString()); | 269 scope.add(storeNames.getAsString()); |
| 270 } else if (storeNames.isStringSequence()) { | 270 } else if (storeNames.isStringSequence()) { |
| 271 for (const String& name : storeNames.getAsStringSequence()) | 271 for (const String& name : storeNames.getAsStringSequence()) |
| 272 scope.add(name); | 272 scope.add(name); |
| 273 } else if (storeNames.isDOMStringList()) { | 273 } else if (storeNames.isDOMStringList()) { |
| 274 const Vector<String>& list = *storeNames.getAsDOMStringList(); | 274 const Vector<String>& list = *storeNames.getAsDOMStringList(); |
| 275 for (const String& name : list) | 275 for (const String& name : list) |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 const AtomicString& IDBDatabase::interfaceName() const | 446 const AtomicString& IDBDatabase::interfaceName() const |
| 447 { | 447 { |
| 448 return EventTargetNames::IDBDatabase; | 448 return EventTargetNames::IDBDatabase; |
| 449 } | 449 } |
| 450 | 450 |
| 451 ExecutionContext* IDBDatabase::executionContext() const | 451 ExecutionContext* IDBDatabase::executionContext() const |
| 452 { | 452 { |
| 453 return ActiveDOMObject::executionContext(); | 453 return ActiveDOMObject::executionContext(); |
| 454 } | 454 } |
| 455 | 455 |
| 456 void IDBDatabase::recordApiCallsHistogram(IndexedDatabaseMethods method) |
| 457 { |
| 458 DEFINE_THREAD_SAFE_STATIC_LOCAL(EnumerationHistogram, apiCallsHistogram, new
EnumerationHistogram("WebCore.IndexedDB.FrontEndAPICalls", IDBMethodsMax)); |
| 459 apiCallsHistogram.count(method); |
| 460 } |
| 461 |
| 456 } // namespace blink | 462 } // namespace blink |
| OLD | NEW |