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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 | 85 |
86 if (!m_permissionClient->allowIndexedDB(scriptState->executionContext(), "Da
tabase Listing")) { | 86 if (!m_permissionClient->allowIndexedDB(scriptState->executionContext(), "Da
tabase Listing")) { |
87 request->onError(DOMError::create(UnknownError, permissionDeniedErrorMes
sage)); | 87 request->onError(DOMError::create(UnknownError, permissionDeniedErrorMes
sage)); |
88 return request; | 88 return request; |
89 } | 89 } |
90 | 90 |
91 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())); |
92 return request; | 92 return request; |
93 } | 93 } |
94 | 94 |
95 IDBOpenDBRequest* IDBFactory::open(ScriptState* scriptState, const String& name,
unsigned long long version, ExceptionState& exceptionState) | 95 IDBOpenDBRequest* IDBFactory::open(ScriptState* scriptState, const String& name,
Optional<unsigned long long> optionalVersion, ExceptionState& exceptionState) |
96 { | 96 { |
97 IDB_TRACE("IDBFactory::open"); | 97 IDB_TRACE("IDBFactory::open"); |
| 98 Platform::current()->histogramEnumeration("WebCore.IndexedDB.FrontEndAPICall
s", IDBOpenCall, IDBMethodsMax); |
| 99 int64_t version = optionalVersion.isMissing() ? IDBDatabaseMetadata::NoIntVe
rsion : optionalVersion.get(); |
98 if (!version) { | 100 if (!version) { |
99 exceptionState.throwTypeError("The version provided must not be 0."); | 101 exceptionState.throwTypeError("The version provided must not be 0."); |
100 return 0; | 102 return 0; |
101 } | 103 } |
102 return openInternal(scriptState, name, version, exceptionState); | |
103 } | |
104 | |
105 IDBOpenDBRequest* IDBFactory::openInternal(ScriptState* scriptState, const Strin
g& name, int64_t version, ExceptionState& exceptionState) | |
106 { | |
107 Platform::current()->histogramEnumeration("WebCore.IndexedDB.FrontEndAPICall
s", IDBOpenCall, IDBMethodsMax); | |
108 ASSERT(version >= 1 || version == IDBDatabaseMetadata::NoIntVersion); | 104 ASSERT(version >= 1 || version == IDBDatabaseMetadata::NoIntVersion); |
109 if (name.isNull()) { | 105 if (name.isNull()) { |
110 exceptionState.throwTypeError("The name provided must not be empty."); | 106 exceptionState.throwTypeError("The name provided must not be empty."); |
111 return 0; | 107 return 0; |
112 } | 108 } |
113 if (!isContextValid(scriptState->executionContext())) | 109 if (!isContextValid(scriptState->executionContext())) |
114 return nullptr; | 110 return nullptr; |
115 if (!scriptState->executionContext()->securityOrigin()->canAccessDatabase())
{ | 111 if (!scriptState->executionContext()->securityOrigin()->canAccessDatabase())
{ |
116 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."); |
117 return 0; | 113 return 0; |
118 } | 114 } |
119 | 115 |
120 IDBDatabaseCallbacks* databaseCallbacks = IDBDatabaseCallbacks::create(); | 116 IDBDatabaseCallbacks* databaseCallbacks = IDBDatabaseCallbacks::create(); |
121 int64_t transactionId = IDBDatabase::nextTransactionId(); | 117 int64_t transactionId = IDBDatabase::nextTransactionId(); |
122 IDBOpenDBRequest* request = IDBOpenDBRequest::create(scriptState, databaseCa
llbacks, transactionId, version); | 118 IDBOpenDBRequest* request = IDBOpenDBRequest::create(scriptState, databaseCa
llbacks, transactionId, version); |
123 | 119 |
124 if (!m_permissionClient->allowIndexedDB(scriptState->executionContext(), nam
e)) { | 120 if (!m_permissionClient->allowIndexedDB(scriptState->executionContext(), nam
e)) { |
125 request->onError(DOMError::create(UnknownError, permissionDeniedErrorMes
sage)); | 121 request->onError(DOMError::create(UnknownError, permissionDeniedErrorMes
sage)); |
126 return request; | 122 return request; |
127 } | 123 } |
128 | 124 |
129 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())); |
130 return request; | 126 return request; |
131 } | 127 } |
132 | 128 |
133 IDBOpenDBRequest* IDBFactory::open(ScriptState* scriptState, const String& name,
ExceptionState& exceptionState) | |
134 { | |
135 IDB_TRACE("IDBFactory::open"); | |
136 return openInternal(scriptState, name, IDBDatabaseMetadata::NoIntVersion, ex
ceptionState); | |
137 } | |
138 | |
139 IDBOpenDBRequest* IDBFactory::deleteDatabase(ScriptState* scriptState, const Str
ing& name, ExceptionState& exceptionState) | 129 IDBOpenDBRequest* IDBFactory::deleteDatabase(ScriptState* scriptState, const Str
ing& name, ExceptionState& exceptionState) |
140 { | 130 { |
141 IDB_TRACE("IDBFactory::deleteDatabase"); | 131 IDB_TRACE("IDBFactory::deleteDatabase"); |
142 Platform::current()->histogramEnumeration("WebCore.IndexedDB.FrontEndAPICall
s", IDBDeleteDatabaseCall, IDBMethodsMax); | 132 Platform::current()->histogramEnumeration("WebCore.IndexedDB.FrontEndAPICall
s", IDBDeleteDatabaseCall, IDBMethodsMax); |
143 if (name.isNull()) { | 133 if (name.isNull()) { |
144 exceptionState.throwTypeError("The name provided must not be empty."); | 134 exceptionState.throwTypeError("The name provided must not be empty."); |
145 return 0; | 135 return 0; |
146 } | 136 } |
147 if (!isContextValid(scriptState->executionContext())) | 137 if (!isContextValid(scriptState->executionContext())) |
148 return nullptr; | 138 return nullptr; |
(...skipping 23 matching lines...) Expand all Loading... |
172 | 162 |
173 if (!first->isValid() || !second->isValid()) { | 163 if (!first->isValid() || !second->isValid()) { |
174 exceptionState.throwDOMException(DataError, IDBDatabase::notValidKeyErro
rMessage); | 164 exceptionState.throwDOMException(DataError, IDBDatabase::notValidKeyErro
rMessage); |
175 return 0; | 165 return 0; |
176 } | 166 } |
177 | 167 |
178 return static_cast<short>(first->compare(second)); | 168 return static_cast<short>(first->compare(second)); |
179 } | 169 } |
180 | 170 |
181 } // namespace blink | 171 } // namespace blink |
OLD | NEW |