OLD | NEW |
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 652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
663 // proxy. It is currently done this way due to concerns about race | 663 // proxy. It is currently done this way due to concerns about race |
664 // conditions. | 664 // conditions. |
665 ZygoteHostImpl::GetInstance()->SetRendererSandboxStatus( | 665 ZygoteHostImpl::GetInstance()->SetRendererSandboxStatus( |
666 (*GetGenericZygote())->GetSandboxStatus()); | 666 (*GetGenericZygote())->GetSandboxStatus()); |
667 } | 667 } |
668 #endif // defined(OS_POSIX) && !defined(OS_ANDROID) && !defined(OS_MACOSX) | 668 #endif // defined(OS_POSIX) && !defined(OS_ANDROID) && !defined(OS_MACOSX) |
669 | 669 |
670 RenderProcessHostImpl::RenderProcessHostImpl( | 670 RenderProcessHostImpl::RenderProcessHostImpl( |
671 BrowserContext* browser_context, | 671 BrowserContext* browser_context, |
672 StoragePartitionImpl* storage_partition_impl, | 672 StoragePartitionImpl* storage_partition_impl, |
673 bool is_for_guests_only) | 673 bool is_for_guests_only, |
| 674 int child_process_param_id) |
674 : fast_shutdown_started_(false), | 675 : fast_shutdown_started_(false), |
675 deleting_soon_(false), | 676 deleting_soon_(false), |
676 #ifndef NDEBUG | 677 #ifndef NDEBUG |
677 is_self_deleted_(false), | 678 is_self_deleted_(false), |
678 #endif | 679 #endif |
679 pending_views_(0), | 680 pending_views_(0), |
680 service_worker_ref_count_(0), | 681 service_worker_ref_count_(0), |
681 shared_worker_ref_count_(0), | 682 shared_worker_ref_count_(0), |
682 is_worker_ref_count_disabled_(false), | 683 is_worker_ref_count_disabled_(false), |
683 route_provider_binding_(this), | 684 route_provider_binding_(this), |
684 visible_widgets_(0), | 685 visible_widgets_(0), |
685 is_process_backgrounded_(false), | 686 is_process_backgrounded_(false), |
686 id_(ChildProcessHostImpl::GenerateChildProcessUniqueId()), | 687 id_(ChildProcessHostImpl::GenerateChildProcessUniqueId()), |
| 688 child_process_param_id_(child_process_param_id), |
687 browser_context_(browser_context), | 689 browser_context_(browser_context), |
688 storage_partition_impl_(storage_partition_impl), | 690 storage_partition_impl_(storage_partition_impl), |
689 sudden_termination_allowed_(true), | 691 sudden_termination_allowed_(true), |
690 ignore_input_events_(false), | 692 ignore_input_events_(false), |
691 is_for_guests_only_(is_for_guests_only), | 693 is_for_guests_only_(is_for_guests_only), |
692 gpu_observer_registered_(false), | 694 gpu_observer_registered_(false), |
693 delayed_cleanup_needed_(false), | 695 delayed_cleanup_needed_(false), |
694 within_process_died_observer_(false), | 696 within_process_died_observer_(false), |
695 #if BUILDFLAG(ENABLE_WEBRTC) | 697 #if BUILDFLAG(ENABLE_WEBRTC) |
696 webrtc_eventlog_host_(id_), | 698 webrtc_eventlog_host_(id_), |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
905 // first so the process type argument will appear first. | 907 // first so the process type argument will appear first. |
906 std::unique_ptr<base::CommandLine> cmd_line = | 908 std::unique_ptr<base::CommandLine> cmd_line = |
907 base::MakeUnique<base::CommandLine>(renderer_path); | 909 base::MakeUnique<base::CommandLine>(renderer_path); |
908 if (!renderer_prefix.empty()) | 910 if (!renderer_prefix.empty()) |
909 cmd_line->PrependWrapper(renderer_prefix); | 911 cmd_line->PrependWrapper(renderer_prefix); |
910 AppendRendererCommandLine(cmd_line.get()); | 912 AppendRendererCommandLine(cmd_line.get()); |
911 | 913 |
912 // Spawn the child process asynchronously to avoid blocking the UI thread. | 914 // Spawn the child process asynchronously to avoid blocking the UI thread. |
913 // As long as there's no renderer prefix, we can use the zygote process | 915 // As long as there's no renderer prefix, we can use the zygote process |
914 // at this stage. | 916 // at this stage. |
| 917 constexpr bool terminate_on_shutdown = true; |
915 child_process_launcher_.reset(new ChildProcessLauncher( | 918 child_process_launcher_.reset(new ChildProcessLauncher( |
916 base::MakeUnique<RendererSandboxedProcessLauncherDelegate>(), | 919 base::MakeUnique<RendererSandboxedProcessLauncherDelegate>(), |
917 std::move(cmd_line), GetID(), this, std::move(pending_connection_), | 920 std::move(cmd_line), GetID(), this, std::move(pending_connection_), |
918 base::Bind(&RenderProcessHostImpl::OnMojoError, id_))); | 921 base::Bind(&RenderProcessHostImpl::OnMojoError, id_), |
| 922 terminate_on_shutdown, child_process_param_id_)); |
919 channel_->Pause(); | 923 channel_->Pause(); |
920 | 924 |
921 fast_shutdown_started_ = false; | 925 fast_shutdown_started_ = false; |
922 } | 926 } |
923 | 927 |
924 if (!gpu_observer_registered_) { | 928 if (!gpu_observer_registered_) { |
925 gpu_observer_registered_ = true; | 929 gpu_observer_registered_ = true; |
926 ui::GpuSwitchingManager::GetInstance()->AddObserver(this); | 930 ui::GpuSwitchingManager::GetInstance()->AddObserver(this); |
927 } | 931 } |
928 | 932 |
(...skipping 2136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3065 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; | 3069 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; |
3066 | 3070 |
3067 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. | 3071 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. |
3068 // Capture the error message in a crash key value. | 3072 // Capture the error message in a crash key value. |
3069 base::debug::ScopedCrashKey error_key_value("mojo-message-error", error); | 3073 base::debug::ScopedCrashKey error_key_value("mojo-message-error", error); |
3070 bad_message::ReceivedBadMessage(render_process_id, | 3074 bad_message::ReceivedBadMessage(render_process_id, |
3071 bad_message::RPH_MOJO_PROCESS_ERROR); | 3075 bad_message::RPH_MOJO_PROCESS_ERROR); |
3072 } | 3076 } |
3073 | 3077 |
3074 } // namespace content | 3078 } // namespace content |
OLD | NEW |