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

Unified Diff: components/data_use_measurement/core/data_use_measurement.cc

Issue 1355893004: Complete the layered architecture of data_use_measurement component. Base URL: https://chromium.googlesource.com/chromium/src.git@NewArchServices
Patch Set: Created 5 years, 3 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
Index: components/data_use_measurement/core/data_use_measurement.cc
diff --git a/components/data_use_measurement/content/data_use_measurement.cc b/components/data_use_measurement/core/data_use_measurement.cc
similarity index 86%
rename from components/data_use_measurement/content/data_use_measurement.cc
rename to components/data_use_measurement/core/data_use_measurement.cc
index 18f910482f7c1465f0bb270e3ea0747b97dde75c..87a0810f35f9da50559eb6e2e917b0555bf927b0 100644
--- a/components/data_use_measurement/content/data_use_measurement.cc
+++ b/components/data_use_measurement/core/data_use_measurement.cc
@@ -2,12 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "components/data_use_measurement/content/data_use_measurement.h"
-
+#include <components/data_use_measurement/core/data_use_measurement.h>
#include "base/metrics/histogram.h"
#include "base/metrics/sparse_histogram.h"
#include "base/strings/stringprintf.h"
-#include "content/public/browser/resource_request_info.h"
#include "net/base/network_change_notifier.h"
#include "net/base/upload_data_stream.h"
#include "net/http/http_response_headers.h"
@@ -43,28 +41,24 @@ void IncreaseSparseHistogramByValue(const std::string& name,
} // namespace
-DataUseMeasurement::DataUseMeasurement()
+DataUseMeasurement::DataUseMeasurement(
+ DataUseMeasurementDelegate* data_use_measurement_delegate)
+ :
#if defined(OS_ANDROID)
- : app_state_(base::android::APPLICATION_STATE_HAS_RUNNING_ACTIVITIES),
+ app_state_(base::android::APPLICATION_STATE_HAS_RUNNING_ACTIVITIES),
app_listener_(new base::android::ApplicationStatusListener(
base::Bind(&DataUseMeasurement::OnApplicationStateChange,
- base::Unretained(this))))
+ base::Unretained(this)))),
#endif
-{
+ data_use_measurement_delegate_(data_use_measurement_delegate) {
}
DataUseMeasurement::~DataUseMeasurement(){};
void DataUseMeasurement::ReportDataUseUMA(
const net::URLRequest* request) const {
- const content::ResourceRequestInfo* info =
- content::ResourceRequestInfo::ForRequest(request);
- // Having |info| is the sign of a request for a web content from user. For now
- // we could add a condition to check ProcessType in info is
- // content::PROCESS_TYPE_RENDERER, but it won't be compatible with upcoming
- // PlzNavigate architecture. So just existence of |info| is verified, and the
- // current check should be compatible with upcoming changes in PlzNavigate.
- bool is_user_traffic = info != nullptr;
+ bool is_user_traffic =
+ data_use_measurement_delegate_->RequestIsFromUser(request);
// Counts rely on URLRequest::GetTotalReceivedBytes() and
// URLRequest::GetTotalSentBytes(), which does not include the send path,

Powered by Google App Engine
This is Rietveld 408576698