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

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

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
« no previous file with comments | « chrome/browser/metrics/drive_metrics_provider.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "chrome/browser/metrics/drive_metrics_provider.h"
6
7 #include "base/base_paths.h"
8 #include "base/bind.h"
9 #include "base/files/file_path.h"
10 #include "base/location.h"
11 #include "base/logging.h"
12 #include "base/path_service.h"
13 #include "base/sys_info.h"
14 #include "chrome/common/chrome_paths.h"
15 #include "content/public/browser/browser_thread.h"
16
17 DriveMetricsProvider::DriveMetricsProvider()
18 : got_metrics_(false), weak_ptr_factory_(this) {}
19
20 DriveMetricsProvider::~DriveMetricsProvider() {}
21
22 void DriveMetricsProvider::ProvideSystemProfileMetrics(
23 metrics::SystemProfileProto* system_profile_proto) {
24 if (!got_metrics_) {
25 content::BrowserThread::PostTaskAndReplyWithResult(
26 content::BrowserThread::FILE, FROM_HERE,
27 base::Bind(&DriveMetricsProvider::GetDriveMetrics,
28 weak_ptr_factory_.GetWeakPtr()),
Dan Beam 2015/03/16 19:20:24 this didn't work
29 base::Bind(&DriveMetricsProvider::GotDriveMetrics,
30 weak_ptr_factory_.GetWeakPtr()));
31 return;
32 }
33
34 auto* hardware = system_profile_proto->mutable_hardware();
35 FillDriveMetrics(metrics_.app_drive, hardware->mutable_app_drive());
36 FillDriveMetrics(metrics_.user_data_drive,
37 hardware->mutable_user_data_drive());
38 }
39
40 DriveMetricsProvider::SeekPenaltyResponse::SeekPenaltyResponse()
41 : success(false) {}
42
43 DriveMetricsProvider::DriveMetrics DriveMetricsProvider::GetDriveMetrics() {
44 DCHECK_CURRENTLY_ON(content::BrowserThread::FILE);
45
46 DriveMetricsProvider::DriveMetrics metrics;
47 QuerySeekPenalty(base::FILE_EXE, &metrics.app_drive);
48 QuerySeekPenalty(chrome::FILE_LOCAL_STATE, &metrics.user_data_drive);
49 return metrics;
50 }
51
52 void DriveMetricsProvider::QuerySeekPenalty(
53 int path_service_key,
54 DriveMetricsProvider::SeekPenaltyResponse* response) {
55 DCHECK(response);
56
57 base::FilePath path;
58 if (!PathService::Get(path_service_key, &path))
59 return;
60
61 response->success =
62 base::SysInfo::HasSeekPenalty(path, &response->has_seek_penalty);
63 }
64
65 void DriveMetricsProvider::GotDriveMetrics(
66 const DriveMetricsProvider::DriveMetrics& metrics) {
67 DCHECK(thread_checker_.CalledOnValidThread());
68 got_metrics_ = true;
69 metrics_ = metrics;
70 }
71
72 void DriveMetricsProvider::FillDriveMetrics(
73 const DriveMetricsProvider::SeekPenaltyResponse& response,
74 metrics::SystemProfileProto::Hardware::Drive* drive) {
75 if (response.success)
76 drive->set_has_seek_penalty(response.has_seek_penalty);
77 }
OLDNEW
« no previous file with comments | « chrome/browser/metrics/drive_metrics_provider.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698