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

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: self-review 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
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..0219f12d3a6b1acfb09dbccc3d58028b46cd4804 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().
+int g_pre_read_options = PRE_READ_OPTION_UNINITIALIZED;
grt (UTC plus 2) 2016/01/21 04:24:00 if i'm reading the build files correctly, this .cc
fdoray 2016/01/21 16:04:16 Yes. The call in chrome.exe is added by this CL he
+
// Returns the registry path in which the PreRead group is stored.
base::string16 GetPreReadRegistryPath(
const base::string16& product_registry_path) {
@@ -43,16 +47,11 @@ 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);
+ DCHECK_EQ(g_pre_read_options, PRE_READ_OPTION_UNINITIALIZED);
grt (UTC plus 2) 2016/01/21 04:24:00 nit: always put the expected value first when usin
fdoray 2016/01/21 16:04:16 Done (I removed this line).
+
+ g_pre_read_options = 0;
// Open the PreRead field trial's registry key.
const base::string16 registry_path =
@@ -63,23 +62,30 @@ void GetPreReadOptions(const base::string16& product_registry_path,
// Set the PreRead field trial's options.
struct VariationMapping {
grt (UTC plus 2) 2016/01/21 04:24:00 nit: make this an anonymous struct since the name
fdoray 2016/01/21 16:04:16 Done.
const base::char16* name;
- bool* variable;
+ PreReadOptions bit;
} const variations_mappings[] = {
- {kNoPreReadVariationName, no_pre_read},
- {kHighPriorityVariationName, high_priority},
- {kOnlyIfColdVariationName, only_if_cold},
- {kPrefetchVirtualMemoryVariationName, prefetch_virtual_memory},
+ {kNoPreReadVariationName, PRE_READ_OPTION_NO_PRE_READ},
+ {kHighPriorityVariationName, PRE_READ_OPTION_HIGH_PRIORITY},
+ {kOnlyIfColdVariationName, PRE_READ_OPTION_ONLY_IF_COLD},
+ {kPrefetchVirtualMemoryVariationName,
+ PRE_READ_OPTION_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);
+ g_pre_read_options &= mapping.bit;
grt (UTC plus 2) 2016/01/21 04:24:00 |=
fdoray 2016/01/21 16:04:16 Done (now using a struct).
+ }
}
}
+int GetPreReadOptions() {
+ return g_pre_read_options;
+}
+
void UpdatePreReadOptions(const base::string16& product_registry_path) {
DCHECK(!product_registry_path.empty());

Powered by Google App Engine
This is Rietveld 408576698