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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/metrics/drive_metrics_provider.cc
diff --git a/chrome/browser/metrics/drive_metrics_provider.cc b/chrome/browser/metrics/drive_metrics_provider.cc
new file mode 100644
index 0000000000000000000000000000000000000000..f2e2ac51cdcae22e8985d81d93fcb14ed2f6759d
--- /dev/null
+++ b/chrome/browser/metrics/drive_metrics_provider.cc
@@ -0,0 +1,79 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/metrics/drive_metrics_provider.h"
+
+#include "base/base_paths.h"
+#include "base/bind.h"
+#include "base/files/file_path.h"
+#include "base/location.h"
+#include "base/logging.h"
+#include "base/path_service.h"
+#include "base/sys_info.h"
+#include "chrome/common/chrome_paths.h"
+#include "content/public/browser/browser_thread.h"
+
+DriveMetricsProvider::DriveMetricsProvider() : weak_ptr_factory_(this) {}
+
+DriveMetricsProvider::~DriveMetricsProvider() {}
+
+void DriveMetricsProvider::ProvideSystemProfileMetrics(
+ metrics::SystemProfileProto* system_profile_proto) {
+ auto* hardware = system_profile_proto->mutable_hardware();
+ FillDriveMetrics(metrics_.app_drive, hardware->mutable_app_drive());
+ FillDriveMetrics(metrics_.user_data_drive,
+ hardware->mutable_user_data_drive());
+}
+
+void DriveMetricsProvider::GetDriveMetrics(const base::Closure& done) {
+ got_metrics_callback_ = done;
+
+ content::BrowserThread::PostTaskAndReplyWithResult(
+ content::BrowserThread::FILE, FROM_HERE,
+ base::Bind(&DriveMetricsProvider::GetDriveMetricsOnFileThread),
+ base::Bind(&DriveMetricsProvider::GotDriveMetrics,
+ weak_ptr_factory_.GetWeakPtr()));
+}
+
+DriveMetricsProvider::SeekPenaltyResponse::SeekPenaltyResponse()
+ : success(false) {}
+
+// static
+DriveMetricsProvider::DriveMetrics
+DriveMetricsProvider::GetDriveMetricsOnFileThread() {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::FILE);
+
+ DriveMetricsProvider::DriveMetrics metrics;
+ QuerySeekPenalty(base::FILE_EXE, &metrics.app_drive);
+ QuerySeekPenalty(chrome::FILE_LOCAL_STATE, &metrics.user_data_drive);
+ return metrics;
+}
+
+// static
+void DriveMetricsProvider::QuerySeekPenalty(
+ int path_service_key,
+ DriveMetricsProvider::SeekPenaltyResponse* response) {
+ DCHECK(response);
+
+ base::FilePath path;
+ if (!PathService::Get(path_service_key, &path))
+ return;
+
+ response->success =
+ base::SysInfo::HasSeekPenalty(path, &response->has_seek_penalty);
+}
+
+void DriveMetricsProvider::GotDriveMetrics(
+ const DriveMetricsProvider::DriveMetrics& metrics) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ metrics_ = metrics;
+ got_metrics_callback_.Run();
+}
+
+void DriveMetricsProvider::FillDriveMetrics(
+ const DriveMetricsProvider::SeekPenaltyResponse& response,
+ metrics::SystemProfileProto::Hardware::Drive* drive) {
+ if (response.success)
+ drive->set_has_seek_penalty(response.has_seek_penalty);
+}
« 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