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 CHROME_BROWSER_METRICS_CHROMEOS_METRICS_PROVIDER_H_
6 #define CHROME_BROWSER_METRICS_CHROMEOS_METRICS_PROVIDER_H_
8 #include "base/memory/weak_ptr.h"
9 #include "chrome/browser/metrics/perf_provider_chromeos.h"
10 #include "components/metrics/metrics_provider.h"
13 class BluetoothAdapter
;
17 class ChromeUserMetricsExtension
;
20 class PrefRegistrySimple
;
23 // Performs ChromeOS specific metrics logging.
24 class ChromeOSMetricsProvider
: public metrics::MetricsProvider
{
26 ChromeOSMetricsProvider();
27 ~ChromeOSMetricsProvider() override
;
29 static void RegisterPrefs(PrefRegistrySimple
* registry
);
32 static void LogCrash(const std::string
& crash_type
);
34 // Loads hardware class information. When this task is complete, |callback|
36 void InitTaskGetHardwareClass(const base::Closure
& callback
);
38 // metrics::MetricsProvider:
39 void OnDidCreateMetricsLog() override
;
40 void ProvideSystemProfileMetrics(
41 metrics::SystemProfileProto
* system_profile_proto
) override
;
42 void ProvideStabilityMetrics(
43 metrics::SystemProfileProto
* system_profile_proto
) override
;
44 void ProvideGeneralMetrics(
45 metrics::ChromeUserMetricsExtension
* uma_proto
) override
;
48 // Called on the FILE thread to load hardware class information.
49 void InitTaskGetHardwareClassOnFileThread();
51 // Update the number of users logged into a multi-profile session.
52 // If the number of users change while the log is open, the call invalidates
53 // the user count value.
54 void UpdateMultiProfileUserCount(
55 metrics::SystemProfileProto
* system_profile_proto
);
57 // Sets the Bluetooth Adapter instance used for the WriteBluetoothProto()
59 void SetBluetoothAdapter(scoped_refptr
<device::BluetoothAdapter
> adapter
);
61 // Writes info about paired Bluetooth devices on this system.
62 void WriteBluetoothProto(metrics::SystemProfileProto
* system_profile_proto
);
64 // Record the device enrollment status.
65 void RecordEnrollmentStatus();
67 metrics::PerfProvider perf_provider_
;
69 // Bluetooth Adapter instance for collecting information about paired devices.
70 scoped_refptr
<device::BluetoothAdapter
> adapter_
;
72 // Whether the user count was registered at the last log initialization.
73 bool registered_user_count_at_log_initialization_
;
75 // The user count at the time that a log was last initialized. Contains a
76 // valid value only if |registered_user_count_at_log_initialization_| is
78 uint64 user_count_at_log_initialization_
;
80 // Hardware class (e.g., hardware qualification ID). This class identifies
81 // the configured system components such as CPU, WiFi adapter, etc.
82 std::string hardware_class_
;
84 base::WeakPtrFactory
<ChromeOSMetricsProvider
> weak_ptr_factory_
;
86 DISALLOW_COPY_AND_ASSIGN(ChromeOSMetricsProvider
);
89 #endif // CHROME_BROWSER_METRICS_CHROMEOS_METRICS_PROVIDER_H_