| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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_SYNC_DEVICE_INFO_DEVICE_COUNT_METRICS_PROVIDER_H_ | 5 #ifndef COMPONENTS_SYNC_DEVICE_INFO_DEVICE_COUNT_METRICS_PROVIDER_H_ |
| 6 #define COMPONENTS_SYNC_DEVICE_INFO_DEVICE_COUNT_METRICS_PROVIDER_H_ | 6 #define COMPONENTS_SYNC_DEVICE_INFO_DEVICE_COUNT_METRICS_PROVIDER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "components/metrics/metrics_provider.h" | 13 #include "components/metrics/metrics_provider.h" |
| 14 | 14 |
| 15 namespace sync_driver { | 15 namespace syncer { |
| 16 | 16 |
| 17 class DeviceInfoTracker; | 17 class DeviceInfoTracker; |
| 18 | 18 |
| 19 // A registerable metrics provider that will emit the number of active syncing | 19 // A registerable metrics provider that will emit the number of active syncing |
| 20 // devices a user has upon UMA upload. When there are multiple active profiles | 20 // devices a user has upon UMA upload. When there are multiple active profiles |
| 21 // that are aware of syncable devices, the largest count is used. This approach | 21 // that are aware of syncable devices, the largest count is used. This approach |
| 22 // is useful for several reasons. We're significantly interested in "power" | 22 // is useful for several reasons. We're significantly interested in "power" |
| 23 // users that have multiple devices and profiles, and if we skipped emitting any | 23 // users that have multiple devices and profiles, and if we skipped emitting any |
| 24 // metrics in multi profile cases, then we'd be unaware of this entire segment | 24 // metrics in multi profile cases, then we'd be unaware of this entire segment |
| 25 // of the population. If we emitted multiple metrics, we would have much more | 25 // of the population. If we emitted multiple metrics, we would have much more |
| 26 // noise and discerning which metrics actually belonged to non-syncing users | 26 // noise and discerning which metrics actually belonged to non-syncing users |
| 27 // would be much trickier. | 27 // would be much trickier. |
| 28 class DeviceCountMetricsProvider : public metrics::MetricsProvider { | 28 class DeviceCountMetricsProvider : public metrics::MetricsProvider { |
| 29 public: | 29 public: |
| 30 typedef base::Callback<void( | 30 typedef base::Callback<void(std::vector<const DeviceInfoTracker*>* trackers)> |
| 31 std::vector<const sync_driver::DeviceInfoTracker*>* trackers)> | |
| 32 ProvideTrackersCallback; | 31 ProvideTrackersCallback; |
| 33 | 32 |
| 34 explicit DeviceCountMetricsProvider( | 33 explicit DeviceCountMetricsProvider( |
| 35 const ProvideTrackersCallback& provide_trackers); | 34 const ProvideTrackersCallback& provide_trackers); |
| 36 ~DeviceCountMetricsProvider() override; | 35 ~DeviceCountMetricsProvider() override; |
| 37 | 36 |
| 38 // MetricsProvider: | 37 // MetricsProvider: |
| 39 void ProvideGeneralMetrics( | 38 void ProvideGeneralMetrics( |
| 40 metrics::ChromeUserMetricsExtension* uma_proto) override; | 39 metrics::ChromeUserMetricsExtension* uma_proto) override; |
| 41 | 40 |
| 42 private: | 41 private: |
| 43 // Returns the max number of active devices across all accounts. | 42 // Returns the max number of active devices across all accounts. |
| 44 int MaxActiveDeviceCount() const; | 43 int MaxActiveDeviceCount() const; |
| 45 | 44 |
| 46 const ProvideTrackersCallback provide_trackers_; | 45 const ProvideTrackersCallback provide_trackers_; |
| 47 | 46 |
| 48 DISALLOW_COPY_AND_ASSIGN(DeviceCountMetricsProvider); | 47 DISALLOW_COPY_AND_ASSIGN(DeviceCountMetricsProvider); |
| 49 }; | 48 }; |
| 50 | 49 |
| 51 } // namespace sync_driver | 50 } // namespace syncer |
| 52 | 51 |
| 53 #endif // COMPONENTS_SYNC_DEVICE_INFO_DEVICE_COUNT_METRICS_PROVIDER_H_ | 52 #endif // COMPONENTS_SYNC_DEVICE_INFO_DEVICE_COUNT_METRICS_PROVIDER_H_ |
| OLD | NEW |