Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(104)

Side by Side Diff: content/ppapi_plugin/ppapi_thread.cc

Issue 2094623002: Use ChannelMojo for plugin-renderer channels. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mojo-ipc-channel-handle
Patch Set: rebase Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | content/renderer/pepper/host_dispatcher_wrapper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 IPC::ChannelHandle plugin_handle;
492 plugin_handle.name = IPC::Channel::GenerateVerifiedChannelID( 493 plugin_handle.name = IPC::Channel::GenerateVerifiedChannelID(
493 base::StringPrintf( 494 base::StringPrintf(
494 "%d.r%d", base::GetCurrentProcId(), renderer_child_id)); 495 "%d.r%d", base::GetCurrentProcId(), renderer_child_id));
496 mojo::MessagePipe message_pipe;
497 plugin_handle.mojo_handle = message_pipe.handle0.release();
495 498
496 ppapi::proxy::ProxyChannel* dispatcher = NULL; 499 ppapi::proxy::ProxyChannel* dispatcher = NULL;
497 bool init_result = false; 500 bool init_result = false;
498 if (is_broker_) { 501 if (is_broker_) {
499 bool peer_is_browser = renderer_pid == base::kNullProcessId; 502 bool peer_is_browser = renderer_pid == base::kNullProcessId;
500 BrokerProcessDispatcher* broker_dispatcher = 503 BrokerProcessDispatcher* broker_dispatcher =
501 new BrokerProcessDispatcher(plugin_entry_points_.get_interface, 504 new BrokerProcessDispatcher(plugin_entry_points_.get_interface,
502 connect_instance_func_, peer_is_browser); 505 connect_instance_func_, peer_is_browser);
503 init_result = broker_dispatcher->InitBrokerWithChannel(this, 506 init_result = broker_dispatcher->InitBrokerWithChannel(this,
504 renderer_pid, 507 renderer_pid,
(...skipping 12 matching lines...) Expand all
517 false); 520 false);
518 dispatcher = plugin_dispatcher; 521 dispatcher = plugin_dispatcher;
519 } 522 }
520 523
521 if (!init_result) { 524 if (!init_result) {
522 delete dispatcher; 525 delete dispatcher;
523 return false; 526 return false;
524 } 527 }
525 528
526 handle->name = plugin_handle.name; 529 handle->name = plugin_handle.name;
527 #if defined(OS_POSIX) 530 handle->mojo_handle = message_pipe.handle1.release();
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.
dcheng 2016/06/27 02:12:48 How come these checks aren't needed in the Mojo ve
Anand Mistry (off Chromium) 2016/06/27 02:25:59 fds are not used when using ChannelMojo (and the r
dcheng 2016/06/27 03:35:02 OK, so the Mojo handles here are always valid?
Anand Mistry (off Chromium) 2016/06/27 04:52:07 Here, yes. But not necessarily in the receive side
531 handle->socket = base::FileDescriptor(dispatcher->TakeRendererFD());
532 if (handle->socket.fd == -1)
533 return false;
534 #endif
535 531
536 // From here, the dispatcher will manage its own lifetime according to the 532 // From here, the dispatcher will manage its own lifetime according to the
537 // lifetime of the attached channel. 533 // lifetime of the attached channel.
538 return true; 534 return true;
539 } 535 }
540 536
541 void PpapiThread::SavePluginName(const base::FilePath& path) { 537 void PpapiThread::SavePluginName(const base::FilePath& path) {
542 ppapi::proxy::PluginGlobals::Get()->set_plugin_name( 538 ppapi::proxy::PluginGlobals::Get()->set_plugin_name(
543 path.BaseName().AsUTF8Unsafe()); 539 path.BaseName().AsUTF8Unsafe());
544 } 540 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 GetHistogramName(is_broker_, "LoadTime", path), 583 GetHistogramName(is_broker_, "LoadTime", path),
588 base::TimeDelta::FromMilliseconds(1), 584 base::TimeDelta::FromMilliseconds(1),
589 base::TimeDelta::FromSeconds(10), 585 base::TimeDelta::FromSeconds(10),
590 50, 586 50,
591 base::HistogramBase::kUmaTargetedHistogramFlag); 587 base::HistogramBase::kUmaTargetedHistogramFlag);
592 588
593 histogram->AddTime(load_time); 589 histogram->AddTime(load_time);
594 } 590 }
595 591
596 } // namespace content 592 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/renderer/pepper/host_dispatcher_wrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698