| 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 816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 827 // Crank up a thread and run the initialization there. With the way that | 827 // Crank up a thread and run the initialization there. With the way that |
| 828 // messages flow between the browser and renderer, this thread is required | 828 // messages flow between the browser and renderer, this thread is required |
| 829 // to prevent a deadlock in single-process mode. Since the primordial | 829 // to prevent a deadlock in single-process mode. Since the primordial |
| 830 // thread in the renderer process runs the WebKit code and can sometimes | 830 // thread in the renderer process runs the WebKit code and can sometimes |
| 831 // make blocking calls to the UI thread (i.e. this thread), they need to run | 831 // make blocking calls to the UI thread (i.e. this thread), they need to run |
| 832 // on separate threads. | 832 // on separate threads. |
| 833 in_process_renderer_.reset( | 833 in_process_renderer_.reset( |
| 834 g_renderer_main_thread_factory(InProcessChildThreadParams( | 834 g_renderer_main_thread_factory(InProcessChildThreadParams( |
| 835 channel_id, | 835 channel_id, |
| 836 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO), | 836 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO), |
| 837 channel_token_, mojo_child_connection_->service_token()))); | 837 std::string(), mojo_child_connection_->service_token()))); |
| 838 | 838 |
| 839 base::Thread::Options options; | 839 base::Thread::Options options; |
| 840 #if defined(OS_WIN) && !defined(OS_MACOSX) | 840 #if defined(OS_WIN) && !defined(OS_MACOSX) |
| 841 // In-process plugins require this to be a UI message loop. | 841 // In-process plugins require this to be a UI message loop. |
| 842 options.message_loop_type = base::MessageLoop::TYPE_UI; | 842 options.message_loop_type = base::MessageLoop::TYPE_UI; |
| 843 #else | 843 #else |
| 844 // We can't have multiple UI loops on Linux and Android, so we don't support | 844 // We can't have multiple UI loops on Linux and Android, so we don't support |
| 845 // in-process plugins. | 845 // in-process plugins. |
| 846 options.message_loop_type = base::MessageLoop::TYPE_DEFAULT; | 846 options.message_loop_type = base::MessageLoop::TYPE_DEFAULT; |
| 847 #endif | 847 #endif |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 887 | 887 |
| 888 is_initialized_ = true; | 888 is_initialized_ = true; |
| 889 init_time_ = base::TimeTicks::Now(); | 889 init_time_ = base::TimeTicks::Now(); |
| 890 return true; | 890 return true; |
| 891 } | 891 } |
| 892 | 892 |
| 893 std::unique_ptr<IPC::ChannelProxy> RenderProcessHostImpl::CreateChannelProxy( | 893 std::unique_ptr<IPC::ChannelProxy> RenderProcessHostImpl::CreateChannelProxy( |
| 894 const std::string& channel_id) { | 894 const std::string& channel_id) { |
| 895 scoped_refptr<base::SingleThreadTaskRunner> runner = | 895 scoped_refptr<base::SingleThreadTaskRunner> runner = |
| 896 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO); | 896 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO); |
| 897 channel_token_ = mojo::edk::GenerateRandomToken(); | 897 IPC::mojom::ChannelBootstrapPtr bootstrap; |
| 898 mojo::ScopedMessagePipeHandle handle = | 898 GetRemoteInterfaces()->GetInterface(&bootstrap); |
| 899 mojo::edk::CreateParentMessagePipe(channel_token_, child_token_); | |
| 900 std::unique_ptr<IPC::ChannelFactory> channel_factory = | 899 std::unique_ptr<IPC::ChannelFactory> channel_factory = |
| 901 IPC::ChannelMojo::CreateServerFactory(std::move(handle), runner); | 900 IPC::ChannelMojo::CreateServerFactory( |
| 901 bootstrap.PassInterface().PassHandle(), runner); |
| 902 | 902 |
| 903 // Do NOT expand ifdef or run time condition checks here! Synchronous | 903 // Do NOT expand ifdef or run time condition checks here! Synchronous |
| 904 // IPCs from browser process are banned. It is only narrowly allowed | 904 // IPCs from browser process are banned. It is only narrowly allowed |
| 905 // for Android WebView to maintain backward compatibility. | 905 // for Android WebView to maintain backward compatibility. |
| 906 // See crbug.com/526842 for details. | 906 // See crbug.com/526842 for details. |
| 907 #if defined(OS_ANDROID) | 907 #if defined(OS_ANDROID) |
| 908 if (GetContentClient()->UsingSynchronousCompositing()) { | 908 if (GetContentClient()->UsingSynchronousCompositing()) { |
| 909 return IPC::SyncChannel::Create( | 909 return IPC::SyncChannel::Create( |
| 910 std::move(channel_factory), this, runner.get(), true, &never_signaled_); | 910 std::move(channel_factory), this, runner.get(), true, &never_signaled_); |
| 911 } | 911 } |
| (...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1427 command_line->AppendSwitch(switches::kEnablePinch); | 1427 command_line->AppendSwitch(switches::kEnablePinch); |
| 1428 | 1428 |
| 1429 #if defined(OS_WIN) | 1429 #if defined(OS_WIN) |
| 1430 command_line->AppendSwitchASCII( | 1430 command_line->AppendSwitchASCII( |
| 1431 switches::kDeviceScaleFactor, | 1431 switches::kDeviceScaleFactor, |
| 1432 base::DoubleToString(display::win::GetDPIScale())); | 1432 base::DoubleToString(display::win::GetDPIScale())); |
| 1433 #endif | 1433 #endif |
| 1434 | 1434 |
| 1435 AppendCompositorCommandLineFlags(command_line); | 1435 AppendCompositorCommandLineFlags(command_line); |
| 1436 | 1436 |
| 1437 if (!channel_token_.empty()) { | |
| 1438 command_line->AppendSwitchASCII( | |
| 1439 switches::kMojoChannelToken, channel_token_); | |
| 1440 } | |
| 1441 | |
| 1442 command_line->AppendSwitchASCII(switches::kMojoApplicationChannelToken, | 1437 command_line->AppendSwitchASCII(switches::kMojoApplicationChannelToken, |
| 1443 mojo_child_connection_->service_token()); | 1438 mojo_child_connection_->service_token()); |
| 1444 } | 1439 } |
| 1445 | 1440 |
| 1446 void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer( | 1441 void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer( |
| 1447 const base::CommandLine& browser_cmd, | 1442 const base::CommandLine& browser_cmd, |
| 1448 base::CommandLine* renderer_cmd) const { | 1443 base::CommandLine* renderer_cmd) const { |
| 1449 // Propagate the following switches to the renderer command line (along | 1444 // Propagate the following switches to the renderer command line (along |
| 1450 // with any associated values) if present in the browser command line. | 1445 // with any associated values) if present in the browser command line. |
| 1451 static const char* const kSwitchNames[] = { | 1446 static const char* const kSwitchNames[] = { |
| (...skipping 1390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2842 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; | 2837 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; |
| 2843 | 2838 |
| 2844 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. Alias | 2839 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. Alias |
| 2845 // enough information here so that we can determine what the bad message was. | 2840 // enough information here so that we can determine what the bad message was. |
| 2846 base::debug::Alias(&error); | 2841 base::debug::Alias(&error); |
| 2847 bad_message::ReceivedBadMessage(process.get(), | 2842 bad_message::ReceivedBadMessage(process.get(), |
| 2848 bad_message::RPH_MOJO_PROCESS_ERROR); | 2843 bad_message::RPH_MOJO_PROCESS_ERROR); |
| 2849 } | 2844 } |
| 2850 | 2845 |
| 2851 } // namespace content | 2846 } // namespace content |
| OLD | NEW |