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 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
604 shell::Connector* connector = | 604 shell::Connector* connector = |
605 BrowserContext::GetShellConnectorFor(browser_context_); | 605 BrowserContext::GetShellConnectorFor(browser_context_); |
606 // Some embedders may not initialize Mojo or the shell connector for a browser | 606 // Some embedders may not initialize Mojo or the shell connector for a browser |
607 // context (e.g. Android WebView)... so just fall back to the per-process | 607 // context (e.g. Android WebView)... so just fall back to the per-process |
608 // connector. | 608 // connector. |
609 if (!connector) { | 609 if (!connector) { |
610 // Additionally, some test code may not initialize the process-wide | 610 // Additionally, some test code may not initialize the process-wide |
611 // MojoShellConnection prior to this point. This class of test code doesn't | 611 // MojoShellConnection prior to this point. This class of test code doesn't |
612 // care about render processes so we can initialize a dummy one. | 612 // care about render processes so we can initialize a dummy one. |
613 if (!MojoShellConnection::GetForProcess()) { | 613 if (!MojoShellConnection::GetForProcess()) { |
614 shell::mojom::ShellClientRequest request = | 614 shell::mojom::ServiceRequest request = mojo::GetProxy(&test_service_); |
615 mojo::GetProxy(&test_shell_client_); | |
616 MojoShellConnection::SetForProcess(MojoShellConnection::Create( | 615 MojoShellConnection::SetForProcess(MojoShellConnection::Create( |
617 std::move(request))); | 616 std::move(request))); |
618 } | 617 } |
619 connector = MojoShellConnection::GetForProcess()->GetConnector(); | 618 connector = MojoShellConnection::GetForProcess()->GetConnector(); |
620 } | 619 } |
621 mojo_child_connection_.reset(new MojoChildConnection( | 620 mojo_child_connection_.reset(new MojoChildConnection( |
622 kRendererMojoApplicationName, | 621 kRendererMojoApplicationName, |
623 base::StringPrintf("%d_%d", id_, instance_id_++), | 622 base::StringPrintf("%d_%d", id_, instance_id_++), |
624 child_token_, | 623 child_token_, |
625 connector)); | 624 connector)); |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
743 // to prevent a deadlock in single-process mode. Since the primordial | 742 // to prevent a deadlock in single-process mode. Since the primordial |
744 // thread in the renderer process runs the WebKit code and can sometimes | 743 // 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 | 744 // make blocking calls to the UI thread (i.e. this thread), they need to run |
746 // on separate threads. | 745 // on separate threads. |
747 in_process_renderer_.reset( | 746 in_process_renderer_.reset( |
748 g_renderer_main_thread_factory(InProcessChildThreadParams( | 747 g_renderer_main_thread_factory(InProcessChildThreadParams( |
749 channel_id, | 748 channel_id, |
750 BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::IO) | 749 BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::IO) |
751 ->task_runner(), | 750 ->task_runner(), |
752 mojo_channel_token_, | 751 mojo_channel_token_, |
753 mojo_child_connection_->shell_client_token()))); | 752 mojo_child_connection_->service_token()))); |
754 | 753 |
755 base::Thread::Options options; | 754 base::Thread::Options options; |
756 #if defined(OS_WIN) && !defined(OS_MACOSX) | 755 #if defined(OS_WIN) && !defined(OS_MACOSX) |
757 // In-process plugins require this to be a UI message loop. | 756 // In-process plugins require this to be a UI message loop. |
758 options.message_loop_type = base::MessageLoop::TYPE_UI; | 757 options.message_loop_type = base::MessageLoop::TYPE_UI; |
759 #else | 758 #else |
760 // We can't have multiple UI loops on Linux and Android, so we don't support | 759 // We can't have multiple UI loops on Linux and Android, so we don't support |
761 // in-process plugins. | 760 // in-process plugins. |
762 options.message_loop_type = base::MessageLoop::TYPE_DEFAULT; | 761 options.message_loop_type = base::MessageLoop::TYPE_DEFAULT; |
763 #endif | 762 #endif |
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1338 base::DoubleToString(display::win::GetDPIScale())); | 1337 base::DoubleToString(display::win::GetDPIScale())); |
1339 #endif | 1338 #endif |
1340 | 1339 |
1341 AppendCompositorCommandLineFlags(command_line); | 1340 AppendCompositorCommandLineFlags(command_line); |
1342 | 1341 |
1343 if (!mojo_channel_token_.empty()) { | 1342 if (!mojo_channel_token_.empty()) { |
1344 command_line->AppendSwitchASCII(switches::kMojoChannelToken, | 1343 command_line->AppendSwitchASCII(switches::kMojoChannelToken, |
1345 mojo_channel_token_); | 1344 mojo_channel_token_); |
1346 } | 1345 } |
1347 command_line->AppendSwitchASCII(switches::kMojoApplicationChannelToken, | 1346 command_line->AppendSwitchASCII(switches::kMojoApplicationChannelToken, |
1348 mojo_child_connection_->shell_client_token()); | 1347 mojo_child_connection_->service_token()); |
1349 } | 1348 } |
1350 | 1349 |
1351 void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer( | 1350 void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer( |
1352 const base::CommandLine& browser_cmd, | 1351 const base::CommandLine& browser_cmd, |
1353 base::CommandLine* renderer_cmd) const { | 1352 base::CommandLine* renderer_cmd) const { |
1354 // Propagate the following switches to the renderer command line (along | 1353 // Propagate the following switches to the renderer command line (along |
1355 // with any associated values) if present in the browser command line. | 1354 // with any associated values) if present in the browser command line. |
1356 static const char* const kSwitchNames[] = { | 1355 static const char* const kSwitchNames[] = { |
1357 switches::kAgcStartupMinVolume, | 1356 switches::kAgcStartupMinVolume, |
1358 switches::kAecRefinedAdaptiveFilter, | 1357 switches::kAecRefinedAdaptiveFilter, |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1596 // Look to pass-on the kWaitForDebugger flag. | 1595 // Look to pass-on the kWaitForDebugger flag. |
1597 std::string value = | 1596 std::string value = |
1598 browser_cmd.GetSwitchValueASCII(switches::kWaitForDebuggerChildren); | 1597 browser_cmd.GetSwitchValueASCII(switches::kWaitForDebuggerChildren); |
1599 if (value.empty() || value == switches::kRendererProcess) { | 1598 if (value.empty() || value == switches::kRendererProcess) { |
1600 renderer_cmd->AppendSwitch(switches::kWaitForDebugger); | 1599 renderer_cmd->AppendSwitch(switches::kWaitForDebugger); |
1601 } | 1600 } |
1602 } | 1601 } |
1603 | 1602 |
1604 DCHECK(mojo_child_connection_); | 1603 DCHECK(mojo_child_connection_); |
1605 renderer_cmd->AppendSwitchASCII(switches::kPrimordialPipeToken, | 1604 renderer_cmd->AppendSwitchASCII(switches::kPrimordialPipeToken, |
1606 mojo_child_connection_->shell_client_token()); | 1605 mojo_child_connection_->service_token()); |
1607 | 1606 |
1608 #if defined(OS_WIN) && !defined(OFFICIAL_BUILD) | 1607 #if defined(OS_WIN) && !defined(OFFICIAL_BUILD) |
1609 // Needed because we can't show the dialog from the sandbox. Don't pass | 1608 // Needed because we can't show the dialog from the sandbox. Don't pass |
1610 // --no-sandbox in official builds because that would bypass the bad_flgs | 1609 // --no-sandbox in official builds because that would bypass the bad_flgs |
1611 // prompt. | 1610 // prompt. |
1612 if (renderer_cmd->HasSwitch(switches::kRendererStartupDialog) && | 1611 if (renderer_cmd->HasSwitch(switches::kRendererStartupDialog) && |
1613 !renderer_cmd->HasSwitch(switches::kNoSandbox)) { | 1612 !renderer_cmd->HasSwitch(switches::kNoSandbox)) { |
1614 renderer_cmd->AppendSwitch(switches::kNoSandbox); | 1613 renderer_cmd->AppendSwitch(switches::kNoSandbox); |
1615 } | 1614 } |
1616 #endif | 1615 #endif |
(...skipping 1210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2827 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; | 2826 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; |
2828 | 2827 |
2829 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. Alias | 2828 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. Alias |
2830 // enough information here so that we can determine what the bad message was. | 2829 // enough information here so that we can determine what the bad message was. |
2831 base::debug::Alias(&error); | 2830 base::debug::Alias(&error); |
2832 bad_message::ReceivedBadMessage(process.get(), | 2831 bad_message::ReceivedBadMessage(process.get(), |
2833 bad_message::RPH_MOJO_PROCESS_ERROR); | 2832 bad_message::RPH_MOJO_PROCESS_ERROR); |
2834 } | 2833 } |
2835 | 2834 |
2836 } // namespace content | 2835 } // namespace content |
OLD | NEW |