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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <limits> | 9 #include <limits> |
10 | 10 |
(...skipping 21 matching lines...) Expand all Loading... |
32 #include "content/ppapi_plugin/plugin_process_dispatcher.h" | 32 #include "content/ppapi_plugin/plugin_process_dispatcher.h" |
33 #include "content/ppapi_plugin/ppapi_blink_platform_impl.h" | 33 #include "content/ppapi_plugin/ppapi_blink_platform_impl.h" |
34 #include "content/public/common/content_client.h" | 34 #include "content/public/common/content_client.h" |
35 #include "content/public/common/content_switches.h" | 35 #include "content/public/common/content_switches.h" |
36 #include "content/public/common/pepper_plugin_info.h" | 36 #include "content/public/common/pepper_plugin_info.h" |
37 #include "content/public/common/sandbox_init.h" | 37 #include "content/public/common/sandbox_init.h" |
38 #include "ipc/ipc_channel_handle.h" | 38 #include "ipc/ipc_channel_handle.h" |
39 #include "ipc/ipc_platform_file.h" | 39 #include "ipc/ipc_platform_file.h" |
40 #include "ipc/ipc_sync_channel.h" | 40 #include "ipc/ipc_sync_channel.h" |
41 #include "ipc/ipc_sync_message_filter.h" | 41 #include "ipc/ipc_sync_message_filter.h" |
| 42 #include "mojo/public/cpp/system/message_pipe.h" |
42 #include "ppapi/c/dev/ppp_network_state_dev.h" | 43 #include "ppapi/c/dev/ppp_network_state_dev.h" |
43 #include "ppapi/c/pp_errors.h" | 44 #include "ppapi/c/pp_errors.h" |
44 #include "ppapi/c/ppp.h" | 45 #include "ppapi/c/ppp.h" |
45 #include "ppapi/proxy/interface_list.h" | 46 #include "ppapi/proxy/interface_list.h" |
46 #include "ppapi/proxy/plugin_globals.h" | 47 #include "ppapi/proxy/plugin_globals.h" |
47 #include "ppapi/proxy/plugin_message_filter.h" | 48 #include "ppapi/proxy/plugin_message_filter.h" |
48 #include "ppapi/proxy/ppapi_messages.h" | 49 #include "ppapi/proxy/ppapi_messages.h" |
49 #include "ppapi/proxy/resource_reply_thread_registrar.h" | 50 #include "ppapi/proxy/resource_reply_thread_registrar.h" |
50 #include "third_party/WebKit/public/web/WebKit.h" | 51 #include "third_party/WebKit/public/web/WebKit.h" |
51 #include "ui/base/ui_base_switches.h" | 52 #include "ui/base/ui_base_switches.h" |
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
481 // Intentionally hang upon the request of the browser. | 482 // Intentionally hang upon the request of the browser. |
482 for (;;) | 483 for (;;) |
483 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(1)); | 484 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(1)); |
484 } | 485 } |
485 | 486 |
486 bool PpapiThread::SetupChannel(base::ProcessId renderer_pid, | 487 bool PpapiThread::SetupChannel(base::ProcessId renderer_pid, |
487 int renderer_child_id, | 488 int renderer_child_id, |
488 bool incognito, | 489 bool incognito, |
489 IPC::ChannelHandle* handle) { | 490 IPC::ChannelHandle* handle) { |
490 DCHECK(is_broker_ == (connect_instance_func_ != NULL)); | 491 DCHECK(is_broker_ == (connect_instance_func_ != NULL)); |
491 IPC::ChannelHandle plugin_handle; | 492 mojo::MessagePipe message_pipe; |
492 plugin_handle.name = IPC::Channel::GenerateVerifiedChannelID( | 493 IPC::ChannelHandle plugin_handle(message_pipe.handle0.release()); |
493 base::StringPrintf( | |
494 "%d.r%d", base::GetCurrentProcId(), renderer_child_id)); | |
495 | |
496 ppapi::proxy::ProxyChannel* dispatcher = NULL; | 494 ppapi::proxy::ProxyChannel* dispatcher = NULL; |
497 bool init_result = false; | 495 bool init_result = false; |
498 if (is_broker_) { | 496 if (is_broker_) { |
499 bool peer_is_browser = renderer_pid == base::kNullProcessId; | 497 bool peer_is_browser = renderer_pid == base::kNullProcessId; |
500 BrokerProcessDispatcher* broker_dispatcher = | 498 BrokerProcessDispatcher* broker_dispatcher = |
501 new BrokerProcessDispatcher(plugin_entry_points_.get_interface, | 499 new BrokerProcessDispatcher(plugin_entry_points_.get_interface, |
502 connect_instance_func_, peer_is_browser); | 500 connect_instance_func_, peer_is_browser); |
503 init_result = broker_dispatcher->InitBrokerWithChannel(this, | 501 init_result = broker_dispatcher->InitBrokerWithChannel(this, |
504 renderer_pid, | 502 renderer_pid, |
505 plugin_handle, | 503 plugin_handle, |
(...skipping 10 matching lines...) Expand all Loading... |
516 plugin_handle, | 514 plugin_handle, |
517 false); | 515 false); |
518 dispatcher = plugin_dispatcher; | 516 dispatcher = plugin_dispatcher; |
519 } | 517 } |
520 | 518 |
521 if (!init_result) { | 519 if (!init_result) { |
522 delete dispatcher; | 520 delete dispatcher; |
523 return false; | 521 return false; |
524 } | 522 } |
525 | 523 |
526 handle->name = plugin_handle.name; | 524 handle->mojo_handle = message_pipe.handle1.release(); |
527 #if defined(OS_POSIX) | |
528 // On POSIX, transfer ownership of the renderer-side (client) FD. | |
529 // This ensures this process will be notified when it is closed even if a | |
530 // connection is not established. | |
531 handle->socket = base::FileDescriptor(dispatcher->TakeRendererFD()); | |
532 if (handle->socket.fd == -1) | |
533 return false; | |
534 #endif | |
535 | 525 |
536 // From here, the dispatcher will manage its own lifetime according to the | 526 // From here, the dispatcher will manage its own lifetime according to the |
537 // lifetime of the attached channel. | 527 // lifetime of the attached channel. |
538 return true; | 528 return true; |
539 } | 529 } |
540 | 530 |
541 void PpapiThread::SavePluginName(const base::FilePath& path) { | 531 void PpapiThread::SavePluginName(const base::FilePath& path) { |
542 ppapi::proxy::PluginGlobals::Get()->set_plugin_name( | 532 ppapi::proxy::PluginGlobals::Get()->set_plugin_name( |
543 path.BaseName().AsUTF8Unsafe()); | 533 path.BaseName().AsUTF8Unsafe()); |
544 } | 534 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
587 GetHistogramName(is_broker_, "LoadTime", path), | 577 GetHistogramName(is_broker_, "LoadTime", path), |
588 base::TimeDelta::FromMilliseconds(1), | 578 base::TimeDelta::FromMilliseconds(1), |
589 base::TimeDelta::FromSeconds(10), | 579 base::TimeDelta::FromSeconds(10), |
590 50, | 580 50, |
591 base::HistogramBase::kUmaTargetedHistogramFlag); | 581 base::HistogramBase::kUmaTargetedHistogramFlag); |
592 | 582 |
593 histogram->AddTime(load_time); | 583 histogram->AddTime(load_time); |
594 } | 584 } |
595 | 585 |
596 } // namespace content | 586 } // namespace content |
OLD | NEW |