| 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 <map> | 5 #include <map> |
| 6 #include <set> | 6 #include <set> |
| 7 | 7 |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 // Need to include this before most other files because it defines | 9 // Need to include this before most other files because it defines |
| 10 // IPC_MESSAGE_LOG_ENABLED. We need to use it to define | 10 // IPC_MESSAGE_LOG_ENABLED. We need to use it to define |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 public PluginDispatcher::PluginDelegate, | 59 public PluginDispatcher::PluginDelegate, |
| 60 public PluginProxyDelegate { | 60 public PluginProxyDelegate { |
| 61 public: | 61 public: |
| 62 explicit PpapiDispatcher(scoped_refptr<base::MessageLoopProxy> io_loop); | 62 explicit PpapiDispatcher(scoped_refptr<base::MessageLoopProxy> io_loop); |
| 63 | 63 |
| 64 // PluginDispatcher::PluginDelegate implementation. | 64 // PluginDispatcher::PluginDelegate implementation. |
| 65 virtual base::MessageLoopProxy* GetIPCMessageLoop() OVERRIDE; | 65 virtual base::MessageLoopProxy* GetIPCMessageLoop() OVERRIDE; |
| 66 virtual base::WaitableEvent* GetShutdownEvent() OVERRIDE; | 66 virtual base::WaitableEvent* GetShutdownEvent() OVERRIDE; |
| 67 virtual IPC::PlatformFileForTransit ShareHandleWithRemote( | 67 virtual IPC::PlatformFileForTransit ShareHandleWithRemote( |
| 68 base::PlatformFile handle, | 68 base::PlatformFile handle, |
| 69 const IPC::SyncChannel& channel, | 69 base::ProcessId peer_pid, |
| 70 bool should_close_source) OVERRIDE; | 70 bool should_close_source) OVERRIDE; |
| 71 virtual std::set<PP_Instance>* GetGloballySeenInstanceIDSet() OVERRIDE; | 71 virtual std::set<PP_Instance>* GetGloballySeenInstanceIDSet() OVERRIDE; |
| 72 virtual uint32 Register(PluginDispatcher* plugin_dispatcher) OVERRIDE; | 72 virtual uint32 Register(PluginDispatcher* plugin_dispatcher) OVERRIDE; |
| 73 virtual void Unregister(uint32 plugin_dispatcher_id) OVERRIDE; | 73 virtual void Unregister(uint32 plugin_dispatcher_id) OVERRIDE; |
| 74 | 74 |
| 75 // PluginProxyDelegate implementation. | 75 // PluginProxyDelegate implementation. |
| 76 virtual IPC::Sender* GetBrowserSender() OVERRIDE; | 76 virtual IPC::Sender* GetBrowserSender() OVERRIDE; |
| 77 virtual std::string GetUILanguage() OVERRIDE; | 77 virtual std::string GetUILanguage() OVERRIDE; |
| 78 virtual void PreCacheFont(const void* logfontw) OVERRIDE; | 78 virtual void PreCacheFont(const void* logfontw) OVERRIDE; |
| 79 virtual void SetActiveURL(const std::string& url) OVERRIDE; | 79 virtual void SetActiveURL(const std::string& url) OVERRIDE; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 97 scoped_refptr<base::MessageLoopProxy> message_loop_; | 97 scoped_refptr<base::MessageLoopProxy> message_loop_; |
| 98 base::WaitableEvent shutdown_event_; | 98 base::WaitableEvent shutdown_event_; |
| 99 }; | 99 }; |
| 100 | 100 |
| 101 PpapiDispatcher::PpapiDispatcher(scoped_refptr<base::MessageLoopProxy> io_loop) | 101 PpapiDispatcher::PpapiDispatcher(scoped_refptr<base::MessageLoopProxy> io_loop) |
| 102 : next_plugin_dispatcher_id_(0), | 102 : next_plugin_dispatcher_id_(0), |
| 103 message_loop_(io_loop), | 103 message_loop_(io_loop), |
| 104 shutdown_event_(true, false) { | 104 shutdown_event_(true, false) { |
| 105 IPC::ChannelHandle channel_handle( | 105 IPC::ChannelHandle channel_handle( |
| 106 "NaCl IPC", base::FileDescriptor(NACL_IPC_FD, false)); | 106 "NaCl IPC", base::FileDescriptor(NACL_IPC_FD, false)); |
| 107 InitWithChannel(this, channel_handle, false); // Channel is server. | 107 // We don't have/need a PID since handle sharing happens outside of the |
| 108 // NaCl sandbox. |
| 109 InitWithChannel(this, base::kNullProcessId, channel_handle, |
| 110 false); // Channel is server. |
| 108 channel()->AddFilter( | 111 channel()->AddFilter( |
| 109 new components::ChildTraceMessageFilter(message_loop_)); | 112 new components::ChildTraceMessageFilter(message_loop_)); |
| 110 } | 113 } |
| 111 | 114 |
| 112 base::MessageLoopProxy* PpapiDispatcher::GetIPCMessageLoop() { | 115 base::MessageLoopProxy* PpapiDispatcher::GetIPCMessageLoop() { |
| 113 return message_loop_.get(); | 116 return message_loop_.get(); |
| 114 } | 117 } |
| 115 | 118 |
| 116 base::WaitableEvent* PpapiDispatcher::GetShutdownEvent() { | 119 base::WaitableEvent* PpapiDispatcher::GetShutdownEvent() { |
| 117 return &shutdown_event_; | 120 return &shutdown_event_; |
| 118 } | 121 } |
| 119 | 122 |
| 120 IPC::PlatformFileForTransit PpapiDispatcher::ShareHandleWithRemote( | 123 IPC::PlatformFileForTransit PpapiDispatcher::ShareHandleWithRemote( |
| 121 base::PlatformFile handle, | 124 base::PlatformFile handle, |
| 122 const IPC::SyncChannel& channel, | 125 base::ProcessId peer_pid, |
| 123 bool should_close_source) { | 126 bool should_close_source) { |
| 124 return IPC::InvalidPlatformFileForTransit(); | 127 return IPC::InvalidPlatformFileForTransit(); |
| 125 } | 128 } |
| 126 | 129 |
| 127 std::set<PP_Instance>* PpapiDispatcher::GetGloballySeenInstanceIDSet() { | 130 std::set<PP_Instance>* PpapiDispatcher::GetGloballySeenInstanceIDSet() { |
| 128 return &instances_; | 131 return &instances_; |
| 129 } | 132 } |
| 130 | 133 |
| 131 uint32 PpapiDispatcher::Register(PluginDispatcher* plugin_dispatcher) { | 134 uint32 PpapiDispatcher::Register(PluginDispatcher* plugin_dispatcher) { |
| 132 if (!plugin_dispatcher || | 135 if (!plugin_dispatcher || |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 SerializedHandle handle) { | 186 SerializedHandle handle) { |
| 184 // Tell the process-global GetInterface which interfaces it can return to the | 187 // Tell the process-global GetInterface which interfaces it can return to the |
| 185 // plugin. | 188 // plugin. |
| 186 ppapi::proxy::InterfaceList::SetProcessGlobalPermissions( | 189 ppapi::proxy::InterfaceList::SetProcessGlobalPermissions( |
| 187 permissions); | 190 permissions); |
| 188 | 191 |
| 189 PluginDispatcher* dispatcher = | 192 PluginDispatcher* dispatcher = |
| 190 new PluginDispatcher(::PPP_GetInterface, permissions, incognito); | 193 new PluginDispatcher(::PPP_GetInterface, permissions, incognito); |
| 191 // The channel handle's true name is not revealed here. | 194 // The channel handle's true name is not revealed here. |
| 192 IPC::ChannelHandle channel_handle("nacl", handle.descriptor()); | 195 IPC::ChannelHandle channel_handle("nacl", handle.descriptor()); |
| 193 if (!dispatcher->InitPluginWithChannel(this, channel_handle, false)) { | 196 if (!dispatcher->InitPluginWithChannel(this, base::kNullProcessId, |
| 197 channel_handle, false)) { |
| 194 delete dispatcher; | 198 delete dispatcher; |
| 195 return; | 199 return; |
| 196 } | 200 } |
| 197 // From here, the dispatcher will manage its own lifetime according to the | 201 // From here, the dispatcher will manage its own lifetime according to the |
| 198 // lifetime of the attached channel. | 202 // lifetime of the attached channel. |
| 199 } | 203 } |
| 200 | 204 |
| 201 void PpapiDispatcher::OnMsgResourceReply( | 205 void PpapiDispatcher::OnMsgResourceReply( |
| 202 const ppapi::proxy::ResourceMessageReplyParams& reply_params, | 206 const ppapi::proxy::ResourceMessageReplyParams& reply_params, |
| 203 const IPC::Message& nested_msg) { | 207 const IPC::Message& nested_msg) { |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 | 276 |
| 273 PpapiDispatcher ppapi_dispatcher(io_thread.message_loop_proxy()); | 277 PpapiDispatcher ppapi_dispatcher(io_thread.message_loop_proxy()); |
| 274 plugin_globals.set_plugin_proxy_delegate(&ppapi_dispatcher); | 278 plugin_globals.set_plugin_proxy_delegate(&ppapi_dispatcher); |
| 275 | 279 |
| 276 loop.Run(); | 280 loop.Run(); |
| 277 | 281 |
| 278 NaClSrpcModuleFini(); | 282 NaClSrpcModuleFini(); |
| 279 | 283 |
| 280 return 0; | 284 return 0; |
| 281 } | 285 } |
| OLD | NEW |