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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/indexed_db/indexed_db_dispatcher_host.cc
diff --git a/content/browser/indexed_db/indexed_db_dispatcher_host.cc b/content/browser/indexed_db/indexed_db_dispatcher_host.cc
index 9613809a9ad01ba66f206753b51e71b5527c8f0b..56993ca12228ed34722e35f37d3ca611ba728273 100644
--- a/content/browser/indexed_db/indexed_db_dispatcher_host.cc
+++ b/content/browser/indexed_db/indexed_db_dispatcher_host.cc
@@ -44,6 +44,14 @@ using blink::WebIDBKey;
namespace content {
+namespace {
+
+bool IsValidOrigin(const url::Origin& origin) {
+ return !origin.unique();
+}
+
+} // namespace
+
IndexedDBDispatcherHost::IndexedDBDispatcherHost(
int ipc_process_id,
net::URLRequestContextGetter* request_context_getter,
@@ -311,8 +319,13 @@ IndexedDBCursor* IndexedDBDispatcherHost::GetCursorFromId(
void IndexedDBDispatcherHost::OnIDBFactoryGetDatabaseNames(
const IndexedDBHostMsg_FactoryGetDatabaseNames_Params& params) {
DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread());
- base::FilePath indexed_db_path = indexed_db_context_->data_path();
+ if (!IsValidOrigin(params.origin)) {
+ 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
+ return;
+ }
+
+ base::FilePath indexed_db_path = indexed_db_context_->data_path();
context()->GetIDBFactory()->GetDatabaseNames(
new IndexedDBCallbacks(this, params.ipc_thread_id,
params.ipc_callbacks_id),
@@ -322,6 +335,12 @@ void IndexedDBDispatcherHost::OnIDBFactoryGetDatabaseNames(
void IndexedDBDispatcherHost::OnIDBFactoryOpen(
const IndexedDBHostMsg_FactoryOpen_Params& params) {
DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread());
+
+ if (!IsValidOrigin(params.origin)) {
+ bad_message::ReceivedBadMessage(this, bad_message::IDBDH_INVALID_ORIGIN);
+ return;
+ }
+
base::TimeTicks begin_time = base::TimeTicks::Now();
base::FilePath indexed_db_path = indexed_db_context_->data_path();
@@ -331,7 +350,8 @@ void IndexedDBDispatcherHost::OnIDBFactoryOpen(
// created) if this origin is already over quota.
scoped_refptr<IndexedDBCallbacks> callbacks = new IndexedDBCallbacks(
this, params.ipc_thread_id, params.ipc_callbacks_id,
- params.ipc_database_callbacks_id, host_transaction_id, params.origin);
+ params.ipc_database_callbacks_id, host_transaction_id,
+ GURL(params.origin.Serialize()));
callbacks->SetConnectionOpenStartTime(begin_time);
scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks =
new IndexedDBDatabaseCallbacks(
@@ -349,6 +369,12 @@ void IndexedDBDispatcherHost::OnIDBFactoryOpen(
void IndexedDBDispatcherHost::OnIDBFactoryDeleteDatabase(
const IndexedDBHostMsg_FactoryDeleteDatabase_Params& params) {
DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread());
+
+ if (!IsValidOrigin(params.origin)) {
+ bad_message::ReceivedBadMessage(this, bad_message::IDBDH_INVALID_ORIGIN);
+ return;
+ }
+
base::FilePath indexed_db_path = indexed_db_context_->data_path();
DCHECK(request_context_);
context()->GetIDBFactory()->DeleteDatabase(
« 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