Roll src/third_party/WebKit 8b42d1d:744641d (svn 186770:186771)
[chromium-blink-merge.git] / chrome / browser / metrics / chromeos_metrics_provider.h
blobeb4506959406769541edb5ed0946fdd5fe8a8a5d
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"
12 namespace device {
13 class BluetoothAdapter;
16 namespace metrics {
17 class ChromeUserMetricsExtension;
20 class PrefRegistrySimple;
21 class PrefService;
23 // Performs ChromeOS specific metrics logging.
24 class ChromeOSMetricsProvider : public metrics::MetricsProvider {
25 public:
26 ChromeOSMetricsProvider();
27 virtual ~ChromeOSMetricsProvider();
29 static void RegisterPrefs(PrefRegistrySimple* registry);
31 // Records a crash.
32 static void LogCrash(const std::string& crash_type);
34 // Loads hardware class information. When this task is complete, |callback|
35 // is run.
36 void InitTaskGetHardwareClass(const base::Closure& callback);
38 // metrics::MetricsProvider:
39 virtual void OnDidCreateMetricsLog() override;
40 virtual void ProvideSystemProfileMetrics(
41 metrics::SystemProfileProto* system_profile_proto) override;
42 virtual void ProvideStabilityMetrics(
43 metrics::SystemProfileProto* system_profile_proto) override;
44 virtual void ProvideGeneralMetrics(
45 metrics::ChromeUserMetricsExtension* uma_proto) override;
47 private:
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()
58 // call.
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 metrics::PerfProvider perf_provider_;
66 // Bluetooth Adapter instance for collecting information about paired devices.
67 scoped_refptr<device::BluetoothAdapter> adapter_;
69 // Whether the user count was registered at the last log initialization.
70 bool registered_user_count_at_log_initialization_;
72 // The user count at the time that a log was last initialized. Contains a
73 // valid value only if |registered_user_count_at_log_initialization_| is
74 // true.
75 uint64 user_count_at_log_initialization_;
77 // Hardware class (e.g., hardware qualification ID). This class identifies
78 // the configured system components such as CPU, WiFi adapter, etc.
79 std::string hardware_class_;
81 base::WeakPtrFactory<ChromeOSMetricsProvider> weak_ptr_factory_;
83 DISALLOW_COPY_AND_ASSIGN(ChromeOSMetricsProvider);
86 #endif // CHROME_BROWSER_METRICS_CHROMEOS_METRICS_PROVIDER_H_