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
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_METRICS_PROFILER_PROFILER_METRICS_PROVIDER_H_
6 #define COMPONENTS_METRICS_PROFILER_PROFILER_METRICS_PROVIDER_H_
8 #include "base/basictypes.h"
9 #include "base/callback.h"
10 #include "components/metrics/metrics_provider.h"
11 #include "components/metrics/profiler/tracking_synchronizer_observer.h"
12 #include "components/metrics/proto/chrome_user_metrics_extension.pb.h"
13 #include "content/public/common/process_type.h"
15 namespace tracked_objects
{
16 struct ProcessDataPhaseSnapshot
;
21 // ProfilerMetricsProvider is responsible for filling out the |profiler_event|
22 // section of the UMA proto.
23 class ProfilerMetricsProvider
: public MetricsProvider
{
25 explicit ProfilerMetricsProvider(
26 const base::Callback
<bool(void)>& cellular_callback
);
27 // Creates profiler metrics provider with a null callback.
28 ProfilerMetricsProvider();
29 ~ProfilerMetricsProvider() override
;
31 // MetricsDataProvider:
32 void ProvideGeneralMetrics(ChromeUserMetricsExtension
* uma_proto
) override
;
34 // Records the passed profiled data, which should be a snapshot of the
35 // browser's profiled performance during startup for a single process.
36 void RecordProfilerData(
37 const tracked_objects::ProcessDataPhaseSnapshot
& process_data
,
38 base::ProcessId process_id
,
39 content::ProcessType process_type
,
41 base::TimeDelta phase_start
,
42 base::TimeDelta phase_finish
,
43 const ProfilerEvents
& past_events
);
46 // Returns true if current connection type is cellular and user is assigned to
47 // experimental group for enabled cellular uploads according to
48 // |cellular_callback_|.
49 bool IsCellularLogicEnabled();
51 // Saved cache of generated Profiler event protos, to be copied into the UMA
52 // proto when ProvideGeneralMetrics() is called. The map is from a profiling
53 // phase id to the profiler event proto that represents profiler data for the
55 std::map
<int, ProfilerEventProto
> profiler_events_cache_
;
57 // Returns true if current connection type is cellular and user is assigned to
58 // experimental group for enabled cellular uploads.
59 base::Callback
<bool(void)> cellular_callback_
;
61 DISALLOW_COPY_AND_ASSIGN(ProfilerMetricsProvider
);
64 } // namespace metrics
66 #endif // COMPONENTS_METRICS_PROFILER_PROFILER_METRICS_PROVIDER_H_