OLD | NEW |
| (Empty) |
1 // Copyright 2016 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. | |
4 | |
5 #include "components/sync_driver/device_count_metrics_provider.h" | |
6 | |
7 #include <algorithm> | |
8 | |
9 #include "base/metrics/sparse_histogram.h" | |
10 #include "components/sync_driver/device_info_tracker.h" | |
11 | |
12 namespace sync_driver { | |
13 | |
14 DeviceCountMetricsProvider::DeviceCountMetricsProvider( | |
15 const ProvideTrackersCallback& provide_trackers) | |
16 : provide_trackers_(provide_trackers) {} | |
17 | |
18 DeviceCountMetricsProvider::~DeviceCountMetricsProvider() {} | |
19 | |
20 int DeviceCountMetricsProvider::MaxActiveDeviceCount() const { | |
21 std::vector<const sync_driver::DeviceInfoTracker*> trackers; | |
22 provide_trackers_.Run(&trackers); | |
23 int max = 0; | |
24 for (auto* tracker : trackers) { | |
25 max = std::max(max, tracker->CountActiveDevices()); | |
26 } | |
27 return max; | |
28 } | |
29 | |
30 void DeviceCountMetricsProvider::ProvideGeneralMetrics( | |
31 metrics::ChromeUserMetricsExtension* uma_proto) { | |
32 UMA_HISTOGRAM_SPARSE_SLOWLY("Sync.DeviceCount", | |
33 std::min(MaxActiveDeviceCount(), 100)); | |
34 } | |
35 | |
36 } // namespace sync_driver | |
OLD | NEW |