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 "content/ppapi_plugin/ppapi_thread.h" | 5 #include "content/ppapi_plugin/ppapi_thread.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 base::MessageLoopProxy* PpapiThread::GetIPCMessageLoop() { | 160 base::MessageLoopProxy* PpapiThread::GetIPCMessageLoop() { |
161 return ChildProcess::current()->io_message_loop_proxy(); | 161 return ChildProcess::current()->io_message_loop_proxy(); |
162 } | 162 } |
163 | 163 |
164 base::WaitableEvent* PpapiThread::GetShutdownEvent() { | 164 base::WaitableEvent* PpapiThread::GetShutdownEvent() { |
165 return ChildProcess::current()->GetShutDownEvent(); | 165 return ChildProcess::current()->GetShutDownEvent(); |
166 } | 166 } |
167 | 167 |
168 IPC::PlatformFileForTransit PpapiThread::ShareHandleWithRemote( | 168 IPC::PlatformFileForTransit PpapiThread::ShareHandleWithRemote( |
169 base::PlatformFile handle, | 169 base::PlatformFile handle, |
170 const IPC::SyncChannel& channel, | 170 base::ProcessId peer_pid, |
171 bool should_close_source) { | 171 bool should_close_source) { |
172 #if defined(OS_WIN) | 172 #if defined(OS_WIN) |
173 if (peer_handle_.IsValid()) { | 173 if (peer_handle_.IsValid()) { |
174 DCHECK(is_broker_); | 174 DCHECK(is_broker_); |
175 return IPC::GetFileHandleForProcess(handle, peer_handle_, | 175 return IPC::GetFileHandleForProcess(handle, peer_handle_, |
176 should_close_source); | 176 should_close_source); |
177 } | 177 } |
178 #endif | 178 #endif |
179 | 179 |
180 return BrokerGetFileHandleForProcess(handle, channel.peer_pid(), | 180 DCHECK(peer_pid != base::kNullProcessId); |
181 should_close_source); | 181 return BrokerGetFileHandleForProcess(handle, peer_pid, should_close_source); |
182 } | 182 } |
183 | 183 |
184 std::set<PP_Instance>* PpapiThread::GetGloballySeenInstanceIDSet() { | 184 std::set<PP_Instance>* PpapiThread::GetGloballySeenInstanceIDSet() { |
185 return &globally_seen_instance_ids_; | 185 return &globally_seen_instance_ids_; |
186 } | 186 } |
187 | 187 |
188 IPC::Sender* PpapiThread::GetBrowserSender() { | 188 IPC::Sender* PpapiThread::GetBrowserSender() { |
189 return this; | 189 return this; |
190 } | 190 } |
191 | 191 |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 if (init_error != PP_OK) { | 346 if (init_error != PP_OK) { |
347 LOG(WARNING) << "InitModule failed with error " << init_error; | 347 LOG(WARNING) << "InitModule failed with error " << init_error; |
348 return; | 348 return; |
349 } | 349 } |
350 } | 350 } |
351 | 351 |
352 // Initialization succeeded, so keep the plugin DLL loaded. | 352 // Initialization succeeded, so keep the plugin DLL loaded. |
353 library_.Reset(library.Release()); | 353 library_.Reset(library.Release()); |
354 } | 354 } |
355 | 355 |
356 void PpapiThread::OnCreateChannel(int renderer_id, bool incognito) { | 356 void PpapiThread::OnCreateChannel(base::ProcessId renderer_pid, |
| 357 int renderer_child_id, |
| 358 bool incognito) { |
357 IPC::ChannelHandle channel_handle; | 359 IPC::ChannelHandle channel_handle; |
358 | 360 |
359 if (!plugin_entry_points_.get_interface || // Plugin couldn't be loaded. | 361 if (!plugin_entry_points_.get_interface || // Plugin couldn't be loaded. |
360 !SetupRendererChannel(renderer_id, incognito, &channel_handle)) { | 362 !SetupRendererChannel(renderer_pid, renderer_child_id, incognito, |
| 363 &channel_handle)) { |
361 Send(new PpapiHostMsg_ChannelCreated(IPC::ChannelHandle())); | 364 Send(new PpapiHostMsg_ChannelCreated(IPC::ChannelHandle())); |
362 return; | 365 return; |
363 } | 366 } |
364 | 367 |
365 Send(new PpapiHostMsg_ChannelCreated(channel_handle)); | 368 Send(new PpapiHostMsg_ChannelCreated(channel_handle)); |
366 } | 369 } |
367 | 370 |
368 void PpapiThread::OnResourceReply( | 371 void PpapiThread::OnResourceReply( |
369 const ppapi::proxy::ResourceMessageReplyParams& reply_params, | 372 const ppapi::proxy::ResourceMessageReplyParams& reply_params, |
370 const IPC::Message& nested_msg) { | 373 const IPC::Message& nested_msg) { |
371 ppapi::proxy::PluginDispatcher::DispatchResourceReply(reply_params, | 374 ppapi::proxy::PluginDispatcher::DispatchResourceReply(reply_params, |
372 nested_msg); | 375 nested_msg); |
373 } | 376 } |
374 | 377 |
375 void PpapiThread::OnSetNetworkState(bool online) { | 378 void PpapiThread::OnSetNetworkState(bool online) { |
376 // Note the browser-process side shouldn't send us these messages in the | 379 // Note the browser-process side shouldn't send us these messages in the |
377 // first unless the plugin has dev permissions, so we don't need to check | 380 // first unless the plugin has dev permissions, so we don't need to check |
378 // again here. We don't want random plugins depending on this dev interface. | 381 // again here. We don't want random plugins depending on this dev interface. |
379 if (!plugin_entry_points_.get_interface) | 382 if (!plugin_entry_points_.get_interface) |
380 return; | 383 return; |
381 const PPP_NetworkState_Dev* ns = static_cast<const PPP_NetworkState_Dev*>( | 384 const PPP_NetworkState_Dev* ns = static_cast<const PPP_NetworkState_Dev*>( |
382 plugin_entry_points_.get_interface(PPP_NETWORK_STATE_DEV_INTERFACE)); | 385 plugin_entry_points_.get_interface(PPP_NETWORK_STATE_DEV_INTERFACE)); |
383 if (ns) | 386 if (ns) |
384 ns->SetOnLine(PP_FromBool(online)); | 387 ns->SetOnLine(PP_FromBool(online)); |
385 } | 388 } |
386 | 389 |
387 bool PpapiThread::SetupRendererChannel(int renderer_id, | 390 bool PpapiThread::SetupRendererChannel(base::ProcessId renderer_pid, |
| 391 int renderer_child_id, |
388 bool incognito, | 392 bool incognito, |
389 IPC::ChannelHandle* handle) { | 393 IPC::ChannelHandle* handle) { |
390 DCHECK(is_broker_ == (connect_instance_func_ != NULL)); | 394 DCHECK(is_broker_ == (connect_instance_func_ != NULL)); |
391 IPC::ChannelHandle plugin_handle; | 395 IPC::ChannelHandle plugin_handle; |
392 plugin_handle.name = IPC::Channel::GenerateVerifiedChannelID( | 396 plugin_handle.name = IPC::Channel::GenerateVerifiedChannelID( |
393 StringPrintf("%d.r%d", base::GetCurrentProcId(), renderer_id)); | 397 StringPrintf("%d.r%d", base::GetCurrentProcId(), renderer_child_id)); |
394 | 398 |
395 ppapi::proxy::ProxyChannel* dispatcher = NULL; | 399 ppapi::proxy::ProxyChannel* dispatcher = NULL; |
396 bool init_result = false; | 400 bool init_result = false; |
397 if (is_broker_) { | 401 if (is_broker_) { |
398 BrokerProcessDispatcher* broker_dispatcher = | 402 BrokerProcessDispatcher* broker_dispatcher = |
399 new BrokerProcessDispatcher(plugin_entry_points_.get_interface, | 403 new BrokerProcessDispatcher(plugin_entry_points_.get_interface, |
400 connect_instance_func_); | 404 connect_instance_func_); |
401 init_result = broker_dispatcher->InitBrokerWithChannel(this, | 405 init_result = broker_dispatcher->InitBrokerWithChannel(this, |
| 406 renderer_pid, |
402 plugin_handle, | 407 plugin_handle, |
403 false); | 408 false); |
404 dispatcher = broker_dispatcher; | 409 dispatcher = broker_dispatcher; |
405 } else { | 410 } else { |
406 PluginProcessDispatcher* plugin_dispatcher = | 411 PluginProcessDispatcher* plugin_dispatcher = |
407 new PluginProcessDispatcher(plugin_entry_points_.get_interface, | 412 new PluginProcessDispatcher(plugin_entry_points_.get_interface, |
408 permissions_, | 413 permissions_, |
409 incognito); | 414 incognito); |
410 init_result = plugin_dispatcher->InitPluginWithChannel(this, | 415 init_result = plugin_dispatcher->InitPluginWithChannel(this, |
| 416 renderer_pid, |
411 plugin_handle, | 417 plugin_handle, |
412 false); | 418 false); |
413 dispatcher = plugin_dispatcher; | 419 dispatcher = plugin_dispatcher; |
414 } | 420 } |
415 | 421 |
416 if (!init_result) { | 422 if (!init_result) { |
417 delete dispatcher; | 423 delete dispatcher; |
418 return false; | 424 return false; |
419 } | 425 } |
420 | 426 |
(...skipping 18 matching lines...) Expand all Loading... |
439 | 445 |
440 // plugin() is NULL when in-process. Which is fine, because this is | 446 // plugin() is NULL when in-process. Which is fine, because this is |
441 // just a hook for setting the process name. | 447 // just a hook for setting the process name. |
442 if (GetContentClient()->plugin()) { | 448 if (GetContentClient()->plugin()) { |
443 GetContentClient()->plugin()->PluginProcessStarted( | 449 GetContentClient()->plugin()->PluginProcessStarted( |
444 path.BaseName().RemoveExtension().LossyDisplayName()); | 450 path.BaseName().RemoveExtension().LossyDisplayName()); |
445 } | 451 } |
446 } | 452 } |
447 | 453 |
448 } // namespace content | 454 } // namespace content |
OLD | NEW |