| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/startup_metric_utils/common/pre_read_field_trial_utils_win.
h" | 5 #include "components/startup_metric_utils/common/pre_read_field_trial_utils_win.
h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 const char kPreReadSyntheticFieldTrialName[] = "SyntheticPreRead"; | 26 const char kPreReadSyntheticFieldTrialName[] = "SyntheticPreRead"; |
| 27 | 27 |
| 28 // Variation names for the PreRead field trial. All variations change the | 28 // Variation names for the PreRead field trial. All variations change the |
| 29 // default behavior, i.e. the default is the inverse of the variation. Thus, | 29 // default behavior, i.e. the default is the inverse of the variation. Thus, |
| 30 // variations that cancel something that is done by default have a negative | 30 // variations that cancel something that is done by default have a negative |
| 31 // name. | 31 // name. |
| 32 const base::char16 kNoPreReadVariationName[] = L"NoPreRead"; | 32 const base::char16 kNoPreReadVariationName[] = L"NoPreRead"; |
| 33 const base::char16 kHighPriorityVariationName[] = L"HighPriority"; | 33 const base::char16 kHighPriorityVariationName[] = L"HighPriority"; |
| 34 const base::char16 kPrefetchVirtualMemoryVariationName[] = | 34 const base::char16 kPrefetchVirtualMemoryVariationName[] = |
| 35 L"PrefetchVirtualMemory"; | 35 L"PrefetchVirtualMemory"; |
| 36 const base::char16 kPreReadChromeChildInBrowser[] = | |
| 37 L"PreReadChromeChildInBrowser"; | |
| 38 | 36 |
| 39 // Registry key in which the PreRead field trial group is stored. | 37 // Registry key in which the PreRead field trial group is stored. |
| 40 const base::char16 kPreReadFieldTrialRegistryKey[] = L"\\PreReadFieldTrial"; | 38 const base::char16 kPreReadFieldTrialRegistryKey[] = L"\\PreReadFieldTrial"; |
| 41 | 39 |
| 42 // Pre-read options to use for the current process. This is initialized by | 40 // Pre-read options to use for the current process. This is initialized by |
| 43 // InitializePreReadOptions(). | 41 // InitializePreReadOptions(). |
| 44 PreReadOptions g_pre_read_options = {}; | 42 PreReadOptions g_pre_read_options = {}; |
| 45 | 43 |
| 46 // Returns the registry path in which the PreRead group is stored. | 44 // Returns the registry path in which the PreRead group is stored. |
| 47 base::string16 GetPreReadRegistryPath( | 45 base::string16 GetPreReadRegistryPath( |
| (...skipping 22 matching lines...) Expand all Loading... |
| 70 const base::string16 registry_path = | 68 const base::string16 registry_path = |
| 71 GetPreReadRegistryPath(product_registry_path); | 69 GetPreReadRegistryPath(product_registry_path); |
| 72 const base::win::RegKey key(HKEY_CURRENT_USER, registry_path.c_str(), | 70 const base::win::RegKey key(HKEY_CURRENT_USER, registry_path.c_str(), |
| 73 KEY_QUERY_VALUE); | 71 KEY_QUERY_VALUE); |
| 74 | 72 |
| 75 // Set the PreRead field trial's options. | 73 // Set the PreRead field trial's options. |
| 76 g_pre_read_options.pre_read = !ReadBool(key, kNoPreReadVariationName); | 74 g_pre_read_options.pre_read = !ReadBool(key, kNoPreReadVariationName); |
| 77 g_pre_read_options.high_priority = ReadBool(key, kHighPriorityVariationName); | 75 g_pre_read_options.high_priority = ReadBool(key, kHighPriorityVariationName); |
| 78 g_pre_read_options.prefetch_virtual_memory = | 76 g_pre_read_options.prefetch_virtual_memory = |
| 79 ReadBool(key, kPrefetchVirtualMemoryVariationName); | 77 ReadBool(key, kPrefetchVirtualMemoryVariationName); |
| 80 g_pre_read_options.pre_read_chrome_child_in_browser = | |
| 81 ReadBool(key, kPreReadChromeChildInBrowser); | |
| 82 } | 78 } |
| 83 | 79 |
| 84 PreReadOptions GetPreReadOptions() { | 80 PreReadOptions GetPreReadOptions() { |
| 85 return g_pre_read_options; | 81 return g_pre_read_options; |
| 86 } | 82 } |
| 87 | 83 |
| 88 void UpdatePreReadOptions(const base::string16& product_registry_path) { | 84 void UpdatePreReadOptions(const base::string16& product_registry_path) { |
| 89 DCHECK(!product_registry_path.empty()); | 85 DCHECK(!product_registry_path.empty()); |
| 90 | 86 |
| 91 const base::string16 registry_path = | 87 const base::string16 registry_path = |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 base::string16 group; | 138 base::string16 group; |
| 143 key.ReadValue(L"", &group); | 139 key.ReadValue(L"", &group); |
| 144 | 140 |
| 145 if (!group.empty()) { | 141 if (!group.empty()) { |
| 146 register_synthetic_field_trial.Run(kPreReadSyntheticFieldTrialName, | 142 register_synthetic_field_trial.Run(kPreReadSyntheticFieldTrialName, |
| 147 base::UTF16ToUTF8(group)); | 143 base::UTF16ToUTF8(group)); |
| 148 } | 144 } |
| 149 } | 145 } |
| 150 | 146 |
| 151 } // namespace startup_metric_utils | 147 } // namespace startup_metric_utils |
| OLD | NEW |