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

Unified Diff: components/metrics/drive_metrics_provider.cc

Issue 1254983003: Componentize DriveMetricsProvider* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Response to review Created 5 years, 5 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 | « components/metrics/drive_metrics_provider.h ('k') | components/metrics/drive_metrics_provider_android.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/metrics/drive_metrics_provider.cc
diff --git a/chrome/browser/metrics/drive_metrics_provider.cc b/components/metrics/drive_metrics_provider.cc
similarity index 79%
rename from chrome/browser/metrics/drive_metrics_provider.cc
rename to components/metrics/drive_metrics_provider.cc
index 4b888498131f8deaec956fc3501660c2118b98df..2df320d3bb9c1ef30c17439138c8f8d5d5fdcb3f 100644
--- a/chrome/browser/metrics/drive_metrics_provider.cc
+++ b/components/metrics/drive_metrics_provider.cc
@@ -2,7 +2,7 @@
// 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 "components/metrics/drive_metrics_provider.h"
#include "base/base_paths.h"
#include "base/bind.h"
@@ -11,11 +11,17 @@
#include "base/logging.h"
#include "base/metrics/histogram_macros.h"
#include "base/path_service.h"
+#include "base/task_runner_util.h"
#include "base/time/time.h"
-#include "chrome/common/chrome_paths.h"
-#include "content/public/browser/browser_thread.h"
-DriveMetricsProvider::DriveMetricsProvider() : weak_ptr_factory_(this) {}
+namespace metrics {
+
+DriveMetricsProvider::DriveMetricsProvider(
+ scoped_refptr<base::SequencedTaskRunner> file_thread,
+ int local_state_path_key)
+ : file_thread_(file_thread),
+ local_state_path_key_(local_state_path_key),
+ weak_ptr_factory_(this) {}
DriveMetricsProvider::~DriveMetricsProvider() {}
@@ -30,9 +36,10 @@ void DriveMetricsProvider::ProvideSystemProfileMetrics(
void DriveMetricsProvider::GetDriveMetrics(const base::Closure& done) {
got_metrics_callback_ = done;
- content::BrowserThread::PostTaskAndReplyWithResult(
- content::BrowserThread::FILE, FROM_HERE,
- base::Bind(&DriveMetricsProvider::GetDriveMetricsOnFileThread),
+ base::PostTaskAndReplyWithResult(
+ file_thread_.get(), FROM_HERE,
+ base::Bind(&DriveMetricsProvider::GetDriveMetricsOnFileThread,
+ local_state_path_key_),
base::Bind(&DriveMetricsProvider::GotDriveMetrics,
weak_ptr_factory_.GetWeakPtr()));
}
@@ -42,12 +49,10 @@ DriveMetricsProvider::SeekPenaltyResponse::SeekPenaltyResponse()
// static
DriveMetricsProvider::DriveMetrics
-DriveMetricsProvider::GetDriveMetricsOnFileThread() {
- DCHECK_CURRENTLY_ON(content::BrowserThread::FILE);
-
+DriveMetricsProvider::GetDriveMetricsOnFileThread(int local_state_path_key) {
DriveMetricsProvider::DriveMetrics metrics;
QuerySeekPenalty(base::FILE_EXE, &metrics.app_drive);
- QuerySeekPenalty(chrome::FILE_LOCAL_STATE, &metrics.user_data_drive);
+ QuerySeekPenalty(local_state_path_key, &metrics.user_data_drive);
return metrics;
}
@@ -88,3 +93,5 @@ void DriveMetricsProvider::FillDriveMetrics(
if (response.success)
drive->set_has_seek_penalty(response.has_seek_penalty);
}
+
+} // namespace metrics
« no previous file with comments | « components/metrics/drive_metrics_provider.h ('k') | components/metrics/drive_metrics_provider_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698