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

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

Issue 1832553002: IndexedDB: Pass url::Origin rather than GURL over IPC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@origin-wdb
Patch Set: Rebased Created 4 years, 8 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
« no previous file with comments | « content/browser/bad_message.h ('k') | content/browser/indexed_db/indexed_db_factory.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/indexed_db/indexed_db_dispatcher_host.h" 5 #include "content/browser/indexed_db/indexed_db_dispatcher_host.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 26 matching lines...) Expand all
37 #include "storage/browser/quota/quota_manager_proxy.h" 37 #include "storage/browser/quota/quota_manager_proxy.h"
38 #include "storage/common/database/database_identifier.h" 38 #include "storage/common/database/database_identifier.h"
39 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBDatabaseExc eption.h" 39 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBDatabaseExc eption.h"
40 #include "url/gurl.h" 40 #include "url/gurl.h"
41 41
42 using storage::DatabaseUtil; 42 using storage::DatabaseUtil;
43 using blink::WebIDBKey; 43 using blink::WebIDBKey;
44 44
45 namespace content { 45 namespace content {
46 46
47 namespace {
48
49 bool IsValidOrigin(const url::Origin& origin) {
50 return !origin.unique();
51 }
52
53 } // namespace
54
47 IndexedDBDispatcherHost::IndexedDBDispatcherHost( 55 IndexedDBDispatcherHost::IndexedDBDispatcherHost(
48 int ipc_process_id, 56 int ipc_process_id,
49 net::URLRequestContextGetter* request_context_getter, 57 net::URLRequestContextGetter* request_context_getter,
50 IndexedDBContextImpl* indexed_db_context, 58 IndexedDBContextImpl* indexed_db_context,
51 ChromeBlobStorageContext* blob_storage_context) 59 ChromeBlobStorageContext* blob_storage_context)
52 : BrowserMessageFilter(IndexedDBMsgStart), 60 : BrowserMessageFilter(IndexedDBMsgStart),
53 request_context_getter_(request_context_getter), 61 request_context_getter_(request_context_getter),
54 request_context_(NULL), 62 request_context_(NULL),
55 indexed_db_context_(indexed_db_context), 63 indexed_db_context_(indexed_db_context),
56 blob_storage_context_(blob_storage_context), 64 blob_storage_context_(blob_storage_context),
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 idb_store_metadata.indexes.push_back(idb_index_metadata); 312 idb_store_metadata.indexes.push_back(idb_index_metadata);
305 } 313 }
306 metadata.object_stores.push_back(idb_store_metadata); 314 metadata.object_stores.push_back(idb_store_metadata);
307 } 315 }
308 return metadata; 316 return metadata;
309 } 317 }
310 318
311 void IndexedDBDispatcherHost::OnIDBFactoryGetDatabaseNames( 319 void IndexedDBDispatcherHost::OnIDBFactoryGetDatabaseNames(
312 const IndexedDBHostMsg_FactoryGetDatabaseNames_Params& params) { 320 const IndexedDBHostMsg_FactoryGetDatabaseNames_Params& params) {
313 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); 321 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread());
322
323 if (!IsValidOrigin(params.origin)) {
324 bad_message::ReceivedBadMessage(this, bad_message::IDBDH_INVALID_ORIGIN);
Charlie Reis 2016/04/13 20:21:07 You're using the same value in multiple places, wh
jsbell 2016/04/13 21:52:45 Yeah, this would only happen if (1) we've got a bu
325 return;
326 }
327
314 base::FilePath indexed_db_path = indexed_db_context_->data_path(); 328 base::FilePath indexed_db_path = indexed_db_context_->data_path();
315
316 context()->GetIDBFactory()->GetDatabaseNames( 329 context()->GetIDBFactory()->GetDatabaseNames(
317 new IndexedDBCallbacks(this, params.ipc_thread_id, 330 new IndexedDBCallbacks(this, params.ipc_thread_id,
318 params.ipc_callbacks_id), 331 params.ipc_callbacks_id),
319 params.origin, indexed_db_path, request_context_); 332 params.origin, indexed_db_path, request_context_);
320 } 333 }
321 334
322 void IndexedDBDispatcherHost::OnIDBFactoryOpen( 335 void IndexedDBDispatcherHost::OnIDBFactoryOpen(
323 const IndexedDBHostMsg_FactoryOpen_Params& params) { 336 const IndexedDBHostMsg_FactoryOpen_Params& params) {
324 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); 337 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread());
338
339 if (!IsValidOrigin(params.origin)) {
340 bad_message::ReceivedBadMessage(this, bad_message::IDBDH_INVALID_ORIGIN);
341 return;
342 }
343
325 base::TimeTicks begin_time = base::TimeTicks::Now(); 344 base::TimeTicks begin_time = base::TimeTicks::Now();
326 base::FilePath indexed_db_path = indexed_db_context_->data_path(); 345 base::FilePath indexed_db_path = indexed_db_context_->data_path();
327 346
328 int64_t host_transaction_id = HostTransactionId(params.transaction_id); 347 int64_t host_transaction_id = HostTransactionId(params.transaction_id);
329 348
330 // TODO(dgrogan): Don't let a non-existing database be opened (and therefore 349 // TODO(dgrogan): Don't let a non-existing database be opened (and therefore
331 // created) if this origin is already over quota. 350 // created) if this origin is already over quota.
332 scoped_refptr<IndexedDBCallbacks> callbacks = new IndexedDBCallbacks( 351 scoped_refptr<IndexedDBCallbacks> callbacks = new IndexedDBCallbacks(
333 this, params.ipc_thread_id, params.ipc_callbacks_id, 352 this, params.ipc_thread_id, params.ipc_callbacks_id,
334 params.ipc_database_callbacks_id, host_transaction_id, params.origin); 353 params.ipc_database_callbacks_id, host_transaction_id,
354 GURL(params.origin.Serialize()));
335 callbacks->SetConnectionOpenStartTime(begin_time); 355 callbacks->SetConnectionOpenStartTime(begin_time);
336 scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks = 356 scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks =
337 new IndexedDBDatabaseCallbacks( 357 new IndexedDBDatabaseCallbacks(
338 this, params.ipc_thread_id, params.ipc_database_callbacks_id); 358 this, params.ipc_thread_id, params.ipc_database_callbacks_id);
339 IndexedDBPendingConnection connection(callbacks, 359 IndexedDBPendingConnection connection(callbacks,
340 database_callbacks, 360 database_callbacks,
341 ipc_process_id_, 361 ipc_process_id_,
342 host_transaction_id, 362 host_transaction_id,
343 params.version); 363 params.version);
344 DCHECK(request_context_); 364 DCHECK(request_context_);
345 context()->GetIDBFactory()->Open(params.name, connection, request_context_, 365 context()->GetIDBFactory()->Open(params.name, connection, request_context_,
346 params.origin, indexed_db_path); 366 params.origin, indexed_db_path);
347 } 367 }
348 368
349 void IndexedDBDispatcherHost::OnIDBFactoryDeleteDatabase( 369 void IndexedDBDispatcherHost::OnIDBFactoryDeleteDatabase(
350 const IndexedDBHostMsg_FactoryDeleteDatabase_Params& params) { 370 const IndexedDBHostMsg_FactoryDeleteDatabase_Params& params) {
351 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); 371 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread());
372
373 if (!IsValidOrigin(params.origin)) {
374 bad_message::ReceivedBadMessage(this, bad_message::IDBDH_INVALID_ORIGIN);
375 return;
376 }
377
352 base::FilePath indexed_db_path = indexed_db_context_->data_path(); 378 base::FilePath indexed_db_path = indexed_db_context_->data_path();
353 DCHECK(request_context_); 379 DCHECK(request_context_);
354 context()->GetIDBFactory()->DeleteDatabase( 380 context()->GetIDBFactory()->DeleteDatabase(
355 params.name, request_context_, 381 params.name, request_context_,
356 new IndexedDBCallbacks(this, params.ipc_thread_id, 382 new IndexedDBCallbacks(this, params.ipc_thread_id,
357 params.ipc_callbacks_id), 383 params.ipc_callbacks_id),
358 params.origin, indexed_db_path); 384 params.origin, indexed_db_path);
359 } 385 }
360 386
361 // OnPutHelper exists only to allow us to hop threads while holding a reference 387 // OnPutHelper exists only to allow us to hop threads while holding a reference
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after
1015 DLOG(ERROR) << "Unable to reset prefetch"; 1041 DLOG(ERROR) << "Unable to reset prefetch";
1016 } 1042 }
1017 1043
1018 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDestroyed( 1044 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDestroyed(
1019 int32_t ipc_object_id) { 1045 int32_t ipc_object_id) {
1020 DCHECK(parent_->context()->TaskRunner()->RunsTasksOnCurrentThread()); 1046 DCHECK(parent_->context()->TaskRunner()->RunsTasksOnCurrentThread());
1021 parent_->DestroyObject(&map_, ipc_object_id); 1047 parent_->DestroyObject(&map_, ipc_object_id);
1022 } 1048 }
1023 1049
1024 } // namespace content 1050 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/bad_message.h ('k') | content/browser/indexed_db/indexed_db_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698