1 // Copyright 2014 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_METRICS_H_ 6 #define COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_METRICS_H_ 7 8 #include "base/time/time.h" 9 10 namespace net { 11 class URLRequest; 12 } 13 14 class PrefService; 15 16 namespace data_reduction_proxy { 17 18 enum DataReductionProxyRequestType { 19 VIA_DATA_REDUCTION_PROXY, // A request served by the data reduction proxy. 20 21 // Below are reasons why a request is not served by the enabled data reduction 22 // proxy. Off-the-record profile data is not counted in all cases. 23 HTTPS, // An https request. 24 SHORT_BYPASS, // The client is bypassed by the proxy for a short time. 25 LONG_BYPASS, // The client is bypassed by the proxy for a long time (due 26 // to country bypass policy, for example). 27 UNKNOWN_TYPE, // Any other reason not listed above. 28 }; 29 30 // Returns DataReductionProxyRequestType for |request|. 31 DataReductionProxyRequestType GetDataReductionProxyRequestType( 32 const net::URLRequest* request); 33 34 // Returns |received_content_length| as adjusted original content length if 35 // |original_content_length| has the invalid value (-1) or |request_type| 36 // is not |VIA_DATA_REDUCTION_PROXY|. 37 int64 GetAdjustedOriginalContentLength( 38 DataReductionProxyRequestType request_type, 39 int64 original_content_length, 40 int64 received_content_length); 41 42 // This is only exposed for testing. It is normally called by 43 // UpdateContentLengthPrefs. 44 void UpdateContentLengthPrefsForDataReductionProxy( 45 int received_content_length, 46 int original_content_length, 47 bool with_data_reduction_proxy_enabled, 48 DataReductionProxyRequestType request_type, 49 base::Time now, PrefService* prefs); 50 51 // Records daily data savings statistics to prefs and reports data savings UMA. 52 void UpdateContentLengthPrefs( 53 int received_content_length, 54 int original_content_length, 55 bool with_data_reduction_proxy_enabled, 56 DataReductionProxyRequestType request_type, 57 PrefService* prefs); 58 59 } // namespace data_reduction_proxy 60 61 #endif // COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_METRICS_H_ 62