| 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/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.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 13 matching lines...) Expand all Loading... |
| 24 // registered so that UMA metrics recorded during the current startup are | 24 // registered so that UMA metrics recorded during the current startup are |
| 25 // annotated with the pre-read group that is actually used during this startup. | 25 // annotated with the pre-read group that is actually used during this startup. |
| 26 const char kPreReadSyntheticFieldTrialName[] = "SyntheticPreRead"; | 26 const char kPreReadSyntheticFieldTrialName[] = "SyntheticPreRead"; |
| 27 | 27 |
| 28 // Variation names for the PreRead field trial. | 28 // Variation names for the PreRead field trial. |
| 29 const base::char16 kNoPreReadVariationName[] = L"NoPreRead"; | 29 const base::char16 kNoPreReadVariationName[] = L"NoPreRead"; |
| 30 const base::char16 kHighPriorityVariationName[] = L"HighPriority"; | 30 const base::char16 kHighPriorityVariationName[] = L"HighPriority"; |
| 31 const base::char16 kOnlyIfColdVariationName[] = L"OnlyIfCold"; | 31 const base::char16 kOnlyIfColdVariationName[] = L"OnlyIfCold"; |
| 32 const base::char16 kPrefetchVirtualMemoryVariationName[] = | 32 const base::char16 kPrefetchVirtualMemoryVariationName[] = |
| 33 L"PrefetchVirtualMemory"; | 33 L"PrefetchVirtualMemory"; |
| 34 const base::char16 kNoPrefetchArgumentVariationName[] = L"NoPrefetchArgument"; |
| 34 | 35 |
| 35 // Registry key in which the PreRead field trial group is stored. | 36 // Registry key in which the PreRead field trial group is stored. |
| 36 const base::char16 kPreReadFieldTrialRegistryKey[] = L"\\PreReadFieldTrial"; | 37 const base::char16 kPreReadFieldTrialRegistryKey[] = L"\\PreReadFieldTrial"; |
| 37 | 38 |
| 38 // Pre-read options to use for the current process. This is initialized by | 39 // Pre-read options to use for the current process. This is initialized by |
| 39 // InitializePreReadOptions(). | 40 // InitializePreReadOptions(). |
| 40 int g_pre_read_options = PRE_READ_OPTION_UNINITIALIZED; | 41 int g_pre_read_options = PRE_READ_OPTION_UNINITIALIZED; |
| 41 | 42 |
| 42 // Returns the registry path in which the PreRead group is stored. | 43 // Returns the registry path in which the PreRead group is stored. |
| 43 base::string16 GetPreReadRegistryPath( | 44 base::string16 GetPreReadRegistryPath( |
| (...skipping 18 matching lines...) Expand all Loading... |
| 62 // Set the PreRead field trial's options. | 63 // Set the PreRead field trial's options. |
| 63 struct VariationMapping { | 64 struct VariationMapping { |
| 64 const base::char16* name; | 65 const base::char16* name; |
| 65 PreReadOptions bit; | 66 PreReadOptions bit; |
| 66 } const variations_mappings[] = { | 67 } const variations_mappings[] = { |
| 67 {kNoPreReadVariationName, PRE_READ_OPTION_NO_PRE_READ}, | 68 {kNoPreReadVariationName, PRE_READ_OPTION_NO_PRE_READ}, |
| 68 {kHighPriorityVariationName, PRE_READ_OPTION_HIGH_PRIORITY}, | 69 {kHighPriorityVariationName, PRE_READ_OPTION_HIGH_PRIORITY}, |
| 69 {kOnlyIfColdVariationName, PRE_READ_OPTION_ONLY_IF_COLD}, | 70 {kOnlyIfColdVariationName, PRE_READ_OPTION_ONLY_IF_COLD}, |
| 70 {kPrefetchVirtualMemoryVariationName, | 71 {kPrefetchVirtualMemoryVariationName, |
| 71 PRE_READ_OPTION_PREFETCH_VIRTUAL_MEMORY}, | 72 PRE_READ_OPTION_PREFETCH_VIRTUAL_MEMORY}, |
| 73 {kNoPrefetchArgumentVariationName, PRE_READ_OPTION_NO_PREFETCH_ARGUMENT}, |
| 72 }; | 74 }; |
| 73 | 75 |
| 74 for (const auto& mapping : variations_mappings) { | 76 for (const auto& mapping : variations_mappings) { |
| 75 // Set the option variable to true if the corresponding value is found in | 77 // Set the option variable to true if the corresponding value is found in |
| 76 // the registry. Set to false otherwise (default behavior). | 78 // the registry. Set to false otherwise (default behavior). |
| 77 DWORD value = 0; | 79 DWORD value = 0; |
| 78 if (key.ReadValueDW(mapping.name, &value) == ERROR_SUCCESS) { | 80 if (key.ReadValueDW(mapping.name, &value) == ERROR_SUCCESS) { |
| 79 DCHECK_EQ(1U, value); | 81 DCHECK_EQ(1U, value); |
| 80 g_pre_read_options &= mapping.bit; | 82 g_pre_read_options &= mapping.bit; |
| 81 } | 83 } |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 base::string16 group; | 145 base::string16 group; |
| 144 key.ReadValue(L"", &group); | 146 key.ReadValue(L"", &group); |
| 145 | 147 |
| 146 if (!group.empty()) { | 148 if (!group.empty()) { |
| 147 register_synthetic_field_trial.Run(kPreReadSyntheticFieldTrialName, | 149 register_synthetic_field_trial.Run(kPreReadSyntheticFieldTrialName, |
| 148 base::UTF16ToUTF8(group)); | 150 base::UTF16ToUTF8(group)); |
| 149 } | 151 } |
| 150 } | 152 } |
| 151 | 153 |
| 152 } // namespace startup_metric_utils | 154 } // namespace startup_metric_utils |
| OLD | NEW |