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

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: 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"
13 15
14 namespace data_reduction_proxy { 16 namespace data_reduction_proxy {
15 17
16 class DataReductionProxyUsageStats 18 class DataReductionProxyUsageStats
17 : public net::NetworkChangeNotifier::NetworkChangeObserver { 19 : public net::NetworkChangeNotifier::NetworkChangeObserver {
18 public: 20 public:
19 // MessageLoopProxy instances are owned by io_thread. |params| outlives 21 // MessageLoopProxy instances are owned by io_thread. |params| outlives
20 // this class instance. 22 // this class instance.
21 DataReductionProxyUsageStats(DataReductionProxyParams* params, 23 DataReductionProxyUsageStats(DataReductionProxyParams* params,
22 base::MessageLoopProxy* ui_thread_proxy, 24 base::MessageLoopProxy* ui_thread_proxy,
23 base::MessageLoopProxy* io_thread_proxy); 25 base::MessageLoopProxy* io_thread_proxy);
24 virtual ~DataReductionProxyUsageStats(); 26 virtual ~DataReductionProxyUsageStats();
25 27
26 /** 28 /**
27 * Callback intended to be called from |ChromeNetworkDelegate| when a 29 * Callback intended to be called from |ChromeNetworkDelegate| when a
28 * request completes. This method is used to gather usage stats. 30 * request completes. This method is used to gather usage stats.
29 */ 31 */
30 void OnUrlRequestCompleted(const net::URLRequest* request, bool started); 32 void OnUrlRequestCompleted(const net::URLRequest* request, bool started);
31 33
32 /** 34 /**
33 * Determines whether the data reduction proxy is unreachable. 35 * Determines whether the data reduction proxy is unreachable.
34 * Returns true if data reduction proxy is unreachable. 36 * Returns true if data reduction proxy is unreachable.
35 */ 37 */
36 bool isDataReductionProxyUnreachable(); 38 bool isDataReductionProxyUnreachable();
37 39
40 /**
bengr 2014/07/12 00:11:59 Use // style comments. Fix the other methods' comm
megjablon 2014/07/14 19:06:41 Done.
41 * Records the last bypass reason to |bypass_type_| and sets
42 * |triggering_request_| to true.
43 */
44 virtual void SetBypassType(
45 net::ProxyService::DataReductionProxyBypassType type);
bengr 2014/07/12 00:11:59 Move up a line if it fits in 80 chars.
megjablon 2014/07/14 19:06:41 Done.
46
47 /**
48 * Records the number of bypassed bytes for various bypass reasons into their
49 * respective UMAs.
50 */
51 void RecordBypassedBytesHistograms(const int64 content_length,
52 const net::URLRequest* request);
53
38 private: 54 private:
39 DataReductionProxyParams* data_reduction_proxy_params_; 55 DataReductionProxyParams* data_reduction_proxy_params_;
56 net::ProxyService::DataReductionProxyBypassType bypass_type_;
57 bool triggering_request_;
40 base::MessageLoopProxy* ui_thread_proxy_; 58 base::MessageLoopProxy* ui_thread_proxy_;
41 base::MessageLoopProxy* io_thread_proxy_; 59 base::MessageLoopProxy* io_thread_proxy_;
42 60
43 // The following 2 fields are used to determine if data reduction proxy is 61 // 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 62 // 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 63 // 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 64 // unreachable if no successful requests are made through it despite a
47 // non-zero number of requests being eligible. 65 // non-zero number of requests being eligible.
48 66
49 // Count of requests which will be tried to be sent through data reduction 67 // 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. 68 // 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 69 // Explicit bypasses are not part of this count. This is the desired behavior
52 // since otherwise both counts would be identical. 70 // since otherwise both counts would be identical.
53 unsigned long eligible_num_requests_through_proxy_; 71 unsigned long eligible_num_requests_through_proxy_;
54 // Count of successfull requests through data reduction proxy. 72 // Count of successfull requests through data reduction proxy.
55 unsigned long actual_num_requests_through_proxy_; 73 unsigned long actual_num_requests_through_proxy_;
56 74
57 // NetworkChangeNotifier::NetworkChangeObserver: 75 // NetworkChangeNotifier::NetworkChangeObserver:
58 virtual void OnNetworkChanged( 76 virtual void OnNetworkChanged(
59 net::NetworkChangeNotifier::ConnectionType type) OVERRIDE; 77 net::NetworkChangeNotifier::ConnectionType type) OVERRIDE;
60 78
61 void IncRequestCountsOnUiThread(bool actual); 79 void IncRequestCountsOnUiThread(bool actual);
62 void ClearRequestCountsOnUiThread(); 80 void ClearRequestCountsOnUiThread();
63 81
64 base::ThreadChecker thread_checker_; 82 base::ThreadChecker thread_checker_;
65 83
84 void RecordTriggeringRequestBypassedBytes(
85 net::ProxyService::DataReductionProxyBypassType bypass_type,
86 int64 content_length);
87 void RecordNetworkErrorBypassedBytes(const net::URLRequest* request,
88 int64 content_length);
89 void RecordBypassedBytes(
90 net::ProxyService::DataReductionProxyBypassType bypass_type,
91 int64 content_length);
92
66 DISALLOW_COPY_AND_ASSIGN(DataReductionProxyUsageStats); 93 DISALLOW_COPY_AND_ASSIGN(DataReductionProxyUsageStats);
67 }; 94 };
68 95
69 } // namespace data_reduction_proxy 96 } // namespace data_reduction_proxy
70 97
71 #endif // COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_USAGE_ST ATS_H_ 98 #endif // COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_USAGE_ST ATS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698