| Index: components/data_use_measurement/content/data_use_measurement.cc
|
| diff --git a/components/data_use_measurement/content/data_use_measurement.cc b/components/data_use_measurement/content/data_use_measurement.cc
|
| index 31b3eb3cbe7482d8cd997d88904e85d5d3842fd4..e45368ae1b65ca1c67fdb70a3ddccd2e30be4ff1 100644
|
| --- a/components/data_use_measurement/content/data_use_measurement.cc
|
| +++ b/components/data_use_measurement/content/data_use_measurement.cc
|
| @@ -61,14 +61,6 @@ 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;
|
|
|
| // Counts rely on URLRequest::GetTotalReceivedBytes() and
|
| // URLRequest::GetTotalSentBytes(), which does not include the send path,
|
| @@ -77,6 +69,7 @@ void DataUseMeasurement::ReportDataUseUMA(
|
| // bytes in lower levels.
|
| int64_t total_upload_bytes = request->GetTotalSentBytes();
|
| int64_t total_received_bytes = request->GetTotalReceivedBytes();
|
| + bool is_user_traffic = IsUserInitiatedRequest(request);
|
|
|
| bool is_connection_cellular =
|
| net::NetworkChangeNotifier::IsConnectionCellular(
|
| @@ -112,6 +105,20 @@ void DataUseMeasurement::ReportDataUseUMA(
|
| }
|
| }
|
|
|
| +// static
|
| +bool DataUseMeasurement::IsUserInitiatedRequest(
|
| + const net::URLRequest* request) {
|
| + // Having ResourceRequestInfo in the URL request is a sign that the request is
|
| + // 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
|
| + // ResourceRequestInfo is verified, and the current check should be compatible
|
| + // with upcoming changes in PlzNavigate.
|
| + // TODO(rajendrant): Verify this condition for different use cases. See
|
| + // crbug.com/626063.
|
| + return content::ResourceRequestInfo::ForRequest(request) != nullptr;
|
| +}
|
| +
|
| #if defined(OS_ANDROID)
|
| void DataUseMeasurement::OnApplicationStateChangeForTesting(
|
| base::android::ApplicationState application_state) {
|
|
|