Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(776)

Side by Side Diff: components/data_reduction_proxy/browser/data_reduction_proxy_usage_stats.h

Issue 568893002: Trigger data reduction proxy unreachable message via on proxy fall back. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 void OnProxyFallback(const net::ProxyServer& bypassed_proxy,
bengr 2014/09/16 18:48:57 Please add a comment that describes what this meth
Not at Google. Contact bengr 2014/09/16 19:34:49 Done.
68 int net_error) const; 68 int net_error);
69 69
70 private: 70 private:
71 enum BypassedBytesType { 71 enum BypassedBytesType {
72 NOT_BYPASSED = 0, /* Not bypassed. */ 72 NOT_BYPASSED = 0, /* Not bypassed. */
73 SSL, /* Bypass due to SSL. */ 73 SSL, /* Bypass due to SSL. */
74 LOCAL_BYPASS_RULES, /* Bypass due to client-side bypass rules. */ 74 LOCAL_BYPASS_RULES, /* Bypass due to client-side bypass rules. */
75 MANAGED_PROXY_CONFIG, /* Bypass due to managed config. */ 75 MANAGED_PROXY_CONFIG, /* Bypass due to managed config. */
76 AUDIO_VIDEO, /* Audio/Video bypass. */ 76 AUDIO_VIDEO, /* Audio/Video bypass. */
77 TRIGGERING_REQUEST, /* Triggering request bypass. */ 77 TRIGGERING_REQUEST, /* Triggering request bypass. */
78 NETWORK_ERROR, /* Network error. */ 78 NETWORK_ERROR, /* Network error. */
79 BYPASSED_BYTES_TYPE_MAX /* This must always be last.*/ 79 BYPASSED_BYTES_TYPE_MAX /* This must always be last.*/
80 }; 80 };
81 81
82 // NetworkChangeNotifier::NetworkChangeObserver: 82 // NetworkChangeNotifier::NetworkChangeObserver:
83 virtual void OnNetworkChanged( 83 virtual void OnNetworkChanged(
84 net::NetworkChangeNotifier::ConnectionType type) OVERRIDE; 84 net::NetworkChangeNotifier::ConnectionType type) OVERRIDE;
85 85
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(); 86 void ClearRequestCounts();
90 87
91 // Checks if the availability status of the data reduction proxy has changed, 88 // Checks if the availability status of the data reduction proxy has changed,
92 // and notifies the UIThread via NotifyUnavailabilityOnUIThread if so. The 89 // and notifies the UIThread via NotifyUnavailabilityOnUIThread if so. The
93 // data reduction proxy is considered unavailable if and only if no requests 90 // 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 91 // went through the proxy but some eligible requests were service by other
95 // routes. 92 // routes.
96 void MaybeNotifyUnavailability(); 93 void MaybeNotifyUnavailability();
97 void NotifyUnavailabilityOnUIThread(bool unavailable); 94 void NotifyUnavailabilityOnUIThread(bool unavailable);
98 95
99 DataReductionProxyParams* data_reduction_proxy_params_; 96 DataReductionProxyParams* data_reduction_proxy_params_;
100 // The last reason for bypass as determined by 97 // The last reason for bypass as determined by
101 // MaybeBypassProxyAndPrepareToRetry 98 // MaybeBypassProxyAndPrepareToRetry
102 DataReductionProxyBypassType last_bypass_type_; 99 DataReductionProxyBypassType last_bypass_type_;
103 // True if the last request triggered the current bypass. 100 // True if the last request triggered the current bypass.
104 bool triggering_request_; 101 bool triggering_request_;
105 base::MessageLoopProxy* ui_thread_proxy_; 102 base::MessageLoopProxy* ui_thread_proxy_;
106 103
107 // The following 2 fields are used to determine if data reduction proxy is 104 // 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 105 // 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 106 // 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 107 // unreachable if no successful requests are made through it despite a
111 // non-zero number of requests being eligible. 108 // non-zero number of requests being eligible.
112 109
113 // Count of requests which will be tried to be sent through data reduction 110 // Count of successful requests through data reduction proxy.
114 // proxy. The count is only based on the config and not the bad proxy list. 111 unsigned long num_successful_requests_through_proxy_;
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 112
119 // Count of successful requests through data reduction proxy. 113 // Count of network errors encountered when connecting to a data reduction
120 unsigned long actual_num_requests_through_proxy_; 114 // proxy.
115 unsigned long num_proxy_net_errors_;
121 116
122 // Whether or not the data reduction proxy is unavailable. 117 // Whether or not the data reduction proxy is unavailable.
123 bool unavailable_; 118 bool unavailable_;
124 119
125 base::ThreadChecker thread_checker_; 120 base::ThreadChecker thread_checker_;
126 121
127 void RecordBypassedBytes( 122 void RecordBypassedBytes(
128 DataReductionProxyBypassType bypass_type, 123 DataReductionProxyBypassType bypass_type,
129 BypassedBytesType bypassed_bytes_type, 124 BypassedBytesType bypassed_bytes_type,
130 int64 content_length); 125 int64 content_length);
131 126
132 // Called when the unavailability status has changed. Runs on the UI thread. 127 // Called when the unavailability status has changed. Runs on the UI thread.
133 base::Callback<void(bool)> unavailable_callback_; 128 base::Callback<void(bool)> unavailable_callback_;
134 129
135 DISALLOW_COPY_AND_ASSIGN(DataReductionProxyUsageStats); 130 DISALLOW_COPY_AND_ASSIGN(DataReductionProxyUsageStats);
136 }; 131 };
137 132
138 } // namespace data_reduction_proxy 133 } // namespace data_reduction_proxy
139 134
140 #endif // COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_USAGE_ST ATS_H_ 135 #endif // COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_USAGE_ST ATS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698