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

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

Issue 577343002: 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, 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"
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 ProxyServer; 19 class ProxyServer;
20 class HttpResponseHeaders;
20 } 21 }
21 22
22 namespace data_reduction_proxy { 23 namespace data_reduction_proxy {
23 24
24 class DataReductionProxyUsageStats 25 class DataReductionProxyUsageStats
25 : public net::NetworkChangeNotifier::NetworkChangeObserver { 26 : public net::NetworkChangeNotifier::NetworkChangeObserver {
26 public: 27 public:
27 // Records a data reduction proxy bypass event as a "BlockType" if 28 // Records a data reduction proxy bypass event as a "BlockType" if
28 // |bypass_all| is true and as a "BypassType" otherwise. Records the event as 29 // |bypass_all| is true and as a "BypassType" otherwise. Records the event as
29 // "Primary" if |is_primary| is true and "Fallback" otherwise. 30 // "Primary" if |is_primary| is true and "Fallback" otherwise.
30 static void RecordDataReductionProxyBypassInfo( 31 static void RecordDataReductionProxyBypassInfo(
31 bool is_primary, 32 bool is_primary,
32 bool bypass_all, 33 bool bypass_all,
33 const net::ProxyServer& proxy_server, 34 const net::ProxyServer& proxy_server,
34 DataReductionProxyBypassType bypass_type); 35 DataReductionProxyBypassType bypass_type);
35 36
37 // For the given response |headers| that are expected to include the data
38 // reduction proxy via header, records response code UMA if the data reduction
39 // proxy via header is not present.
40 static void DetectAndRecordMissingViaHeaderResponseCode(
41 bool is_primary, const net::HttpResponseHeaders* headers);
42
36 // MessageLoopProxy instance is owned by io_thread. |params| outlives 43 // MessageLoopProxy instance is owned by io_thread. |params| outlives
37 // this class instance. 44 // this class instance.
38 DataReductionProxyUsageStats(DataReductionProxyParams* params, 45 DataReductionProxyUsageStats(DataReductionProxyParams* params,
39 base::MessageLoopProxy* ui_thread_proxy); 46 base::MessageLoopProxy* ui_thread_proxy);
40 virtual ~DataReductionProxyUsageStats(); 47 virtual ~DataReductionProxyUsageStats();
41 48
42 // Sets the callback to be called on the UI thread when the unavailability 49 // Sets the callback to be called on the UI thread when the unavailability
43 // status has changed. 50 // status has changed.
44 void set_unavailable_callback( 51 void set_unavailable_callback(
45 const base::Callback<void(bool)>& unavailable_callback) { 52 const base::Callback<void(bool)>& unavailable_callback) {
(...skipping 14 matching lines...) Expand all
60 // |request| into UMAs based on bypass type. |data_reduction_proxy_enabled| 67 // |request| into UMAs based on bypass type. |data_reduction_proxy_enabled|
61 // tells us the state of the kDataReductionProxyEnabled preference. 68 // tells us the state of the kDataReductionProxyEnabled preference.
62 void RecordBypassedBytesHistograms( 69 void RecordBypassedBytesHistograms(
63 net::URLRequest& request, 70 net::URLRequest& request,
64 const BooleanPrefMember& data_reduction_proxy_enabled, 71 const BooleanPrefMember& data_reduction_proxy_enabled,
65 const net::ProxyConfig& data_reduction_proxy_config); 72 const net::ProxyConfig& data_reduction_proxy_config);
66 73
67 void RecordBypassEventHistograms(const net::ProxyServer& bypassed_proxy, 74 void RecordBypassEventHistograms(const net::ProxyServer& bypassed_proxy,
68 int net_error) const; 75 int net_error) const;
69 76
77 // Records UMA of the number of response bytes of responses that are expected
78 // to have the data reduction proxy via header, but where the data reduction
79 // proxy via header is not present.
80 void RecordMissingViaHeaderBytes(net::URLRequest* request);
81
70 private: 82 private:
71 enum BypassedBytesType { 83 enum BypassedBytesType {
72 NOT_BYPASSED = 0, /* Not bypassed. */ 84 NOT_BYPASSED = 0, /* Not bypassed. */
73 SSL, /* Bypass due to SSL. */ 85 SSL, /* Bypass due to SSL. */
74 LOCAL_BYPASS_RULES, /* Bypass due to client-side bypass rules. */ 86 LOCAL_BYPASS_RULES, /* Bypass due to client-side bypass rules. */
75 MANAGED_PROXY_CONFIG, /* Bypass due to managed config. */ 87 MANAGED_PROXY_CONFIG, /* Bypass due to managed config. */
76 AUDIO_VIDEO, /* Audio/Video bypass. */ 88 AUDIO_VIDEO, /* Audio/Video bypass. */
77 TRIGGERING_REQUEST, /* Triggering request bypass. */ 89 TRIGGERING_REQUEST, /* Triggering request bypass. */
78 NETWORK_ERROR, /* Network error. */ 90 NETWORK_ERROR, /* Network error. */
79 BYPASSED_BYTES_TYPE_MAX /* This must always be last.*/ 91 BYPASSED_BYTES_TYPE_MAX /* This must always be last.*/
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 143
132 // Called when the unavailability status has changed. Runs on the UI thread. 144 // Called when the unavailability status has changed. Runs on the UI thread.
133 base::Callback<void(bool)> unavailable_callback_; 145 base::Callback<void(bool)> unavailable_callback_;
134 146
135 DISALLOW_COPY_AND_ASSIGN(DataReductionProxyUsageStats); 147 DISALLOW_COPY_AND_ASSIGN(DataReductionProxyUsageStats);
136 }; 148 };
137 149
138 } // namespace data_reduction_proxy 150 } // namespace data_reduction_proxy
139 151
140 #endif // COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_USAGE_ST ATS_H_ 152 #endif // COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_USAGE_ST ATS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698