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

Unified Diff: components/data_use_measurement/content/data_use_measurement.h

Issue 2358663004: Fix foregound vs background data use measurement (Closed)
Patch Set: remove logs Created 4 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/content/data_use_measurement.h
diff --git a/components/data_use_measurement/content/data_use_measurement.h b/components/data_use_measurement/content/data_use_measurement.h
index c115dc4bf27927ee2d8adc74b078b3d4ee0a26ba..f035ce4ace8afa08147ca3ca2732225c2bc3025f 100644
--- a/components/data_use_measurement/content/data_use_measurement.h
+++ b/components/data_use_measurement/content/data_use_measurement.h
@@ -40,6 +40,9 @@ class DataUseMeasurement {
const metrics::UpdateUsagePrefCallbackType& metrics_data_use_forwarder);
~DataUseMeasurement();
+ // Called before a request is sent.
+ void OnBeforeURLRequest(net::URLRequest* request);
+
// Called right after a redirect response code was received for |request|.
void OnBeforeRedirect(const net::URLRequest& request,
const GURL& new_location);
@@ -58,6 +61,8 @@ class DataUseMeasurement {
#endif
private:
+ friend class DataUseMeasurementTest;
+
// Specifies that data is received or sent, respectively.
enum TrafficDirection { DOWNSTREAM, UPSTREAM };
@@ -75,8 +80,11 @@ class DataUseMeasurement {
// ("Downstream") path, whether the app was in the "Foreground" or
// "Background", and whether a "Cellular" or "WiFi" network was use. For
// example, "Prefix.Upstream.Foreground.Cellular" is a possible output.
+ // |started_in_foreground| indicates if the request started when the app was
+ // in foreground.
std::string GetHistogramName(const char* prefix,
TrafficDirection dir,
+ bool started_in_foreground,
bool is_connection_cellular) const;
#if defined(OS_ANDROID)
@@ -93,9 +101,12 @@ class DataUseMeasurement {
// exchanged message, its direction (which is upstream or downstream) and
// reports to two histogram groups. DataUse.MessageSize.ServiceName and
// DataUse.Services.{Dimensions}. In the second one, services are buckets.
+ // |started_in_foreground| indicates if the request started when the app was
+ // in foreground.
void ReportDataUsageServices(
data_use_measurement::DataUseUserData::ServiceName service,
TrafficDirection dir,
+ bool started_in_foreground,
bool is_connection_cellular,
int64_t message_size) const;

Powered by Google App Engine
This is Rietveld 408576698