QUIC - cleanup changes to sync chromium tree with internal source.
[chromium-blink-merge.git] / base / profiler / native_stack_sampler.h
blobbc170dcf933e6e9bc7554fda261182a142178f75
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
3 // found in the LICENSE file.
5 #ifndef BASE_PROFILER_NATIVE_STACK_SAMPLER_H_
6 #define BASE_PROFILER_NATIVE_STACK_SAMPLER_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "base/profiler/stack_sampling_profiler.h"
10 #include "base/threading/platform_thread.h"
12 namespace base {
14 // NativeStackSampler is an implementation detail of StackSamplingProfiler. It
15 // abstracts the native implementation required to record a stack sample for a
16 // given thread.
17 class NativeStackSampler {
18 public:
19 virtual ~NativeStackSampler();
21 // Creates a stack sampler that records samples for |thread_handle|. Returns
22 // null if this platform does not support stack sampling.
23 static scoped_ptr<NativeStackSampler> Create(PlatformThreadId thread_id);
25 // The following functions are all called on the SamplingThread (not the
26 // thread being sampled).
28 // Notifies the sampler that we're starting to record a new profile. Modules
29 // shared across samples in the profile should be recorded in |modules|.
30 virtual void ProfileRecordingStarting(
31 std::vector<StackSamplingProfiler::Module>* modules) = 0;
33 // Records a stack sample to |sample|.
34 virtual void RecordStackSample(StackSamplingProfiler::Sample* sample) = 0;
36 // Notifies the sampler that we've stopped recording the current
37 // profile.
38 virtual void ProfileRecordingStopped() = 0;
40 protected:
41 NativeStackSampler();
43 private:
44 DISALLOW_COPY_AND_ASSIGN(NativeStackSampler);
47 } // namespace base
49 #endif // BASE_PROFILER_NATIVE_STACK_SAMPLER_H_