OLD | NEW |
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 "ppapi/proxy/dispatcher.h" | 5 #include "ppapi/proxy/dispatcher.h" |
6 | 6 |
7 #include <string.h> // For memset. | 7 #include <string.h> // For memset. |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 | 10 |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 | 158 |
159 // static | 159 // static |
160 InterfaceList* InterfaceList::GetInstance() { | 160 InterfaceList* InterfaceList::GetInstance() { |
161 return Singleton<InterfaceList>::get(); | 161 return Singleton<InterfaceList>::get(); |
162 } | 162 } |
163 | 163 |
164 } // namespace | 164 } // namespace |
165 | 165 |
166 Dispatcher::Dispatcher(base::ProcessHandle remote_process_handle, | 166 Dispatcher::Dispatcher(base::ProcessHandle remote_process_handle, |
167 GetInterfaceFunc local_get_interface) | 167 GetInterfaceFunc local_get_interface) |
168 : remote_process_handle_(remote_process_handle), | 168 : delegate_(NULL), |
| 169 remote_process_handle_(remote_process_handle), |
169 test_sink_(NULL), | 170 test_sink_(NULL), |
170 disallow_trusted_interfaces_(false), // TODO(brettw) make this settable. | 171 disallow_trusted_interfaces_(false), // TODO(brettw) make this settable. |
171 local_get_interface_(local_get_interface), | 172 local_get_interface_(local_get_interface), |
172 callback_tracker_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { | 173 callback_tracker_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { |
173 } | 174 } |
174 | 175 |
175 Dispatcher::~Dispatcher() { | 176 Dispatcher::~Dispatcher() { |
176 } | 177 } |
177 | 178 |
178 bool Dispatcher::InitWithChannel(MessageLoop* ipc_message_loop, | 179 bool Dispatcher::InitWithChannel(Delegate* delegate, |
179 const IPC::ChannelHandle& channel_handle, | 180 const IPC::ChannelHandle& channel_handle, |
180 bool is_client, | 181 bool is_client) { |
181 base::WaitableEvent* shutdown_event) { | |
182 IPC::Channel::Mode mode = is_client ? IPC::Channel::MODE_CLIENT | 182 IPC::Channel::Mode mode = is_client ? IPC::Channel::MODE_CLIENT |
183 : IPC::Channel::MODE_SERVER; | 183 : IPC::Channel::MODE_SERVER; |
184 channel_.reset(new IPC::SyncChannel(channel_handle, mode, this, | 184 channel_.reset(new IPC::SyncChannel(channel_handle, mode, this, |
185 ipc_message_loop, false, shutdown_event)); | 185 delegate->GetIPCMessageLoop(), false, |
| 186 delegate->GetShutdownEvent())); |
186 return true; | 187 return true; |
187 } | 188 } |
188 | 189 |
189 void Dispatcher::InitWithTestSink(IPC::TestSink* test_sink) { | 190 void Dispatcher::InitWithTestSink(IPC::TestSink* test_sink) { |
190 DCHECK(!test_sink_); | 191 DCHECK(!test_sink_); |
191 test_sink_ = test_sink; | 192 test_sink_ = test_sink; |
192 } | 193 } |
193 | 194 |
194 bool Dispatcher::OnMessageReceived(const IPC::Message& msg) { | 195 bool Dispatcher::OnMessageReceived(const IPC::Message& msg) { |
195 // Control messages. | 196 // Control messages. |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 return channel_->Send(msg); | 291 return channel_->Send(msg); |
291 | 292 |
292 // Remote side crashed, drop this message. | 293 // Remote side crashed, drop this message. |
293 delete msg; | 294 delete msg; |
294 return false; | 295 return false; |
295 } | 296 } |
296 | 297 |
297 } // namespace proxy | 298 } // namespace proxy |
298 } // namespace pp | 299 } // namespace pp |
299 | 300 |
OLD | NEW |