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

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

Issue 390533003: Bypassed Bytes UMAs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed bengr comments Created 6 years, 5 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/message_loop/message_loop_proxy.h" 8 #include "base/message_loop/message_loop_proxy.h"
9 #include "base/prefs/pref_member.h"
9 #include "base/threading/thread_checker.h" 10 #include "base/threading/thread_checker.h"
10 #include "components/data_reduction_proxy/browser/data_reduction_proxy_params.h" 11 #include "components/data_reduction_proxy/browser/data_reduction_proxy_params.h"
11 #include "net/base/host_port_pair.h" 12 #include "net/base/host_port_pair.h"
12 #include "net/base/network_change_notifier.h" 13 #include "net/base/network_change_notifier.h"
14 #include "net/proxy/proxy_service.h"
15 #include "net/url_request/url_request.h"
13 16
14 namespace data_reduction_proxy { 17 namespace data_reduction_proxy {
15 18
16 class DataReductionProxyUsageStats 19 class DataReductionProxyUsageStats
17 : public net::NetworkChangeNotifier::NetworkChangeObserver { 20 : public net::NetworkChangeNotifier::NetworkChangeObserver {
18 public: 21 public:
19 // MessageLoopProxy instances are owned by io_thread. |params| outlives 22 // MessageLoopProxy instances are owned by io_thread. |params| outlives
20 // this class instance. 23 // this class instance.
21 DataReductionProxyUsageStats(DataReductionProxyParams* params, 24 DataReductionProxyUsageStats(DataReductionProxyParams* params,
22 base::MessageLoopProxy* ui_thread_proxy, 25 base::MessageLoopProxy* ui_thread_proxy,
23 base::MessageLoopProxy* io_thread_proxy); 26 base::MessageLoopProxy* io_thread_proxy);
24 virtual ~DataReductionProxyUsageStats(); 27 virtual ~DataReductionProxyUsageStats();
25 28
26 /** 29 // Callback intended to be called from |ChromeNetworkDelegate| when a
27 * Callback intended to be called from |ChromeNetworkDelegate| when a 30 // request completes. This method is used to gather usage stats.
28 * request completes. This method is used to gather usage stats.
29 */
30 void OnUrlRequestCompleted(const net::URLRequest* request, bool started); 31 void OnUrlRequestCompleted(const net::URLRequest* request, bool started);
31 32
32 /** 33 // Determines whether the data reduction proxy is unreachable.
33 * Determines whether the data reduction proxy is unreachable. 34 // Returns true if data reduction proxy is unreachable.
34 * Returns true if data reduction proxy is unreachable.
35 */
36 bool isDataReductionProxyUnreachable(); 35 bool isDataReductionProxyUnreachable();
37 36
37 // Records the last bypass reason to |bypass_type_| and sets
38 // |triggering_request_| to true. A triggering request is the first request to
39 // cause the current bypass.
40 void SetBypassType(net::ProxyService::DataReductionProxyBypassType type);
41
42 // Given the |content_length| and associated |request|, records the
43 // number of bypassed bytes for that |request| into UMAs based on bypass type.
44 // |data_reduction_proxy_enabled| tells us the state of the
45 // kDataReductionProxyEnabled preference.
46 void RecordBypassedBytesHistograms(
47 int64 content_length,
48 const net::URLRequest& request,
49 const BooleanPrefMember& data_reduction_proxy_enabled);
50
38 private: 51 private:
52 enum BypassedBytesType {
Alexei Svitkine (slow) 2014/07/22 13:57:21 Mention that this is used in a histogram, so entri
megjablon 2014/07/22 18:40:46 This isn't used in the histograms, it's used to ma
Alexei Svitkine (slow) 2014/07/22 18:50:18 Okay, in that case remove the explicit values of e
megjablon 2014/07/22 21:41:45 Done.
53 NOT_BYPASSED = 0, /* Not bypassed. */
54 SSL = 1, /* Bypass due to SSL. */
55 LOCAL_BYPASS_RULES = 2, /* Bypass due to client-side bypass rules. */
56 AUDIO_VIDEO = 3, /* Audio/Video bypass. */
57 TRIGGERING_REQUEST = 4, /* Triggering request bypass. */
58 NETWORK_ERROR = 5, /* Network error. */
59 BYPASSED_BYTES_TYPE_MAX = 6 /*This must always be last.*/
bengr 2014/07/22 16:59:44 Add a space in the comment.
megjablon 2014/07/22 18:40:46 Done.
60 };
61
39 DataReductionProxyParams* data_reduction_proxy_params_; 62 DataReductionProxyParams* data_reduction_proxy_params_;
63 // The last reason for bypass as determined by
64 // MaybeBypassProxyAndPrepareToRetry
65 net::ProxyService::DataReductionProxyBypassType last_bypass_type_;
66 // True if the last request triggered the current bypass.
67 bool triggering_request_;
40 base::MessageLoopProxy* ui_thread_proxy_; 68 base::MessageLoopProxy* ui_thread_proxy_;
41 base::MessageLoopProxy* io_thread_proxy_; 69 base::MessageLoopProxy* io_thread_proxy_;
42 70
43 // The following 2 fields are used to determine if data reduction proxy is 71 // The following 2 fields are used to determine if data reduction proxy is
44 // unreachable. We keep a count of requests which should go through 72 // unreachable. We keep a count of requests which should go through
45 // data request proxy, as well as those which actually do. The proxy is 73 // data request proxy, as well as those which actually do. The proxy is
46 // unreachable if no successful requests are made through it despite a 74 // unreachable if no successful requests are made through it despite a
47 // non-zero number of requests being eligible. 75 // non-zero number of requests being eligible.
48 76
49 // Count of requests which will be tried to be sent through data reduction 77 // Count of requests which will be tried to be sent through data reduction
50 // proxy. The count is only based on the config and not the bad proxy list. 78 // proxy. The count is only based on the config and not the bad proxy list.
51 // Explicit bypasses are not part of this count. This is the desired behavior 79 // Explicit bypasses are not part of this count. This is the desired behavior
52 // since otherwise both counts would be identical. 80 // since otherwise both counts would be identical.
53 unsigned long eligible_num_requests_through_proxy_; 81 unsigned long eligible_num_requests_through_proxy_;
54 // Count of successfull requests through data reduction proxy. 82 // Count of successfull requests through data reduction proxy.
55 unsigned long actual_num_requests_through_proxy_; 83 unsigned long actual_num_requests_through_proxy_;
56 84
57 // NetworkChangeNotifier::NetworkChangeObserver: 85 // NetworkChangeNotifier::NetworkChangeObserver:
58 virtual void OnNetworkChanged( 86 virtual void OnNetworkChanged(
59 net::NetworkChangeNotifier::ConnectionType type) OVERRIDE; 87 net::NetworkChangeNotifier::ConnectionType type) OVERRIDE;
60 88
61 void IncRequestCountsOnUiThread(bool actual); 89 void IncRequestCountsOnUiThread(bool actual);
62 void ClearRequestCountsOnUiThread(); 90 void ClearRequestCountsOnUiThread();
63 91
64 base::ThreadChecker thread_checker_; 92 base::ThreadChecker thread_checker_;
65 93
94 void RecordBypassedBytes(
95 net::ProxyService::DataReductionProxyBypassType bypass_type,
96 BypassedBytesType bypassed_bytes_type,
97 int64 content_length);
98
66 DISALLOW_COPY_AND_ASSIGN(DataReductionProxyUsageStats); 99 DISALLOW_COPY_AND_ASSIGN(DataReductionProxyUsageStats);
67 }; 100 };
68 101
69 } // namespace data_reduction_proxy 102 } // namespace data_reduction_proxy
70 103
71 #endif // COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_USAGE_ST ATS_H_ 104 #endif // COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_USAGE_ST ATS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698