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

Side by Side Diff: chrome/browser/metrics/disk_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: nits 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 #include "chrome/browser/metrics/disk_metrics_provider.h"
6
7 #include "base/bind.h"
8 #include "base/files/file_path.h"
9 #include "base/location.h"
10 #include "base/logging.h"
11 #include "base/path_service.h"
12 #include "base/sys_info.h"
13 #include "chrome/common/chrome_paths.h"
14 #include "components/metrics/proto/system_profile.pb.h"
15 #include "content/public/browser/browser_thread.h"
16
17 namespace {
18
19 DiskMetrics GetDiskMetrics() {
20 DCHECK_CURRENTLY_ON(content::BrowserThread::FILE);
21
22 DiskMetrics metrics;
23
24 base::FilePath app_dir;
25 if (PathService::Get(chrome::DIR_APP, &app_dir)) {
26 metrics.app_disk.success = base::SysInfo::HasSeekPenalty(
27 app_dir, &metrics.app_disk.has_seek_penalty);
28 }
29
30 base::FilePath user_data_dir;
31 if (PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) {
32 metrics.user_data_disk.success = base::SysInfo::HasSeekPenalty(
33 user_data_dir, &metrics.user_data_disk.has_seek_penalty);
34 }
35
36 return metrics;
37 }
38
39 } // namespace
40
41 DiskMetricsProvider::DiskMetricsProvider() : weak_ptr_factory_(this) {
42 content::BrowserThread::PostTaskAndReplyWithResult(
43 content::BrowserThread::FILE, FROM_HERE,
Alexei Svitkine (slow) 2015/03/12 16:41:06 Any reason to use FILE thread explicitly rather th
Dan Beam 2015/03/13 19:31:32 can't be in components/ AFAIU because it depends o
44 base::Bind(&GetDiskMetrics),
45 base::Bind(&DiskMetricsProvider::GotDiskMetrics,
46 weak_ptr_factory_.GetWeakPtr()));
47 }
48
49 DiskMetricsProvider::~DiskMetricsProvider() {}
50
51 void DiskMetricsProvider::ProvideSystemProfileMetrics(
52 metrics::SystemProfileProto* system_profile_proto) {
53 if (metrics_.app_disk.success) {
Alexei Svitkine (slow) 2015/03/12 16:41:06 Nit: You can make a helper that takes metrics_.app
Dan Beam 2015/03/13 19:31:32 Done.
54 system_profile_proto->mutable_hardware()->mutable_app_disk()->
55 set_has_seek_penalty(metrics_.app_disk.has_seek_penalty);
56 }
57 if (metrics_.user_data_disk.success) {
58 system_profile_proto->mutable_hardware()->mutable_user_data_disk()->
59 set_has_seek_penalty(metrics_.user_data_disk.has_seek_penalty);
60 }
61 }
62
63 SeekPenaltyResponse::SeekPenaltyResponse() : success(false) {}
64
65 void DiskMetricsProvider::GotDiskMetrics(const DiskMetrics& metrics) {
66 DCHECK(thread_checker_.CalledOnValidThread());
67 metrics_ = metrics;
68 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698