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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
172 bool PpapiDispatcher::OnMessageReceived(const IPC::Message& msg) { | 172 bool PpapiDispatcher::OnMessageReceived(const IPC::Message& msg) { |
173 IPC_BEGIN_MESSAGE_MAP(PpapiDispatcher, msg) | 173 IPC_BEGIN_MESSAGE_MAP(PpapiDispatcher, msg) |
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 static bool cmdline_and_logging_initialized = false; | |
183 | |
182 void PpapiDispatcher::OnMsgCreateNaClChannel( | 184 void PpapiDispatcher::OnMsgCreateNaClChannel( |
183 int renderer_id, | 185 int renderer_id, |
184 const ppapi::PpapiPermissions& permissions, | 186 const ppapi::PpapiNaClChannelArgs& args, |
185 bool incognito, | |
186 SerializedHandle handle) { | 187 SerializedHandle handle) { |
188 if (!cmdline_and_logging_initialized) { | |
dmichael (off chromium)
2013/04/10 23:10:22
Does this ever happen more than once? If it really
| |
189 CommandLine::Init(0, NULL); | |
190 for (size_t i = 0; i < args.switch_names.size(); ++i) { | |
191 DCHECK(i < args.switch_values.size()); | |
192 CommandLine::ForCurrentProcess()->AppendSwitchASCII( | |
193 args.switch_names[i], args.switch_values[i]); | |
194 } | |
195 logging::InitLogging( | |
196 NULL, | |
197 logging::LOG_ONLY_TO_SYSTEM_DEBUG_LOG, | |
198 logging::DONT_LOCK_LOG_FILE, | |
199 logging::DELETE_OLD_LOG_FILE, | |
200 logging::DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS); | |
201 cmdline_and_logging_initialized = true; | |
202 } | |
203 | |
187 // Tell the process-global GetInterface which interfaces it can return to the | 204 // Tell the process-global GetInterface which interfaces it can return to the |
188 // plugin. | 205 // plugin. |
189 ppapi::proxy::InterfaceList::SetProcessGlobalPermissions( | 206 ppapi::proxy::InterfaceList::SetProcessGlobalPermissions( |
190 permissions); | 207 args.permissions); |
191 | 208 |
192 PluginDispatcher* dispatcher = | 209 PluginDispatcher* dispatcher = |
193 new PluginDispatcher(::PPP_GetInterface, permissions, incognito); | 210 new PluginDispatcher(::PPP_GetInterface, args.permissions, |
211 args.off_the_record); | |
194 // The channel handle's true name is not revealed here. | 212 // The channel handle's true name is not revealed here. |
195 IPC::ChannelHandle channel_handle("nacl", handle.descriptor()); | 213 IPC::ChannelHandle channel_handle("nacl", handle.descriptor()); |
196 if (!dispatcher->InitPluginWithChannel(this, base::kNullProcessId, | 214 if (!dispatcher->InitPluginWithChannel(this, base::kNullProcessId, |
197 channel_handle, false)) { | 215 channel_handle, false)) { |
198 delete dispatcher; | 216 delete dispatcher; |
199 return; | 217 return; |
200 } | 218 } |
201 // From here, the dispatcher will manage its own lifetime according to the | 219 // From here, the dispatcher will manage its own lifetime according to the |
202 // lifetime of the attached channel. | 220 // lifetime of the attached channel. |
203 } | 221 } |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
276 | 294 |
277 PpapiDispatcher ppapi_dispatcher(io_thread.message_loop_proxy()); | 295 PpapiDispatcher ppapi_dispatcher(io_thread.message_loop_proxy()); |
278 plugin_globals.set_plugin_proxy_delegate(&ppapi_dispatcher); | 296 plugin_globals.set_plugin_proxy_delegate(&ppapi_dispatcher); |
279 | 297 |
280 loop.Run(); | 298 loop.Run(); |
281 | 299 |
282 NaClSrpcModuleFini(); | 300 NaClSrpcModuleFini(); |
283 | 301 |
284 return 0; | 302 return 0; |
285 } | 303 } |
OLD | NEW |