| 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 |
| 11 // IPC_MESSAGE_MACROS_LOG_ENABLED so ppapi_messages.h will generate the | 11 // IPC_MESSAGE_MACROS_LOG_ENABLED so ppapi_messages.h will generate the |
| 12 // ViewMsgLog et al. functions. | 12 // ViewMsgLog et al. functions. |
| 13 | 13 |
| 14 #include "base/command_line.h" |
| 14 #include "base/message_loop.h" | 15 #include "base/message_loop.h" |
| 15 #include "base/synchronization/waitable_event.h" | 16 #include "base/synchronization/waitable_event.h" |
| 16 #include "base/threading/thread.h" | 17 #include "base/threading/thread.h" |
| 17 #include "components/tracing/child_trace_message_filter.h" | 18 #include "components/tracing/child_trace_message_filter.h" |
| 18 #include "ipc/ipc_channel_handle.h" | 19 #include "ipc/ipc_channel_handle.h" |
| 19 #include "ipc/ipc_logging.h" | 20 #include "ipc/ipc_logging.h" |
| 20 #include "ipc/ipc_message.h" | 21 #include "ipc/ipc_message.h" |
| 21 #include "native_client/src/shared/ppapi_proxy/ppruntime.h" | 22 #include "native_client/src/shared/ppapi_proxy/ppruntime.h" |
| 22 #include "native_client/src/shared/srpc/nacl_srpc.h" | 23 #include "native_client/src/shared/srpc/nacl_srpc.h" |
| 23 #include "native_client/src/untrusted/irt/irt_ppapi.h" | 24 #include "native_client/src/untrusted/irt/irt_ppapi.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 virtual IPC::Sender* GetBrowserSender() OVERRIDE; | 77 virtual IPC::Sender* GetBrowserSender() OVERRIDE; |
| 77 virtual std::string GetUILanguage() OVERRIDE; | 78 virtual std::string GetUILanguage() OVERRIDE; |
| 78 virtual void PreCacheFont(const void* logfontw) OVERRIDE; | 79 virtual void PreCacheFont(const void* logfontw) OVERRIDE; |
| 79 virtual void SetActiveURL(const std::string& url) OVERRIDE; | 80 virtual void SetActiveURL(const std::string& url) OVERRIDE; |
| 80 | 81 |
| 81 // IPC::Listener implementation. | 82 // IPC::Listener implementation. |
| 82 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 83 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 83 | 84 |
| 84 private: | 85 private: |
| 85 void OnMsgCreateNaClChannel(int renderer_id, | 86 void OnMsgCreateNaClChannel(int renderer_id, |
| 86 const ppapi::PpapiPermissions& permissions, | 87 const ppapi::PpapiNaClChannelArgs& args, |
| 87 bool incognito, | |
| 88 SerializedHandle handle); | 88 SerializedHandle handle); |
| 89 void OnMsgResourceReply( | 89 void OnMsgResourceReply( |
| 90 const ppapi::proxy::ResourceMessageReplyParams& reply_params, | 90 const ppapi::proxy::ResourceMessageReplyParams& reply_params, |
| 91 const IPC::Message& nested_msg); | 91 const IPC::Message& nested_msg); |
| 92 void OnPluginDispatcherMessageReceived(const IPC::Message& msg); | 92 void OnPluginDispatcherMessageReceived(const IPC::Message& msg); |
| 93 | 93 |
| 94 std::set<PP_Instance> instances_; | 94 std::set<PP_Instance> instances_; |
| 95 std::map<uint32, PluginDispatcher*> plugin_dispatchers_; | 95 std::map<uint32, PluginDispatcher*> plugin_dispatchers_; |
| 96 uint32 next_plugin_dispatcher_id_; | 96 uint32 next_plugin_dispatcher_id_; |
| 97 scoped_refptr<base::MessageLoopProxy> message_loop_; | 97 scoped_refptr<base::MessageLoopProxy> message_loop_; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 IPC_MESSAGE_HANDLER(PpapiMsg_CreateNaClChannel, OnMsgCreateNaClChannel) | 174 IPC_MESSAGE_HANDLER(PpapiMsg_CreateNaClChannel, OnMsgCreateNaClChannel) |
| 175 IPC_MESSAGE_HANDLER(PpapiPluginMsg_ResourceReply, OnMsgResourceReply) | 175 IPC_MESSAGE_HANDLER(PpapiPluginMsg_ResourceReply, OnMsgResourceReply) |
| 176 // All other messages are simply forwarded to a PluginDispatcher. | 176 // All other messages are simply forwarded to a PluginDispatcher. |
| 177 IPC_MESSAGE_UNHANDLED(OnPluginDispatcherMessageReceived(msg)) | 177 IPC_MESSAGE_UNHANDLED(OnPluginDispatcherMessageReceived(msg)) |
| 178 IPC_END_MESSAGE_MAP() | 178 IPC_END_MESSAGE_MAP() |
| 179 return true; | 179 return true; |
| 180 } | 180 } |
| 181 | 181 |
| 182 void PpapiDispatcher::OnMsgCreateNaClChannel( | 182 void PpapiDispatcher::OnMsgCreateNaClChannel( |
| 183 int renderer_id, | 183 int renderer_id, |
| 184 const ppapi::PpapiPermissions& permissions, | 184 const ppapi::PpapiNaClChannelArgs& args, |
| 185 bool incognito, | |
| 186 SerializedHandle handle) { | 185 SerializedHandle handle) { |
| 186 static bool command_line_and_logging_initialized = false; |
| 187 if (!command_line_and_logging_initialized) { |
| 188 CommandLine::Init(0, NULL); |
| 189 for (size_t i = 0; i < args.switch_names.size(); ++i) { |
| 190 DCHECK(i < args.switch_values.size()); |
| 191 CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
| 192 args.switch_names[i], args.switch_values[i]); |
| 193 } |
| 194 logging::InitLogging( |
| 195 NULL, |
| 196 logging::LOG_ONLY_TO_SYSTEM_DEBUG_LOG, |
| 197 logging::DONT_LOCK_LOG_FILE, |
| 198 logging::DELETE_OLD_LOG_FILE, |
| 199 logging::DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS); |
| 200 command_line_and_logging_initialized = true; |
| 201 } |
| 187 // Tell the process-global GetInterface which interfaces it can return to the | 202 // Tell the process-global GetInterface which interfaces it can return to the |
| 188 // plugin. | 203 // plugin. |
| 189 ppapi::proxy::InterfaceList::SetProcessGlobalPermissions( | 204 ppapi::proxy::InterfaceList::SetProcessGlobalPermissions( |
| 190 permissions); | 205 args.permissions); |
| 191 | 206 |
| 192 PluginDispatcher* dispatcher = | 207 PluginDispatcher* dispatcher = |
| 193 new PluginDispatcher(::PPP_GetInterface, permissions, incognito); | 208 new PluginDispatcher(::PPP_GetInterface, args.permissions, |
| 209 args.off_the_record); |
| 194 // The channel handle's true name is not revealed here. | 210 // The channel handle's true name is not revealed here. |
| 195 IPC::ChannelHandle channel_handle("nacl", handle.descriptor()); | 211 IPC::ChannelHandle channel_handle("nacl", handle.descriptor()); |
| 196 if (!dispatcher->InitPluginWithChannel(this, base::kNullProcessId, | 212 if (!dispatcher->InitPluginWithChannel(this, base::kNullProcessId, |
| 197 channel_handle, false)) { | 213 channel_handle, false)) { |
| 198 delete dispatcher; | 214 delete dispatcher; |
| 199 return; | 215 return; |
| 200 } | 216 } |
| 201 // From here, the dispatcher will manage its own lifetime according to the | 217 // From here, the dispatcher will manage its own lifetime according to the |
| 202 // lifetime of the attached channel. | 218 // lifetime of the attached channel. |
| 203 } | 219 } |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 | 292 |
| 277 PpapiDispatcher ppapi_dispatcher(io_thread.message_loop_proxy()); | 293 PpapiDispatcher ppapi_dispatcher(io_thread.message_loop_proxy()); |
| 278 plugin_globals.set_plugin_proxy_delegate(&ppapi_dispatcher); | 294 plugin_globals.set_plugin_proxy_delegate(&ppapi_dispatcher); |
| 279 | 295 |
| 280 loop.Run(); | 296 loop.Run(); |
| 281 | 297 |
| 282 NaClSrpcModuleFini(); | 298 NaClSrpcModuleFini(); |
| 283 | 299 |
| 284 return 0; | 300 return 0; |
| 285 } | 301 } |
| OLD | NEW |