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

Side by Side Diff: chrome/common/stack_sampling_configuration.h

Issue 2360143006: Stack sampling profiler: run the profiler in the GPU process on trunk builds (Closed)
Patch Set: address comments Created 4 years, 2 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
« no previous file with comments | « chrome/common/chrome_switches.cc ('k') | chrome/common/stack_sampling_configuration.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 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>
9
10 #include "base/callback.h"
8 #include "base/macros.h" 11 #include "base/macros.h"
9 #include "base/profiler/stack_sampling_profiler.h" 12 #include "base/profiler/stack_sampling_profiler.h"
10 13
11 // Chooses a configuration for the stack sampling profiler for browser process 14 namespace base {
12 // startup. This must live outside of ChromeBrowserMainParts so it can be 15 class CommandLine;
13 // friended by ChromeMetricsServiceAccessor. 16 } // namespace base
17
18 // StackSamplingConfiguration chooses a configuration for the enable state of
19 // the stack sampling profiler across all processes. This configuration is
20 // determined once at browser process startup. Configurations for child
21 // processes are communicated via command line arguments.
14 class StackSamplingConfiguration { 22 class StackSamplingConfiguration {
15 public: 23 public:
16 StackSamplingConfiguration(); 24 StackSamplingConfiguration();
17 25
18 // Get the stack sampling params to use for this session. 26 // Get the stack sampling params to use for this process.
19 base::StackSamplingProfiler::SamplingParams GetSamplingParams() const; 27 base::StackSamplingProfiler::SamplingParams
28 GetSamplingParamsForCurrentProcess() const;
20 29
21 // Returns true if the profiler should be started at all. 30 // Returns true if the profiler should be started for the current process.
22 bool IsProfilerEnabled() const; 31 bool IsProfilerEnabledForCurrentProcess() const;
23 32
24 // Get the synthetic field trial configuration. Returns true if a synthetic 33 // Get the synthetic field trial configuration. Returns true if a synthetic
25 // field trial should be registered. 34 // field trial should be registered. This should only be called from the
35 // browser process.
26 bool GetSyntheticFieldTrial(std::string* trial_name, 36 bool GetSyntheticFieldTrial(std::string* trial_name,
27 std::string* group_name) const; 37 std::string* group_name) const;
28 38
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.
41 void AppendCommandLineSwitchForChildProcess(
42 const std::string& process_type,
43 base::CommandLine* command_line) const;
44
45 // Returns the StackSamplingConfiguration for the process.
46 static StackSamplingConfiguration* Get();
47
29 private: 48 private:
30 enum ProfileConfiguration { 49 enum ProfileConfiguration {
50 // Chrome-wide configurations set in the browser process.
31 PROFILE_DISABLED, 51 PROFILE_DISABLED,
32 PROFILE_CONTROL, 52 PROFILE_CONTROL,
33 PROFILE_NO_SAMPLES, // Run the profiler thread, but don't collect profiles. 53 PROFILE_BROWSER_PROCESS,
34 PROFILE_5HZ, 54 PROFILE_GPU_PROCESS,
35 PROFILE_10HZ, 55 PROFILE_BROWSER_AND_GPU_PROCESS,
36 PROFILE_100HZ 56
57 // Configuration set in the child processes, which receive their enable
58 // state on the command line from the browser process.
59 PROFILE_FROM_COMMAND_LINE
37 }; 60 };
38 61
62 // Generates sampling profiler configurations for all processes.
39 static ProfileConfiguration GenerateConfiguration(); 63 static ProfileConfiguration GenerateConfiguration();
40 64
65 // In the browser process this represents the configuration to use across all
66 // Chrome processes. In the child processes it is always
67 // PROFILE_FROM_COMMAND_LINE.
41 const ProfileConfiguration configuration_; 68 const ProfileConfiguration configuration_;
42 69
43 DISALLOW_COPY_AND_ASSIGN(StackSamplingConfiguration); 70 DISALLOW_COPY_AND_ASSIGN(StackSamplingConfiguration);
44 }; 71 };
45 72
46 #endif // CHROME_COMMON_STACK_SAMPLING_CONFIGURATION_H_ 73 #endif // CHROME_COMMON_STACK_SAMPLING_CONFIGURATION_H_
OLDNEW
« no previous file with comments | « chrome/common/chrome_switches.cc ('k') | chrome/common/stack_sampling_configuration.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698