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

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

Issue 596163002: Revert "Adds UMA to measure when the data reduction proxy via header is missing" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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"
11 #include "base/threading/thread_checker.h" 11 #include "base/threading/thread_checker.h"
12 #include "components/data_reduction_proxy/browser/data_reduction_proxy_params.h" 12 #include "components/data_reduction_proxy/browser/data_reduction_proxy_params.h"
13 #include "components/data_reduction_proxy/common/data_reduction_proxy_headers.h" 13 #include "components/data_reduction_proxy/common/data_reduction_proxy_headers.h"
14 #include "net/base/host_port_pair.h" 14 #include "net/base/host_port_pair.h"
15 #include "net/base/network_change_notifier.h" 15 #include "net/base/network_change_notifier.h"
16 #include "net/url_request/url_request.h" 16 #include "net/url_request/url_request.h"
17 17
18 namespace net { 18 namespace net {
19 class HttpResponseHeaders;
20 class ProxyConfig;
21 class ProxyServer; 19 class ProxyServer;
22 } 20 }
23 21
24 namespace data_reduction_proxy { 22 namespace data_reduction_proxy {
25 23
26 class DataReductionProxyUsageStats 24 class DataReductionProxyUsageStats
27 : public net::NetworkChangeNotifier::NetworkChangeObserver { 25 : public net::NetworkChangeNotifier::NetworkChangeObserver {
28 public: 26 public:
29 // Records a data reduction proxy bypass event as a "BlockType" if 27 // Records a data reduction proxy bypass event as a "BlockType" if
30 // |bypass_all| is true and as a "BypassType" otherwise. Records the event as 28 // |bypass_all| is true and as a "BypassType" otherwise. Records the event as
31 // "Primary" if |is_primary| is true and "Fallback" otherwise. 29 // "Primary" if |is_primary| is true and "Fallback" otherwise.
32 static void RecordDataReductionProxyBypassInfo( 30 static void RecordDataReductionProxyBypassInfo(
33 bool is_primary, 31 bool is_primary,
34 bool bypass_all, 32 bool bypass_all,
35 const net::ProxyServer& proxy_server, 33 const net::ProxyServer& proxy_server,
36 DataReductionProxyBypassType bypass_type); 34 DataReductionProxyBypassType bypass_type);
37 35
38 // For the given response |headers| that are expected to include the data
39 // reduction proxy via header, records response code UMA if the data reduction
40 // proxy via header is not present.
41 static void DetectAndRecordMissingViaHeaderResponseCode(
42 bool is_primary,
43 const net::HttpResponseHeaders* headers);
44
45 // MessageLoopProxy instance is owned by io_thread. |params| outlives 36 // MessageLoopProxy instance is owned by io_thread. |params| outlives
46 // this class instance. 37 // this class instance.
47 DataReductionProxyUsageStats( 38 DataReductionProxyUsageStats(
48 DataReductionProxyParams* params, 39 DataReductionProxyParams* params,
49 const scoped_refptr<base::MessageLoopProxy>& ui_thread_proxy); 40 const scoped_refptr<base::MessageLoopProxy>& ui_thread_proxy);
50 virtual ~DataReductionProxyUsageStats(); 41 virtual ~DataReductionProxyUsageStats();
51 42
52 // Sets the callback to be called on the UI thread when the unavailability 43 // Sets the callback to be called on the UI thread when the unavailability
53 // status has changed. 44 // status has changed.
54 void set_unavailable_callback( 45 void set_unavailable_callback(
55 const base::Callback<void(bool)>& unavailable_callback) { 46 const base::Callback<void(bool)>& unavailable_callback) {
56 unavailable_callback_ = unavailable_callback; 47 unavailable_callback_ = unavailable_callback;
57 } 48 }
58 49
59 // Callback intended to be called from |ChromeNetworkDelegate| when a 50 // Callback intended to be called from |ChromeNetworkDelegate| when a
60 // request completes. This method is used to gather usage stats. 51 // request completes. This method is used to gather usage stats.
61 void OnUrlRequestCompleted(const net::URLRequest* request, bool started); 52 void OnUrlRequestCompleted(const net::URLRequest* request, bool started);
62 53
63 // Records the last bypass reason to |bypass_type_| and sets 54 // Records the last bypass reason to |bypass_type_| and sets
64 // |triggering_request_| to true. A triggering request is the first request to 55 // |triggering_request_| to true. A triggering request is the first request to
65 // cause the current bypass. 56 // cause the current bypass.
66 void SetBypassType(DataReductionProxyBypassType type); 57 void SetBypassType(DataReductionProxyBypassType type);
67 58
68 // Records all the data reduction proxy bytes-related histograms for the 59 // Given |data_reduction_proxy_enabled|, a |request|, and the
69 // completed URLRequest |request|. 60 // |data_reduction_proxy_config| records the number of bypassed bytes for that
70 void RecordBytesHistograms( 61 // |request| into UMAs based on bypass type. |data_reduction_proxy_enabled|
71 net::URLRequest* request, 62 // tells us the state of the kDataReductionProxyEnabled preference.
63 void RecordBypassedBytesHistograms(
64 net::URLRequest& request,
72 const BooleanPrefMember& data_reduction_proxy_enabled, 65 const BooleanPrefMember& data_reduction_proxy_enabled,
73 const net::ProxyConfig& data_reduction_proxy_config); 66 const net::ProxyConfig& data_reduction_proxy_config);
74 67
75 // Called by |ChromeNetworkDelegate| when a proxy is put into the bad proxy 68 // Called by |ChromeNetworkDelegate| when a proxy is put into the bad proxy
76 // list. Used to track when the data reduction proxy falls back. 69 // list. Used to track when the data reduction proxy falls back.
77 void OnProxyFallback(const net::ProxyServer& bypassed_proxy, 70 void OnProxyFallback(const net::ProxyServer& bypassed_proxy,
78 int net_error); 71 int net_error);
79 72
80 private: 73 private:
81 friend class DataReductionProxyUsageStatsTest;
82 FRIEND_TEST_ALL_PREFIXES(DataReductionProxyUsageStatsTest,
83 RecordMissingViaHeaderBytes);
84
85 enum BypassedBytesType { 74 enum BypassedBytesType {
86 NOT_BYPASSED = 0, /* Not bypassed. */ 75 NOT_BYPASSED = 0, /* Not bypassed. */
87 SSL, /* Bypass due to SSL. */ 76 SSL, /* Bypass due to SSL. */
88 LOCAL_BYPASS_RULES, /* Bypass due to client-side bypass rules. */ 77 LOCAL_BYPASS_RULES, /* Bypass due to client-side bypass rules. */
89 MANAGED_PROXY_CONFIG, /* Bypass due to managed config. */ 78 MANAGED_PROXY_CONFIG, /* Bypass due to managed config. */
90 AUDIO_VIDEO, /* Audio/Video bypass. */ 79 AUDIO_VIDEO, /* Audio/Video bypass. */
91 TRIGGERING_REQUEST, /* Triggering request bypass. */ 80 TRIGGERING_REQUEST, /* Triggering request bypass. */
92 NETWORK_ERROR, /* Network error. */ 81 NETWORK_ERROR, /* Network error. */
93 BYPASSED_BYTES_TYPE_MAX /* This must always be last.*/ 82 BYPASSED_BYTES_TYPE_MAX /* This must always be last.*/
94 }; 83 };
95 84
96 // Given |data_reduction_proxy_enabled|, a |request|, and the
97 // |data_reduction_proxy_config| records the number of bypassed bytes for that
98 // |request| into UMAs based on bypass type. |data_reduction_proxy_enabled|
99 // tells us the state of the kDataReductionProxyEnabled preference.
100 void RecordBypassedBytesHistograms(
101 net::URLRequest* request,
102 const BooleanPrefMember& data_reduction_proxy_enabled,
103 const net::ProxyConfig& data_reduction_proxy_config);
104
105 // Records UMA of the number of response bytes of responses that are expected
106 // to have the data reduction proxy via header, but where the data reduction
107 // proxy via header is not present.
108 void RecordMissingViaHeaderBytes(net::URLRequest* request);
109
110 // NetworkChangeNotifier::NetworkChangeObserver: 85 // NetworkChangeNotifier::NetworkChangeObserver:
111 virtual void OnNetworkChanged( 86 virtual void OnNetworkChanged(
112 net::NetworkChangeNotifier::ConnectionType type) OVERRIDE; 87 net::NetworkChangeNotifier::ConnectionType type) OVERRIDE;
113 88
114 // Called when request counts change. Resets counts if they exceed thresholds, 89 // Called when request counts change. Resets counts if they exceed thresholds,
115 // and calls MaybeNotifyUnavailability otherwise. 90 // and calls MaybeNotifyUnavailability otherwise.
116 void OnRequestCountChanged(); 91 void OnRequestCountChanged();
117 92
118 // Clears request counts unconditionally. 93 // Clears request counts unconditionally.
119 void ClearRequestCounts(); 94 void ClearRequestCounts();
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 134
160 // Called when the unavailability status has changed. Runs on the UI thread. 135 // Called when the unavailability status has changed. Runs on the UI thread.
161 base::Callback<void(bool)> unavailable_callback_; 136 base::Callback<void(bool)> unavailable_callback_;
162 137
163 DISALLOW_COPY_AND_ASSIGN(DataReductionProxyUsageStats); 138 DISALLOW_COPY_AND_ASSIGN(DataReductionProxyUsageStats);
164 }; 139 };
165 140
166 } // namespace data_reduction_proxy 141 } // namespace data_reduction_proxy
167 142
168 #endif // COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_USAGE_ST ATS_H_ 143 #endif // COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_USAGE_ST ATS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698