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

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

Issue 2370643004: Port messages sent by WebIDBFactoryImpl to Mojo. (Closed)
Patch Set: Address last nits and fix leaks in unit tests. Created 4 years, 2 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
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 20 matching lines...) Expand all
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/IDBKey.h" 38 #include "modules/indexeddb/IDBKey.h"
39 #include "modules/indexeddb/IDBTracing.h" 39 #include "modules/indexeddb/IDBTracing.h"
40 #include "modules/indexeddb/IndexedDBClient.h" 40 #include "modules/indexeddb/IndexedDBClient.h"
41 #include "modules/indexeddb/WebIDBCallbacksImpl.h"
42 #include "modules/indexeddb/WebIDBDatabaseCallbacksImpl.h"
43 #include "platform/Histogram.h" 41 #include "platform/Histogram.h"
44 #include "platform/weborigin/SecurityOrigin.h" 42 #include "platform/weborigin/SecurityOrigin.h"
45 #include "public/platform/Platform.h" 43 #include "public/platform/Platform.h"
46 #include "public/platform/WebSecurityOrigin.h" 44 #include "public/platform/WebSecurityOrigin.h"
45 #include "public/platform/modules/indexeddb/WebIDBDatabaseCallbacks.h"
47 #include "public/platform/modules/indexeddb/WebIDBFactory.h" 46 #include "public/platform/modules/indexeddb/WebIDBFactory.h"
48 #include <memory> 47 #include <memory>
49 48
50 namespace blink { 49 namespace blink {
51 50
52 static const char permissionDeniedErrorMessage[] = 51 static const char permissionDeniedErrorMessage[] =
53 "The user denied permission to access the database."; 52 "The user denied permission to access the database.";
54 53
55 IDBFactory::IDBFactory() {} 54 IDBFactory::IDBFactory() {}
56 55
(...skipping 24 matching lines...) Expand all
81 80
82 if (!IndexedDBClient::from(scriptState->getExecutionContext()) 81 if (!IndexedDBClient::from(scriptState->getExecutionContext())
83 ->allowIndexedDB(scriptState->getExecutionContext(), 82 ->allowIndexedDB(scriptState->getExecutionContext(),
84 "Database Listing")) { 83 "Database Listing")) {
85 request->onError( 84 request->onError(
86 DOMException::create(UnknownError, permissionDeniedErrorMessage)); 85 DOMException::create(UnknownError, permissionDeniedErrorMessage));
87 return request; 86 return request;
88 } 87 }
89 88
90 Platform::current()->idbFactory()->getDatabaseNames( 89 Platform::current()->idbFactory()->getDatabaseNames(
91 WebIDBCallbacksImpl::create(request).release(), 90 request->createWebCallbacks().release(),
92 WebSecurityOrigin( 91 WebSecurityOrigin(
93 scriptState->getExecutionContext()->getSecurityOrigin())); 92 scriptState->getExecutionContext()->getSecurityOrigin()));
94 return request; 93 return request;
95 } 94 }
96 95
97 IDBOpenDBRequest* IDBFactory::open(ScriptState* scriptState, 96 IDBOpenDBRequest* IDBFactory::open(ScriptState* scriptState,
98 const String& name, 97 const String& name,
99 unsigned long long version, 98 unsigned long long version,
100 ExceptionState& exceptionState) { 99 ExceptionState& exceptionState) {
101 IDB_TRACE("IDBFactory::open"); 100 IDB_TRACE("IDBFactory::open");
(...skipping 26 matching lines...) Expand all
128 scriptState, databaseCallbacks, transactionId, version); 127 scriptState, databaseCallbacks, transactionId, version);
129 128
130 if (!IndexedDBClient::from(scriptState->getExecutionContext()) 129 if (!IndexedDBClient::from(scriptState->getExecutionContext())
131 ->allowIndexedDB(scriptState->getExecutionContext(), name)) { 130 ->allowIndexedDB(scriptState->getExecutionContext(), name)) {
132 request->onError( 131 request->onError(
133 DOMException::create(UnknownError, permissionDeniedErrorMessage)); 132 DOMException::create(UnknownError, permissionDeniedErrorMessage));
134 return request; 133 return request;
135 } 134 }
136 135
137 Platform::current()->idbFactory()->open( 136 Platform::current()->idbFactory()->open(
138 name, version, transactionId, 137 name, version, transactionId, request->createWebCallbacks().release(),
139 WebIDBCallbacksImpl::create(request).release(), 138 databaseCallbacks->createWebCallbacks().release(),
140 WebIDBDatabaseCallbacksImpl::create(databaseCallbacks).release(),
141 WebSecurityOrigin( 139 WebSecurityOrigin(
142 scriptState->getExecutionContext()->getSecurityOrigin())); 140 scriptState->getExecutionContext()->getSecurityOrigin()));
143 return request; 141 return request;
144 } 142 }
145 143
146 IDBOpenDBRequest* IDBFactory::open(ScriptState* scriptState, 144 IDBOpenDBRequest* IDBFactory::open(ScriptState* scriptState,
147 const String& name, 145 const String& name,
148 ExceptionState& exceptionState) { 146 ExceptionState& exceptionState) {
149 IDB_TRACE("IDBFactory::open"); 147 IDB_TRACE("IDBFactory::open");
150 return openInternal(scriptState, name, IDBDatabaseMetadata::NoVersion, 148 return openInternal(scriptState, name, IDBDatabaseMetadata::NoVersion,
(...skipping 19 matching lines...) Expand all
170 scriptState, nullptr, 0, IDBDatabaseMetadata::DefaultVersion); 168 scriptState, nullptr, 0, IDBDatabaseMetadata::DefaultVersion);
171 169
172 if (!IndexedDBClient::from(scriptState->getExecutionContext()) 170 if (!IndexedDBClient::from(scriptState->getExecutionContext())
173 ->allowIndexedDB(scriptState->getExecutionContext(), name)) { 171 ->allowIndexedDB(scriptState->getExecutionContext(), name)) {
174 request->onError( 172 request->onError(
175 DOMException::create(UnknownError, permissionDeniedErrorMessage)); 173 DOMException::create(UnknownError, permissionDeniedErrorMessage));
176 return request; 174 return request;
177 } 175 }
178 176
179 Platform::current()->idbFactory()->deleteDatabase( 177 Platform::current()->idbFactory()->deleteDatabase(
180 name, WebIDBCallbacksImpl::create(request).release(), 178 name, request->createWebCallbacks().release(),
181 WebSecurityOrigin( 179 WebSecurityOrigin(
182 scriptState->getExecutionContext()->getSecurityOrigin())); 180 scriptState->getExecutionContext()->getSecurityOrigin()));
183 return request; 181 return request;
184 } 182 }
185 183
186 short IDBFactory::cmp(ScriptState* scriptState, 184 short IDBFactory::cmp(ScriptState* scriptState,
187 const ScriptValue& firstValue, 185 const ScriptValue& firstValue,
188 const ScriptValue& secondValue, 186 const ScriptValue& secondValue,
189 ExceptionState& exceptionState) { 187 ExceptionState& exceptionState) {
190 IDBKey* first = ScriptValue::to<IDBKey*>(scriptState->isolate(), firstValue, 188 IDBKey* first = ScriptValue::to<IDBKey*>(scriptState->isolate(), firstValue,
(...skipping 15 matching lines...) Expand all
206 if (!second->isValid()) { 204 if (!second->isValid()) {
207 exceptionState.throwDOMException(DataError, 205 exceptionState.throwDOMException(DataError,
208 IDBDatabase::notValidKeyErrorMessage); 206 IDBDatabase::notValidKeyErrorMessage);
209 return 0; 207 return 0;
210 } 208 }
211 209
212 return static_cast<short>(first->compare(second)); 210 return static_cast<short>(first->compare(second));
213 } 211 }
214 212
215 } // namespace blink 213 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698