Index: content/app/content_main_runner.cc |
diff --git a/content/app/content_main_runner.cc b/content/app/content_main_runner.cc |
index 01bb5f00f42ce6a9499708f7a53c5766054c62fc..18939da1c8f2c193525d30982a7332ed92acd15c 100644 |
--- a/content/app/content_main_runner.cc |
+++ b/content/app/content_main_runner.cc |
@@ -26,12 +26,14 @@ |
#include "base/logging.h" |
#include "base/macros.h" |
#include "base/memory/scoped_vector.h" |
+#include "base/memory/shared_memory.h" |
#include "base/metrics/field_trial.h" |
#include "base/metrics/histogram_base.h" |
#include "base/metrics/statistics_recorder.h" |
#include "base/path_service.h" |
#include "base/process/launch.h" |
#include "base/process/memory.h" |
+#include "base/process/process.h" |
#include "base/process/process_handle.h" |
#include "base/profiler/scoped_tracker.h" |
#include "base/strings/string_number_conversions.h" |
@@ -146,12 +148,34 @@ void InitializeFieldTrialAndFeatureList( |
// Ensure any field trials in browser are reflected into the child |
// process. |
+ #if defined(OS_WIN) |
+ if (command_line.HasSwitch("field_trial_handle")) { |
+ int field_trial_handle = std::stoi( |
+ command_line.GetSwitchValueASCII("field_trial_handle")); |
+ size_t field_trial_length = std::stoi( |
+ command_line.GetSwitchValueASCII("field_trial_length")); |
+ |
+ HANDLE handle = reinterpret_cast<HANDLE>(field_trial_handle); |
+ base::SharedMemoryHandle shm_handle = base::SharedMemoryHandle( |
+ handle, base::GetCurrentProcId()); |
+ |
+ base::SharedMemory shared_memory(shm_handle, false); |
+ shared_memory.Map(field_trial_length); |
+ |
+ char *field_trial_state = static_cast<char*>(shared_memory.memory()); |
+ bool result = base::FieldTrialList::CreateTrialsFromString( |
+ std::string(field_trial_state), |
+ std::set<std::string>()); |
+ DCHECK(result); |
+ } |
+ #else |
if (command_line.HasSwitch(switches::kForceFieldTrials)) { |
bool result = base::FieldTrialList::CreateTrialsFromString( |
- command_line.GetSwitchValueASCII(switches::kForceFieldTrials), |
- std::set<std::string>()); |
+ command_line.GetSwitchValueASCII(switches::kForceFieldTrials), |
+ std::set<std::string>()); |
DCHECK(result); |
} |
+ #endif |
std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList); |
feature_list->InitializeFromCommandLine( |