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 766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
777 if (!renderer_prefix.empty()) | 777 if (!renderer_prefix.empty()) |
778 cmd_line->PrependWrapper(renderer_prefix); | 778 cmd_line->PrependWrapper(renderer_prefix); |
779 AppendRendererCommandLine(cmd_line); | 779 AppendRendererCommandLine(cmd_line); |
780 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, channel_id); | 780 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, channel_id); |
781 | 781 |
782 // Spawn the child process asynchronously to avoid blocking the UI thread. | 782 // Spawn the child process asynchronously to avoid blocking the UI thread. |
783 // As long as there's no renderer prefix, we can use the zygote process | 783 // As long as there's no renderer prefix, we can use the zygote process |
784 // at this stage. | 784 // at this stage. |
785 child_process_launcher_.reset(new ChildProcessLauncher( | 785 child_process_launcher_.reset(new ChildProcessLauncher( |
786 new RendererSandboxedProcessLauncherDelegate(channel_.get()), cmd_line, | 786 new RendererSandboxedProcessLauncherDelegate(channel_.get()), cmd_line, |
787 GetID(), this, child_token_)); | 787 GetID(), this, child_token_, |
| 788 base::Bind(&RenderProcessHostImpl::OnMojoError, |
| 789 weak_factory_.GetWeakPtr(), |
| 790 base::ThreadTaskRunnerHandle::Get()))); |
788 | 791 |
789 fast_shutdown_started_ = false; | 792 fast_shutdown_started_ = false; |
790 } | 793 } |
791 | 794 |
792 if (!gpu_observer_registered_) { | 795 if (!gpu_observer_registered_) { |
793 gpu_observer_registered_ = true; | 796 gpu_observer_registered_ = true; |
794 ui::GpuSwitchingManager::GetInstance()->AddObserver(this); | 797 ui::GpuSwitchingManager::GetInstance()->AddObserver(this); |
795 } | 798 } |
796 | 799 |
797 power_monitor_broadcaster_.Init(); | 800 power_monitor_broadcaster_.Init(); |
(...skipping 2001 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2799 continue; | 2802 continue; |
2800 | 2803 |
2801 // Skip widgets in other processes. | 2804 // Skip widgets in other processes. |
2802 if (rvh->GetProcess()->GetID() != GetID()) | 2805 if (rvh->GetProcess()->GetID() != GetID()) |
2803 continue; | 2806 continue; |
2804 | 2807 |
2805 rvh->OnWebkitPreferencesChanged(); | 2808 rvh->OnWebkitPreferencesChanged(); |
2806 } | 2809 } |
2807 } | 2810 } |
2808 | 2811 |
| 2812 // static |
| 2813 void RenderProcessHostImpl::OnMojoError( |
| 2814 base::WeakPtr<RenderProcessHostImpl> process, |
| 2815 scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
| 2816 const std::string& error) { |
| 2817 if (!task_runner->BelongsToCurrentThread()) { |
| 2818 task_runner->PostTask(FROM_HERE, |
| 2819 base::Bind(&RenderProcessHostImpl::OnMojoError, |
| 2820 process, task_runner, error)); |
| 2821 } |
| 2822 if (!process) |
| 2823 return; |
| 2824 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; |
| 2825 |
| 2826 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. Alias |
| 2827 // enough information here so that we can determine what the bad message was. |
| 2828 base::debug::Alias(&error); |
| 2829 bad_message::ReceivedBadMessage(process.get(), |
| 2830 bad_message::RPH_MOJO_PROCESS_ERROR); |
| 2831 } |
| 2832 |
2809 } // namespace content | 2833 } // namespace content |
OLD | NEW |