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..08ee11752797f0984044190ea2ff8b6d826cc775 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(switches::kFieldTrialHandle)) { |
+ std::string arg = |
Alexei Svitkine (slow)
2016/10/04 18:49:35
Suggest moving this code to base/metrics. We can h
lawrencewu
2016/10/05 20:57:56
Done. Regarding the ifdefs, I think they're necess
lawrencewu
2016/10/06 20:14:57
Done. Regarding the ifdefs, I think they're necess
|
+ command_line.GetSwitchValueASCII(switches::kFieldTrialHandle); |
+ size_t token = arg.find(","); |
+ int field_trial_handle = std::stoi(arg.substr(0, token)); |
+ int field_trial_length = std::stoi(arg.substr(token + 1, arg.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>()); |
DCHECK(result); |
} |
+#endif |
std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList); |
feature_list->InitializeFromCommandLine( |