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

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

Issue 2320213004: Port IndexedDB open() and database callbacks to Mojo. (Closed)
Patch Set: Make DatabaseClient an associated interface. Created 4 years, 3 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 // 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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 message.type() == IndexedDBHostMsg_AckReceivedBlobs::ID)); 126 message.type() == IndexedDBHostMsg_AckReceivedBlobs::ID));
127 127
128 bool handled = database_dispatcher_host_->OnMessageReceived(message) || 128 bool handled = database_dispatcher_host_->OnMessageReceived(message) ||
129 cursor_dispatcher_host_->OnMessageReceived(message); 129 cursor_dispatcher_host_->OnMessageReceived(message);
130 130
131 if (!handled) { 131 if (!handled) {
132 handled = true; 132 handled = true;
133 IPC_BEGIN_MESSAGE_MAP(IndexedDBDispatcherHost, message) 133 IPC_BEGIN_MESSAGE_MAP(IndexedDBDispatcherHost, message)
134 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_FactoryGetDatabaseNames, 134 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_FactoryGetDatabaseNames,
135 OnIDBFactoryGetDatabaseNames) 135 OnIDBFactoryGetDatabaseNames)
136 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_FactoryOpen, OnIDBFactoryOpen)
137 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_FactoryDeleteDatabase, 136 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_FactoryDeleteDatabase,
138 OnIDBFactoryDeleteDatabase) 137 OnIDBFactoryDeleteDatabase)
139 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_AckReceivedBlobs, OnAckReceivedBlobs) 138 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_AckReceivedBlobs, OnAckReceivedBlobs)
140 IPC_MESSAGE_UNHANDLED(handled = false) 139 IPC_MESSAGE_UNHANDLED(handled = false)
141 IPC_END_MESSAGE_MAP() 140 IPC_END_MESSAGE_MAP()
142 } 141 }
143 return handled; 142 return handled;
144 } 143 }
145 144
146 int32_t IndexedDBDispatcherHost::Add(IndexedDBCursor* cursor) { 145 int32_t IndexedDBDispatcherHost::Add(IndexedDBCursor* cursor) {
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 return; 315 return;
317 } 316 }
318 317
319 base::FilePath indexed_db_path = indexed_db_context_->data_path(); 318 base::FilePath indexed_db_path = indexed_db_context_->data_path();
320 context()->GetIDBFactory()->GetDatabaseNames( 319 context()->GetIDBFactory()->GetDatabaseNames(
321 new IndexedDBCallbacks(this, params.ipc_thread_id, 320 new IndexedDBCallbacks(this, params.ipc_thread_id,
322 params.ipc_callbacks_id), 321 params.ipc_callbacks_id),
323 params.origin, indexed_db_path, request_context_getter_); 322 params.origin, indexed_db_path, request_context_getter_);
324 } 323 }
325 324
326 void IndexedDBDispatcherHost::OnIDBFactoryOpen(
327 const IndexedDBHostMsg_FactoryOpen_Params& params) {
328 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread());
329
330 if (!IsValidOrigin(params.origin)) {
331 bad_message::ReceivedBadMessage(this, bad_message::IDBDH_INVALID_ORIGIN);
332 return;
333 }
334
335 base::TimeTicks begin_time = base::TimeTicks::Now();
336 base::FilePath indexed_db_path = indexed_db_context_->data_path();
337
338 int64_t host_transaction_id = HostTransactionId(params.transaction_id);
339
340 // TODO(dgrogan): Don't let a non-existing database be opened (and therefore
341 // created) if this origin is already over quota.
342 scoped_refptr<IndexedDBCallbacks> callbacks = new IndexedDBCallbacks(
343 this, params.ipc_thread_id, params.ipc_callbacks_id,
344 params.ipc_database_callbacks_id, host_transaction_id, params.origin);
345 callbacks->SetConnectionOpenStartTime(begin_time);
346 scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks =
347 new IndexedDBDatabaseCallbacks(
348 this, params.ipc_thread_id, params.ipc_database_callbacks_id);
349 std::unique_ptr<IndexedDBPendingConnection> connection =
350 base::MakeUnique<IndexedDBPendingConnection>(
351 callbacks, database_callbacks, ipc_process_id_, host_transaction_id,
352 params.version);
353 DCHECK(request_context_getter_);
354 context()->GetIDBFactory()->Open(params.name, std::move(connection),
355 request_context_getter_, params.origin,
356 indexed_db_path);
357 }
358
359 void IndexedDBDispatcherHost::OnIDBFactoryDeleteDatabase( 325 void IndexedDBDispatcherHost::OnIDBFactoryDeleteDatabase(
360 const IndexedDBHostMsg_FactoryDeleteDatabase_Params& params) { 326 const IndexedDBHostMsg_FactoryDeleteDatabase_Params& params) {
361 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); 327 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread());
362 328
363 if (!IsValidOrigin(params.origin)) { 329 if (!IsValidOrigin(params.origin)) {
364 bad_message::ReceivedBadMessage(this, bad_message::IDBDH_INVALID_ORIGIN); 330 bad_message::ReceivedBadMessage(this, bad_message::IDBDH_INVALID_ORIGIN);
365 return; 331 return;
366 } 332 }
367 333
368 base::FilePath indexed_db_path = indexed_db_context_->data_path(); 334 base::FilePath indexed_db_path = indexed_db_context_->data_path();
(...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after
1057 DLOG(ERROR) << "Unable to reset prefetch"; 1023 DLOG(ERROR) << "Unable to reset prefetch";
1058 } 1024 }
1059 1025
1060 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDestroyed( 1026 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDestroyed(
1061 int32_t ipc_object_id) { 1027 int32_t ipc_object_id) {
1062 DCHECK(parent_->context()->TaskRunner()->RunsTasksOnCurrentThread()); 1028 DCHECK(parent_->context()->TaskRunner()->RunsTasksOnCurrentThread());
1063 parent_->DestroyObject(&map_, ipc_object_id); 1029 parent_->DestroyObject(&map_, ipc_object_id);
1064 } 1030 }
1065 1031
1066 } // namespace content 1032 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/indexed_db/indexed_db_dispatcher_host.h ('k') | content/browser/indexed_db/indexed_db_factory_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698