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

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: add feature logic for sharing field trials 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 950 matching lines...) Expand 10 before | Expand all | Expand 10 after
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()), cmd_line,
971 GetID(), this, child_token_, 971 GetID(), this, field_trial_state_.get(), child_token_,
972 base::Bind(&RenderProcessHostImpl::OnMojoError, 972 base::Bind(&RenderProcessHostImpl::OnMojoError,
973 weak_factory_.GetWeakPtr(), 973 weak_factory_.GetWeakPtr(),
974 base::ThreadTaskRunnerHandle::Get()))); 974 base::ThreadTaskRunnerHandle::Get())));
975 channel_->Pause(); 975 channel_->Pause();
976 976
977 fast_shutdown_started_ = false; 977 fast_shutdown_started_ = false;
978 } 978 }
979 979
980 // Push any pending messages to the channel now. Note that if the child 980 // Push any pending messages to the channel now. Note that if the child
981 // process is still launching, the channel will be paused and outgoing 981 // process is still launching, the channel will be paused and outgoing
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after
1580 gpu_data_manager->AppendRendererCommandLine(command_line); 1580 gpu_data_manager->AppendRendererCommandLine(command_line);
1581 1581
1582 // Slimming Paint v2 implies layer lists in the renderer. 1582 // Slimming Paint v2 implies layer lists in the renderer.
1583 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 1583 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
1584 switches::kEnableSlimmingPaintV2)) { 1584 switches::kEnableSlimmingPaintV2)) {
1585 command_line->AppendSwitch(cc::switches::kEnableLayerLists); 1585 command_line->AppendSwitch(cc::switches::kEnableLayerLists);
1586 } 1586 }
1587 } 1587 }
1588 1588
1589 void RenderProcessHostImpl::AppendRendererCommandLine( 1589 void RenderProcessHostImpl::AppendRendererCommandLine(
1590 base::CommandLine* command_line) const { 1590 base::CommandLine* command_line) {
1591 // Pass the process type first, so it shows first in process listings. 1591 // Pass the process type first, so it shows first in process listings.
1592 command_line->AppendSwitchASCII(switches::kProcessType, 1592 command_line->AppendSwitchASCII(switches::kProcessType,
1593 switches::kRendererProcess); 1593 switches::kRendererProcess);
1594 1594
1595 #if defined(OS_WIN) 1595 #if defined(OS_WIN)
1596 command_line->AppendArg(switches::kPrefetchArgumentRenderer); 1596 command_line->AppendArg(switches::kPrefetchArgumentRenderer);
1597 #endif // defined(OS_WIN) 1597 #endif // defined(OS_WIN)
1598 1598
1599 // Now send any options from our own command line we want to propagate. 1599 // Now send any options from our own command line we want to propagate.
1600 const base::CommandLine& browser_command_line = 1600 const base::CommandLine& browser_command_line =
(...skipping 18 matching lines...) Expand all
1619 #endif 1619 #endif
1620 1620
1621 AppendCompositorCommandLineFlags(command_line); 1621 AppendCompositorCommandLineFlags(command_line);
1622 1622
1623 command_line->AppendSwitchASCII(switches::kMojoApplicationChannelToken, 1623 command_line->AppendSwitchASCII(switches::kMojoApplicationChannelToken,
1624 mojo_child_connection_->service_token()); 1624 mojo_child_connection_->service_token());
1625 } 1625 }
1626 1626
1627 void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer( 1627 void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer(
1628 const base::CommandLine& browser_cmd, 1628 const base::CommandLine& browser_cmd,
1629 base::CommandLine* renderer_cmd) const { 1629 base::CommandLine* renderer_cmd) {
1630 // Propagate the following switches to the renderer command line (along 1630 // Propagate the following switches to the renderer command line (along
1631 // with any associated values) if present in the browser command line. 1631 // with any associated values) if present in the browser command line.
1632 static const char* const kSwitchNames[] = { 1632 static const char* const kSwitchNames[] = {
1633 switches::kAgcStartupMinVolume, 1633 switches::kAgcStartupMinVolume,
1634 switches::kAecRefinedAdaptiveFilter, 1634 switches::kAecRefinedAdaptiveFilter,
1635 switches::kAllowLoopbackInPeerConnection, 1635 switches::kAllowLoopbackInPeerConnection,
1636 switches::kAndroidFontsPath, 1636 switches::kAndroidFontsPath,
1637 switches::kAudioBufferSize, 1637 switches::kAudioBufferSize,
1638 switches::kBlinkSettings, 1638 switches::kBlinkSettings,
1639 switches::kDefaultTileWidth, 1639 switches::kDefaultTileWidth,
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
1832 #endif 1832 #endif
1833 #if defined(ENABLE_IPC_FUZZER) 1833 #if defined(ENABLE_IPC_FUZZER)
1834 switches::kIpcDumpDirectory, 1834 switches::kIpcDumpDirectory,
1835 switches::kIpcFuzzerTestcase, 1835 switches::kIpcFuzzerTestcase,
1836 #endif 1836 #endif
1837 switches::kUseMusInRenderer, 1837 switches::kUseMusInRenderer,
1838 }; 1838 };
1839 renderer_cmd->CopySwitchesFrom(browser_cmd, kSwitchNames, 1839 renderer_cmd->CopySwitchesFrom(browser_cmd, kSwitchNames,
1840 arraysize(kSwitchNames)); 1840 arraysize(kSwitchNames));
1841 1841
1842 BrowserChildProcessHostImpl::CopyFeatureAndFieldTrialFlags(renderer_cmd); 1842 #if defined(OS_WIN)
1843 if (base::FeatureList::IsEnabled(
1844 features::kShareFieldTrialStateViaSharedMemory))
1845 field_trial_state_.reset(new base::SharedMemory());
Alexei Svitkine (slow) 2016/10/04 18:49:36 I don't like duplicating this code - especially si
lawrencewu 2016/10/05 20:57:56 Done.
1846 #endif
1847 BrowserChildProcessHostImpl::CopyFeatureAndFieldTrialFlags(
1848 renderer_cmd, field_trial_state_.get());
1849 #if defined(OS_WIN)
1850 if (!field_trial_state_.get()->handle().GetHandle())
1851 field_trial_state_.reset();
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

Powered by Google App Engine
This is Rietveld 408576698