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

Side by Side Diff: components/startup_metric_utils/common/pre_read_field_trial_utils_win.h

Issue 1595633002: Use valid /prefetch arguments for process launches on Windows. - do not submit (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move
Patch Set: address simple comments from gab 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 unified diff | Download patch
OLDNEW
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 #ifndef COMPONENTS_STARTUP_METRIC_UTILS_COMMON_PRE_READ_FIELD_TRIAL_UTILS_WIN_H_ 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_ 6 #define COMPONENTS_STARTUP_METRIC_UTILS_COMMON_PRE_READ_FIELD_TRIAL_UTILS_WIN_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/callback_forward.h" 10 #include "base/callback_forward.h"
11 #include "base/strings/string16.h" 11 #include "base/strings/string16.h"
12 12
13 // Utility functions to support the PreRead field trial. The PreRead field trial 13 // Utility functions to support the PreRead field trial. The PreRead field trial
14 // changes the way DLLs are pre-read during startup. 14 // changes the way DLLs are pre-read during startup.
15 15
16 namespace startup_metric_utils { 16 namespace startup_metric_utils {
17 17
18 // Callback to register a synthetic field trial. 18 // Callback to register a synthetic field trial.
19 using RegisterPreReadSyntheticFieldTrialCallback = 19 using RegisterPreReadSyntheticFieldTrialCallback =
20 const base::Callback<bool(const std::string&, const std::string&)>; 20 const base::Callback<bool(const std::string&, const std::string&)>;
21 21
22 // Get DLL pre-reading options. |product_registry_path| is the registry path 22 // The options controlled by the PreRead field trial.
23 // under which the registry key for this field trial resides. The |no_pre_read| 23 enum PreReadOptions {
24 // option is set if DLLs should not be pre-read. The |high_priority| option is 24 // No explicit DLL pre-reading.
25 // set if pre-reading should be done with a high thread priority. The 25 NO_PRE_READ = 1 << 0,
26 // |only_if_cold| option is set if only cold DLLs should be pre-read. The 26
27 // |prefetch_virtual_memory| option is set if the 27 // Pre-read DLLs with a high thread priority.
28 // ::PrefetchVirtualMemory function should be used to pre-read DLLs, if 28 HIGH_PRIORITY = 1 << 1,
29 // available. 29
30 void GetPreReadOptions(const base::string16& product_registry_path, 30 // Pre-read DLLs only when they are cold.
31 bool* no_pre_read, 31 ONLY_IF_COLD = 1 << 2,
32 bool* high_priority, 32
33 bool* only_if_cold, 33 // Pre-read DLLs using the ::PrefetchVirtualMemory function, if available.
34 bool* prefetch_virtual_memory); 34 PREFETCH_VIRTUAL_MEMORY = 1 << 3,
35
36 // Do not launch processes with a valid /prefetch argument.
37 NO_PREFETCH_ARGUMENT = 1 << 4,
38 };
39
40 // Returns DLL pre-reading options. |product_registry_path| is the
41 // registry path under which the registry key for this field trial resides.
42 int GetPreReadOptions(const base::string16& product_registry_path);
35 43
36 // Updates DLL pre-reading options in the registry with the latest info for the 44 // Updates DLL pre-reading options in the registry with the latest info for the
37 // next startup. |product_registry_path| is the registry path under which the 45 // next startup. |product_registry_path| is the registry path under which the
38 // registry key for this field trial resides. 46 // registry key for this field trial resides.
39 void UpdatePreReadOptions(const base::string16& product_registry_path); 47 void UpdatePreReadOptions(const base::string16& product_registry_path);
40 48
41 // Registers a synthetic field trial with the PreRead group currently stored in 49 // Registers a synthetic field trial with the PreRead group currently stored in
42 // the registry. This must be done before the first metric log 50 // the registry. This must be done before the first metric log
43 // (metrics::MetricsLog) is created. Otherwise, UMA metrics generated during 51 // (metrics::MetricsLog) is created. Otherwise, UMA metrics generated during
44 // startup won't be correctly annotated. |product_registry_path| is the registry 52 // startup won't be correctly annotated. |product_registry_path| is the registry
45 // path under which the key for this field trial resides. 53 // path under which the key for this field trial resides.
46 void RegisterPreReadSyntheticFieldTrial( 54 void RegisterPreReadSyntheticFieldTrial(
47 const base::string16& product_registry_path, 55 const base::string16& product_registry_path,
48 const RegisterPreReadSyntheticFieldTrialCallback& 56 const RegisterPreReadSyntheticFieldTrialCallback&
49 register_synthetic_field_trial); 57 register_synthetic_field_trial);
50 58
51 } // namespace startup_metric_utils 59 } // namespace startup_metric_utils
52 60
53 #endif // COMPONENTS_STARTUP_METRIC_UTILS_COMMON_PRE_READ_FIELD_TRIAL_UTILS_WIN _H_ 61 #endif // COMPONENTS_STARTUP_METRIC_UTILS_COMMON_PRE_READ_FIELD_TRIAL_UTILS_WIN _H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698