OLD | NEW |
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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 } | 117 } |
118 | 118 |
119 base::TaskRunner* IndexedDBDispatcherHost::OverrideTaskRunnerForMessage( | 119 base::TaskRunner* IndexedDBDispatcherHost::OverrideTaskRunnerForMessage( |
120 const IPC::Message& message) { | 120 const IPC::Message& message) { |
121 if (IPC_MESSAGE_CLASS(message) == IndexedDBMsgStart && | 121 if (IPC_MESSAGE_CLASS(message) == IndexedDBMsgStart && |
122 message.type() != IndexedDBHostMsg_DatabasePut::ID) | 122 message.type() != IndexedDBHostMsg_DatabasePut::ID) |
123 return indexed_db_context_->TaskRunner(); | 123 return indexed_db_context_->TaskRunner(); |
124 return NULL; | 124 return NULL; |
125 } | 125 } |
126 | 126 |
127 bool IndexedDBDispatcherHost::OnMessageReceived(const IPC::Message& message, | 127 bool IndexedDBDispatcherHost::OnMessageReceived(const IPC::Message& message) { |
128 bool* message_was_ok) { | |
129 if (IPC_MESSAGE_CLASS(message) != IndexedDBMsgStart) | 128 if (IPC_MESSAGE_CLASS(message) != IndexedDBMsgStart) |
130 return false; | 129 return false; |
131 | 130 |
132 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread() || | 131 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread() || |
133 message.type() == IndexedDBHostMsg_DatabasePut::ID); | 132 message.type() == IndexedDBHostMsg_DatabasePut::ID); |
134 | 133 |
135 bool handled = | 134 bool handled = database_dispatcher_host_->OnMessageReceived(message) || |
136 database_dispatcher_host_->OnMessageReceived(message, message_was_ok) || | 135 cursor_dispatcher_host_->OnMessageReceived(message); |
137 cursor_dispatcher_host_->OnMessageReceived(message, message_was_ok); | |
138 | 136 |
139 if (!handled) { | 137 if (!handled) { |
140 handled = true; | 138 handled = true; |
141 IPC_BEGIN_MESSAGE_MAP_EX(IndexedDBDispatcherHost, message, *message_was_ok) | 139 IPC_BEGIN_MESSAGE_MAP(IndexedDBDispatcherHost, message) |
142 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_FactoryGetDatabaseNames, | 140 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_FactoryGetDatabaseNames, |
143 OnIDBFactoryGetDatabaseNames) | 141 OnIDBFactoryGetDatabaseNames) |
144 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_FactoryOpen, OnIDBFactoryOpen) | 142 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_FactoryOpen, OnIDBFactoryOpen) |
145 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_FactoryDeleteDatabase, | 143 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_FactoryDeleteDatabase, |
146 OnIDBFactoryDeleteDatabase) | 144 OnIDBFactoryDeleteDatabase) |
147 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_AckReceivedBlobs, OnAckReceivedBlobs) | 145 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_AckReceivedBlobs, OnAckReceivedBlobs) |
148 IPC_MESSAGE_UNHANDLED(handled = false) | 146 IPC_MESSAGE_UNHANDLED(handled = false) |
149 IPC_END_MESSAGE_MAP() | 147 IPC_END_MESSAGE_MAP() |
150 } | 148 } |
151 return handled; | 149 return handled; |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 iter++) { | 453 iter++) { |
456 IndexedDBConnection* connection = map_.Lookup(iter->first); | 454 IndexedDBConnection* connection = map_.Lookup(iter->first); |
457 if (connection && connection->IsConnected()) { | 455 if (connection && connection->IsConnected()) { |
458 connection->Close(); | 456 connection->Close(); |
459 parent_->Context()->ConnectionClosed(iter->second, connection); | 457 parent_->Context()->ConnectionClosed(iter->second, connection); |
460 } | 458 } |
461 } | 459 } |
462 } | 460 } |
463 | 461 |
464 bool IndexedDBDispatcherHost::DatabaseDispatcherHost::OnMessageReceived( | 462 bool IndexedDBDispatcherHost::DatabaseDispatcherHost::OnMessageReceived( |
465 const IPC::Message& message, | 463 const IPC::Message& message) { |
466 bool* msg_is_ok) { | |
467 | 464 |
468 DCHECK( | 465 DCHECK( |
469 (message.type() == IndexedDBHostMsg_DatabasePut::ID) || | 466 (message.type() == IndexedDBHostMsg_DatabasePut::ID) || |
470 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); | 467 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
471 | 468 |
472 bool handled = true; | 469 bool handled = true; |
473 IPC_BEGIN_MESSAGE_MAP_EX( | 470 IPC_BEGIN_MESSAGE_MAP( |
474 IndexedDBDispatcherHost::DatabaseDispatcherHost, message, *msg_is_ok) | 471 IndexedDBDispatcherHost::DatabaseDispatcherHost, message) |
475 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCreateObjectStore, | 472 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCreateObjectStore, |
476 OnCreateObjectStore) | 473 OnCreateObjectStore) |
477 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDeleteObjectStore, | 474 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDeleteObjectStore, |
478 OnDeleteObjectStore) | 475 OnDeleteObjectStore) |
479 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCreateTransaction, | 476 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCreateTransaction, |
480 OnCreateTransaction) | 477 OnCreateTransaction) |
481 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseClose, OnClose) | 478 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseClose, OnClose) |
482 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDestroyed, OnDestroyed) | 479 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDestroyed, OnDestroyed) |
483 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseGet, OnGet) | 480 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseGet, OnGet) |
484 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabasePut, OnPutWrapper) | 481 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabasePut, OnPutWrapper) |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
875 | 872 |
876 IndexedDBDispatcherHost::CursorDispatcherHost::CursorDispatcherHost( | 873 IndexedDBDispatcherHost::CursorDispatcherHost::CursorDispatcherHost( |
877 IndexedDBDispatcherHost* parent) | 874 IndexedDBDispatcherHost* parent) |
878 : parent_(parent) { | 875 : parent_(parent) { |
879 map_.set_check_on_null_data(true); | 876 map_.set_check_on_null_data(true); |
880 } | 877 } |
881 | 878 |
882 IndexedDBDispatcherHost::CursorDispatcherHost::~CursorDispatcherHost() {} | 879 IndexedDBDispatcherHost::CursorDispatcherHost::~CursorDispatcherHost() {} |
883 | 880 |
884 bool IndexedDBDispatcherHost::CursorDispatcherHost::OnMessageReceived( | 881 bool IndexedDBDispatcherHost::CursorDispatcherHost::OnMessageReceived( |
885 const IPC::Message& message, | 882 const IPC::Message& message) { |
886 bool* msg_is_ok) { | |
887 bool handled = true; | 883 bool handled = true; |
888 IPC_BEGIN_MESSAGE_MAP_EX( | 884 IPC_BEGIN_MESSAGE_MAP( |
889 IndexedDBDispatcherHost::CursorDispatcherHost, message, *msg_is_ok) | 885 IndexedDBDispatcherHost::CursorDispatcherHost, message) |
890 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_CursorAdvance, OnAdvance) | 886 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_CursorAdvance, OnAdvance) |
891 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_CursorContinue, OnContinue) | 887 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_CursorContinue, OnContinue) |
892 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_CursorPrefetch, OnPrefetch) | 888 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_CursorPrefetch, OnPrefetch) |
893 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_CursorPrefetchReset, OnPrefetchReset) | 889 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_CursorPrefetchReset, OnPrefetchReset) |
894 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_CursorDestroyed, OnDestroyed) | 890 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_CursorDestroyed, OnDestroyed) |
895 IPC_MESSAGE_UNHANDLED(handled = false) | 891 IPC_MESSAGE_UNHANDLED(handled = false) |
896 IPC_END_MESSAGE_MAP() | 892 IPC_END_MESSAGE_MAP() |
897 | 893 |
898 DCHECK( | 894 DCHECK( |
899 !handled || | 895 !handled || |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
979 } | 975 } |
980 | 976 |
981 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDestroyed( | 977 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDestroyed( |
982 int32 ipc_object_id) { | 978 int32 ipc_object_id) { |
983 DCHECK( | 979 DCHECK( |
984 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); | 980 parent_->indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
985 parent_->DestroyObject(&map_, ipc_object_id); | 981 parent_->DestroyObject(&map_, ipc_object_id); |
986 } | 982 } |
987 | 983 |
988 } // namespace content | 984 } // namespace content |
OLD | NEW |