Fire an error if a pref used in the UI is missing once all prefs are fetched.
[chromium-blink-merge.git] / chrome / browser / metrics / drive_metrics_provider.h
blob530c0a4c285621da6699f03f5965104694772644
1 // Copyright 2015 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_DRIVE_METRICS_PROVIDER_H_
6 #define CHROME_BROWSER_METRICS_DRIVE_METRICS_PROVIDER_H_
8 #include "base/callback.h"
9 #include "base/macros.h"
10 #include "base/memory/weak_ptr.h"
11 #include "base/threading/thread_checker.h"
12 #include "components/metrics/metrics_provider.h"
13 #include "components/metrics/proto/system_profile.pb.h"
15 // Provides metrics about the local drives on a user's computer. Currently only
16 // checks to see if they incur a seek-time penalty (e.g. if they're SSDs).
18 // Defers gathering metrics until after "rush hour" (startup) so as to not bog
19 // down the FILE thread.
20 class DriveMetricsProvider : public metrics::MetricsProvider {
21 public:
22 DriveMetricsProvider();
23 ~DriveMetricsProvider() override;
25 // metrics::MetricsDataProvider:
26 void ProvideSystemProfileMetrics(
27 metrics::SystemProfileProto* system_profile_proto) override;
29 // Called by ChromeMetricsServiceClient to start gathering metrics.
30 void GetDriveMetrics(const base::Closure& done);
32 private:
33 // A response to querying a drive as to whether it incurs a seek penalty.
34 // |has_seek_penalty| is set if |success| is true.
35 struct SeekPenaltyResponse {
36 SeekPenaltyResponse();
37 bool success;
38 bool has_seek_penalty;
41 struct DriveMetrics {
42 SeekPenaltyResponse app_drive;
43 SeekPenaltyResponse user_data_drive;
46 // Gather metrics about various drives on the FILE thread.
47 static DriveMetrics GetDriveMetricsOnFileThread();
49 // Tries to determine whether there is a penalty for seeking on the drive that
50 // hosts |path_service_key| (for example: the drive that holds "Local State").
51 static void QuerySeekPenalty(int path_service_key,
52 SeekPenaltyResponse* response);
54 // Called when metrics are done being gathered from the FILE thread.
55 void GotDriveMetrics(const DriveMetrics& metrics);
57 // Fills |drive| with information from successful |response|s.
58 void FillDriveMetrics(
59 const SeekPenaltyResponse& response,
60 metrics::SystemProfileProto::Hardware::Drive* drive);
62 // Information gathered about various important drives.
63 DriveMetrics metrics_;
65 // Called when metrics are done being collected.
66 base::Closure got_metrics_callback_;
68 base::ThreadChecker thread_checker_;
69 base::WeakPtrFactory<DriveMetricsProvider> weak_ptr_factory_;
71 DISALLOW_COPY_AND_ASSIGN(DriveMetricsProvider);
74 #endif // CHROME_BROWSER_METRICS_DRIVE_METRICS_PROVIDER_H_