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

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: DONT_ASSERT_ANYTHING 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() : weak_ptr_factory_(this) {}
18
19 DriveMetricsProvider::~DriveMetricsProvider() {}
20
21 void DriveMetricsProvider::ProvideSystemProfileMetrics(
22 metrics::SystemProfileProto* system_profile_proto) {
23 auto* hardware = system_profile_proto->mutable_hardware();
24 FillDriveMetrics(metrics_.app_drive, hardware->mutable_app_drive());
25 FillDriveMetrics(metrics_.user_data_drive,
26 hardware->mutable_user_data_drive());
27 }
28
29 void DriveMetricsProvider::GetDriveMetrics(const base::Closure& done) {
30 got_metrics_callback_ = done;
31
32 content::BrowserThread::PostTaskAndReplyWithResult(
33 content::BrowserThread::FILE, FROM_HERE,
34 base::Bind(&DriveMetricsProvider::GetDriveMetricsOnFileThread),
35 base::Bind(&DriveMetricsProvider::GotDriveMetrics,
36 weak_ptr_factory_.GetWeakPtr()));
37 }
38
39 DriveMetricsProvider::SeekPenaltyResponse::SeekPenaltyResponse()
40 : success(false) {}
41
42 // static
43 DriveMetricsProvider::DriveMetrics
44 DriveMetricsProvider::GetDriveMetricsOnFileThread() {
45 DCHECK_CURRENTLY_ON(content::BrowserThread::FILE);
46
47 DriveMetricsProvider::DriveMetrics metrics;
48 QuerySeekPenalty(base::FILE_EXE, &metrics.app_drive);
49 QuerySeekPenalty(chrome::FILE_LOCAL_STATE, &metrics.user_data_drive);
50 return metrics;
51 }
52
53 // static
54 void DriveMetricsProvider::QuerySeekPenalty(
55 int path_service_key,
56 DriveMetricsProvider::SeekPenaltyResponse* response) {
57 DCHECK(response);
58
59 base::FilePath path;
60 if (!PathService::Get(path_service_key, &path))
61 return;
62
63 response->success =
64 base::SysInfo::HasSeekPenalty(path, &response->has_seek_penalty);
65 }
66
67 void DriveMetricsProvider::GotDriveMetrics(
68 const DriveMetricsProvider::DriveMetrics& metrics) {
69 DCHECK(thread_checker_.CalledOnValidThread());
70 metrics_ = metrics;
71 got_metrics_callback_.Run();
72 }
73
74 void DriveMetricsProvider::FillDriveMetrics(
75 const DriveMetricsProvider::SeekPenaltyResponse& response,
76 metrics::SystemProfileProto::Hardware::Drive* drive) {
77 if (response.success)
78 drive->set_has_seek_penalty(response.has_seek_penalty);
79 }
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