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.
5 #ifndef COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_METRICS_H_
6 #define COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_METRICS_H_
8 #include "base/time/time.h"
16 namespace data_reduction_proxy
{
18 class DataReductionProxyStatisticsPrefs
;
20 enum DataReductionProxyRequestType
{
21 VIA_DATA_REDUCTION_PROXY
, // A request served by the data reduction proxy.
23 // Below are reasons why a request is not served by the enabled data reduction
24 // proxy. Off-the-record profile data is not counted in all cases.
25 HTTPS
, // An https request.
26 SHORT_BYPASS
, // The client is bypassed by the proxy for a short time.
27 LONG_BYPASS
, // The client is bypassed by the proxy for a long time (due
28 // to country bypass policy, for example).
29 UNKNOWN_TYPE
, // Any other reason not listed above.
32 // Returns DataReductionProxyRequestType for |request|.
33 DataReductionProxyRequestType
GetDataReductionProxyRequestType(
34 const net::URLRequest
* request
);
36 // Returns |received_content_length| as adjusted original content length if
37 // |original_content_length| has the invalid value (-1) or |request_type|
38 // is not |VIA_DATA_REDUCTION_PROXY|.
39 int64
GetAdjustedOriginalContentLength(
40 DataReductionProxyRequestType request_type
,
41 int64 original_content_length
,
42 int64 received_content_length
);
44 // This is only exposed for testing. It is normally called by
45 // UpdateContentLengthPrefs.
46 void UpdateContentLengthPrefsForDataReductionProxy(
47 int received_content_length
,
48 int original_content_length
,
49 bool with_data_reduction_proxy_enabled
,
50 DataReductionProxyRequestType request_type
,
52 DataReductionProxyStatisticsPrefs
* prefs
);
54 // Records daily data savings statistics to prefs and reports data savings UMA.
55 void UpdateContentLengthPrefs(
56 int received_content_length
,
57 int original_content_length
,
58 PrefService
* profile_prefs
,
59 DataReductionProxyRequestType request_type
,
60 DataReductionProxyStatisticsPrefs
* prefs
);
62 } // namespace data_reduction_proxy
64 #endif // COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_METRICS_H_