| 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 const String& name, | 145 const String& name, |
| 146 ExceptionState& exceptionState) { | 146 ExceptionState& exceptionState) { |
| 147 IDB_TRACE("IDBFactory::open"); | 147 IDB_TRACE("IDBFactory::open"); |
| 148 return openInternal(scriptState, name, IDBDatabaseMetadata::NoVersion, | 148 return openInternal(scriptState, name, IDBDatabaseMetadata::NoVersion, |
| 149 exceptionState); | 149 exceptionState); |
| 150 } | 150 } |
| 151 | 151 |
| 152 IDBOpenDBRequest* IDBFactory::deleteDatabase(ScriptState* scriptState, | 152 IDBOpenDBRequest* IDBFactory::deleteDatabase(ScriptState* scriptState, |
| 153 const String& name, | 153 const String& name, |
| 154 ExceptionState& exceptionState) { | 154 ExceptionState& exceptionState) { |
| 155 return deleteDatabaseInternal(scriptState, name, exceptionState, false); |
| 156 } |
| 157 |
| 158 IDBOpenDBRequest* IDBFactory::closeConnectionsAndDeleteDatabase( |
| 159 ScriptState* scriptState, |
| 160 const String& name, |
| 161 ExceptionState& exceptionState) { |
| 162 return deleteDatabaseInternal(scriptState, name, exceptionState, true); |
| 163 } |
| 164 |
| 165 IDBOpenDBRequest* IDBFactory::deleteDatabaseInternal( |
| 166 ScriptState* scriptState, |
| 167 const String& name, |
| 168 ExceptionState& exceptionState, |
| 169 bool forceClose) { |
| 155 IDB_TRACE("IDBFactory::deleteDatabase"); | 170 IDB_TRACE("IDBFactory::deleteDatabase"); |
| 156 IDBDatabase::recordApiCallsHistogram(IDBDeleteDatabaseCall); | 171 IDBDatabase::recordApiCallsHistogram(IDBDeleteDatabaseCall); |
| 157 if (!isContextValid(scriptState->getExecutionContext())) | 172 if (!isContextValid(scriptState->getExecutionContext())) |
| 158 return nullptr; | 173 return nullptr; |
| 159 if (!scriptState->getExecutionContext() | 174 if (!scriptState->getExecutionContext() |
| 160 ->getSecurityOrigin() | 175 ->getSecurityOrigin() |
| 161 ->canAccessDatabase()) { | 176 ->canAccessDatabase()) { |
| 162 exceptionState.throwSecurityError( | 177 exceptionState.throwSecurityError( |
| 163 "access to the Indexed Database API is denied in this context."); | 178 "access to the Indexed Database API is denied in this context."); |
| 164 return nullptr; | 179 return nullptr; |
| 165 } | 180 } |
| 166 | 181 |
| 167 IDBOpenDBRequest* request = IDBOpenDBRequest::create( | 182 IDBOpenDBRequest* request = IDBOpenDBRequest::create( |
| 168 scriptState, nullptr, 0, IDBDatabaseMetadata::DefaultVersion); | 183 scriptState, nullptr, 0, IDBDatabaseMetadata::DefaultVersion); |
| 169 | 184 |
| 170 if (!IndexedDBClient::from(scriptState->getExecutionContext()) | 185 if (!IndexedDBClient::from(scriptState->getExecutionContext()) |
| 171 ->allowIndexedDB(scriptState->getExecutionContext(), name)) { | 186 ->allowIndexedDB(scriptState->getExecutionContext(), name)) { |
| 172 request->onError( | 187 request->onError( |
| 173 DOMException::create(UnknownError, permissionDeniedErrorMessage)); | 188 DOMException::create(UnknownError, permissionDeniedErrorMessage)); |
| 174 return request; | 189 return request; |
| 175 } | 190 } |
| 176 | 191 |
| 177 Platform::current()->idbFactory()->deleteDatabase( | 192 Platform::current()->idbFactory()->deleteDatabase( |
| 178 name, request->createWebCallbacks().release(), | 193 name, request->createWebCallbacks().release(), |
| 179 WebSecurityOrigin( | 194 WebSecurityOrigin( |
| 180 scriptState->getExecutionContext()->getSecurityOrigin())); | 195 scriptState->getExecutionContext()->getSecurityOrigin()), |
| 196 forceClose); |
| 181 return request; | 197 return request; |
| 182 } | 198 } |
| 183 | 199 |
| 184 short IDBFactory::cmp(ScriptState* scriptState, | 200 short IDBFactory::cmp(ScriptState* scriptState, |
| 185 const ScriptValue& firstValue, | 201 const ScriptValue& firstValue, |
| 186 const ScriptValue& secondValue, | 202 const ScriptValue& secondValue, |
| 187 ExceptionState& exceptionState) { | 203 ExceptionState& exceptionState) { |
| 188 IDBKey* first = ScriptValue::to<IDBKey*>(scriptState->isolate(), firstValue, | 204 IDBKey* first = ScriptValue::to<IDBKey*>(scriptState->isolate(), firstValue, |
| 189 exceptionState); | 205 exceptionState); |
| 190 if (exceptionState.hadException()) | 206 if (exceptionState.hadException()) |
| (...skipping 13 matching lines...) Expand all Loading... |
| 204 if (!second->isValid()) { | 220 if (!second->isValid()) { |
| 205 exceptionState.throwDOMException(DataError, | 221 exceptionState.throwDOMException(DataError, |
| 206 IDBDatabase::notValidKeyErrorMessage); | 222 IDBDatabase::notValidKeyErrorMessage); |
| 207 return 0; | 223 return 0; |
| 208 } | 224 } |
| 209 | 225 |
| 210 return static_cast<short>(first->compare(second)); | 226 return static_cast<short>(first->compare(second)); |
| 211 } | 227 } |
| 212 | 228 |
| 213 } // namespace blink | 229 } // namespace blink |
| OLD | NEW |