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

Side by Side Diff: content/browser/in_process_webkit/indexed_db_dispatcher_host.cc

Issue 8202003: IndexedDB: Update calls to and implementations of WebIDBFactory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 9 years, 1 month 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 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/in_process_webkit/indexed_db_dispatcher_host.h" 5 #include "content/browser/in_process_webkit/indexed_db_dispatcher_host.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "content/browser/browser_thread.h" 10 #include "content/browser/browser_thread.h"
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 // TODO(jorlow): This doesn't support file:/// urls properly. We probably need 203 // TODO(jorlow): This doesn't support file:/// urls properly. We probably need
204 // to add some toString method to WebSecurityOrigin that doesn't 204 // to add some toString method to WebSecurityOrigin that doesn't
205 // return null for them. Look at 205 // return null for them. Look at
206 // DatabaseUtil::GetOriginFromIdentifier. 206 // DatabaseUtil::GetOriginFromIdentifier.
207 WebSecurityOrigin origin( 207 WebSecurityOrigin origin(
208 WebSecurityOrigin::createFromDatabaseIdentifier(params.origin)); 208 WebSecurityOrigin::createFromDatabaseIdentifier(params.origin));
209 GURL origin_url(origin.toString()); 209 GURL origin_url(origin.toString());
210 210
211 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); 211 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT));
212 212
213 WebKit::WebIDBFactory::BackingStoreType backingStoreType =
214 WebKit::WebIDBFactory::LevelDBBackingStore;
215
216 if (CommandLine::ForCurrentProcess()->HasSwitch(
217 switches::kSQLiteIndexedDatabase)) {
218 backingStoreType = WebKit::WebIDBFactory::SQLiteBackingStore;
219 }
220
221 // TODO(dgrogan): Delete this magic constant once we've removed sqlite.
222 static const uint64 kIncognitoSqliteBackendQuota = 50 * 1024 * 1024;
223
224 Context()->GetIDBFactory()->getDatabaseNames( 213 Context()->GetIDBFactory()->getDatabaseNames(
225 new IndexedDBCallbacks<WebDOMStringList>(this, params.response_id), 214 new IndexedDBCallbacks<WebDOMStringList>(this, params.response_id),
226 origin, NULL, webkit_glue::FilePathToWebString(indexed_db_path), 215 origin, NULL, webkit_glue::FilePathToWebString(indexed_db_path));
227 kIncognitoSqliteBackendQuota, backingStoreType);
228 } 216 }
229 217
230 void IndexedDBDispatcherHost::OnIDBFactoryOpen( 218 void IndexedDBDispatcherHost::OnIDBFactoryOpen(
231 const IndexedDBHostMsg_FactoryOpen_Params& params) { 219 const IndexedDBHostMsg_FactoryOpen_Params& params) {
232 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); 220 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT));
233 FilePath base_path = webkit_context_->data_path(); 221 FilePath base_path = webkit_context_->data_path();
234 FilePath indexed_db_path; 222 FilePath indexed_db_path;
235 if (!base_path.empty()) { 223 if (!base_path.empty()) {
236 indexed_db_path = base_path.Append( 224 indexed_db_path = base_path.Append(
237 IndexedDBContext::kIndexedDBDirectory); 225 IndexedDBContext::kIndexedDBDirectory);
238 } 226 }
239 227
240 // TODO(jorlow): This doesn't support file:/// urls properly. We probably need 228 // TODO(jorlow): This doesn't support file:/// urls properly. We probably need
241 // to add some toString method to WebSecurityOrigin that doesn't 229 // to add some toString method to WebSecurityOrigin that doesn't
242 // return null for them. Look at 230 // return null for them. Look at
243 // DatabaseUtil::GetOriginFromIdentifier. 231 // DatabaseUtil::GetOriginFromIdentifier.
244 WebSecurityOrigin origin( 232 WebSecurityOrigin origin(
245 WebSecurityOrigin::createFromDatabaseIdentifier(params.origin)); 233 WebSecurityOrigin::createFromDatabaseIdentifier(params.origin));
246 GURL origin_url(origin.toString()); 234 GURL origin_url(origin.toString());
247 235
248 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); 236 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT));
249 237
250 WebKit::WebIDBFactory::BackingStoreType backingStoreType =
251 WebKit::WebIDBFactory::LevelDBBackingStore;
252
253 if (CommandLine::ForCurrentProcess()->HasSwitch(
254 switches::kSQLiteIndexedDatabase)) {
255 backingStoreType = WebKit::WebIDBFactory::SQLiteBackingStore;
256 }
257
258 // TODO(dgrogan): Delete this magic constant once we've removed sqlite.
259 static const uint64 kIncognitoSqliteBackendQuota = 50 * 1024 * 1024;
260
261 // TODO(dgrogan): Don't let a non-existing database be opened (and therefore 238 // TODO(dgrogan): Don't let a non-existing database be opened (and therefore
262 // created) if this origin is already over quota. 239 // created) if this origin is already over quota.
263 Context()->GetIDBFactory()->open( 240 Context()->GetIDBFactory()->open(
264 params.name, 241 params.name,
265 new IndexedDBCallbacks<WebIDBDatabase>(this, params.response_id, 242 new IndexedDBCallbacks<WebIDBDatabase>(this, params.response_id,
266 origin_url), 243 origin_url),
267 origin, NULL, webkit_glue::FilePathToWebString(indexed_db_path), 244 origin, NULL, webkit_glue::FilePathToWebString(indexed_db_path));
268 kIncognitoSqliteBackendQuota, backingStoreType);
269 } 245 }
270 246
271 void IndexedDBDispatcherHost::OnIDBFactoryDeleteDatabase( 247 void IndexedDBDispatcherHost::OnIDBFactoryDeleteDatabase(
272 const IndexedDBHostMsg_FactoryDeleteDatabase_Params& params) { 248 const IndexedDBHostMsg_FactoryDeleteDatabase_Params& params) {
273 FilePath base_path = webkit_context_->data_path(); 249 FilePath base_path = webkit_context_->data_path();
274 FilePath indexed_db_path; 250 FilePath indexed_db_path;
275 if (!base_path.empty()) { 251 if (!base_path.empty()) {
276 indexed_db_path = base_path.Append( 252 indexed_db_path = base_path.Append(
277 IndexedDBContext::kIndexedDBDirectory); 253 IndexedDBContext::kIndexedDBDirectory);
278 } 254 }
(...skipping 811 matching lines...) Expand 10 before | Expand all | Expand 10 after
1090 } 1066 }
1091 idb_transaction->didCompleteTaskEvents(); 1067 idb_transaction->didCompleteTaskEvents();
1092 } 1068 }
1093 1069
1094 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnDestroyed( 1070 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnDestroyed(
1095 int32 object_id) { 1071 int32 object_id) {
1096 transaction_size_map_.erase(object_id); 1072 transaction_size_map_.erase(object_id);
1097 transaction_url_map_.erase(object_id); 1073 transaction_url_map_.erase(object_id);
1098 parent_->DestroyObject(&map_, object_id); 1074 parent_->DestroyObject(&map_, object_id);
1099 } 1075 }
OLDNEW
« no previous file with comments | « content/browser/in_process_webkit/indexed_db_browsertest.cc ('k') | content/public/common/content_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698