| 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..73fdc163e0f9e9b885e53300f9f56e6430152e60 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 = IsUserTraffic(request);
|
|
|
| bool is_connection_cellular =
|
| net::NetworkChangeNotifier::IsConnectionCellular(
|
| @@ -112,6 +105,16 @@ void DataUseMeasurement::ReportDataUseUMA(
|
| }
|
| }
|
|
|
| +bool DataUseMeasurement::IsUserTraffic(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.
|
| + return content::ResourceRequestInfo::ForRequest(request) != nullptr;
|
| +}
|
| +
|
| #if defined(OS_ANDROID)
|
| void DataUseMeasurement::OnApplicationStateChangeForTesting(
|
| base::android::ApplicationState application_state) {
|
|
|