| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 const IPC::ChannelHandle& channel_handle, | 80 const IPC::ChannelHandle& channel_handle, |
| 81 bool is_client, | 81 bool is_client, |
| 82 base::WaitableEvent* shutdown_event) { | 82 base::WaitableEvent* shutdown_event) { |
| 83 IPC::Channel::Mode mode = is_client ? IPC::Channel::MODE_CLIENT | 83 IPC::Channel::Mode mode = is_client ? IPC::Channel::MODE_CLIENT |
| 84 : IPC::Channel::MODE_SERVER; | 84 : IPC::Channel::MODE_SERVER; |
| 85 channel_.reset(new IPC::SyncChannel(channel_handle, mode, this, | 85 channel_.reset(new IPC::SyncChannel(channel_handle, mode, this, |
| 86 ipc_message_loop, false, shutdown_event)); | 86 ipc_message_loop, false, shutdown_event)); |
| 87 return true; | 87 return true; |
| 88 } | 88 } |
| 89 | 89 |
| 90 void Dispatcher::OnMessageReceived(const IPC::Message& msg) { | 90 bool Dispatcher::OnMessageReceived(const IPC::Message& msg) { |
| 91 // Control messages. | 91 // Control messages. |
| 92 if (msg.routing_id() == MSG_ROUTING_CONTROL) { | 92 if (msg.routing_id() == MSG_ROUTING_CONTROL) { |
| 93 bool handled = true; |
| 93 IPC_BEGIN_MESSAGE_MAP(Dispatcher, msg) | 94 IPC_BEGIN_MESSAGE_MAP(Dispatcher, msg) |
| 94 IPC_MESSAGE_HANDLER(PpapiMsg_DeclareInterfaces, | 95 IPC_MESSAGE_HANDLER(PpapiMsg_DeclareInterfaces, |
| 95 OnMsgDeclareInterfaces) | 96 OnMsgDeclareInterfaces) |
| 96 IPC_MESSAGE_HANDLER(PpapiMsg_SupportsInterface, OnMsgSupportsInterface) | 97 IPC_MESSAGE_HANDLER(PpapiMsg_SupportsInterface, OnMsgSupportsInterface) |
| 97 IPC_MESSAGE_FORWARD(PpapiMsg_ExecuteCallback, &callback_tracker_, | 98 IPC_MESSAGE_FORWARD(PpapiMsg_ExecuteCallback, &callback_tracker_, |
| 98 CallbackTracker::ReceiveExecuteSerializedCallback) | 99 CallbackTracker::ReceiveExecuteSerializedCallback) |
| 100 IPC_MESSAGE_UNHANDLED(handled = false) |
| 99 IPC_END_MESSAGE_MAP() | 101 IPC_END_MESSAGE_MAP() |
| 100 return; | 102 return handled; |
| 101 } | 103 } |
| 102 | 104 |
| 103 // Interface-specific messages. | 105 // Interface-specific messages. |
| 104 if (msg.routing_id() > 0 && msg.routing_id() < INTERFACE_ID_COUNT) { | 106 if (msg.routing_id() > 0 && msg.routing_id() < INTERFACE_ID_COUNT) { |
| 105 InterfaceProxy* proxy = id_to_proxy_[msg.routing_id()]; | 107 InterfaceProxy* proxy = id_to_proxy_[msg.routing_id()]; |
| 106 if (proxy) | 108 if (proxy) |
| 107 proxy->OnMessageReceived(msg); | 109 return proxy->OnMessageReceived(msg); |
| 108 else | 110 |
| 109 NOTREACHED(); | 111 NOTREACHED(); |
| 110 // TODO(brettw): kill the plugin if it starts sending invalid messages? | 112 // TODO(brettw): kill the plugin if it starts sending invalid messages? |
| 111 } | 113 } |
| 114 |
| 115 return false; |
| 112 } | 116 } |
| 113 | 117 |
| 114 void Dispatcher::SetSerializationRules( | 118 void Dispatcher::SetSerializationRules( |
| 115 VarSerializationRules* var_serialization_rules) { | 119 VarSerializationRules* var_serialization_rules) { |
| 116 serialization_rules_.reset(var_serialization_rules); | 120 serialization_rules_.reset(var_serialization_rules); |
| 117 } | 121 } |
| 118 | 122 |
| 119 void Dispatcher::InjectProxy(InterfaceID id, | 123 void Dispatcher::InjectProxy(InterfaceID id, |
| 120 const std::string& name, | 124 const std::string& name, |
| 121 InterfaceProxy* proxy) { | 125 InterfaceProxy* proxy) { |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 if (interface_name == PPB_URLLOADERTRUSTED_INTERFACE) | 273 if (interface_name == PPB_URLLOADERTRUSTED_INTERFACE) |
| 270 return new PPB_URLLoaderTrusted_Proxy(this, interface_functions); | 274 return new PPB_URLLoaderTrusted_Proxy(this, interface_functions); |
| 271 } | 275 } |
| 272 | 276 |
| 273 return NULL; | 277 return NULL; |
| 274 } | 278 } |
| 275 | 279 |
| 276 } // namespace proxy | 280 } // namespace proxy |
| 277 } // namespace pp | 281 } // namespace pp |
| 278 | 282 |
| OLD | NEW |