Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(279)

Side by Side Diff: Source/modules/indexeddb/IDBFactory.cpp

Issue 1182233003: IndexedDB: Replace use of DOMError with DOMException (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 13 matching lines...) Expand all
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29 #include "config.h" 29 #include "config.h"
30 #include "modules/indexeddb/IDBFactory.h" 30 #include "modules/indexeddb/IDBFactory.h"
31 31
32 #include "bindings/core/v8/ExceptionState.h" 32 #include "bindings/core/v8/ExceptionState.h"
33 #include "bindings/modules/v8/V8BindingForModules.h" 33 #include "bindings/modules/v8/V8BindingForModules.h"
34 #include "core/dom/DOMException.h"
34 #include "core/dom/Document.h" 35 #include "core/dom/Document.h"
35 #include "core/dom/ExceptionCode.h" 36 #include "core/dom/ExceptionCode.h"
36 #include "modules/indexeddb/IDBDatabase.h" 37 #include "modules/indexeddb/IDBDatabase.h"
37 #include "modules/indexeddb/IDBDatabaseCallbacks.h" 38 #include "modules/indexeddb/IDBDatabaseCallbacks.h"
38 #include "modules/indexeddb/IDBHistograms.h" 39 #include "modules/indexeddb/IDBHistograms.h"
39 #include "modules/indexeddb/IDBKey.h" 40 #include "modules/indexeddb/IDBKey.h"
40 #include "modules/indexeddb/IDBTracing.h" 41 #include "modules/indexeddb/IDBTracing.h"
41 #include "modules/indexeddb/IndexedDBClient.h" 42 #include "modules/indexeddb/IndexedDBClient.h"
42 #include "modules/indexeddb/WebIDBCallbacksImpl.h" 43 #include "modules/indexeddb/WebIDBCallbacksImpl.h"
43 #include "modules/indexeddb/WebIDBDatabaseCallbacksImpl.h" 44 #include "modules/indexeddb/WebIDBDatabaseCallbacksImpl.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 if (!isContextValid(scriptState->executionContext())) 77 if (!isContextValid(scriptState->executionContext()))
77 return nullptr; 78 return nullptr;
78 if (!scriptState->executionContext()->securityOrigin()->canAccessDatabase()) { 79 if (!scriptState->executionContext()->securityOrigin()->canAccessDatabase()) {
79 exceptionState.throwSecurityError("access to the Indexed Database API is denied in this context."); 80 exceptionState.throwSecurityError("access to the Indexed Database API is denied in this context.");
80 return nullptr; 81 return nullptr;
81 } 82 }
82 83
83 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::createNull(), nullptr); 84 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::createNull(), nullptr);
84 85
85 if (!m_permissionClient->allowIndexedDB(scriptState->executionContext(), "Da tabase Listing")) { 86 if (!m_permissionClient->allowIndexedDB(scriptState->executionContext(), "Da tabase Listing")) {
86 request->onError(DOMError::create(UnknownError, permissionDeniedErrorMes sage)); 87 request->onError(DOMException::create(UnknownError, permissionDeniedErro rMessage));
87 return request; 88 return request;
88 } 89 }
89 90
90 Platform::current()->idbFactory()->getDatabaseNames(WebIDBCallbacksImpl::cre ate(request).leakPtr(), createDatabaseIdentifierFromSecurityOrigin(scriptState-> executionContext()->securityOrigin())); 91 Platform::current()->idbFactory()->getDatabaseNames(WebIDBCallbacksImpl::cre ate(request).leakPtr(), createDatabaseIdentifierFromSecurityOrigin(scriptState-> executionContext()->securityOrigin()));
91 return request; 92 return request;
92 } 93 }
93 94
94 IDBOpenDBRequest* IDBFactory::open(ScriptState* scriptState, const String& name, unsigned long long version, ExceptionState& exceptionState) 95 IDBOpenDBRequest* IDBFactory::open(ScriptState* scriptState, const String& name, unsigned long long version, ExceptionState& exceptionState)
95 { 96 {
96 IDB_TRACE("IDBFactory::open"); 97 IDB_TRACE("IDBFactory::open");
(...skipping 13 matching lines...) Expand all
110 if (!scriptState->executionContext()->securityOrigin()->canAccessDatabase()) { 111 if (!scriptState->executionContext()->securityOrigin()->canAccessDatabase()) {
111 exceptionState.throwSecurityError("access to the Indexed Database API is denied in this context."); 112 exceptionState.throwSecurityError("access to the Indexed Database API is denied in this context.");
112 return nullptr; 113 return nullptr;
113 } 114 }
114 115
115 IDBDatabaseCallbacks* databaseCallbacks = IDBDatabaseCallbacks::create(); 116 IDBDatabaseCallbacks* databaseCallbacks = IDBDatabaseCallbacks::create();
116 int64_t transactionId = IDBDatabase::nextTransactionId(); 117 int64_t transactionId = IDBDatabase::nextTransactionId();
117 IDBOpenDBRequest* request = IDBOpenDBRequest::create(scriptState, databaseCa llbacks, transactionId, version); 118 IDBOpenDBRequest* request = IDBOpenDBRequest::create(scriptState, databaseCa llbacks, transactionId, version);
118 119
119 if (!m_permissionClient->allowIndexedDB(scriptState->executionContext(), nam e)) { 120 if (!m_permissionClient->allowIndexedDB(scriptState->executionContext(), nam e)) {
120 request->onError(DOMError::create(UnknownError, permissionDeniedErrorMes sage)); 121 request->onError(DOMException::create(UnknownError, permissionDeniedErro rMessage));
121 return request; 122 return request;
122 } 123 }
123 124
124 Platform::current()->idbFactory()->open(name, version, transactionId, WebIDB CallbacksImpl::create(request).leakPtr(), WebIDBDatabaseCallbacksImpl::create(da tabaseCallbacks).leakPtr(), createDatabaseIdentifierFromSecurityOrigin(scriptSta te->executionContext()->securityOrigin())); 125 Platform::current()->idbFactory()->open(name, version, transactionId, WebIDB CallbacksImpl::create(request).leakPtr(), WebIDBDatabaseCallbacksImpl::create(da tabaseCallbacks).leakPtr(), createDatabaseIdentifierFromSecurityOrigin(scriptSta te->executionContext()->securityOrigin()));
125 return request; 126 return request;
126 } 127 }
127 128
128 IDBOpenDBRequest* IDBFactory::open(ScriptState* scriptState, const String& name, ExceptionState& exceptionState) 129 IDBOpenDBRequest* IDBFactory::open(ScriptState* scriptState, const String& name, ExceptionState& exceptionState)
129 { 130 {
130 IDB_TRACE("IDBFactory::open"); 131 IDB_TRACE("IDBFactory::open");
131 return openInternal(scriptState, name, IDBDatabaseMetadata::NoIntVersion, ex ceptionState); 132 return openInternal(scriptState, name, IDBDatabaseMetadata::NoIntVersion, ex ceptionState);
132 } 133 }
133 134
134 IDBOpenDBRequest* IDBFactory::deleteDatabase(ScriptState* scriptState, const Str ing& name, ExceptionState& exceptionState) 135 IDBOpenDBRequest* IDBFactory::deleteDatabase(ScriptState* scriptState, const Str ing& name, ExceptionState& exceptionState)
135 { 136 {
136 IDB_TRACE("IDBFactory::deleteDatabase"); 137 IDB_TRACE("IDBFactory::deleteDatabase");
137 Platform::current()->histogramEnumeration("WebCore.IndexedDB.FrontEndAPICall s", IDBDeleteDatabaseCall, IDBMethodsMax); 138 Platform::current()->histogramEnumeration("WebCore.IndexedDB.FrontEndAPICall s", IDBDeleteDatabaseCall, IDBMethodsMax);
138 if (!isContextValid(scriptState->executionContext())) 139 if (!isContextValid(scriptState->executionContext()))
139 return nullptr; 140 return nullptr;
140 if (!scriptState->executionContext()->securityOrigin()->canAccessDatabase()) { 141 if (!scriptState->executionContext()->securityOrigin()->canAccessDatabase()) {
141 exceptionState.throwSecurityError("access to the Indexed Database API is denied in this context."); 142 exceptionState.throwSecurityError("access to the Indexed Database API is denied in this context.");
142 return nullptr; 143 return nullptr;
143 } 144 }
144 145
145 IDBOpenDBRequest* request = IDBOpenDBRequest::create(scriptState, nullptr, 0 , IDBDatabaseMetadata::DefaultIntVersion); 146 IDBOpenDBRequest* request = IDBOpenDBRequest::create(scriptState, nullptr, 0 , IDBDatabaseMetadata::DefaultIntVersion);
146 147
147 if (!m_permissionClient->allowIndexedDB(scriptState->executionContext(), nam e)) { 148 if (!m_permissionClient->allowIndexedDB(scriptState->executionContext(), nam e)) {
148 request->onError(DOMError::create(UnknownError, permissionDeniedErrorMes sage)); 149 request->onError(DOMException::create(UnknownError, permissionDeniedErro rMessage));
149 return request; 150 return request;
150 } 151 }
151 152
152 Platform::current()->idbFactory()->deleteDatabase(name, WebIDBCallbacksImpl: :create(request).leakPtr(), createDatabaseIdentifierFromSecurityOrigin(scriptSta te->executionContext()->securityOrigin())); 153 Platform::current()->idbFactory()->deleteDatabase(name, WebIDBCallbacksImpl: :create(request).leakPtr(), createDatabaseIdentifierFromSecurityOrigin(scriptSta te->executionContext()->securityOrigin()));
153 return request; 154 return request;
154 } 155 }
155 156
156 short IDBFactory::cmp(ScriptState* scriptState, const ScriptValue& firstValue, c onst ScriptValue& secondValue, ExceptionState& exceptionState) 157 short IDBFactory::cmp(ScriptState* scriptState, const ScriptValue& firstValue, c onst ScriptValue& secondValue, ExceptionState& exceptionState)
157 { 158 {
158 IDBKey* first = ScriptValue::to<IDBKey*>(scriptState->isolate(), firstValue, exceptionState); 159 IDBKey* first = ScriptValue::to<IDBKey*>(scriptState->isolate(), firstValue, exceptionState);
(...skipping 11 matching lines...) Expand all
170 ASSERT(second); 171 ASSERT(second);
171 if (!second->isValid()) { 172 if (!second->isValid()) {
172 exceptionState.throwDOMException(DataError, IDBDatabase::notValidKeyErro rMessage); 173 exceptionState.throwDOMException(DataError, IDBDatabase::notValidKeyErro rMessage);
173 return 0; 174 return 0;
174 } 175 }
175 176
176 return static_cast<short>(first->compare(second)); 177 return static_cast<short>(first->compare(second));
177 } 178 }
178 179
179 } // namespace blink 180 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/indexeddb/IDBDatabaseCallbacks.cpp ('k') | Source/modules/indexeddb/IDBOpenDBRequest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698