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

Side by Side Diff: components/data_reduction_proxy/core/browser/data_reduction_proxy_bypass_stats.h

Issue 956223002: Rename DataReductionProxyUsageStats to DataReductionProxyBypassStats (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits Created 5 years, 8 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_CORE_BROWSER_DATA_REDUCTION_PROXY_USAGE_ STATS_H_ 5 #ifndef COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_BYPASS _STATS_H_
6 #define COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_USAGE_ STATS_H_ 6 #define COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_BYPASS _STATS_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/prefs/pref_member.h" 9 #include "base/prefs/pref_member.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
11 #include "base/threading/thread_checker.h" 11 #include "base/threading/thread_checker.h"
12 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_heade rs.h" 12 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_heade rs.h"
13 #include "net/base/host_port_pair.h" 13 #include "net/base/host_port_pair.h"
14 #include "net/base/network_change_notifier.h" 14 #include "net/base/network_change_notifier.h"
15 #include "net/url_request/url_request.h" 15 #include "net/url_request/url_request.h"
16 16
17 namespace net { 17 namespace net {
18 class HttpResponseHeaders; 18 class HttpResponseHeaders;
19 class ProxyConfig; 19 class ProxyConfig;
20 class ProxyServer; 20 class ProxyServer;
21 } 21 }
22 22
23 namespace data_reduction_proxy { 23 namespace data_reduction_proxy {
24 24
25 class DataReductionProxyConfig; 25 class DataReductionProxyConfig;
26 26
27 // TODO(bengr): Rename as DataReductionProxyBypassStats. 27 class DataReductionProxyBypassStats
28 class DataReductionProxyUsageStats
29 : public net::NetworkChangeNotifier::NetworkChangeObserver { 28 : public net::NetworkChangeNotifier::NetworkChangeObserver {
30 public: 29 public:
31 typedef base::Callback<void(bool /* unreachable */)> UnreachableCallback; 30 typedef base::Callback<void(bool /* unreachable */)> UnreachableCallback;
32 31
33 // Records a data reduction proxy bypass event as a "BlockType" if 32 // Records a data reduction proxy bypass event as a "BlockType" if
34 // |bypass_all| is true and as a "BypassType" otherwise. Records the event as 33 // |bypass_all| is true and as a "BypassType" otherwise. Records the event as
35 // "Primary" if |is_primary| is true and "Fallback" otherwise. 34 // "Primary" if |is_primary| is true and "Fallback" otherwise.
36 static void RecordDataReductionProxyBypassInfo( 35 static void RecordDataReductionProxyBypassInfo(
37 bool is_primary, 36 bool is_primary,
38 bool bypass_all, 37 bool bypass_all,
39 const net::ProxyServer& proxy_server, 38 const net::ProxyServer& proxy_server,
40 DataReductionProxyBypassType bypass_type); 39 DataReductionProxyBypassType bypass_type);
41 40
42 // For the given response |headers| that are expected to include the data 41 // For the given response |headers| that are expected to include the data
43 // reduction proxy via header, records response code UMA if the data reduction 42 // reduction proxy via header, records response code UMA if the data reduction
44 // proxy via header is not present. 43 // proxy via header is not present.
45 static void DetectAndRecordMissingViaHeaderResponseCode( 44 static void DetectAndRecordMissingViaHeaderResponseCode(
46 bool is_primary, 45 bool is_primary,
47 const net::HttpResponseHeaders* headers); 46 const net::HttpResponseHeaders* headers);
48 47
49 // |params| outlives this class instance. |unreachable_callback| provides a 48 // |params| outlives this class instance. |unreachable_callback| provides a
50 // hook to inform the user that the Data Reduction Proxy is unreachable, which 49 // hook to inform the user that the Data Reduction Proxy is unreachable, which
51 // occurs on the UI thread, hence the |ui_task_runner|. 50 // occurs on the UI thread, hence the |ui_task_runner|.
52 // |config| must not be null. 51 // |config| must not be null.
53 DataReductionProxyUsageStats( 52 DataReductionProxyBypassStats(
54 DataReductionProxyConfig* config, 53 DataReductionProxyConfig* config,
55 UnreachableCallback unreachable_callback, 54 UnreachableCallback unreachable_callback,
56 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner); 55 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner);
57 56
58 ~DataReductionProxyUsageStats() override; 57 ~DataReductionProxyBypassStats() override;
59 58
60 // Callback intended to be called from |DataReductionProxyNetworkDelegate| 59 // Callback intended to be called from |DataReductionProxyNetworkDelegate|
61 // when a request completes. This method is used to gather usage stats. 60 // when a request completes. This method is used to gather bypass stats.
62 void OnUrlRequestCompleted(const net::URLRequest* request, bool started); 61 void OnUrlRequestCompleted(const net::URLRequest* request, bool started);
63 62
64 // Records the last bypass reason to |bypass_type_| and sets 63 // Records the last bypass reason to |bypass_type_| and sets
65 // |triggering_request_| to true. A triggering request is the first request to 64 // |triggering_request_| to true. A triggering request is the first request to
66 // cause the current bypass. 65 // cause the current bypass.
67 void SetBypassType(DataReductionProxyBypassType type); 66 void SetBypassType(DataReductionProxyBypassType type);
68 67
69 // Visible for testing. 68 // Visible for testing.
70 DataReductionProxyBypassType GetBypassType() const; 69 DataReductionProxyBypassType GetBypassType() const;
71 70
72 // Records all the data reduction proxy bytes-related histograms for the 71 // Records all the data reduction proxy bytes-related histograms for the
73 // completed URLRequest |request|. 72 // completed URLRequest |request|.
74 void RecordBytesHistograms( 73 void RecordBytesHistograms(
75 const net::URLRequest& request, 74 const net::URLRequest& request,
76 const BooleanPrefMember& data_reduction_proxy_enabled, 75 const BooleanPrefMember& data_reduction_proxy_enabled,
77 const net::ProxyConfig& data_reduction_proxy_config); 76 const net::ProxyConfig& data_reduction_proxy_config);
78 77
79 // Called by |ChromeNetworkDelegate| when a proxy is put into the bad proxy 78 // Called by |ChromeNetworkDelegate| when a proxy is put into the bad proxy
80 // list. Used to track when the data reduction proxy falls back. 79 // list. Used to track when the data reduction proxy falls back.
81 void OnProxyFallback(const net::ProxyServer& bypassed_proxy, 80 void OnProxyFallback(const net::ProxyServer& bypassed_proxy,
82 int net_error); 81 int net_error);
83 82
84 // Called by |ChromeNetworkDelegate| when an HTTP connect has been called. 83 // Called by |ChromeNetworkDelegate| when an HTTP connect has been called.
85 // Used to track proxy connection failures. 84 // Used to track proxy connection failures.
86 void OnConnectComplete(const net::HostPortPair& proxy_server, 85 void OnConnectComplete(const net::HostPortPair& proxy_server,
87 int net_error); 86 int net_error);
88 87
89 private: 88 private:
90 friend class DataReductionProxyUsageStatsTest; 89 friend class DataReductionProxyBypassStatsTest;
91 FRIEND_TEST_ALL_PREFIXES(DataReductionProxyUsageStatsTest, 90 FRIEND_TEST_ALL_PREFIXES(DataReductionProxyBypassStatsTest,
92 RecordMissingViaHeaderBytes); 91 RecordMissingViaHeaderBytes);
93 92
94 enum BypassedBytesType { 93 enum BypassedBytesType {
95 NOT_BYPASSED = 0, /* Not bypassed. */ 94 NOT_BYPASSED = 0, /* Not bypassed. */
96 SSL, /* Bypass due to SSL. */ 95 SSL, /* Bypass due to SSL. */
97 LOCAL_BYPASS_RULES, /* Bypass due to client-side bypass rules. */ 96 LOCAL_BYPASS_RULES, /* Bypass due to client-side bypass rules. */
98 PROXY_OVERRIDDEN, /* Bypass due to a proxy taking precedence. */ 97 PROXY_OVERRIDDEN, /* Bypass due to a proxy taking precedence. */
99 AUDIO_VIDEO, /* Audio/Video bypass. */ 98 AUDIO_VIDEO, /* Audio/Video bypass. */
100 TRIGGERING_REQUEST, /* Triggering request bypass. */ 99 TRIGGERING_REQUEST, /* Triggering request bypass. */
101 NETWORK_ERROR, /* Network error. */ 100 NETWORK_ERROR, /* Network error. */
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 157
159 // Count of network errors encountered when connecting to a data reduction 158 // Count of network errors encountered when connecting to a data reduction
160 // proxy. 159 // proxy.
161 unsigned long proxy_net_errors_count_; 160 unsigned long proxy_net_errors_count_;
162 161
163 // Whether or not the data reduction proxy is unavailable. 162 // Whether or not the data reduction proxy is unavailable.
164 bool unavailable_; 163 bool unavailable_;
165 164
166 base::ThreadChecker thread_checker_; 165 base::ThreadChecker thread_checker_;
167 166
168 DISALLOW_COPY_AND_ASSIGN(DataReductionProxyUsageStats); 167 DISALLOW_COPY_AND_ASSIGN(DataReductionProxyBypassStats);
169 }; 168 };
170 169
171 } // namespace data_reduction_proxy 170 } // namespace data_reduction_proxy
172 171
173 #endif // COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_USA GE_STATS_H_ 172 #endif // COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_BYP ASS_STATS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698