Chromium Code Reviews| 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 28 matching lines...) Expand all Loading... | |
| 39 // Add a command line switch that instructs the child process to run the | 39 // Add a command line switch that instructs the child process to run the |
| 40 // profiler. This should only be called from the browser process. | 40 // profiler. This should only be called from the browser process. |
| 41 void AppendCommandLineSwitchForChildProcess( | 41 void AppendCommandLineSwitchForChildProcess( |
| 42 const std::string& process_type, | 42 const std::string& process_type, |
| 43 base::CommandLine* command_line) const; | 43 base::CommandLine* command_line) const; |
| 44 | 44 |
| 45 // Returns the StackSamplingConfiguration for the process. | 45 // Returns the StackSamplingConfiguration for the process. |
| 46 static StackSamplingConfiguration* Get(); | 46 static StackSamplingConfiguration* Get(); |
| 47 | 47 |
| 48 private: | 48 private: |
| 49 // Configuration to use for this Chrome instance. | |
| 49 enum ProfileConfiguration { | 50 enum ProfileConfiguration { |
| 50 // Chrome-wide configurations set in the browser process. | 51 // Chrome-wide configurations set in the browser process. |
| 51 PROFILE_DISABLED, | 52 PROFILE_DISABLED, |
| 52 PROFILE_CONTROL, | 53 PROFILE_CONTROL, |
| 53 PROFILE_BROWSER_PROCESS, | 54 PROFILE_BROWSER_PROCESS, |
| 54 PROFILE_GPU_PROCESS, | 55 PROFILE_GPU_PROCESS, |
| 55 PROFILE_BROWSER_AND_GPU_PROCESS, | 56 PROFILE_BROWSER_AND_GPU_PROCESS, |
| 56 | 57 |
| 57 // Configuration set in the child processes, which receive their enable | 58 // Configuration set in the child processes, which receive their enable |
| 58 // state on the command line from the browser process. | 59 // state on the command line from the browser process. |
| 59 PROFILE_FROM_COMMAND_LINE | 60 PROFILE_FROM_COMMAND_LINE |
| 60 }; | 61 }; |
| 61 | 62 |
| 63 // Configuration variations, along with weights to use when randomly choosing | |
| 64 // one of a set of variations. | |
| 65 struct Variation { | |
| 66 ProfileConfiguration config; | |
| 67 int weight; | |
| 68 }; | |
| 69 | |
| 70 // Randomly chooses a configuration from the weighted variations. Weights must | |
| 71 // sum to 100. | |
|
Ilya Sherman
2016/10/12 20:52:31
Why are weights required to sum to 100? What if y
Mike Wittman
2016/10/12 21:50:41
It's not strictly needed, but is a small sanity ch
Ilya Sherman
2016/10/12 22:16:17
Got it, that makes sense. Would be nice to briefl
Mike Wittman
2016/10/12 23:00:32
Done.
| |
| 72 static ProfileConfiguration ChooseConfiguration( | |
| 73 const std::vector<Variation>& variations); | |
| 74 | |
| 62 // Generates sampling profiler configurations for all processes. | 75 // Generates sampling profiler configurations for all processes. |
| 63 static ProfileConfiguration GenerateConfiguration(); | 76 static ProfileConfiguration GenerateConfiguration(); |
| 64 | 77 |
| 65 // In the browser process this represents the configuration to use across all | 78 // In the browser process this represents the configuration to use across all |
| 66 // Chrome processes. In the child processes it is always | 79 // Chrome processes. In the child processes it is always |
| 67 // PROFILE_FROM_COMMAND_LINE. | 80 // PROFILE_FROM_COMMAND_LINE. |
| 68 const ProfileConfiguration configuration_; | 81 const ProfileConfiguration configuration_; |
| 69 | 82 |
| 70 DISALLOW_COPY_AND_ASSIGN(StackSamplingConfiguration); | 83 DISALLOW_COPY_AND_ASSIGN(StackSamplingConfiguration); |
| 71 }; | 84 }; |
| 72 | 85 |
| 73 #endif // CHROME_COMMON_STACK_SAMPLING_CONFIGURATION_H_ | 86 #endif // CHROME_COMMON_STACK_SAMPLING_CONFIGURATION_H_ |
| OLD | NEW |