| 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..b5fcdd11aee90b0425a865fc48cace8d4f206149 100644
|
| --- a/content/browser/browser_child_process_host_impl.cc
|
| +++ b/content/browser/browser_child_process_host_impl.cc
|
| @@ -208,7 +208,8 @@ void BrowserChildProcessHostImpl::TerminateAll() {
|
|
|
| // static
|
| void BrowserChildProcessHostImpl::CopyFeatureAndFieldTrialFlags(
|
| - base::CommandLine* cmd_line) {
|
| + base::CommandLine* cmd_line,
|
| + base::SharedMemory* shared_memory) {
|
| std::string enabled_features;
|
| std::string disabled_features;
|
| base::FeatureList::GetInstance()->GetFeatureOverrides(&enabled_features,
|
| @@ -223,14 +224,32 @@ void BrowserChildProcessHostImpl::CopyFeatureAndFieldTrialFlags(
|
| std::string field_trial_states;
|
| base::FieldTrialList::AllStatesToString(&field_trial_states);
|
| if (!field_trial_states.empty()) {
|
| - cmd_line->AppendSwitchASCII(switches::kForceFieldTrials,
|
| - field_trial_states);
|
| + // Use shared memory to pass field_trial_states if we can, otherwise
|
| + // fallback to the command line.
|
| + if (shared_memory) {
|
| + 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 *
|
| + auto uintptr_handle =
|
| + reinterpret_cast<std::uintptr_t>(shared_memory->handle().GetHandle());
|
| + std::string field_trial_handle =
|
| + std::to_string(uintptr_handle) + "," + std::to_string(length);
|
| +
|
| + cmd_line->AppendSwitchASCII(switches::kFieldTrialHandle,
|
| + field_trial_handle);
|
| + } else {
|
| + cmd_line->AppendSwitchASCII(switches::kForceFieldTrials,
|
| + field_trial_states);
|
| + }
|
| }
|
| }
|
|
|
| void BrowserChildProcessHostImpl::Launch(
|
| SandboxedProcessLauncherDelegate* delegate,
|
| base::CommandLine* cmd_line,
|
| + const base::SharedMemory* field_trial_state,
|
| bool terminate_on_shutdown) {
|
| DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
|
|
| @@ -258,11 +277,7 @@ void BrowserChildProcessHostImpl::Launch(
|
|
|
| notify_child_disconnected_ = true;
|
| child_process_.reset(new ChildProcessLauncher(
|
| - delegate,
|
| - cmd_line,
|
| - data_.id,
|
| - this,
|
| - child_token_,
|
| + delegate, cmd_line, data_.id, this, field_trial_state, child_token_,
|
| base::Bind(&BrowserChildProcessHostImpl::OnMojoError,
|
| weak_factory_.GetWeakPtr(),
|
| base::ThreadTaskRunnerHandle::Get()),
|
|
|