| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 CHROME_BROWSER_METRICS_CHROMEOS_METRICS_PROVIDER_H_ | 5 #ifndef CHROME_BROWSER_METRICS_CHROMEOS_METRICS_PROVIDER_H_ |
| 6 #define CHROME_BROWSER_METRICS_CHROMEOS_METRICS_PROVIDER_H_ | 6 #define CHROME_BROWSER_METRICS_CHROMEOS_METRICS_PROVIDER_H_ |
| 7 | 7 |
| 8 #include "base/memory/weak_ptr.h" |
| 8 #include "chrome/browser/metrics/perf_provider_chromeos.h" | 9 #include "chrome/browser/metrics/perf_provider_chromeos.h" |
| 9 #include "components/metrics/metrics_provider.h" | 10 #include "components/metrics/metrics_provider.h" |
| 10 | 11 |
| 11 namespace device { | 12 namespace device { |
| 12 class BluetoothAdapter; | 13 class BluetoothAdapter; |
| 13 } | 14 } |
| 14 | 15 |
| 15 namespace metrics { | 16 namespace metrics { |
| 16 class ChromeUserMetricsExtension; | 17 class ChromeUserMetricsExtension; |
| 17 } | 18 } |
| 18 | 19 |
| 19 class PrefRegistrySimple; | 20 class PrefRegistrySimple; |
| 20 class PrefService; | 21 class PrefService; |
| 21 | 22 |
| 22 // Performs ChromeOS specific metrics logging. | 23 // Performs ChromeOS specific metrics logging. |
| 23 class ChromeOSMetricsProvider : public metrics::MetricsProvider { | 24 class ChromeOSMetricsProvider : public metrics::MetricsProvider { |
| 24 public: | 25 public: |
| 25 ChromeOSMetricsProvider(); | 26 ChromeOSMetricsProvider(); |
| 26 virtual ~ChromeOSMetricsProvider(); | 27 virtual ~ChromeOSMetricsProvider(); |
| 27 | 28 |
| 28 static void RegisterPrefs(PrefRegistrySimple* registry); | 29 static void RegisterPrefs(PrefRegistrySimple* registry); |
| 29 | 30 |
| 30 // Records a crash. | 31 // Records a crash. |
| 31 static void LogCrash(const std::string& crash_type); | 32 static void LogCrash(const std::string& crash_type); |
| 32 | 33 |
| 34 // Loads hardware class information. When this task is complete, |callback| |
| 35 // is run. |
| 36 void InitTaskGetHardwareClass(const base::Closure& callback); |
| 37 |
| 33 // metrics::MetricsProvider: | 38 // metrics::MetricsProvider: |
| 34 virtual void OnDidCreateMetricsLog() OVERRIDE; | 39 virtual void OnDidCreateMetricsLog() OVERRIDE; |
| 35 virtual void ProvideSystemProfileMetrics( | 40 virtual void ProvideSystemProfileMetrics( |
| 36 metrics::SystemProfileProto* system_profile_proto) OVERRIDE; | 41 metrics::SystemProfileProto* system_profile_proto) OVERRIDE; |
| 37 virtual void ProvideStabilityMetrics( | 42 virtual void ProvideStabilityMetrics( |
| 38 metrics::SystemProfileProto* system_profile_proto) OVERRIDE; | 43 metrics::SystemProfileProto* system_profile_proto) OVERRIDE; |
| 39 virtual void ProvideGeneralMetrics( | 44 virtual void ProvideGeneralMetrics( |
| 40 metrics::ChromeUserMetricsExtension* uma_proto) OVERRIDE; | 45 metrics::ChromeUserMetricsExtension* uma_proto) OVERRIDE; |
| 41 | 46 |
| 42 private: | 47 private: |
| 48 // Called on the FILE thread to load hardware class information. |
| 49 void InitTaskGetHardwareClassOnFileThread(); |
| 50 |
| 43 // Update the number of users logged into a multi-profile session. | 51 // Update the number of users logged into a multi-profile session. |
| 44 // If the number of users change while the log is open, the call invalidates | 52 // If the number of users change while the log is open, the call invalidates |
| 45 // the user count value. | 53 // the user count value. |
| 46 void UpdateMultiProfileUserCount( | 54 void UpdateMultiProfileUserCount( |
| 47 metrics::SystemProfileProto* system_profile_proto); | 55 metrics::SystemProfileProto* system_profile_proto); |
| 48 | 56 |
| 49 // Sets the Bluetooth Adapter instance used for the WriteBluetoothProto() | 57 // Sets the Bluetooth Adapter instance used for the WriteBluetoothProto() |
| 50 // call. | 58 // call. |
| 51 void SetBluetoothAdapter(scoped_refptr<device::BluetoothAdapter> adapter); | 59 void SetBluetoothAdapter(scoped_refptr<device::BluetoothAdapter> adapter); |
| 52 | 60 |
| 53 // Writes info about paired Bluetooth devices on this system. | 61 // Writes info about paired Bluetooth devices on this system. |
| 54 void WriteBluetoothProto(metrics::SystemProfileProto* system_profile_proto); | 62 void WriteBluetoothProto(metrics::SystemProfileProto* system_profile_proto); |
| 55 | 63 |
| 56 metrics::PerfProvider perf_provider_; | 64 metrics::PerfProvider perf_provider_; |
| 57 | 65 |
| 58 // Bluetooth Adapter instance for collecting information about paired devices. | 66 // Bluetooth Adapter instance for collecting information about paired devices. |
| 59 scoped_refptr<device::BluetoothAdapter> adapter_; | 67 scoped_refptr<device::BluetoothAdapter> adapter_; |
| 60 | 68 |
| 61 // Whether the user count was registered at the last log initialization. | 69 // Whether the user count was registered at the last log initialization. |
| 62 bool registered_user_count_at_log_initialization_; | 70 bool registered_user_count_at_log_initialization_; |
| 63 | 71 |
| 64 // The user count at the time that a log was last initialized. Contains a | 72 // The user count at the time that a log was last initialized. Contains a |
| 65 // valid value only if |registered_user_count_at_log_initialization_| is | 73 // valid value only if |registered_user_count_at_log_initialization_| is |
| 66 // true. | 74 // true. |
| 67 uint64 user_count_at_log_initialization_; | 75 uint64 user_count_at_log_initialization_; |
| 68 | 76 |
| 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_; |
| 80 |
| 81 base::WeakPtrFactory<ChromeOSMetricsProvider> weak_ptr_factory_; |
| 82 |
| 69 DISALLOW_COPY_AND_ASSIGN(ChromeOSMetricsProvider); | 83 DISALLOW_COPY_AND_ASSIGN(ChromeOSMetricsProvider); |
| 70 }; | 84 }; |
| 71 | 85 |
| 72 #endif // CHROME_BROWSER_METRICS_CHROMEOS_METRICS_PROVIDER_H_ | 86 #endif // CHROME_BROWSER_METRICS_CHROMEOS_METRICS_PROVIDER_H_ |
| OLD | NEW |