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 #ifndef CHROME_COMMON_STACK_SAMPLING_CONFIGURATION_H_ | 5 #ifndef CHROME_COMMON_STACK_SAMPLING_CONFIGURATION_H_ |
6 #define CHROME_COMMON_STACK_SAMPLING_CONFIGURATION_H_ | 6 #define CHROME_COMMON_STACK_SAMPLING_CONFIGURATION_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 | 25 |
26 // Get the stack sampling params to use for this process. | 26 // Get the stack sampling params to use for this process. |
27 base::StackSamplingProfiler::SamplingParams | 27 base::StackSamplingProfiler::SamplingParams |
28 GetSamplingParamsForCurrentProcess() const; | 28 GetSamplingParamsForCurrentProcess() const; |
29 | 29 |
30 // Returns true if the profiler should be started for the current process. | 30 // Returns true if the profiler should be started for the current process. |
31 bool IsProfilerEnabledForCurrentProcess() const; | 31 bool IsProfilerEnabledForCurrentProcess() const; |
32 | 32 |
33 // Get the synthetic field trial configuration. Returns true if a synthetic | 33 // Get the synthetic field trial configuration. Returns true if a synthetic |
34 // field trial should be registered. This should only be called from the | 34 // field trial should be registered. This should only be called from the |
35 // browser process. | 35 // browser process. When run at startup, the profiler must use a synthetic |
| 36 // field trial since it runs before the metrics field trials are initialized. |
36 bool GetSyntheticFieldTrial(std::string* trial_name, | 37 bool GetSyntheticFieldTrial(std::string* trial_name, |
37 std::string* group_name) const; | 38 std::string* group_name) const; |
38 | 39 |
39 // Add a command line switch that instructs the child process to run the | 40 // Add a command line switch that instructs the child process to run the |
40 // profiler. This should only be called from the browser process. | 41 // profiler. This should only be called from the browser process. |
41 void AppendCommandLineSwitchForChildProcess( | 42 void AppendCommandLineSwitchForChildProcess( |
42 const std::string& process_type, | 43 const std::string& process_type, |
43 base::CommandLine* command_line) const; | 44 base::CommandLine* command_line) const; |
44 | 45 |
45 // Returns the StackSamplingConfiguration for the process. | 46 // Returns the StackSamplingConfiguration for the process. |
46 static StackSamplingConfiguration* Get(); | 47 static StackSamplingConfiguration* Get(); |
47 | 48 |
48 private: | 49 private: |
| 50 // Configuration to use for this Chrome instance. |
49 enum ProfileConfiguration { | 51 enum ProfileConfiguration { |
50 // Chrome-wide configurations set in the browser process. | 52 // Chrome-wide configurations set in the browser process. |
51 PROFILE_DISABLED, | 53 PROFILE_DISABLED, |
52 PROFILE_CONTROL, | 54 PROFILE_CONTROL, |
53 PROFILE_BROWSER_PROCESS, | 55 PROFILE_BROWSER_PROCESS, |
54 PROFILE_GPU_PROCESS, | 56 PROFILE_GPU_PROCESS, |
55 PROFILE_BROWSER_AND_GPU_PROCESS, | 57 PROFILE_BROWSER_AND_GPU_PROCESS, |
56 | 58 |
57 // Configuration set in the child processes, which receive their enable | 59 // Configuration set in the child processes, which receive their enable |
58 // state on the command line from the browser process. | 60 // state on the command line from the browser process. |
59 PROFILE_FROM_COMMAND_LINE | 61 PROFILE_FROM_COMMAND_LINE |
60 }; | 62 }; |
61 | 63 |
| 64 // Configuration variations, along with weights to use when randomly choosing |
| 65 // one of a set of variations. |
| 66 struct Variation { |
| 67 ProfileConfiguration config; |
| 68 int weight; |
| 69 }; |
| 70 |
| 71 // Randomly chooses a configuration from the weighted variations. Weights are |
| 72 // expected to sum to 100 as a sanity check. |
| 73 static ProfileConfiguration ChooseConfiguration( |
| 74 const std::vector<Variation>& variations); |
| 75 |
62 // Generates sampling profiler configurations for all processes. | 76 // Generates sampling profiler configurations for all processes. |
63 static ProfileConfiguration GenerateConfiguration(); | 77 static ProfileConfiguration GenerateConfiguration(); |
64 | 78 |
65 // In the browser process this represents the configuration to use across all | 79 // In the browser process this represents the configuration to use across all |
66 // Chrome processes. In the child processes it is always | 80 // Chrome processes. In the child processes it is always |
67 // PROFILE_FROM_COMMAND_LINE. | 81 // PROFILE_FROM_COMMAND_LINE. |
68 const ProfileConfiguration configuration_; | 82 const ProfileConfiguration configuration_; |
69 | 83 |
70 DISALLOW_COPY_AND_ASSIGN(StackSamplingConfiguration); | 84 DISALLOW_COPY_AND_ASSIGN(StackSamplingConfiguration); |
71 }; | 85 }; |
72 | 86 |
73 #endif // CHROME_COMMON_STACK_SAMPLING_CONFIGURATION_H_ | 87 #endif // CHROME_COMMON_STACK_SAMPLING_CONFIGURATION_H_ |
OLD | NEW |