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 949 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
960 base::CommandLine* cmd_line = new base::CommandLine(renderer_path); | 960 base::CommandLine* cmd_line = new base::CommandLine(renderer_path); |
961 if (!renderer_prefix.empty()) | 961 if (!renderer_prefix.empty()) |
962 cmd_line->PrependWrapper(renderer_prefix); | 962 cmd_line->PrependWrapper(renderer_prefix); |
963 AppendRendererCommandLine(cmd_line); | 963 AppendRendererCommandLine(cmd_line); |
964 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, channel_id); | 964 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, channel_id); |
965 | 965 |
966 // Spawn the child process asynchronously to avoid blocking the UI thread. | 966 // Spawn the child process asynchronously to avoid blocking the UI thread. |
967 // As long as there's no renderer prefix, we can use the zygote process | 967 // As long as there's no renderer prefix, we can use the zygote process |
968 // at this stage. | 968 // at this stage. |
969 child_process_launcher_.reset(new ChildProcessLauncher( | 969 child_process_launcher_.reset(new ChildProcessLauncher( |
970 new RendererSandboxedProcessLauncherDelegate(channel_.get()), cmd_line, | 970 new RendererSandboxedProcessLauncherDelegate(channel_.get()), |
971 field_trial_state_.get(), | |
972 cmd_line, | |
971 GetID(), this, child_token_, | 973 GetID(), this, child_token_, |
972 base::Bind(&RenderProcessHostImpl::OnMojoError, | 974 base::Bind(&RenderProcessHostImpl::OnMojoError, |
973 weak_factory_.GetWeakPtr(), | 975 weak_factory_.GetWeakPtr(), |
974 base::ThreadTaskRunnerHandle::Get()))); | 976 base::ThreadTaskRunnerHandle::Get()))); |
975 channel_->Pause(); | 977 channel_->Pause(); |
976 | 978 |
977 fast_shutdown_started_ = false; | 979 fast_shutdown_started_ = false; |
978 } | 980 } |
979 | 981 |
980 // Push any pending messages to the channel now. Note that if the child | 982 // Push any pending messages to the channel now. Note that if the child |
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1580 gpu_data_manager->AppendRendererCommandLine(command_line); | 1582 gpu_data_manager->AppendRendererCommandLine(command_line); |
1581 | 1583 |
1582 // Slimming Paint v2 implies layer lists in the renderer. | 1584 // Slimming Paint v2 implies layer lists in the renderer. |
1583 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 1585 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
1584 switches::kEnableSlimmingPaintV2)) { | 1586 switches::kEnableSlimmingPaintV2)) { |
1585 command_line->AppendSwitch(cc::switches::kEnableLayerLists); | 1587 command_line->AppendSwitch(cc::switches::kEnableLayerLists); |
1586 } | 1588 } |
1587 } | 1589 } |
1588 | 1590 |
1589 void RenderProcessHostImpl::AppendRendererCommandLine( | 1591 void RenderProcessHostImpl::AppendRendererCommandLine( |
1590 base::CommandLine* command_line) const { | 1592 base::CommandLine* command_line) { |
1591 // Pass the process type first, so it shows first in process listings. | 1593 // Pass the process type first, so it shows first in process listings. |
1592 command_line->AppendSwitchASCII(switches::kProcessType, | 1594 command_line->AppendSwitchASCII(switches::kProcessType, |
1593 switches::kRendererProcess); | 1595 switches::kRendererProcess); |
1594 | 1596 |
1595 #if defined(OS_WIN) | 1597 #if defined(OS_WIN) |
1596 command_line->AppendArg(switches::kPrefetchArgumentRenderer); | 1598 command_line->AppendArg(switches::kPrefetchArgumentRenderer); |
1597 #endif // defined(OS_WIN) | 1599 #endif // defined(OS_WIN) |
1598 | 1600 |
1599 // Now send any options from our own command line we want to propagate. | 1601 // Now send any options from our own command line we want to propagate. |
1600 const base::CommandLine& browser_command_line = | 1602 const base::CommandLine& browser_command_line = |
(...skipping 18 matching lines...) Expand all Loading... | |
1619 #endif | 1621 #endif |
1620 | 1622 |
1621 AppendCompositorCommandLineFlags(command_line); | 1623 AppendCompositorCommandLineFlags(command_line); |
1622 | 1624 |
1623 command_line->AppendSwitchASCII(switches::kMojoApplicationChannelToken, | 1625 command_line->AppendSwitchASCII(switches::kMojoApplicationChannelToken, |
1624 mojo_child_connection_->service_token()); | 1626 mojo_child_connection_->service_token()); |
1625 } | 1627 } |
1626 | 1628 |
1627 void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer( | 1629 void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer( |
1628 const base::CommandLine& browser_cmd, | 1630 const base::CommandLine& browser_cmd, |
1629 base::CommandLine* renderer_cmd) const { | 1631 base::CommandLine* renderer_cmd) { |
1630 // Propagate the following switches to the renderer command line (along | 1632 // Propagate the following switches to the renderer command line (along |
1631 // with any associated values) if present in the browser command line. | 1633 // with any associated values) if present in the browser command line. |
1632 static const char* const kSwitchNames[] = { | 1634 static const char* const kSwitchNames[] = { |
1633 switches::kAgcStartupMinVolume, | 1635 switches::kAgcStartupMinVolume, |
1634 switches::kAecRefinedAdaptiveFilter, | 1636 switches::kAecRefinedAdaptiveFilter, |
1635 switches::kAllowLoopbackInPeerConnection, | 1637 switches::kAllowLoopbackInPeerConnection, |
1636 switches::kAndroidFontsPath, | 1638 switches::kAndroidFontsPath, |
1637 switches::kAudioBufferSize, | 1639 switches::kAudioBufferSize, |
1638 switches::kBlinkSettings, | 1640 switches::kBlinkSettings, |
1639 switches::kDefaultTileWidth, | 1641 switches::kDefaultTileWidth, |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1832 #endif | 1834 #endif |
1833 #if defined(ENABLE_IPC_FUZZER) | 1835 #if defined(ENABLE_IPC_FUZZER) |
1834 switches::kIpcDumpDirectory, | 1836 switches::kIpcDumpDirectory, |
1835 switches::kIpcFuzzerTestcase, | 1837 switches::kIpcFuzzerTestcase, |
1836 #endif | 1838 #endif |
1837 switches::kUseMusInRenderer, | 1839 switches::kUseMusInRenderer, |
1838 }; | 1840 }; |
1839 renderer_cmd->CopySwitchesFrom(browser_cmd, kSwitchNames, | 1841 renderer_cmd->CopySwitchesFrom(browser_cmd, kSwitchNames, |
1840 arraysize(kSwitchNames)); | 1842 arraysize(kSwitchNames)); |
1841 | 1843 |
1844 #if defined(OS_WIN) | |
Alexei Svitkine (slow)
2016/10/03 15:28:05
I think you can just ifdef the line below and have
lawrencewu
2016/10/03 21:36:11
Done.
| |
1845 field_trial_state_.reset(new base::SharedMemory()); | |
1846 BrowserChildProcessHostImpl::CopyFeatureAndFieldTrialFlags( | |
1847 renderer_cmd, field_trial_state_.get()); | |
1848 #else | |
1842 BrowserChildProcessHostImpl::CopyFeatureAndFieldTrialFlags(renderer_cmd); | 1849 BrowserChildProcessHostImpl::CopyFeatureAndFieldTrialFlags(renderer_cmd); |
1850 #endif | |
1843 | 1851 |
1844 if (browser_cmd.HasSwitch(switches::kTraceStartup) && | 1852 if (browser_cmd.HasSwitch(switches::kTraceStartup) && |
1845 BrowserMainLoop::GetInstance()->is_tracing_startup_for_duration()) { | 1853 BrowserMainLoop::GetInstance()->is_tracing_startup_for_duration()) { |
1846 // Pass kTraceStartup switch to renderer only if startup tracing has not | 1854 // Pass kTraceStartup switch to renderer only if startup tracing has not |
1847 // finished. | 1855 // finished. |
1848 renderer_cmd->AppendSwitchASCII( | 1856 renderer_cmd->AppendSwitchASCII( |
1849 switches::kTraceStartup, | 1857 switches::kTraceStartup, |
1850 browser_cmd.GetSwitchValueASCII(switches::kTraceStartup)); | 1858 browser_cmd.GetSwitchValueASCII(switches::kTraceStartup)); |
1851 } | 1859 } |
1852 | 1860 |
(...skipping 1187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3040 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; | 3048 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; |
3041 | 3049 |
3042 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. Alias | 3050 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. Alias |
3043 // enough information here so that we can determine what the bad message was. | 3051 // enough information here so that we can determine what the bad message was. |
3044 base::debug::Alias(&error); | 3052 base::debug::Alias(&error); |
3045 bad_message::ReceivedBadMessage(process.get(), | 3053 bad_message::ReceivedBadMessage(process.get(), |
3046 bad_message::RPH_MOJO_PROCESS_ERROR); | 3054 bad_message::RPH_MOJO_PROCESS_ERROR); |
3047 } | 3055 } |
3048 | 3056 |
3049 } // namespace content | 3057 } // namespace content |
OLD | NEW |