Home | History | Annotate | Download | only in browser
      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 class DataReductionProxyStatisticsPrefs;
     19 
     20 enum DataReductionProxyRequestType {
     21   VIA_DATA_REDUCTION_PROXY,  // A request served by the data reduction proxy.
     22 
     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.
     30 };
     31 
     32 // Returns DataReductionProxyRequestType for |request|.
     33 DataReductionProxyRequestType GetDataReductionProxyRequestType(
     34     const net::URLRequest* request);
     35 
     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);
     43 
     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,
     51     base::Time now,
     52     DataReductionProxyStatisticsPrefs* prefs);
     53 
     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);
     61 
     62 }  // namespace data_reduction_proxy
     63 
     64 #endif  // COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_METRICS_H_
     65