| 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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 #include "content/public/common/result_codes.h" | 158 #include "content/public/common/result_codes.h" |
| 159 #include "content/public/common/sandboxed_process_launcher_delegate.h" | 159 #include "content/public/common/sandboxed_process_launcher_delegate.h" |
| 160 #include "content/public/common/url_constants.h" | 160 #include "content/public/common/url_constants.h" |
| 161 #include "device/battery/battery_monitor_impl.h" | 161 #include "device/battery/battery_monitor_impl.h" |
| 162 #include "gpu/GLES2/gl2extchromium.h" | 162 #include "gpu/GLES2/gl2extchromium.h" |
| 163 #include "gpu/command_buffer/client/gpu_switches.h" | 163 #include "gpu/command_buffer/client/gpu_switches.h" |
| 164 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 164 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
| 165 #include "gpu/command_buffer/service/gpu_switches.h" | 165 #include "gpu/command_buffer/service/gpu_switches.h" |
| 166 #include "ipc/attachment_broker.h" | 166 #include "ipc/attachment_broker.h" |
| 167 #include "ipc/attachment_broker_privileged.h" | 167 #include "ipc/attachment_broker_privileged.h" |
| 168 #include "ipc/ipc.mojom.h" | |
| 169 #include "ipc/ipc_channel.h" | 168 #include "ipc/ipc_channel.h" |
| 170 #include "ipc/ipc_channel_mojo.h" | 169 #include "ipc/ipc_channel_mojo.h" |
| 171 #include "ipc/ipc_logging.h" | 170 #include "ipc/ipc_logging.h" |
| 172 #include "ipc/ipc_switches.h" | 171 #include "ipc/ipc_switches.h" |
| 173 #include "media/base/media_switches.h" | 172 #include "media/base/media_switches.h" |
| 174 #include "mojo/edk/embedder/embedder.h" | 173 #include "mojo/edk/embedder/embedder.h" |
| 175 #include "net/url_request/url_request_context_getter.h" | 174 #include "net/url_request/url_request_context_getter.h" |
| 176 #include "ppapi/shared_impl/ppapi_switches.h" | 175 #include "ppapi/shared_impl/ppapi_switches.h" |
| 177 #include "services/shell/public/cpp/connection.h" | 176 #include "services/shell/public/cpp/connection.h" |
| 178 #include "services/shell/public/cpp/interface_provider.h" | 177 #include "services/shell/public/cpp/interface_provider.h" |
| (...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 814 // Crank up a thread and run the initialization there. With the way that | 813 // Crank up a thread and run the initialization there. With the way that |
| 815 // messages flow between the browser and renderer, this thread is required | 814 // messages flow between the browser and renderer, this thread is required |
| 816 // to prevent a deadlock in single-process mode. Since the primordial | 815 // to prevent a deadlock in single-process mode. Since the primordial |
| 817 // thread in the renderer process runs the WebKit code and can sometimes | 816 // thread in the renderer process runs the WebKit code and can sometimes |
| 818 // make blocking calls to the UI thread (i.e. this thread), they need to run | 817 // make blocking calls to the UI thread (i.e. this thread), they need to run |
| 819 // on separate threads. | 818 // on separate threads. |
| 820 in_process_renderer_.reset( | 819 in_process_renderer_.reset( |
| 821 g_renderer_main_thread_factory(InProcessChildThreadParams( | 820 g_renderer_main_thread_factory(InProcessChildThreadParams( |
| 822 channel_id, | 821 channel_id, |
| 823 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO), | 822 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO), |
| 824 std::string(), mojo_child_connection_->service_token()))); | 823 mojo_channel_token_, |
| 824 mojo_child_connection_->service_token()))); |
| 825 | 825 |
| 826 base::Thread::Options options; | 826 base::Thread::Options options; |
| 827 #if defined(OS_WIN) && !defined(OS_MACOSX) | 827 #if defined(OS_WIN) && !defined(OS_MACOSX) |
| 828 // In-process plugins require this to be a UI message loop. | 828 // In-process plugins require this to be a UI message loop. |
| 829 options.message_loop_type = base::MessageLoop::TYPE_UI; | 829 options.message_loop_type = base::MessageLoop::TYPE_UI; |
| 830 #else | 830 #else |
| 831 // We can't have multiple UI loops on Linux and Android, so we don't support | 831 // We can't have multiple UI loops on Linux and Android, so we don't support |
| 832 // in-process plugins. | 832 // in-process plugins. |
| 833 options.message_loop_type = base::MessageLoop::TYPE_DEFAULT; | 833 options.message_loop_type = base::MessageLoop::TYPE_DEFAULT; |
| 834 #endif | 834 #endif |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 874 | 874 |
| 875 is_initialized_ = true; | 875 is_initialized_ = true; |
| 876 init_time_ = base::TimeTicks::Now(); | 876 init_time_ = base::TimeTicks::Now(); |
| 877 return true; | 877 return true; |
| 878 } | 878 } |
| 879 | 879 |
| 880 std::unique_ptr<IPC::ChannelProxy> RenderProcessHostImpl::CreateChannelProxy( | 880 std::unique_ptr<IPC::ChannelProxy> RenderProcessHostImpl::CreateChannelProxy( |
| 881 const std::string& channel_id) { | 881 const std::string& channel_id) { |
| 882 scoped_refptr<base::SingleThreadTaskRunner> runner = | 882 scoped_refptr<base::SingleThreadTaskRunner> runner = |
| 883 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO); | 883 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO); |
| 884 IPC::mojom::ChannelBootstrapPtr bootstrap; | 884 mojo_channel_token_ = mojo::edk::GenerateRandomToken(); |
| 885 GetRemoteInterfaces()->GetInterface(&bootstrap); | 885 mojo::ScopedMessagePipeHandle handle = |
| 886 mojo::edk::CreateParentMessagePipe(mojo_channel_token_, child_token_); |
| 887 |
| 886 std::unique_ptr<IPC::ChannelFactory> channel_factory = | 888 std::unique_ptr<IPC::ChannelFactory> channel_factory = |
| 887 IPC::ChannelMojo::CreateServerFactory( | 889 IPC::ChannelMojo::CreateServerFactory(std::move(handle), runner); |
| 888 bootstrap.PassInterface().PassHandle(), runner); | |
| 889 | 890 |
| 890 // Do NOT expand ifdef or run time condition checks here! Synchronous | 891 // Do NOT expand ifdef or run time condition checks here! Synchronous |
| 891 // IPCs from browser process are banned. It is only narrowly allowed | 892 // IPCs from browser process are banned. It is only narrowly allowed |
| 892 // for Android WebView to maintain backward compatibility. | 893 // for Android WebView to maintain backward compatibility. |
| 893 // See crbug.com/526842 for details. | 894 // See crbug.com/526842 for details. |
| 894 #if defined(OS_ANDROID) | 895 #if defined(OS_ANDROID) |
| 895 if (GetContentClient()->UsingSynchronousCompositing()) { | 896 if (GetContentClient()->UsingSynchronousCompositing()) { |
| 896 return IPC::SyncChannel::Create( | 897 return IPC::SyncChannel::Create( |
| 897 std::move(channel_factory), this, runner.get(), true, &never_signaled_); | 898 std::move(channel_factory), this, runner.get(), true, &never_signaled_); |
| 898 } | 899 } |
| (...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1413 command_line->AppendSwitch(switches::kEnablePinch); | 1414 command_line->AppendSwitch(switches::kEnablePinch); |
| 1414 | 1415 |
| 1415 #if defined(OS_WIN) | 1416 #if defined(OS_WIN) |
| 1416 command_line->AppendSwitchASCII( | 1417 command_line->AppendSwitchASCII( |
| 1417 switches::kDeviceScaleFactor, | 1418 switches::kDeviceScaleFactor, |
| 1418 base::DoubleToString(display::win::GetDPIScale())); | 1419 base::DoubleToString(display::win::GetDPIScale())); |
| 1419 #endif | 1420 #endif |
| 1420 | 1421 |
| 1421 AppendCompositorCommandLineFlags(command_line); | 1422 AppendCompositorCommandLineFlags(command_line); |
| 1422 | 1423 |
| 1424 if (!mojo_channel_token_.empty()) { |
| 1425 command_line->AppendSwitchASCII(switches::kMojoChannelToken, |
| 1426 mojo_channel_token_); |
| 1427 } |
| 1423 command_line->AppendSwitchASCII(switches::kMojoApplicationChannelToken, | 1428 command_line->AppendSwitchASCII(switches::kMojoApplicationChannelToken, |
| 1424 mojo_child_connection_->service_token()); | 1429 mojo_child_connection_->service_token()); |
| 1425 } | 1430 } |
| 1426 | 1431 |
| 1427 void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer( | 1432 void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer( |
| 1428 const base::CommandLine& browser_cmd, | 1433 const base::CommandLine& browser_cmd, |
| 1429 base::CommandLine* renderer_cmd) const { | 1434 base::CommandLine* renderer_cmd) const { |
| 1430 // Propagate the following switches to the renderer command line (along | 1435 // Propagate the following switches to the renderer command line (along |
| 1431 // with any associated values) if present in the browser command line. | 1436 // with any associated values) if present in the browser command line. |
| 1432 static const char* const kSwitchNames[] = { | 1437 static const char* const kSwitchNames[] = { |
| (...skipping 1391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2824 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; | 2829 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; |
| 2825 | 2830 |
| 2826 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. Alias | 2831 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. Alias |
| 2827 // enough information here so that we can determine what the bad message was. | 2832 // enough information here so that we can determine what the bad message was. |
| 2828 base::debug::Alias(&error); | 2833 base::debug::Alias(&error); |
| 2829 bad_message::ReceivedBadMessage(process.get(), | 2834 bad_message::ReceivedBadMessage(process.get(), |
| 2830 bad_message::RPH_MOJO_PROCESS_ERROR); | 2835 bad_message::RPH_MOJO_PROCESS_ERROR); |
| 2831 } | 2836 } |
| 2832 | 2837 |
| 2833 } // namespace content | 2838 } // namespace content |
| OLD | NEW |