Index: content/browser/browser_child_process_host_impl.cc |
diff --git a/content/browser/browser_child_process_host_impl.cc b/content/browser/browser_child_process_host_impl.cc |
index e3eacd3ce01dead3132bee37df83760295395796..a85b3bb5f2eb7752a6dd16e0e19324e84bf602e0 100644 |
--- a/content/browser/browser_child_process_host_impl.cc |
+++ b/content/browser/browser_child_process_host_impl.cc |
@@ -207,8 +207,13 @@ void BrowserChildProcessHostImpl::TerminateAll() { |
} |
// static |
+#if defined(OS_WIN) |
+void BrowserChildProcessHostImpl::CopyFeatureAndFieldTrialFlags( |
+ base::CommandLine* cmd_line, base::SharedMemory* shared_memory) { |
+#else |
void BrowserChildProcessHostImpl::CopyFeatureAndFieldTrialFlags( |
base::CommandLine* cmd_line) { |
+#endif |
std::string enabled_features; |
std::string disabled_features; |
base::FeatureList::GetInstance()->GetFeatureOverrides(&enabled_features, |
@@ -223,13 +228,31 @@ void BrowserChildProcessHostImpl::CopyFeatureAndFieldTrialFlags( |
std::string field_trial_states; |
base::FieldTrialList::AllStatesToString(&field_trial_states); |
if (!field_trial_states.empty()) { |
+ // Use shared memory to pass field_trial_states if we're on Windows, |
+ // otherwise fallback to the command line. |
+#if defined(OS_WIN) |
+ size_t length = field_trial_states.size() + 1; |
+ shared_memory->CreateAndMapAnonymous(length); |
+ memcpy(shared_memory->memory(), field_trial_states.c_str(), length); |
+ |
+ // HANDLE is just typedef'd to void * |
+ HANDLE handle = shared_memory->handle().GetHandle(); |
+ auto uintptr_handle = reinterpret_cast<std::uintptr_t>(handle); |
+ std::string string_handle = std::to_string(uintptr_handle); |
+ cmd_line->AppendSwitchASCII("field_trial_handle", string_handle); |
+ cmd_line->AppendSwitchASCII("field_trial_length", std::to_string(length)); |
+#else |
cmd_line->AppendSwitchASCII(switches::kForceFieldTrials, |
field_trial_states); |
+#endif |
} |
} |
void BrowserChildProcessHostImpl::Launch( |
SandboxedProcessLauncherDelegate* delegate, |
+#if defined(OS_WIN) |
+ HANDLE field_trial_handle, |
+#endif |
base::CommandLine* cmd_line, |
bool terminate_on_shutdown) { |
DCHECK_CURRENTLY_ON(BrowserThread::IO); |
@@ -259,6 +282,9 @@ void BrowserChildProcessHostImpl::Launch( |
notify_child_disconnected_ = true; |
child_process_.reset(new ChildProcessLauncher( |
delegate, |
+ #if defined(OS_WIN) |
+ field_trial_handle, |
+ #endif |
cmd_line, |
data_.id, |
this, |