OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_PROFILER_PROFILER_METRICS_PROVIDER_H_ | 5 #ifndef COMPONENTS_METRICS_PROFILER_PROFILER_METRICS_PROVIDER_H_ |
6 #define COMPONENTS_METRICS_PROFILER_PROFILER_METRICS_PROVIDER_H_ | 6 #define COMPONENTS_METRICS_PROFILER_PROFILER_METRICS_PROVIDER_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "components/metrics/metrics_provider.h" | 10 #include "components/metrics/metrics_provider.h" |
| 11 #include "components/metrics/profiler/tracking_synchronizer_observer.h" |
11 #include "components/metrics/proto/chrome_user_metrics_extension.pb.h" | 12 #include "components/metrics/proto/chrome_user_metrics_extension.pb.h" |
12 | 13 |
13 namespace tracked_objects { | 14 namespace tracked_objects { |
14 struct ProcessDataSnapshot; | 15 struct ProcessDataPhaseSnapshot; |
15 } | 16 } |
16 | 17 |
17 namespace metrics { | 18 namespace metrics { |
18 | 19 |
19 // ProfilerMetricsProvider is responsible for filling out the |profiler_event| | 20 // ProfilerMetricsProvider is responsible for filling out the |profiler_event| |
20 // section of the UMA proto. | 21 // section of the UMA proto. |
21 class ProfilerMetricsProvider : public MetricsProvider { | 22 class ProfilerMetricsProvider : public MetricsProvider { |
22 public: | 23 public: |
23 explicit ProfilerMetricsProvider( | 24 explicit ProfilerMetricsProvider( |
24 const base::Callback<void(bool*)>& cellular_callback); | 25 const base::Callback<void(bool*)>& cellular_callback); |
25 // Creates profiler metrics provider with a null callback. | 26 // Creates profiler metrics provider with a null callback. |
26 ProfilerMetricsProvider(); | 27 ProfilerMetricsProvider(); |
27 ~ProfilerMetricsProvider() override; | 28 ~ProfilerMetricsProvider() override; |
28 | 29 |
29 // MetricsDataProvider: | 30 // MetricsDataProvider: |
30 void ProvideGeneralMetrics(ChromeUserMetricsExtension* uma_proto) override; | 31 void ProvideGeneralMetrics(ChromeUserMetricsExtension* uma_proto) override; |
31 | 32 |
32 // Records the passed profiled data, which should be a snapshot of the | 33 // Records the passed profiled data, which should be a snapshot of the |
33 // browser's profiled performance during startup for a single process. | 34 // browser's profiled performance during startup for a single process. |
34 void RecordProfilerData( | 35 void RecordProfilerData( |
35 const tracked_objects::ProcessDataSnapshot& process_data, | 36 const tracked_objects::ProcessDataPhaseSnapshot& process_data, |
36 int process_type); | 37 int process_id, |
| 38 int process_type, |
| 39 int profiling_phase, |
| 40 const base::TimeDelta& profiling_phase_start, |
| 41 const base::TimeDelta& profiling_phase_finish, |
| 42 const ProfilerEventsSet& past_profiler_events); |
37 | 43 |
38 private: | 44 private: |
39 // Returns whether current connection is cellular or not according to the | 45 // Returns whether current connection is cellular or not according to the |
40 // callback. | 46 // callback. |
41 bool IsCellularConnection(); | 47 bool IsCellularConnection(); |
42 | 48 |
43 // Saved cache of generated Profiler event protos, to be copied into the UMA | 49 // Saved cache of generated Profiler event protos, to be copied into the UMA |
44 // proto when ProvideGeneralMetrics() is called. | 50 // proto when ProvideGeneralMetrics() is called. The map is from a profiling |
45 ProfilerEventProto profiler_event_cache_; | 51 // phase id to the profiler event proto that represents profiler data for the |
46 | 52 // profiling phase. |
47 // True if this instance has recorded profiler data since the last call to | 53 std::map<int, ProfilerEventProto> profiler_events_cache_; |
48 // ProvideGeneralMetrics(). | |
49 bool has_profiler_data_; | |
50 | 54 |
51 // Callback function used to get current network connection type. | 55 // Callback function used to get current network connection type. |
52 base::Callback<void(bool*)> cellular_callback_; | 56 base::Callback<void(bool*)> cellular_callback_; |
53 | 57 |
54 DISALLOW_COPY_AND_ASSIGN(ProfilerMetricsProvider); | 58 DISALLOW_COPY_AND_ASSIGN(ProfilerMetricsProvider); |
55 }; | 59 }; |
56 | 60 |
57 } // namespace metrics | 61 } // namespace metrics |
58 | 62 |
59 #endif // COMPONENTS_METRICS_PROFILER_PROFILER_METRICS_PROVIDER_H_ | 63 #endif // COMPONENTS_METRICS_PROFILER_PROFILER_METRICS_PROVIDER_H_ |
OLD | NEW |