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

Side by Side Diff: content/browser/renderer_host/render_process_host_impl.cc

Issue 2019973002: [mojo-edk] Bind a child token to child launches and port reservations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 6 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 // Represents the browser side of the browser <--> renderer communication 5 // Represents the browser side of the browser <--> renderer communication
6 // channel. There will be one RenderProcessHost per renderer process. 6 // channel. There will be one RenderProcessHost per renderer process.
7 7
8 #include "content/browser/renderer_host/render_process_host_impl.h" 8 #include "content/browser/renderer_host/render_process_host_impl.h"
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 StoragePartitionImpl* storage_partition_impl, 551 StoragePartitionImpl* storage_partition_impl,
552 bool is_for_guests_only) 552 bool is_for_guests_only)
553 : fast_shutdown_started_(false), 553 : fast_shutdown_started_(false),
554 deleting_soon_(false), 554 deleting_soon_(false),
555 #ifndef NDEBUG 555 #ifndef NDEBUG
556 is_self_deleted_(false), 556 is_self_deleted_(false),
557 #endif 557 #endif
558 pending_views_(0), 558 pending_views_(0),
559 immediate_sender_(new SafeSenderProxy(this, true)), 559 immediate_sender_(new SafeSenderProxy(this, true)),
560 io_thread_sender_(new SafeSenderProxy(this, false)), 560 io_thread_sender_(new SafeSenderProxy(this, false)),
561 mojo_application_host_(new MojoApplicationHost), 561 child_token_(mojo::edk::GenerateRandomToken()),
562 mojo_application_host_(new MojoApplicationHost(child_token_)),
562 visible_widgets_(0), 563 visible_widgets_(0),
563 is_process_backgrounded_(false), 564 is_process_backgrounded_(false),
564 is_initialized_(false), 565 is_initialized_(false),
565 id_(ChildProcessHostImpl::GenerateChildProcessUniqueId()), 566 id_(ChildProcessHostImpl::GenerateChildProcessUniqueId()),
566 browser_context_(browser_context), 567 browser_context_(browser_context),
567 storage_partition_impl_(storage_partition_impl), 568 storage_partition_impl_(storage_partition_impl),
568 sudden_termination_allowed_(true), 569 sudden_termination_allowed_(true),
569 ignore_input_events_(false), 570 ignore_input_events_(false),
570 is_for_guests_only_(is_for_guests_only), 571 is_for_guests_only_(is_for_guests_only),
571 gpu_observer_registered_(false), 572 gpu_observer_registered_(false),
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 } 688 }
688 689
689 bool RenderProcessHostImpl::Init() { 690 bool RenderProcessHostImpl::Init() {
690 // calling Init() more than once does nothing, this makes it more convenient 691 // calling Init() more than once does nothing, this makes it more convenient
691 // for the view host which may not be sure in some cases 692 // for the view host which may not be sure in some cases
692 if (channel_) 693 if (channel_)
693 return true; 694 return true;
694 695
695 mojo_child_connection_.reset(new MojoChildConnection( 696 mojo_child_connection_.reset(new MojoChildConnection(
696 kRendererMojoApplicationName, 697 kRendererMojoApplicationName,
697 base::StringPrintf("%d_%d", id_, instance_id_++))); 698 base::StringPrintf("%d_%d", id_, instance_id_++),
699 child_token_));
698 700
699 base::CommandLine::StringType renderer_prefix; 701 base::CommandLine::StringType renderer_prefix;
700 // A command prefix is something prepended to the command line of the spawned 702 // A command prefix is something prepended to the command line of the spawned
701 // process. 703 // process.
702 const base::CommandLine& browser_command_line = 704 const base::CommandLine& browser_command_line =
703 *base::CommandLine::ForCurrentProcess(); 705 *base::CommandLine::ForCurrentProcess();
704 renderer_prefix = 706 renderer_prefix =
705 browser_command_line.GetSwitchValueNative(switches::kRendererCmdPrefix); 707 browser_command_line.GetSwitchValueNative(switches::kRendererCmdPrefix);
706 708
707 #if defined(OS_LINUX) 709 #if defined(OS_LINUX)
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 if (!renderer_prefix.empty()) 775 if (!renderer_prefix.empty())
774 cmd_line->PrependWrapper(renderer_prefix); 776 cmd_line->PrependWrapper(renderer_prefix);
775 AppendRendererCommandLine(cmd_line); 777 AppendRendererCommandLine(cmd_line);
776 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, channel_id); 778 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, channel_id);
777 779
778 // Spawn the child process asynchronously to avoid blocking the UI thread. 780 // Spawn the child process asynchronously to avoid blocking the UI thread.
779 // As long as there's no renderer prefix, we can use the zygote process 781 // As long as there's no renderer prefix, we can use the zygote process
780 // at this stage. 782 // at this stage.
781 child_process_launcher_.reset(new ChildProcessLauncher( 783 child_process_launcher_.reset(new ChildProcessLauncher(
782 new RendererSandboxedProcessLauncherDelegate(channel_.get()), cmd_line, 784 new RendererSandboxedProcessLauncherDelegate(channel_.get()), cmd_line,
783 GetID(), this)); 785 GetID(), this, child_token_));
784 786
785 fast_shutdown_started_ = false; 787 fast_shutdown_started_ = false;
786 } 788 }
787 789
788 if (!gpu_observer_registered_) { 790 if (!gpu_observer_registered_) {
789 gpu_observer_registered_ = true; 791 gpu_observer_registered_ = true;
790 ui::GpuSwitchingManager::GetInstance()->AddObserver(this); 792 ui::GpuSwitchingManager::GetInstance()->AddObserver(this);
791 } 793 }
792 794
793 power_monitor_broadcaster_.Init(); 795 power_monitor_broadcaster_.Init();
794 796
795 is_initialized_ = true; 797 is_initialized_ = true;
796 init_time_ = base::TimeTicks::Now(); 798 init_time_ = base::TimeTicks::Now();
797 return true; 799 return true;
798 } 800 }
799 801
800 std::unique_ptr<IPC::ChannelProxy> RenderProcessHostImpl::CreateChannelProxy( 802 std::unique_ptr<IPC::ChannelProxy> RenderProcessHostImpl::CreateChannelProxy(
801 const std::string& channel_id) { 803 const std::string& channel_id) {
802 scoped_refptr<base::SingleThreadTaskRunner> runner = 804 scoped_refptr<base::SingleThreadTaskRunner> runner =
803 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); 805 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO);
804 mojo_channel_token_ = mojo::edk::GenerateRandomToken(); 806 mojo_channel_token_ = mojo::edk::GenerateRandomToken();
805 mojo::ScopedMessagePipeHandle handle = 807 mojo::ScopedMessagePipeHandle handle =
806 mojo::edk::CreateParentMessagePipe(mojo_channel_token_); 808 mojo::edk::CreateParentMessagePipe(mojo_channel_token_, child_token_);
807 809
808 // Do NOT expand ifdef or run time condition checks here! Synchronous 810 // Do NOT expand ifdef or run time condition checks here! Synchronous
809 // IPCs from browser process are banned. It is only narrowly allowed 811 // IPCs from browser process are banned. It is only narrowly allowed
810 // for Android WebView to maintain backward compatibility. 812 // for Android WebView to maintain backward compatibility.
811 // See crbug.com/526842 for details. 813 // See crbug.com/526842 for details.
812 #if defined(OS_ANDROID) 814 #if defined(OS_ANDROID)
813 if (GetContentClient()->UsingSynchronousCompositing()) { 815 if (GetContentClient()->UsingSynchronousCompositing()) {
814 return IPC::SyncChannel::Create( 816 return IPC::SyncChannel::Create(
815 IPC::ChannelMojo::CreateServerFactory(std::move(handle)), this, 817 IPC::ChannelMojo::CreateServerFactory(std::move(handle)), this,
816 runner.get(), true, &never_signaled_); 818 runner.get(), true, &never_signaled_);
(...skipping 1593 matching lines...) Expand 10 before | Expand all | Expand 10 after
2410 #endif 2412 #endif
2411 channel_.reset(); 2413 channel_.reset();
2412 while (!queued_messages_.empty()) 2414 while (!queued_messages_.empty())
2413 queued_messages_.pop(); 2415 queued_messages_.pop();
2414 UpdateProcessPriority(); 2416 UpdateProcessPriority();
2415 DCHECK(!is_process_backgrounded_); 2417 DCHECK(!is_process_backgrounded_);
2416 2418
2417 // RenderProcessExited observers and RenderProcessGone handlers might 2419 // RenderProcessExited observers and RenderProcessGone handlers might
2418 // navigate or perform other actions that require a connection. Ensure that 2420 // navigate or perform other actions that require a connection. Ensure that
2419 // there is one before calling them. 2421 // there is one before calling them.
2420 mojo_application_host_.reset(new MojoApplicationHost); 2422 child_token_ = mojo::edk::GenerateRandomToken();
2423 mojo_application_host_.reset(new MojoApplicationHost(child_token_));
2421 2424
2422 within_process_died_observer_ = true; 2425 within_process_died_observer_ = true;
2423 NotificationService::current()->Notify( 2426 NotificationService::current()->Notify(
2424 NOTIFICATION_RENDERER_PROCESS_CLOSED, Source<RenderProcessHost>(this), 2427 NOTIFICATION_RENDERER_PROCESS_CLOSED, Source<RenderProcessHost>(this),
2425 Details<RendererClosedDetails>(&details)); 2428 Details<RendererClosedDetails>(&details));
2426 FOR_EACH_OBSERVER(RenderProcessHostObserver, observers_, 2429 FOR_EACH_OBSERVER(RenderProcessHostObserver, observers_,
2427 RenderProcessExited(this, status, exit_code)); 2430 RenderProcessExited(this, status, exit_code));
2428 within_process_died_observer_ = false; 2431 within_process_died_observer_ = false;
2429 2432
2430 message_port_message_filter_ = NULL; 2433 message_port_message_filter_ = NULL;
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
2793 2796
2794 // Skip widgets in other processes. 2797 // Skip widgets in other processes.
2795 if (rvh->GetProcess()->GetID() != GetID()) 2798 if (rvh->GetProcess()->GetID() != GetID())
2796 continue; 2799 continue;
2797 2800
2798 rvh->OnWebkitPreferencesChanged(); 2801 rvh->OnWebkitPreferencesChanged();
2799 } 2802 }
2800 } 2803 }
2801 2804
2802 } // namespace content 2805 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_process_host_impl.h ('k') | content/browser/utility_process_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698