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

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: Sync to head. 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 // Called by |ChromeNetworkDelegate| when a proxy is put into the bad proxy
68 int net_error) const; 68 // list. Used to track when the data reduction proxy falls back.
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 88 // Called when request counts change. Resets counts if they exceed thresholds,
87 // requests that were eligible to go through the proxy. 89 // and calls MaybeNotifyUnavailability otherwise.
88 void IncrementRequestCounts(bool actual); 90 void OnRequestCountChanged();
91
92 // Clears request counts unconditionally.
89 void ClearRequestCounts(); 93 void ClearRequestCounts();
90 94
91 // Checks if the availability status of the data reduction proxy has changed, 95 // Checks if the availability status of the data reduction proxy has changed,
92 // and notifies the UIThread via NotifyUnavailabilityOnUIThread if so. The 96 // and notifies the UIThread via NotifyUnavailabilityOnUIThread if so. The
93 // data reduction proxy is considered unavailable if and only if no requests 97 // 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 98 // went through the proxy but some eligible requests were service by other
95 // routes. 99 // routes.
96 void MaybeNotifyUnavailability(); 100 void NotifyUnavailabilityIfChanged();
97 void NotifyUnavailabilityOnUIThread(bool unavailable); 101 void NotifyUnavailabilityOnUIThread(bool unavailable);
98 102
99 DataReductionProxyParams* data_reduction_proxy_params_; 103 DataReductionProxyParams* data_reduction_proxy_params_;
100 // The last reason for bypass as determined by 104 // The last reason for bypass as determined by
101 // MaybeBypassProxyAndPrepareToRetry 105 // MaybeBypassProxyAndPrepareToRetry
102 DataReductionProxyBypassType last_bypass_type_; 106 DataReductionProxyBypassType last_bypass_type_;
103 // True if the last request triggered the current bypass. 107 // True if the last request triggered the current bypass.
104 bool triggering_request_; 108 bool triggering_request_;
105 base::MessageLoopProxy* ui_thread_proxy_; 109 base::MessageLoopProxy* ui_thread_proxy_;
106 110
107 // The following 2 fields are used to determine if data reduction proxy is 111 // 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 112 // 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 113 // 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 114 // unreachable if no successful requests are made through it despite a
111 // non-zero number of requests being eligible. 115 // non-zero number of requests being eligible.
112 116
113 // Count of requests which will be tried to be sent through data reduction 117 // Count of successful requests through the data reduction proxy.
114 // proxy. The count is only based on the config and not the bad proxy list. 118 unsigned long successful_requests_through_proxy_count_;
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 119
119 // Count of successful requests through data reduction proxy. 120 // Count of network errors encountered when connecting to a data reduction
120 unsigned long actual_num_requests_through_proxy_; 121 // proxy.
122 unsigned long proxy_net_errors_count_;
121 123
122 // Whether or not the data reduction proxy is unavailable. 124 // Whether or not the data reduction proxy is unavailable.
123 bool unavailable_; 125 bool unavailable_;
124 126
125 base::ThreadChecker thread_checker_; 127 base::ThreadChecker thread_checker_;
126 128
127 void RecordBypassedBytes( 129 void RecordBypassedBytes(
128 DataReductionProxyBypassType bypass_type, 130 DataReductionProxyBypassType bypass_type,
129 BypassedBytesType bypassed_bytes_type, 131 BypassedBytesType bypassed_bytes_type,
130 int64 content_length); 132 int64 content_length);
131 133
132 // Called when the unavailability status has changed. Runs on the UI thread. 134 // Called when the unavailability status has changed. Runs on the UI thread.
133 base::Callback<void(bool)> unavailable_callback_; 135 base::Callback<void(bool)> unavailable_callback_;
134 136
135 DISALLOW_COPY_AND_ASSIGN(DataReductionProxyUsageStats); 137 DISALLOW_COPY_AND_ASSIGN(DataReductionProxyUsageStats);
136 }; 138 };
137 139
138 } // namespace data_reduction_proxy 140 } // namespace data_reduction_proxy
139 141
140 #endif // COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_USAGE_ST ATS_H_ 142 #endif // COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_USAGE_ST ATS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698