Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(126)

Side by Side Diff: content/browser/renderer_host/render_process_host_impl.cc

Issue 2365273004: Initial implementation for sharing field trial state (win) (Closed)
Patch Set: Write unit test for BrowserChildProcessHostImpl Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 #if defined(OS_WIN)
972 field_trial_state_.get()->handle().GetHandle(),
Alexei Svitkine (slow) 2016/09/30 21:47:52 Can we pass base::SharedMemory* instead of HANDLE?
lawrencewu 2016/10/03 14:14:36 Done.
973 #endif
974 cmd_line,
971 GetID(), this, child_token_, 975 GetID(), this, child_token_,
972 base::Bind(&RenderProcessHostImpl::OnMojoError, 976 base::Bind(&RenderProcessHostImpl::OnMojoError,
973 weak_factory_.GetWeakPtr(), 977 weak_factory_.GetWeakPtr(),
974 base::ThreadTaskRunnerHandle::Get()))); 978 base::ThreadTaskRunnerHandle::Get())));
975 channel_->Pause(); 979 channel_->Pause();
976 980
977 fast_shutdown_started_ = false; 981 fast_shutdown_started_ = false;
978 } 982 }
979 983
980 // Push any pending messages to the channel now. Note that if the child 984 // 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
1580 gpu_data_manager->AppendRendererCommandLine(command_line); 1584 gpu_data_manager->AppendRendererCommandLine(command_line);
1581 1585
1582 // Slimming Paint v2 implies layer lists in the renderer. 1586 // Slimming Paint v2 implies layer lists in the renderer.
1583 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 1587 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
1584 switches::kEnableSlimmingPaintV2)) { 1588 switches::kEnableSlimmingPaintV2)) {
1585 command_line->AppendSwitch(cc::switches::kEnableLayerLists); 1589 command_line->AppendSwitch(cc::switches::kEnableLayerLists);
1586 } 1590 }
1587 } 1591 }
1588 1592
1589 void RenderProcessHostImpl::AppendRendererCommandLine( 1593 void RenderProcessHostImpl::AppendRendererCommandLine(
1590 base::CommandLine* command_line) const { 1594 base::CommandLine* command_line) {
1591 // Pass the process type first, so it shows first in process listings. 1595 // Pass the process type first, so it shows first in process listings.
1592 command_line->AppendSwitchASCII(switches::kProcessType, 1596 command_line->AppendSwitchASCII(switches::kProcessType,
1593 switches::kRendererProcess); 1597 switches::kRendererProcess);
1594 1598
1595 #if defined(OS_WIN) 1599 #if defined(OS_WIN)
1596 command_line->AppendArg(switches::kPrefetchArgumentRenderer); 1600 command_line->AppendArg(switches::kPrefetchArgumentRenderer);
1597 #endif // defined(OS_WIN) 1601 #endif // defined(OS_WIN)
1598 1602
1599 // Now send any options from our own command line we want to propagate. 1603 // Now send any options from our own command line we want to propagate.
1600 const base::CommandLine& browser_command_line = 1604 const base::CommandLine& browser_command_line =
(...skipping 18 matching lines...) Expand all
1619 #endif 1623 #endif
1620 1624
1621 AppendCompositorCommandLineFlags(command_line); 1625 AppendCompositorCommandLineFlags(command_line);
1622 1626
1623 command_line->AppendSwitchASCII(switches::kMojoApplicationChannelToken, 1627 command_line->AppendSwitchASCII(switches::kMojoApplicationChannelToken,
1624 mojo_child_connection_->service_token()); 1628 mojo_child_connection_->service_token());
1625 } 1629 }
1626 1630
1627 void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer( 1631 void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer(
1628 const base::CommandLine& browser_cmd, 1632 const base::CommandLine& browser_cmd,
1629 base::CommandLine* renderer_cmd) const { 1633 base::CommandLine* renderer_cmd) {
1630 // Propagate the following switches to the renderer command line (along 1634 // Propagate the following switches to the renderer command line (along
1631 // with any associated values) if present in the browser command line. 1635 // with any associated values) if present in the browser command line.
1632 static const char* const kSwitchNames[] = { 1636 static const char* const kSwitchNames[] = {
1633 switches::kAgcStartupMinVolume, 1637 switches::kAgcStartupMinVolume,
1634 switches::kAecRefinedAdaptiveFilter, 1638 switches::kAecRefinedAdaptiveFilter,
1635 switches::kAllowLoopbackInPeerConnection, 1639 switches::kAllowLoopbackInPeerConnection,
1636 switches::kAndroidFontsPath, 1640 switches::kAndroidFontsPath,
1637 switches::kAudioBufferSize, 1641 switches::kAudioBufferSize,
1638 switches::kBlinkSettings, 1642 switches::kBlinkSettings,
1639 switches::kDefaultTileWidth, 1643 switches::kDefaultTileWidth,
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
1832 #endif 1836 #endif
1833 #if defined(ENABLE_IPC_FUZZER) 1837 #if defined(ENABLE_IPC_FUZZER)
1834 switches::kIpcDumpDirectory, 1838 switches::kIpcDumpDirectory,
1835 switches::kIpcFuzzerTestcase, 1839 switches::kIpcFuzzerTestcase,
1836 #endif 1840 #endif
1837 switches::kUseMusInRenderer, 1841 switches::kUseMusInRenderer,
1838 }; 1842 };
1839 renderer_cmd->CopySwitchesFrom(browser_cmd, kSwitchNames, 1843 renderer_cmd->CopySwitchesFrom(browser_cmd, kSwitchNames,
1840 arraysize(kSwitchNames)); 1844 arraysize(kSwitchNames));
1841 1845
1846 #if defined(OS_WIN)
1847 field_trial_state_.reset(new base::SharedMemory());
1848 BrowserChildProcessHostImpl::CopyFeatureAndFieldTrialFlags(
1849 renderer_cmd, field_trial_state_.get());
1850 #else
1842 BrowserChildProcessHostImpl::CopyFeatureAndFieldTrialFlags(renderer_cmd); 1851 BrowserChildProcessHostImpl::CopyFeatureAndFieldTrialFlags(renderer_cmd);
1852 #endif
1843 1853
1844 if (browser_cmd.HasSwitch(switches::kTraceStartup) && 1854 if (browser_cmd.HasSwitch(switches::kTraceStartup) &&
1845 BrowserMainLoop::GetInstance()->is_tracing_startup_for_duration()) { 1855 BrowserMainLoop::GetInstance()->is_tracing_startup_for_duration()) {
1846 // Pass kTraceStartup switch to renderer only if startup tracing has not 1856 // Pass kTraceStartup switch to renderer only if startup tracing has not
1847 // finished. 1857 // finished.
1848 renderer_cmd->AppendSwitchASCII( 1858 renderer_cmd->AppendSwitchASCII(
1849 switches::kTraceStartup, 1859 switches::kTraceStartup,
1850 browser_cmd.GetSwitchValueASCII(switches::kTraceStartup)); 1860 browser_cmd.GetSwitchValueASCII(switches::kTraceStartup));
1851 } 1861 }
1852 1862
(...skipping 1187 matching lines...) Expand 10 before | Expand all | Expand 10 after
3040 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; 3050 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error;
3041 3051
3042 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. Alias 3052 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. Alias
3043 // enough information here so that we can determine what the bad message was. 3053 // enough information here so that we can determine what the bad message was.
3044 base::debug::Alias(&error); 3054 base::debug::Alias(&error);
3045 bad_message::ReceivedBadMessage(process.get(), 3055 bad_message::ReceivedBadMessage(process.get(),
3046 bad_message::RPH_MOJO_PROCESS_ERROR); 3056 bad_message::RPH_MOJO_PROCESS_ERROR);
3047 } 3057 }
3048 3058
3049 } // namespace content 3059 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_process_host_impl.h ('k') | content/browser/utility_process_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698