| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef COMPONENTS_STARTUP_METRIC_UTILS_COMMON_PRE_READ_FIELD_TRIAL_UTILS_WIN_H_ | |
| 6 #define COMPONENTS_STARTUP_METRIC_UTILS_COMMON_PRE_READ_FIELD_TRIAL_UTILS_WIN_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/callback_forward.h" | |
| 11 #include "base/strings/string16.h" | |
| 12 | |
| 13 // Utility functions to support the PreRead field trial. The PreRead field trial | |
| 14 // changes the way DLLs are pre-read during startup. | |
| 15 | |
| 16 namespace startup_metric_utils { | |
| 17 | |
| 18 // Callback to register a synthetic field trial. | |
| 19 using RegisterPreReadSyntheticFieldTrialCallback = | |
| 20 const base::Callback<bool(const std::string&, const std::string&)>; | |
| 21 | |
| 22 // The options controlled by the PreRead field trial. | |
| 23 struct PreReadOptions { | |
| 24 // Pre-read DLLs explicitly. | |
| 25 bool pre_read : 1; | |
| 26 | |
| 27 // Pre-read DLLs with a high thread priority. | |
| 28 bool high_priority : 1; | |
| 29 | |
| 30 // Pre-read DLLs using the ::PrefetchVirtualMemory function, if available. | |
| 31 bool prefetch_virtual_memory : 1; | |
| 32 }; | |
| 33 | |
| 34 // Initializes DLL pre-reading options from the registry. | |
| 35 // |product_registry_path| is the registry path under which the registry key for | |
| 36 // this field trial resides. | |
| 37 void InitializePreReadOptions(const base::string16& product_registry_path); | |
| 38 | |
| 39 // Returns the bitfield of the DLL pre-reading options to use for the current | |
| 40 // process. InitializePreReadOptions() must have been called before this. | |
| 41 PreReadOptions GetPreReadOptions(); | |
| 42 | |
| 43 // Updates DLL pre-reading options in the registry with the latest info for the | |
| 44 // next startup. |product_registry_path| is the registry path under which the | |
| 45 // registry key for this field trial resides. | |
| 46 void UpdatePreReadOptions(const base::string16& product_registry_path); | |
| 47 | |
| 48 // Registers a synthetic field trial with the PreRead group currently stored in | |
| 49 // the registry. This must be done before the first metric log | |
| 50 // (metrics::MetricsLog) is created. Otherwise, UMA metrics generated during | |
| 51 // startup won't be correctly annotated. |product_registry_path| is the registry | |
| 52 // path under which the key for this field trial resides. | |
| 53 void RegisterPreReadSyntheticFieldTrial( | |
| 54 const base::string16& product_registry_path, | |
| 55 const RegisterPreReadSyntheticFieldTrialCallback& | |
| 56 register_synthetic_field_trial); | |
| 57 | |
| 58 } // namespace startup_metric_utils | |
| 59 | |
| 60 #endif // COMPONENTS_STARTUP_METRIC_UTILS_COMMON_PRE_READ_FIELD_TRIAL_UTILS_WIN
_H_ | |
| OLD | NEW |