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

Side by Side Diff: components/metrics/call_stack_profile_metrics_provider.h

Issue 1029653002: Enable startup profiling by Win x64 stack sampling profiler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@statprof-metrics-provider
Patch Set: early destruction fix Created 5 years, 9 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
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 COMPONENTS_METRICS_CALL_STACK_PROFILE_METRICS_PROVIDER_H_ 5 #ifndef COMPONENTS_METRICS_CALL_STACK_PROFILE_METRICS_PROVIDER_H_
6 #define COMPONENTS_METRICS_CALL_STACK_PROFILE_METRICS_PROVIDER_H_ 6 #define COMPONENTS_METRICS_CALL_STACK_PROFILE_METRICS_PROVIDER_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/memory/ref_counted.h"
11 #include "base/memory/weak_ptr.h"
10 #include "base/profiler/stack_sampling_profiler.h" 12 #include "base/profiler/stack_sampling_profiler.h"
11 #include "components/metrics/metrics_provider.h" 13 #include "components/metrics/metrics_provider.h"
12 14
15 namespace base {
16 class MessageLoopProxy;
17 } // namespace base
18
13 namespace metrics { 19 namespace metrics {
14 class ChromeUserMetricsExtension; 20 class ChromeUserMetricsExtension;
15 21
16 // Performs metrics logging for the stack sampling profiler. 22 // Performs metrics logging for the stack sampling profiler.
17 class CallStackProfileMetricsProvider : public MetricsProvider { 23 class CallStackProfileMetricsProvider : public MetricsProvider {
18 public: 24 public:
19 CallStackProfileMetricsProvider(); 25 CallStackProfileMetricsProvider();
20 ~CallStackProfileMetricsProvider() override; 26 ~CallStackProfileMetricsProvider() override;
21 27
22 // MetricsProvider: 28 // MetricsProvider:
29 void OnRecordingEnabled() override;
30 void OnRecordingDisabled() override;
23 void ProvideGeneralMetrics(ChromeUserMetricsExtension* uma_proto) override; 31 void ProvideGeneralMetrics(ChromeUserMetricsExtension* uma_proto) override;
24 32
25 // Uses |profiles| as the source data for the next invocation of 33 // Uses |profiles| as the source data for the next invocation of
26 // ProvideGeneralMetrics, rather than sourcing them from the 34 // ProvideGeneralMetrics, rather than sourcing them from the
27 // StackSamplingProfiler. 35 // StackSamplingProfiler.
28 void SetSourceProfilesForTesting( 36 void SetSourceProfilesForTesting(
29 const std::vector<base::StackSamplingProfiler::Profile>& profiles); 37 const std::vector<base::StackSamplingProfiler::Profile>& profiles);
30 38
39 protected:
40 // Finch field trial and group for reporting profiles. Provided here for test
41 // use.
42 static const char kFieldTrialName[];
43 static const char kReportProfilesGroupName[];
44
31 private: 45 private:
32 std::vector<base::StackSamplingProfiler::Profile> source_profiles_for_test_; 46 // Returns true if reporting of profiles is enabled according to the
47 // controlling Finch field trial.
48 static bool IsSamplingProfilingReportingEnabled();
49
50 // Invoked by the profiler on another thread.
51 static void ReceiveCompletedProfiles(
52 scoped_refptr<base::MessageLoopProxy> message_loop,
53 base::WeakPtr<CallStackProfileMetricsProvider> provider,
54 const std::vector<base::StackSamplingProfiler::Profile>& profiles);
55 void AppendCompletedProfiles(
56 const std::vector<base::StackSamplingProfiler::Profile>& profiles);
57
58 std::vector<base::StackSamplingProfiler::Profile> pending_profiles_;
59
60 base::WeakPtrFactory<CallStackProfileMetricsProvider> weak_factory_;
33 61
34 DISALLOW_COPY_AND_ASSIGN(CallStackProfileMetricsProvider); 62 DISALLOW_COPY_AND_ASSIGN(CallStackProfileMetricsProvider);
35 }; 63 };
36 64
37 } // namespace metrics 65 } // namespace metrics
38 66
39 #endif // COMPONENTS_METRICS_CALL_STACK_PROFILE_METRICS_PROVIDER_H_ 67 #endif // COMPONENTS_METRICS_CALL_STACK_PROFILE_METRICS_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698