Index: components/startup_metric_utils/common/pre_read_field_trial_utils_win.cc |
diff --git a/components/startup_metric_utils/common/pre_read_field_trial_utils_win.cc b/components/startup_metric_utils/common/pre_read_field_trial_utils_win.cc |
index a75a81c6bbef30ca309d63848d86af3fdd45fdb8..65f0eb0677eec577cc5eeaa416bb2c20a90712cc 100644 |
--- a/components/startup_metric_utils/common/pre_read_field_trial_utils_win.cc |
+++ b/components/startup_metric_utils/common/pre_read_field_trial_utils_win.cc |
@@ -31,6 +31,7 @@ const base::char16 kHighPriorityVariationName[] = L"HighPriority"; |
const base::char16 kOnlyIfColdVariationName[] = L"OnlyIfCold"; |
const base::char16 kPrefetchVirtualMemoryVariationName[] = |
L"PrefetchVirtualMemory"; |
+const base::char16 kNoPrefetchArgumentVariationName[] = L"NoPrefetchArgument"; |
gab
2016/01/26 21:40:26
It may not be clear to a reader that the reason so
fdoray
2016/01/27 20:12:19
Done.
|
// Registry key in which the PreRead field trial group is stored. |
const base::char16 kPreReadFieldTrialRegistryKey[] = L"\\PreReadFieldTrial"; |
@@ -45,6 +46,12 @@ base::string16 GetPreReadRegistryPath( |
return product_registry_path + kPreReadFieldTrialRegistryKey; |
} |
+// Returns true if |key| has a value named |name| which is not zero. |
+bool ReadBool(const base::win::RegKey& key, const base::char16* name) { |
+ DWORD value = 0; |
+ return key.ReadValueDW(name, &value) == ERROR_SUCCESS && value != 0; |
+} |
+ |
} // namespace |
void InitializePreReadOptions(const base::string16& product_registry_path) { |
@@ -57,27 +64,13 @@ void InitializePreReadOptions(const base::string16& product_registry_path) { |
KEY_QUERY_VALUE); |
// Set the PreRead field trial's options. |
- struct { |
- const base::char16* name; |
- bool* option; |
- } const variations_mappings[] = { |
- {kNoPreReadVariationName, &g_pre_read_options.no_pre_read}, |
- {kHighPriorityVariationName, &g_pre_read_options.high_priority}, |
- {kOnlyIfColdVariationName, &g_pre_read_options.only_if_cold}, |
- {kPrefetchVirtualMemoryVariationName, |
- &g_pre_read_options.prefetch_virtual_memory}, |
- }; |
- |
- for (const auto& mapping : variations_mappings) { |
- // Set the option variable to true if the corresponding value is found in |
- // the registry. Set to false otherwise (default behavior). |
- DWORD value = 0; |
- if (key.ReadValueDW(mapping.name, &value) == ERROR_SUCCESS) { |
- DCHECK_EQ(1U, value); |
- DCHECK(!*mapping.option); |
- *mapping.option = true; |
- } |
- } |
+ g_pre_read_options.pre_read = !ReadBool(key, kNoPreReadVariationName); |
+ g_pre_read_options.high_priority = ReadBool(key, kHighPriorityVariationName); |
+ g_pre_read_options.only_if_cold = ReadBool(key, kOnlyIfColdVariationName); |
+ g_pre_read_options.prefetch_virtual_memory = |
+ ReadBool(key, kPrefetchVirtualMemoryVariationName); |
+ g_pre_read_options.prefetch_argument = |
+ !ReadBool(key, kNoPrefetchArgumentVariationName); |
} |
PreReadOptions GetPreReadOptions() { |