| 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 | 28 |
| 29 #include "modules/indexeddb/IDBFactory.h" | 29 #include "modules/indexeddb/IDBFactory.h" |
| 30 | 30 |
| 31 #include "bindings/core/v8/ExceptionState.h" | 31 #include "bindings/core/v8/ExceptionState.h" |
| 32 #include "bindings/modules/v8/V8BindingForModules.h" | 32 #include "bindings/modules/v8/V8BindingForModules.h" |
| 33 #include "core/dom/DOMException.h" | 33 #include "core/dom/DOMException.h" |
| 34 #include "core/dom/Document.h" | 34 #include "core/dom/Document.h" |
| 35 #include "core/dom/ExceptionCode.h" | 35 #include "core/dom/ExceptionCode.h" |
| 36 #include "modules/indexeddb/IDBDatabase.h" | 36 #include "modules/indexeddb/IDBDatabase.h" |
| 37 #include "modules/indexeddb/IDBDatabaseCallbacks.h" | 37 #include "modules/indexeddb/IDBDatabaseCallbacks.h" |
| 38 #include "modules/indexeddb/IDBHistograms.h" | |
| 39 #include "modules/indexeddb/IDBKey.h" | 38 #include "modules/indexeddb/IDBKey.h" |
| 40 #include "modules/indexeddb/IDBTracing.h" | 39 #include "modules/indexeddb/IDBTracing.h" |
| 41 #include "modules/indexeddb/IndexedDBClient.h" | 40 #include "modules/indexeddb/IndexedDBClient.h" |
| 42 #include "modules/indexeddb/WebIDBCallbacksImpl.h" | 41 #include "modules/indexeddb/WebIDBCallbacksImpl.h" |
| 43 #include "modules/indexeddb/WebIDBDatabaseCallbacksImpl.h" | 42 #include "modules/indexeddb/WebIDBDatabaseCallbacksImpl.h" |
| 43 #include "platform/Histogram.h" |
| 44 #include "platform/weborigin/DatabaseIdentifier.h" | 44 #include "platform/weborigin/DatabaseIdentifier.h" |
| 45 #include "platform/weborigin/SecurityOrigin.h" | 45 #include "platform/weborigin/SecurityOrigin.h" |
| 46 #include "public/platform/Platform.h" | 46 #include "public/platform/Platform.h" |
| 47 #include "public/platform/modules/indexeddb/WebIDBFactory.h" | 47 #include "public/platform/modules/indexeddb/WebIDBFactory.h" |
| 48 | 48 |
| 49 namespace blink { | 49 namespace blink { |
| 50 | 50 |
| 51 static const char permissionDeniedErrorMessage[] = "The user denied permission t
o access the database."; | 51 static const char permissionDeniedErrorMessage[] = "The user denied permission t
o access the database."; |
| 52 | 52 |
| 53 IDBFactory::IDBFactory(IndexedDBClient* permissionClient) | 53 IDBFactory::IDBFactory(IndexedDBClient* permissionClient) |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 IDB_TRACE("IDBFactory::open"); | 96 IDB_TRACE("IDBFactory::open"); |
| 97 if (!version) { | 97 if (!version) { |
| 98 exceptionState.throwTypeError("The version provided must not be 0."); | 98 exceptionState.throwTypeError("The version provided must not be 0."); |
| 99 return nullptr; | 99 return nullptr; |
| 100 } | 100 } |
| 101 return openInternal(scriptState, name, version, exceptionState); | 101 return openInternal(scriptState, name, version, exceptionState); |
| 102 } | 102 } |
| 103 | 103 |
| 104 IDBOpenDBRequest* IDBFactory::openInternal(ScriptState* scriptState, const Strin
g& name, int64_t version, ExceptionState& exceptionState) | 104 IDBOpenDBRequest* IDBFactory::openInternal(ScriptState* scriptState, const Strin
g& name, int64_t version, ExceptionState& exceptionState) |
| 105 { | 105 { |
| 106 Platform::current()->histogramEnumeration("WebCore.IndexedDB.FrontEndAPICall
s", IDBOpenCall, IDBMethodsMax); | 106 IDBDatabase::recordApiCallsHistogram(IDBOpenCall); |
| 107 ASSERT(version >= 1 || version == IDBDatabaseMetadata::NoIntVersion); | 107 ASSERT(version >= 1 || version == IDBDatabaseMetadata::NoIntVersion); |
| 108 if (!isContextValid(scriptState->executionContext())) | 108 if (!isContextValid(scriptState->executionContext())) |
| 109 return nullptr; | 109 return nullptr; |
| 110 if (!scriptState->executionContext()->securityOrigin()->canAccessDatabase())
{ | 110 if (!scriptState->executionContext()->securityOrigin()->canAccessDatabase())
{ |
| 111 exceptionState.throwSecurityError("access to the Indexed Database API is
denied in this context."); | 111 exceptionState.throwSecurityError("access to the Indexed Database API is
denied in this context."); |
| 112 return nullptr; | 112 return nullptr; |
| 113 } | 113 } |
| 114 | 114 |
| 115 IDBDatabaseCallbacks* databaseCallbacks = IDBDatabaseCallbacks::create(); | 115 IDBDatabaseCallbacks* databaseCallbacks = IDBDatabaseCallbacks::create(); |
| 116 int64_t transactionId = IDBDatabase::nextTransactionId(); | 116 int64_t transactionId = IDBDatabase::nextTransactionId(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 127 | 127 |
| 128 IDBOpenDBRequest* IDBFactory::open(ScriptState* scriptState, const String& name,
ExceptionState& exceptionState) | 128 IDBOpenDBRequest* IDBFactory::open(ScriptState* scriptState, const String& name,
ExceptionState& exceptionState) |
| 129 { | 129 { |
| 130 IDB_TRACE("IDBFactory::open"); | 130 IDB_TRACE("IDBFactory::open"); |
| 131 return openInternal(scriptState, name, IDBDatabaseMetadata::NoIntVersion, ex
ceptionState); | 131 return openInternal(scriptState, name, IDBDatabaseMetadata::NoIntVersion, ex
ceptionState); |
| 132 } | 132 } |
| 133 | 133 |
| 134 IDBOpenDBRequest* IDBFactory::deleteDatabase(ScriptState* scriptState, const Str
ing& name, ExceptionState& exceptionState) | 134 IDBOpenDBRequest* IDBFactory::deleteDatabase(ScriptState* scriptState, const Str
ing& name, ExceptionState& exceptionState) |
| 135 { | 135 { |
| 136 IDB_TRACE("IDBFactory::deleteDatabase"); | 136 IDB_TRACE("IDBFactory::deleteDatabase"); |
| 137 Platform::current()->histogramEnumeration("WebCore.IndexedDB.FrontEndAPICall
s", IDBDeleteDatabaseCall, IDBMethodsMax); | 137 IDBDatabase::recordApiCallsHistogram(IDBDeleteDatabaseCall); |
| 138 if (!isContextValid(scriptState->executionContext())) | 138 if (!isContextValid(scriptState->executionContext())) |
| 139 return nullptr; | 139 return nullptr; |
| 140 if (!scriptState->executionContext()->securityOrigin()->canAccessDatabase())
{ | 140 if (!scriptState->executionContext()->securityOrigin()->canAccessDatabase())
{ |
| 141 exceptionState.throwSecurityError("access to the Indexed Database API is
denied in this context."); | 141 exceptionState.throwSecurityError("access to the Indexed Database API is
denied in this context."); |
| 142 return nullptr; | 142 return nullptr; |
| 143 } | 143 } |
| 144 | 144 |
| 145 IDBOpenDBRequest* request = IDBOpenDBRequest::create(scriptState, nullptr, 0
, IDBDatabaseMetadata::DefaultIntVersion); | 145 IDBOpenDBRequest* request = IDBOpenDBRequest::create(scriptState, nullptr, 0
, IDBDatabaseMetadata::DefaultIntVersion); |
| 146 | 146 |
| 147 if (!m_permissionClient->allowIndexedDB(scriptState->executionContext(), nam
e)) { | 147 if (!m_permissionClient->allowIndexedDB(scriptState->executionContext(), nam
e)) { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 170 ASSERT(second); | 170 ASSERT(second); |
| 171 if (!second->isValid()) { | 171 if (!second->isValid()) { |
| 172 exceptionState.throwDOMException(DataError, IDBDatabase::notValidKeyErro
rMessage); | 172 exceptionState.throwDOMException(DataError, IDBDatabase::notValidKeyErro
rMessage); |
| 173 return 0; | 173 return 0; |
| 174 } | 174 } |
| 175 | 175 |
| 176 return static_cast<short>(first->compare(second)); | 176 return static_cast<short>(first->compare(second)); |
| 177 } | 177 } |
| 178 | 178 |
| 179 } // namespace blink | 179 } // namespace blink |
| OLD | NEW |