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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 #include "content/public/common/result_codes.h" | 156 #include "content/public/common/result_codes.h" |
157 #include "content/public/common/sandboxed_process_launcher_delegate.h" | 157 #include "content/public/common/sandboxed_process_launcher_delegate.h" |
158 #include "content/public/common/url_constants.h" | 158 #include "content/public/common/url_constants.h" |
159 #include "device/battery/battery_monitor_impl.h" | 159 #include "device/battery/battery_monitor_impl.h" |
160 #include "gpu/GLES2/gl2extchromium.h" | 160 #include "gpu/GLES2/gl2extchromium.h" |
161 #include "gpu/command_buffer/client/gpu_switches.h" | 161 #include "gpu/command_buffer/client/gpu_switches.h" |
162 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 162 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
163 #include "gpu/command_buffer/service/gpu_switches.h" | 163 #include "gpu/command_buffer/service/gpu_switches.h" |
164 #include "ipc/attachment_broker.h" | 164 #include "ipc/attachment_broker.h" |
165 #include "ipc/attachment_broker_privileged.h" | 165 #include "ipc/attachment_broker_privileged.h" |
166 #include "ipc/ipc.mojom.h" | |
167 #include "ipc/ipc_channel.h" | 166 #include "ipc/ipc_channel.h" |
168 #include "ipc/ipc_channel_mojo.h" | 167 #include "ipc/ipc_channel_mojo.h" |
169 #include "ipc/ipc_logging.h" | 168 #include "ipc/ipc_logging.h" |
170 #include "ipc/ipc_switches.h" | 169 #include "ipc/ipc_switches.h" |
171 #include "media/base/media_switches.h" | 170 #include "media/base/media_switches.h" |
172 #include "mojo/edk/embedder/embedder.h" | 171 #include "mojo/edk/embedder/embedder.h" |
173 #include "net/url_request/url_request_context_getter.h" | 172 #include "net/url_request/url_request_context_getter.h" |
174 #include "ppapi/shared_impl/ppapi_switches.h" | 173 #include "ppapi/shared_impl/ppapi_switches.h" |
175 #include "services/shell/runner/common/switches.h" | 174 #include "services/shell/runner/common/switches.h" |
176 #include "storage/browser/fileapi/sandbox_file_system_backend.h" | 175 #include "storage/browser/fileapi/sandbox_file_system_backend.h" |
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
743 // messages flow between the browser and renderer, this thread is required | 742 // messages flow between the browser and renderer, this thread is required |
744 // to prevent a deadlock in single-process mode. Since the primordial | 743 // to prevent a deadlock in single-process mode. Since the primordial |
745 // thread in the renderer process runs the WebKit code and can sometimes | 744 // thread in the renderer process runs the WebKit code and can sometimes |
746 // make blocking calls to the UI thread (i.e. this thread), they need to run | 745 // make blocking calls to the UI thread (i.e. this thread), they need to run |
747 // on separate threads. | 746 // on separate threads. |
748 in_process_renderer_.reset( | 747 in_process_renderer_.reset( |
749 g_renderer_main_thread_factory(InProcessChildThreadParams( | 748 g_renderer_main_thread_factory(InProcessChildThreadParams( |
750 channel_id, | 749 channel_id, |
751 BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::IO) | 750 BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::IO) |
752 ->task_runner(), | 751 ->task_runner(), |
753 std::string(), | 752 mojo_channel_token_, |
754 mojo_child_connection_->shell_client_token()))); | 753 mojo_child_connection_->shell_client_token()))); |
755 | 754 |
756 base::Thread::Options options; | 755 base::Thread::Options options; |
757 #if defined(OS_WIN) && !defined(OS_MACOSX) | 756 #if defined(OS_WIN) && !defined(OS_MACOSX) |
758 // In-process plugins require this to be a UI message loop. | 757 // In-process plugins require this to be a UI message loop. |
759 options.message_loop_type = base::MessageLoop::TYPE_UI; | 758 options.message_loop_type = base::MessageLoop::TYPE_UI; |
760 #else | 759 #else |
761 // We can't have multiple UI loops on Linux and Android, so we don't support | 760 // We can't have multiple UI loops on Linux and Android, so we don't support |
762 // in-process plugins. | 761 // in-process plugins. |
763 options.message_loop_type = base::MessageLoop::TYPE_DEFAULT; | 762 options.message_loop_type = base::MessageLoop::TYPE_DEFAULT; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
804 | 803 |
805 is_initialized_ = true; | 804 is_initialized_ = true; |
806 init_time_ = base::TimeTicks::Now(); | 805 init_time_ = base::TimeTicks::Now(); |
807 return true; | 806 return true; |
808 } | 807 } |
809 | 808 |
810 std::unique_ptr<IPC::ChannelProxy> RenderProcessHostImpl::CreateChannelProxy( | 809 std::unique_ptr<IPC::ChannelProxy> RenderProcessHostImpl::CreateChannelProxy( |
811 const std::string& channel_id) { | 810 const std::string& channel_id) { |
812 scoped_refptr<base::SingleThreadTaskRunner> runner = | 811 scoped_refptr<base::SingleThreadTaskRunner> runner = |
813 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); | 812 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); |
814 IPC::mojom::BootstrapPtr bootstrap; | 813 mojo_channel_token_ = mojo::edk::GenerateRandomToken(); |
815 mojo_child_connection_->connection()->GetInterface(&bootstrap); | 814 mojo::ScopedMessagePipeHandle handle = |
816 mojo::ScopedMessagePipeHandle handle = bootstrap.PassInterface().PassHandle(); | 815 mojo::edk::CreateParentMessagePipe(mojo_channel_token_, child_token_); |
817 | 816 |
818 // Do NOT expand ifdef or run time condition checks here! Synchronous | 817 // Do NOT expand ifdef or run time condition checks here! Synchronous |
819 // IPCs from browser process are banned. It is only narrowly allowed | 818 // IPCs from browser process are banned. It is only narrowly allowed |
820 // for Android WebView to maintain backward compatibility. | 819 // for Android WebView to maintain backward compatibility. |
821 // See crbug.com/526842 for details. | 820 // See crbug.com/526842 for details. |
822 #if defined(OS_ANDROID) | 821 #if defined(OS_ANDROID) |
823 if (GetContentClient()->UsingSynchronousCompositing()) { | 822 if (GetContentClient()->UsingSynchronousCompositing()) { |
824 return IPC::SyncChannel::Create( | 823 return IPC::SyncChannel::Create( |
825 IPC::ChannelMojo::CreateServerFactory(std::move(handle)), this, | 824 IPC::ChannelMojo::CreateServerFactory(std::move(handle)), this, |
826 runner.get(), true, &never_signaled_); | 825 runner.get(), true, &never_signaled_); |
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1332 command_line->AppendSwitch(switches::kEnablePinch); | 1331 command_line->AppendSwitch(switches::kEnablePinch); |
1333 | 1332 |
1334 #if defined(OS_WIN) | 1333 #if defined(OS_WIN) |
1335 command_line->AppendSwitchASCII( | 1334 command_line->AppendSwitchASCII( |
1336 switches::kDeviceScaleFactor, | 1335 switches::kDeviceScaleFactor, |
1337 base::DoubleToString(display::win::GetDPIScale())); | 1336 base::DoubleToString(display::win::GetDPIScale())); |
1338 #endif | 1337 #endif |
1339 | 1338 |
1340 AppendCompositorCommandLineFlags(command_line); | 1339 AppendCompositorCommandLineFlags(command_line); |
1341 | 1340 |
| 1341 if (!mojo_channel_token_.empty()) { |
| 1342 command_line->AppendSwitchASCII(switches::kMojoChannelToken, |
| 1343 mojo_channel_token_); |
| 1344 } |
1342 command_line->AppendSwitchASCII(switches::kMojoApplicationChannelToken, | 1345 command_line->AppendSwitchASCII(switches::kMojoApplicationChannelToken, |
1343 mojo_child_connection_->shell_client_token()); | 1346 mojo_child_connection_->shell_client_token()); |
1344 } | 1347 } |
1345 | 1348 |
1346 void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer( | 1349 void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer( |
1347 const base::CommandLine& browser_cmd, | 1350 const base::CommandLine& browser_cmd, |
1348 base::CommandLine* renderer_cmd) const { | 1351 base::CommandLine* renderer_cmd) const { |
1349 // Propagate the following switches to the renderer command line (along | 1352 // Propagate the following switches to the renderer command line (along |
1350 // with any associated values) if present in the browser command line. | 1353 // with any associated values) if present in the browser command line. |
1351 static const char* const kSwitchNames[] = { | 1354 static const char* const kSwitchNames[] = { |
(...skipping 1469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2821 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; | 2824 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; |
2822 | 2825 |
2823 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. Alias | 2826 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. Alias |
2824 // enough information here so that we can determine what the bad message was. | 2827 // enough information here so that we can determine what the bad message was. |
2825 base::debug::Alias(&error); | 2828 base::debug::Alias(&error); |
2826 bad_message::ReceivedBadMessage(process.get(), | 2829 bad_message::ReceivedBadMessage(process.get(), |
2827 bad_message::RPH_MOJO_PROCESS_ERROR); | 2830 bad_message::RPH_MOJO_PROCESS_ERROR); |
2828 } | 2831 } |
2829 | 2832 |
2830 } // namespace content | 2833 } // namespace content |
OLD | NEW |