| 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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 | 144 |
| 145 // static | 145 // static |
| 146 InterfaceList* InterfaceList::GetInstance() { | 146 InterfaceList* InterfaceList::GetInstance() { |
| 147 return Singleton<InterfaceList>::get(); | 147 return Singleton<InterfaceList>::get(); |
| 148 } | 148 } |
| 149 | 149 |
| 150 } // namespace | 150 } // namespace |
| 151 | 151 |
| 152 Dispatcher::Dispatcher(base::ProcessHandle remote_process_handle, | 152 Dispatcher::Dispatcher(base::ProcessHandle remote_process_handle, |
| 153 GetInterfaceFunc local_get_interface) | 153 GetInterfaceFunc local_get_interface) |
| 154 : pp_module_(0), | 154 : remote_process_handle_(remote_process_handle), |
| 155 remote_process_handle_(remote_process_handle), | |
| 156 test_sink_(NULL), | 155 test_sink_(NULL), |
| 157 disallow_trusted_interfaces_(false), // TODO(brettw) make this settable. | 156 disallow_trusted_interfaces_(false), // TODO(brettw) make this settable. |
| 158 local_get_interface_(local_get_interface), | 157 local_get_interface_(local_get_interface), |
| 159 callback_tracker_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { | 158 callback_tracker_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { |
| 160 } | 159 } |
| 161 | 160 |
| 162 Dispatcher::~Dispatcher() { | 161 Dispatcher::~Dispatcher() { |
| 163 } | 162 } |
| 164 | 163 |
| 165 bool Dispatcher::InitWithChannel(MessageLoop* ipc_message_loop, | 164 bool Dispatcher::InitWithChannel(MessageLoop* ipc_message_loop, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 185 IPC_BEGIN_MESSAGE_MAP(Dispatcher, msg) | 184 IPC_BEGIN_MESSAGE_MAP(Dispatcher, msg) |
| 186 IPC_MESSAGE_FORWARD(PpapiMsg_ExecuteCallback, &callback_tracker_, | 185 IPC_MESSAGE_FORWARD(PpapiMsg_ExecuteCallback, &callback_tracker_, |
| 187 CallbackTracker::ReceiveExecuteSerializedCallback) | 186 CallbackTracker::ReceiveExecuteSerializedCallback) |
| 188 IPC_MESSAGE_UNHANDLED(handled = false) | 187 IPC_MESSAGE_UNHANDLED(handled = false) |
| 189 IPC_END_MESSAGE_MAP() | 188 IPC_END_MESSAGE_MAP() |
| 190 return handled; | 189 return handled; |
| 191 } | 190 } |
| 192 return false; | 191 return false; |
| 193 } | 192 } |
| 194 | 193 |
| 194 void Dispatcher::OnChannelError() { |
| 195 channel_.reset(); |
| 196 } |
| 197 |
| 195 // static | 198 // static |
| 196 const InterfaceProxy::Info* Dispatcher::GetPPBInterfaceInfo( | 199 const InterfaceProxy::Info* Dispatcher::GetPPBInterfaceInfo( |
| 197 const std::string& name) { | 200 const std::string& name) { |
| 198 const InterfaceList* list = InterfaceList::GetInstance(); | 201 const InterfaceList* list = InterfaceList::GetInstance(); |
| 199 InterfaceList::NameToInfo::const_iterator found = | 202 InterfaceList::NameToInfo::const_iterator found = |
| 200 list->name_to_browser_info_.find(name); | 203 list->name_to_browser_info_.find(name); |
| 201 if (found == list->name_to_browser_info_.end()) | 204 if (found == list->name_to_browser_info_.end()) |
| 202 return NULL; | 205 return NULL; |
| 203 return found->second; | 206 return found->second; |
| 204 } | 207 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 235 serialization_rules_.reset(var_serialization_rules); | 238 serialization_rules_.reset(var_serialization_rules); |
| 236 } | 239 } |
| 237 | 240 |
| 238 const void* Dispatcher::GetLocalInterface(const char* interface) { | 241 const void* Dispatcher::GetLocalInterface(const char* interface) { |
| 239 return local_get_interface_(interface); | 242 return local_get_interface_(interface); |
| 240 } | 243 } |
| 241 | 244 |
| 242 bool Dispatcher::Send(IPC::Message* msg) { | 245 bool Dispatcher::Send(IPC::Message* msg) { |
| 243 if (test_sink_) | 246 if (test_sink_) |
| 244 return test_sink_->Send(msg); | 247 return test_sink_->Send(msg); |
| 245 return channel_->Send(msg); | 248 if (channel_.get()) |
| 249 return channel_->Send(msg); |
| 250 |
| 251 // Remote side crashed, drop this message. |
| 252 delete msg; |
| 253 return false; |
| 246 } | 254 } |
| 247 | 255 |
| 248 } // namespace proxy | 256 } // namespace proxy |
| 249 } // namespace pp | 257 } // namespace pp |
| 250 | 258 |
| OLD | NEW |