| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef COMPONENTS_DATA_USE_MEASUREMENT_CONTENT_DATA_USE_MEASUREMENT_H_ | 5 #ifndef COMPONENTS_DATA_USE_MEASUREMENT_CONTENT_DATA_USE_MEASUREMENT_H_ |
| 6 #define COMPONENTS_DATA_USE_MEASUREMENT_CONTENT_DATA_USE_MEASUREMENT_H_ | 6 #define COMPONENTS_DATA_USE_MEASUREMENT_CONTENT_DATA_USE_MEASUREMENT_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 // http://crbug.com/527460 | 34 // http://crbug.com/527460 |
| 35 class DataUseMeasurement { | 35 class DataUseMeasurement { |
| 36 public: | 36 public: |
| 37 explicit DataUseMeasurement( | 37 explicit DataUseMeasurement( |
| 38 const metrics::UpdateUsagePrefCallbackType& metrics_data_use_forwarder); | 38 const metrics::UpdateUsagePrefCallbackType& metrics_data_use_forwarder); |
| 39 ~DataUseMeasurement(); | 39 ~DataUseMeasurement(); |
| 40 | 40 |
| 41 // Records the data use of the |request|, thus |request| must be non-null. | 41 // Records the data use of the |request|, thus |request| must be non-null. |
| 42 void ReportDataUseUMA(const net::URLRequest* request) const; | 42 void ReportDataUseUMA(const net::URLRequest* request) const; |
| 43 | 43 |
| 44 // Returns true if the URLRequest |request| is initiated by user traffic. |
| 45 static bool IsUserTraffic(const net::URLRequest* request); |
| 46 |
| 44 #if defined(OS_ANDROID) | 47 #if defined(OS_ANDROID) |
| 45 // This function should just be used for testing purposes. A change in | 48 // This function should just be used for testing purposes. A change in |
| 46 // application state can be simulated by calling this function. | 49 // application state can be simulated by calling this function. |
| 47 void OnApplicationStateChangeForTesting( | 50 void OnApplicationStateChangeForTesting( |
| 48 base::android::ApplicationState application_state); | 51 base::android::ApplicationState application_state); |
| 49 #endif | 52 #endif |
| 50 | 53 |
| 51 private: | 54 private: |
| 52 // Specifies that data is received or sent, respectively. | 55 // Specifies that data is received or sent, respectively. |
| 53 enum TrafficDirection { DOWNSTREAM, UPSTREAM }; | 56 enum TrafficDirection { DOWNSTREAM, UPSTREAM }; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 // foreground or in the background. It is owned by DataUseMeasurement. | 105 // foreground or in the background. It is owned by DataUseMeasurement. |
| 103 std::unique_ptr<base::android::ApplicationStatusListener> app_listener_; | 106 std::unique_ptr<base::android::ApplicationStatusListener> app_listener_; |
| 104 #endif | 107 #endif |
| 105 | 108 |
| 106 DISALLOW_COPY_AND_ASSIGN(DataUseMeasurement); | 109 DISALLOW_COPY_AND_ASSIGN(DataUseMeasurement); |
| 107 }; | 110 }; |
| 108 | 111 |
| 109 } // namespace data_use_measurement | 112 } // namespace data_use_measurement |
| 110 | 113 |
| 111 #endif // COMPONENTS_DATA_USE_MEASUREMENT_CONTENT_DATA_USE_MEASUREMENT_H_ | 114 #endif // COMPONENTS_DATA_USE_MEASUREMENT_CONTENT_DATA_USE_MEASUREMENT_H_ |
| OLD | NEW |