Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/weak_ptr.h" | |
| 10 #include "base/profiler/stack_sampling_profiler.h" | 11 #include "base/profiler/stack_sampling_profiler.h" |
| 12 #include "base/synchronization/lock.h" | |
| 11 #include "components/metrics/metrics_provider.h" | 13 #include "components/metrics/metrics_provider.h" |
| 12 | 14 |
| 13 namespace metrics { | 15 namespace metrics { |
| 14 class ChromeUserMetricsExtension; | 16 class ChromeUserMetricsExtension; |
| 15 | 17 |
| 16 // Performs metrics logging for the stack sampling profiler. | 18 // Performs metrics logging for the stack sampling profiler. |
| 17 class CallStackProfileMetricsProvider : public MetricsProvider { | 19 class CallStackProfileMetricsProvider : public MetricsProvider { |
| 18 public: | 20 public: |
| 19 CallStackProfileMetricsProvider(); | 21 CallStackProfileMetricsProvider(); |
| 20 ~CallStackProfileMetricsProvider() override; | 22 ~CallStackProfileMetricsProvider() override; |
| 21 | 23 |
| 22 // MetricsProvider: | 24 // MetricsProvider: |
| 25 void OnRecordingEnabled() override; | |
| 26 void OnRecordingDisabled() override; | |
| 23 void ProvideGeneralMetrics(ChromeUserMetricsExtension* uma_proto) override; | 27 void ProvideGeneralMetrics(ChromeUserMetricsExtension* uma_proto) override; |
| 24 | 28 |
| 25 // Uses |profiles| as the source data for the next invocation of | 29 // Uses |profiles| as the source data for the next invocation of |
| 26 // ProvideGeneralMetrics, rather than sourcing them from the | 30 // ProvideGeneralMetrics, rather than sourcing them from the |
| 27 // StackSamplingProfiler. | 31 // StackSamplingProfiler. |
| 28 void SetSourceProfilesForTesting( | 32 void SetSourceProfilesForTesting( |
| 29 const std::vector<base::StackSamplingProfiler::Profile>& profiles); | 33 const std::vector<base::StackSamplingProfiler::Profile>& profiles); |
| 30 | 34 |
| 35 // Finch field trial and group for reporting profiles. | |
| 36 static const char kFieldTrialName[]; | |
| 37 static const char kReportProfilesGroupName[]; | |
|
Ilya Sherman
2015/03/24 04:02:03
nit: If these are only used for tests, please mark
Mike Wittman
2015/03/24 18:37:39
Done.
| |
| 38 | |
| 31 private: | 39 private: |
| 32 std::vector<base::StackSamplingProfiler::Profile> source_profiles_for_test_; | 40 // These functions will be called on a separate thread. |
| 41 void ReceiveCompletedProfiles( | |
| 42 const std::vector<base::StackSamplingProfiler::Profile>& profiles); | |
| 43 static void IgnoreCompletedProfiles( | |
| 44 const std::vector<base::StackSamplingProfiler::Profile>& profiles); | |
|
Ilya Sherman
2015/03/24 04:02:03
Can this be moved to an anonymous namespace in the
Mike Wittman
2015/03/24 18:37:39
Done.
| |
| 45 | |
| 46 // Pending profiles are updated from the profiler on a separate thread, so | |
| 47 // must be guarded by a lock. | |
| 48 base::Lock pending_profiles_lock_; | |
| 49 std::vector<base::StackSamplingProfiler::Profile> pending_profiles_; | |
|
Ilya Sherman
2015/03/24 04:02:03
Could you please instead post a task to the thread
Mike Wittman
2015/03/24 18:37:39
Done.
| |
| 50 | |
| 51 base::WeakPtrFactory<CallStackProfileMetricsProvider> weak_factory_; | |
| 33 | 52 |
| 34 DISALLOW_COPY_AND_ASSIGN(CallStackProfileMetricsProvider); | 53 DISALLOW_COPY_AND_ASSIGN(CallStackProfileMetricsProvider); |
| 35 }; | 54 }; |
| 36 | 55 |
| 37 } // namespace metrics | 56 } // namespace metrics |
| 38 | 57 |
| 39 #endif // COMPONENTS_METRICS_CALL_STACK_PROFILE_METRICS_PROVIDER_H_ | 58 #endif // COMPONENTS_METRICS_CALL_STACK_PROFILE_METRICS_PROVIDER_H_ |
| OLD | NEW |