Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(338)

Unified Diff: components/startup_metric_utils/common/pre_read_field_trial_utils_win.cc

Issue 1610733002: Store PreRead options obtained from the registry in a global variable. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: don't return a const ref Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/startup_metric_utils/common/pre_read_field_trial_utils_win.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 6aa82a19d93e59d8da9f80ca767206fe5f438be6..a75a81c6bbef30ca309d63848d86af3fdd45fdb8 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
@@ -35,6 +35,10 @@ const base::char16 kPrefetchVirtualMemoryVariationName[] =
// Registry key in which the PreRead field trial group is stored.
const base::char16 kPreReadFieldTrialRegistryKey[] = L"\\PreReadFieldTrial";
+// Pre-read options to use for the current process. This is initialized by
+// InitializePreReadOptions().
+PreReadOptions g_pre_read_options = {false, false, false, false};
+
// Returns the registry path in which the PreRead group is stored.
base::string16 GetPreReadRegistryPath(
const base::string16& product_registry_path) {
@@ -43,16 +47,8 @@ base::string16 GetPreReadRegistryPath(
} // namespace
-void GetPreReadOptions(const base::string16& product_registry_path,
- bool* no_pre_read,
- bool* high_priority,
- bool* only_if_cold,
- bool* prefetch_virtual_memory) {
+void InitializePreReadOptions(const base::string16& product_registry_path) {
DCHECK(!product_registry_path.empty());
- DCHECK(no_pre_read);
- DCHECK(high_priority);
- DCHECK(only_if_cold);
- DCHECK(prefetch_virtual_memory);
// Open the PreRead field trial's registry key.
const base::string16 registry_path =
@@ -61,25 +57,33 @@ void GetPreReadOptions(const base::string16& product_registry_path,
KEY_QUERY_VALUE);
// Set the PreRead field trial's options.
- struct VariationMapping {
+ struct {
const base::char16* name;
- bool* variable;
+ bool* option;
} const variations_mappings[] = {
- {kNoPreReadVariationName, no_pre_read},
- {kHighPriorityVariationName, high_priority},
- {kOnlyIfColdVariationName, only_if_cold},
- {kPrefetchVirtualMemoryVariationName, prefetch_virtual_memory},
+ {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;
- *mapping.variable = key.ReadValueDW(mapping.name, &value) == ERROR_SUCCESS;
- DCHECK(!*mapping.variable || value == 1);
+ if (key.ReadValueDW(mapping.name, &value) == ERROR_SUCCESS) {
+ DCHECK_EQ(1U, value);
+ DCHECK(!*mapping.option);
+ *mapping.option = true;
+ }
}
}
+PreReadOptions GetPreReadOptions() {
+ return g_pre_read_options;
+}
+
void UpdatePreReadOptions(const base::string16& product_registry_path) {
DCHECK(!product_registry_path.empty());
« no previous file with comments | « components/startup_metric_utils/common/pre_read_field_trial_utils_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698