| 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" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/profiler/stack_sampling_profiler.h" | 12 #include "base/profiler/stack_sampling_profiler.h" |
| 13 #include "components/metrics/call_stack_profile_metrics_provider.h" |
| 13 | 14 |
| 14 namespace base { | 15 namespace base { |
| 15 class CommandLine; | 16 class CommandLine; |
| 16 } // namespace base | 17 } // namespace base |
| 17 | 18 |
| 18 // StackSamplingConfiguration chooses a configuration for the enable state of | 19 // StackSamplingConfiguration chooses a configuration for the enable state of |
| 19 // the stack sampling profiler across all processes. This configuration is | 20 // the stack sampling profiler across all processes. This configuration is |
| 20 // determined once at browser process startup. Configurations for child | 21 // determined once at browser process startup. Configurations for child |
| 21 // processes are communicated via command line arguments. | 22 // processes are communicated via command line arguments. |
| 22 class StackSamplingConfiguration { | 23 class StackSamplingConfiguration { |
| 23 public: | 24 public: |
| 24 StackSamplingConfiguration(); | 25 StackSamplingConfiguration(); |
| 25 | 26 |
| 26 // Get the stack sampling params to use for this process. | 27 // Get the stack sampling params to use for this process. |
| 27 base::StackSamplingProfiler::SamplingParams | 28 base::StackSamplingProfiler::SamplingParams |
| 28 GetSamplingParamsForCurrentProcess() const; | 29 GetSamplingParamsForCurrentProcess() const; |
| 30 |
| 31 // Returns the profiler callback to use for this process. |
| 32 base::StackSamplingProfiler::CompletedCallback |
| 33 GetProfilerCallbackForCurrentProcess(); |
| 29 | 34 |
| 30 // Returns true if the profiler should be started for the current process. | 35 // Returns true if the profiler should be started for the current process. |
| 31 bool IsProfilerEnabledForCurrentProcess() const; | 36 bool IsProfilerEnabledForCurrentProcess() const; |
| 32 | 37 |
| 33 // Get the synthetic field trial configuration. Returns true if a synthetic | 38 // Get the synthetic field trial configuration. Returns true if a synthetic |
| 34 // field trial should be registered. This should only be called from the | 39 // field trial should be registered. This should only be called from the |
| 35 // browser process. When run at startup, the profiler must use a synthetic | 40 // 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. | 41 // field trial since it runs before the metrics field trials are initialized. |
| 37 bool GetSyntheticFieldTrial(std::string* trial_name, | 42 bool GetSyntheticFieldTrial(std::string* trial_name, |
| 38 std::string* group_name) const; | 43 std::string* group_name) const; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 const std::vector<Variation>& variations); | 79 const std::vector<Variation>& variations); |
| 75 | 80 |
| 76 // Generates sampling profiler configurations for all processes. | 81 // Generates sampling profiler configurations for all processes. |
| 77 static ProfileConfiguration GenerateConfiguration(); | 82 static ProfileConfiguration GenerateConfiguration(); |
| 78 | 83 |
| 79 // In the browser process this represents the configuration to use across all | 84 // In the browser process this represents the configuration to use across all |
| 80 // Chrome processes. In the child processes it is always | 85 // Chrome processes. In the child processes it is always |
| 81 // PROFILE_FROM_COMMAND_LINE. | 86 // PROFILE_FROM_COMMAND_LINE. |
| 82 const ProfileConfiguration configuration_; | 87 const ProfileConfiguration configuration_; |
| 83 | 88 |
| 89 // The current profiling params. Not const since these may be changed when |
| 90 // transitioning from start-up profiling to periodic profiling. |
| 91 metrics::CallStackProfileParams profile_params_; |
| 92 |
| 84 DISALLOW_COPY_AND_ASSIGN(StackSamplingConfiguration); | 93 DISALLOW_COPY_AND_ASSIGN(StackSamplingConfiguration); |
| 85 }; | 94 }; |
| 86 | 95 |
| 87 #endif // CHROME_COMMON_STACK_SAMPLING_CONFIGURATION_H_ | 96 #endif // CHROME_COMMON_STACK_SAMPLING_CONFIGURATION_H_ |
| OLD | NEW |