Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(670)

Side by Side Diff: chrome/browser/metrics/drive_metrics_provider.h

Issue 999623002: metrics/base: log whether drives have seek penalties. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: asvitkine@ review Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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.
4
5 #ifndef CHROME_BROWSER_METRICS_DRIVE_METRICS_PROVIDER_H_
6 #define CHROME_BROWSER_METRICS_DRIVE_METRICS_PROVIDER_H_
7
8 #include "base/macros.h"
9 #include "base/memory/weak_ptr.h"
10 #include "base/threading/thread_checker.h"
11 #include "components/metrics/metrics_provider.h"
12 #include "components/metrics/proto/system_profile.pb.h"
13
14 // Provides metrics about the local drives on a user's computer. Currently only
15 // checks to see if they incur a seek-time penalty (e.g. if they're SSDs).
16 //
17 // Defers gathering metrics until after "rush hour" (startup) so as to not bog
18 // down the FILE thread.
19 class DriveMetricsProvider : public metrics::MetricsProvider {
20 public:
21 DriveMetricsProvider();
22 ~DriveMetricsProvider() override;
23
24 // metrics::MetricsDataProvider:
25 void ProvideSystemProfileMetrics(
26 metrics::SystemProfileProto* system_profile_proto) override;
27
28 private:
29 // A response to querying a drive as to whether it incurs a seek penalty.
30 // |has_seek_penalty| is set if |success| is true.
31 struct SeekPenaltyResponse {
32 SeekPenaltyResponse();
33 bool success;
34 bool has_seek_penalty;
35 };
36
37 struct DriveMetrics {
38 SeekPenaltyResponse app_drive;
39 SeekPenaltyResponse user_data_drive;
40 };
41
42 // Gather metrics about various drives on the FILE thread.
43 DriveMetrics GetDriveMetrics();
44
45 // Tries to determine whether there is a penalty for seeking on the drive that
46 // hosts |path_service_key| (for example: the drive that holds "Local State").
47 void QuerySeekPenalty(int path_service_key, SeekPenaltyResponse* response);
48
49 // Called when metrics are done being gathered from the FILE thread.
50 void GotDriveMetrics(const DriveMetrics& metrics);
51
52 // Fills |drive| with information from successful |response|s.
53 void FillDriveMetrics(
54 const SeekPenaltyResponse& response,
55 metrics::SystemProfileProto::Hardware::Drive* drive);
56
57 // False until |GotDriveMetrics| is called.
58 bool got_metrics_;
59
60 // Information gathered about various important drives.
61 DriveMetrics metrics_;
62
63 base::ThreadChecker thread_checker_;
64 base::WeakPtrFactory<DriveMetricsProvider> weak_ptr_factory_;
65
66 DISALLOW_COPY_AND_ASSIGN(DriveMetricsProvider);
67 };
68
69 #endif // CHROME_BROWSER_METRICS_DRIVE_METRICS_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698