Chromium Code Reviews| 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..b9b636bcbc74f75175eabce9eda203c9f9eb7a15 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); |
|
bengr
2016/07/06 17:04:27
is_user_initiated_request, if you change the name
Raj
2016/07/06 18:28:23
Done.
|
| bool is_connection_cellular = |
| net::NetworkChangeNotifier::IsConnectionCellular( |
| @@ -112,6 +105,17 @@ void DataUseMeasurement::ReportDataUseUMA( |
| } |
| } |
| +// static |
| +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. |
|
bengr
2016/07/06 17:04:27
This should be verified. File a bug and reference
Raj
2016/07/06 18:28:23
Filed bug. Pls add any usecases this needs to be v
|
| + return content::ResourceRequestInfo::ForRequest(request) != nullptr; |
| +} |
| + |
| #if defined(OS_ANDROID) |
| void DataUseMeasurement::OnApplicationStateChangeForTesting( |
| base::android::ApplicationState application_state) { |