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

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: address comments 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"
13 #include "base/synchronization/lock.h"
Ilya Sherman 2015/03/24 21:07:55 nit: No longer needed.
Mike Wittman 2015/03/24 22:40:59 Done.
11 #include "components/metrics/metrics_provider.h" 14 #include "components/metrics/metrics_provider.h"
12 15
13 namespace metrics { 16 namespace metrics {
14 class ChromeUserMetricsExtension; 17 class ChromeUserMetricsExtension;
15 18
16 // Performs metrics logging for the stack sampling profiler. 19 // Performs metrics logging for the stack sampling profiler.
17 class CallStackProfileMetricsProvider : public MetricsProvider { 20 class CallStackProfileMetricsProvider : public MetricsProvider {
18 public: 21 public:
19 CallStackProfileMetricsProvider(); 22 CallStackProfileMetricsProvider();
20 ~CallStackProfileMetricsProvider() override; 23 ~CallStackProfileMetricsProvider() override;
21 24
22 // MetricsProvider: 25 // MetricsProvider:
26 void OnRecordingEnabled() override;
27 void OnRecordingDisabled() override;
23 void ProvideGeneralMetrics(ChromeUserMetricsExtension* uma_proto) override; 28 void ProvideGeneralMetrics(ChromeUserMetricsExtension* uma_proto) override;
24 29
25 // Uses |profiles| as the source data for the next invocation of 30 // Uses |profiles| as the source data for the next invocation of
26 // ProvideGeneralMetrics, rather than sourcing them from the 31 // ProvideGeneralMetrics, rather than sourcing them from the
27 // StackSamplingProfiler. 32 // StackSamplingProfiler.
28 void SetSourceProfilesForTesting( 33 void SetSourceProfilesForTesting(
29 const std::vector<base::StackSamplingProfiler::Profile>& profiles); 34 const std::vector<base::StackSamplingProfiler::Profile>& profiles);
30 35
36 protected:
37 // Finch field trial and group for reporting profiles. Provided here for test
38 // use.
39 static const char kFieldTrialName[];
40 static const char kReportProfilesGroupName[];
Ilya Sherman 2015/03/24 21:07:55 Optional: Actually, an easier option for testing m
Mike Wittman 2015/03/24 22:40:59 Hmm, I'm not enthusiastic about the impact of that
41
31 private: 42 private:
32 std::vector<base::StackSamplingProfiler::Profile> source_profiles_for_test_; 43 // Returns true if reporting of profiles is enabled according to the
44 // controlling Finch field trial.
45 static bool IsSamplingProfilingReportingEnabled();
46
47 // Invoked by the profiler on another thread.
48 static void ReceiveCompletedProfiles(
49 scoped_refptr<base::MessageLoopProxy> message_loop,
Ilya Sherman 2015/03/24 21:07:55 nit: Forward-declare the MessageLoopProxy class?
Mike Wittman 2015/03/24 22:40:59 Done.
50 base::WeakPtr<CallStackProfileMetricsProvider> provider,
51 const std::vector<base::StackSamplingProfiler::Profile>& profiles);
52 void AppendCompletedProfiles(
53 const std::vector<base::StackSamplingProfiler::Profile>& profiles);
54
55 std::vector<base::StackSamplingProfiler::Profile> pending_profiles_;
56
57 base::WeakPtrFactory<CallStackProfileMetricsProvider> weak_factory_;
33 58
34 DISALLOW_COPY_AND_ASSIGN(CallStackProfileMetricsProvider); 59 DISALLOW_COPY_AND_ASSIGN(CallStackProfileMetricsProvider);
35 }; 60 };
36 61
37 } // namespace metrics 62 } // namespace metrics
38 63
39 #endif // COMPONENTS_METRICS_CALL_STACK_PROFILE_METRICS_PROVIDER_H_ 64 #endif // COMPONENTS_METRICS_CALL_STACK_PROFILE_METRICS_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698