Revert of ui: Clean up damaged rects and clear them after painting. (patchset #2...
[chromium-blink-merge.git] / components / metrics / call_stack_profile_metrics_provider.h
blob60f297977483a2b2d9b155f9f4f603568cea8c1b
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 COMPONENTS_METRICS_CALL_STACK_PROFILE_METRICS_PROVIDER_H_
6 #define COMPONENTS_METRICS_CALL_STACK_PROFILE_METRICS_PROVIDER_H_
8 #include <vector>
10 #include "base/memory/ref_counted.h"
11 #include "base/memory/weak_ptr.h"
12 #include "base/profiler/stack_sampling_profiler.h"
13 #include "components/metrics/metrics_provider.h"
15 namespace base {
16 class MessageLoopProxy;
17 } // namespace base
19 namespace metrics {
20 class ChromeUserMetricsExtension;
22 // Performs metrics logging for the stack sampling profiler.
23 class CallStackProfileMetricsProvider : public MetricsProvider {
24 public:
25 // The event that triggered the profile collection.
26 enum Trigger {
27 UNKNOWN,
28 PROCESS_STARTUP,
29 JANKY_TASK,
30 THREAD_HUNG
33 CallStackProfileMetricsProvider();
34 ~CallStackProfileMetricsProvider() override;
36 // MetricsProvider:
37 void OnRecordingEnabled() override;
38 void OnRecordingDisabled() override;
39 void ProvideGeneralMetrics(ChromeUserMetricsExtension* uma_proto) override;
41 // Appends |profiles| for use by the next invocation of ProvideGeneralMetrics,
42 // rather than sourcing them from the StackSamplingProfiler.
43 void AppendSourceProfilesForTesting(
44 const std::vector<base::StackSamplingProfiler::CallStackProfile>&
45 profiles);
47 protected:
48 // Finch field trial and group for reporting profiles. Provided here for test
49 // use.
50 static const char kFieldTrialName[];
51 static const char kReportProfilesGroupName[];
53 private:
54 // Returns true if reporting of profiles is enabled according to the
55 // controlling Finch field trial.
56 static bool IsSamplingProfilingReportingEnabled();
58 // Invoked by the profiler on another thread.
59 static void ReceiveCompletedProfiles(
60 scoped_refptr<base::MessageLoopProxy> message_loop,
61 base::WeakPtr<CallStackProfileMetricsProvider> provider,
62 const base::StackSamplingProfiler::CallStackProfiles& profiles);
63 void AppendCompletedProfiles(
64 const base::StackSamplingProfiler::CallStackProfiles& profiles);
66 base::StackSamplingProfiler::CallStackProfiles pending_profiles_;
68 base::WeakPtrFactory<CallStackProfileMetricsProvider> weak_factory_;
70 DISALLOW_COPY_AND_ASSIGN(CallStackProfileMetricsProvider);
73 } // namespace metrics
75 #endif // COMPONENTS_METRICS_CALL_STACK_PROFILE_METRICS_PROVIDER_H_