• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2024 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef BASE_PROFILER_THREAD_GROUP_PROFILER_CLIENT_H_
6 #define BASE_PROFILER_THREAD_GROUP_PROFILER_CLIENT_H_
7 
8 #include <memory>
9 
10 #include "base/base_export.h"
11 #include "base/functional/callback.h"
12 #include "base/profiler/stack_sampling_profiler.h"
13 
14 namespace base {
15 
16 class CommandLine;
17 class ProfileBuilder;
18 
19 // Interface for controlling thread group profiling behavior.
20 // This interface is designed to be implemented by embedders who will
21 // configure profiling behavior for worker threads in a thread pool.
22 class BASE_EXPORT ThreadGroupProfilerClient {
23  public:
24   ThreadGroupProfilerClient() = default;
25   ThreadGroupProfilerClient(const ThreadGroupProfilerClient&) = delete;
26   ThreadGroupProfilerClient& operator=(const ThreadGroupProfilerClient&) =
27       delete;
28   virtual ~ThreadGroupProfilerClient() = default;
29 
30   // Returns the sampling parameters for a new profiler instance.
31   virtual StackSamplingProfiler::SamplingParams GetSamplingParams() = 0;
32 
33   // Creates a ProfileBuilder for recording profile data.
34   virtual std::unique_ptr<ProfileBuilder> CreateProfileBuilder(
35       OnceClosure builder_completed_callback) = 0;
36 
37   // Returns a factory function for creating unwinders.
38   virtual base::StackSamplingProfiler::UnwindersFactory
39   GetUnwindersFactory() = 0;
40 
41   // Determines whether profiling is enabled for the current process.
42   virtual bool IsProfilerEnabledForCurrentProcess() = 0;
43 
44   // Checks if the embedder is in single-process mode based on the command line.
45   virtual bool IsSingleProcess(const base::CommandLine& command_line) = 0;
46 };
47 
48 }  // namespace base
49 
50 #endif  // BASE_PROFILER_THREAD_GROUP_PROFILER_CLIENT_H_
51