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