OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_USAGE_STATS _H_ | 5 #ifndef COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_USAGE_STATS _H_ |
6 #define COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_USAGE_STATS _H_ | 6 #define COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_USAGE_STATS _H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/message_loop/message_loop_proxy.h" | 9 #include "base/message_loop/message_loop_proxy.h" |
10 #include "base/prefs/pref_member.h" | 10 #include "base/prefs/pref_member.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
57 | 57 |
58 // Given |data_reduction_proxy_enabled|, a |request|, and the | 58 // Given |data_reduction_proxy_enabled|, a |request|, and the |
59 // |data_reduction_proxy_config| records the number of bypassed bytes for that | 59 // |data_reduction_proxy_config| records the number of bypassed bytes for that |
60 // |request| into UMAs based on bypass type. |data_reduction_proxy_enabled| | 60 // |request| into UMAs based on bypass type. |data_reduction_proxy_enabled| |
61 // tells us the state of the kDataReductionProxyEnabled preference. | 61 // tells us the state of the kDataReductionProxyEnabled preference. |
62 void RecordBypassedBytesHistograms( | 62 void RecordBypassedBytesHistograms( |
63 net::URLRequest& request, | 63 net::URLRequest& request, |
64 const BooleanPrefMember& data_reduction_proxy_enabled, | 64 const BooleanPrefMember& data_reduction_proxy_enabled, |
65 const net::ProxyConfig& data_reduction_proxy_config); | 65 const net::ProxyConfig& data_reduction_proxy_config); |
66 | 66 |
67 void RecordBypassEventHistograms(const net::ProxyServer& bypassed_proxy, | 67 // Called by |ChromeNetworkDelegate| when a proxy is put into bad proxy list. |
bengr
2014/09/19 21:28:13
nit: "into the"
Not at Google. Contact bengr
2014/09/22 21:46:58
Done.
| |
68 int net_error) const; | 68 // Used to track when data reduction proxy falls back. |
bengr
2014/09/19 21:28:12
nit: "when the"
Not at Google. Contact bengr
2014/09/22 21:46:58
Done.
| |
69 void OnProxyFallback(const net::ProxyServer& bypassed_proxy, | |
70 int net_error); | |
69 | 71 |
70 private: | 72 private: |
71 enum BypassedBytesType { | 73 enum BypassedBytesType { |
72 NOT_BYPASSED = 0, /* Not bypassed. */ | 74 NOT_BYPASSED = 0, /* Not bypassed. */ |
73 SSL, /* Bypass due to SSL. */ | 75 SSL, /* Bypass due to SSL. */ |
74 LOCAL_BYPASS_RULES, /* Bypass due to client-side bypass rules. */ | 76 LOCAL_BYPASS_RULES, /* Bypass due to client-side bypass rules. */ |
75 MANAGED_PROXY_CONFIG, /* Bypass due to managed config. */ | 77 MANAGED_PROXY_CONFIG, /* Bypass due to managed config. */ |
76 AUDIO_VIDEO, /* Audio/Video bypass. */ | 78 AUDIO_VIDEO, /* Audio/Video bypass. */ |
77 TRIGGERING_REQUEST, /* Triggering request bypass. */ | 79 TRIGGERING_REQUEST, /* Triggering request bypass. */ |
78 NETWORK_ERROR, /* Network error. */ | 80 NETWORK_ERROR, /* Network error. */ |
79 BYPASSED_BYTES_TYPE_MAX /* This must always be last.*/ | 81 BYPASSED_BYTES_TYPE_MAX /* This must always be last.*/ |
80 }; | 82 }; |
81 | 83 |
82 // NetworkChangeNotifier::NetworkChangeObserver: | 84 // NetworkChangeNotifier::NetworkChangeObserver: |
83 virtual void OnNetworkChanged( | 85 virtual void OnNetworkChanged( |
84 net::NetworkChangeNotifier::ConnectionType type) OVERRIDE; | 86 net::NetworkChangeNotifier::ConnectionType type) OVERRIDE; |
85 | 87 |
86 // Counts requests that went through the data reduction proxy and counts | |
87 // requests that were eligible to go through the proxy. | |
88 void IncrementRequestCounts(bool actual); | |
89 void ClearRequestCounts(); | 88 void ClearRequestCounts(); |
90 | 89 |
91 // Checks if the availability status of the data reduction proxy has changed, | 90 // Checks if the availability status of the data reduction proxy has changed, |
92 // and notifies the UIThread via NotifyUnavailabilityOnUIThread if so. The | 91 // and notifies the UIThread via NotifyUnavailabilityOnUIThread if so. The |
93 // data reduction proxy is considered unavailable if and only if no requests | 92 // data reduction proxy is considered unavailable if and only if no requests |
94 // went through the proxy but some eligible requests were service by other | 93 // went through the proxy but some eligible requests were service by other |
95 // routes. | 94 // routes. |
96 void MaybeNotifyUnavailability(); | 95 void MaybeNotifyUnavailability(); |
97 void NotifyUnavailabilityOnUIThread(bool unavailable); | 96 void NotifyUnavailabilityOnUIThread(bool unavailable); |
98 | 97 |
99 DataReductionProxyParams* data_reduction_proxy_params_; | 98 DataReductionProxyParams* data_reduction_proxy_params_; |
100 // The last reason for bypass as determined by | 99 // The last reason for bypass as determined by |
101 // MaybeBypassProxyAndPrepareToRetry | 100 // MaybeBypassProxyAndPrepareToRetry |
102 DataReductionProxyBypassType last_bypass_type_; | 101 DataReductionProxyBypassType last_bypass_type_; |
103 // True if the last request triggered the current bypass. | 102 // True if the last request triggered the current bypass. |
104 bool triggering_request_; | 103 bool triggering_request_; |
105 base::MessageLoopProxy* ui_thread_proxy_; | 104 base::MessageLoopProxy* ui_thread_proxy_; |
106 | 105 |
107 // The following 2 fields are used to determine if data reduction proxy is | 106 // The following 2 fields are used to determine if data reduction proxy is |
108 // unreachable. We keep a count of requests which should go through | 107 // unreachable. We keep a count of requests which should go through |
109 // data request proxy, as well as those which actually do. The proxy is | 108 // data request proxy, as well as those which actually do. The proxy is |
110 // unreachable if no successful requests are made through it despite a | 109 // unreachable if no successful requests are made through it despite a |
111 // non-zero number of requests being eligible. | 110 // non-zero number of requests being eligible. |
112 | 111 |
113 // Count of requests which will be tried to be sent through data reduction | 112 // Count of successful requests through data reduction proxy. |
bengr
2014/09/19 21:28:13
nit: "through the"
Not at Google. Contact bengr
2014/09/22 21:46:58
Done.
| |
114 // proxy. The count is only based on the config and not the bad proxy list. | 113 unsigned long num_successful_requests_through_proxy_; |
bengr
2014/09/19 21:28:12
I don't like "num". If you don't like the removal
Not at Google. Contact bengr
2014/09/22 21:46:58
Done.
Would have preferred count_successful_reque
| |
115 // Explicit bypasses are not part of this count. This is the desired behavior | |
116 // since otherwise both counts would be identical. | |
117 unsigned long eligible_num_requests_through_proxy_; | |
118 | 114 |
119 // Count of successful requests through data reduction proxy. | 115 // Count of network errors encountered when connecting to a data reduction |
120 unsigned long actual_num_requests_through_proxy_; | 116 // proxy. |
117 unsigned long num_proxy_net_errors_; | |
121 | 118 |
122 // Whether or not the data reduction proxy is unavailable. | 119 // Whether or not the data reduction proxy is unavailable. |
123 bool unavailable_; | 120 bool unavailable_; |
124 | 121 |
125 base::ThreadChecker thread_checker_; | 122 base::ThreadChecker thread_checker_; |
126 | 123 |
127 void RecordBypassedBytes( | 124 void RecordBypassedBytes( |
128 DataReductionProxyBypassType bypass_type, | 125 DataReductionProxyBypassType bypass_type, |
129 BypassedBytesType bypassed_bytes_type, | 126 BypassedBytesType bypassed_bytes_type, |
130 int64 content_length); | 127 int64 content_length); |
131 | 128 |
132 // Called when the unavailability status has changed. Runs on the UI thread. | 129 // Called when the unavailability status has changed. Runs on the UI thread. |
133 base::Callback<void(bool)> unavailable_callback_; | 130 base::Callback<void(bool)> unavailable_callback_; |
134 | 131 |
135 DISALLOW_COPY_AND_ASSIGN(DataReductionProxyUsageStats); | 132 DISALLOW_COPY_AND_ASSIGN(DataReductionProxyUsageStats); |
136 }; | 133 }; |
137 | 134 |
138 } // namespace data_reduction_proxy | 135 } // namespace data_reduction_proxy |
139 | 136 |
140 #endif // COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_USAGE_ST ATS_H_ | 137 #endif // COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_USAGE_ST ATS_H_ |
OLD | NEW |