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

Unified Diff: components/data_reduction_proxy/browser/data_reduction_proxy_protocol_unittest.cc

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 side-by-side diff with in-line comments
Download patch
Index: components/data_reduction_proxy/browser/data_reduction_proxy_protocol_unittest.cc
diff --git a/components/data_reduction_proxy/browser/data_reduction_proxy_protocol_unittest.cc b/components/data_reduction_proxy/browser/data_reduction_proxy_protocol_unittest.cc
index 3057899fe128804af57815293ed54283ee971b67..41311f54b400a4eab05a67127c950978f38bd78d 100644
--- a/components/data_reduction_proxy/browser/data_reduction_proxy_protocol_unittest.cc
+++ b/components/data_reduction_proxy/browser/data_reduction_proxy_protocol_unittest.cc
@@ -11,6 +11,7 @@
#include "base/run_loop.h"
#include "base/strings/stringprintf.h"
#include "components/data_reduction_proxy/browser/data_reduction_proxy_params_test_utils.h"
+#include "components/data_reduction_proxy/browser/data_reduction_proxy_usage_stats.h"
#include "net/base/completion_callback.h"
#include "net/base/host_port_pair.h"
#include "net/base/network_delegate.h"
@@ -49,13 +50,25 @@ void HeadersToRaw(std::string* headers) {
namespace data_reduction_proxy {
+// A test DataReductionUsageStats
+class TestDataReductionProxyUsageStats : public DataReductionProxyUsageStats {
+ public:
+ TestDataReductionProxyUsageStats() : DataReductionProxyUsageStats(NULL,
bengr 2014/07/12 00:11:59 Can all the params fit on the same line as the fir
bengr 2014/07/14 22:04:29 Done.
+ NULL,
+ NULL) {}
+ virtual void SetBypassType(
+ net::ProxyService::DataReductionProxyBypassType type) OVERRIDE {}
bengr 2014/07/14 17:44:02 I'd add a variable, e.g., set_bypass_type_called_c
megjablon 2014/07/14 19:06:41 With moving the SetBypassType outside of MaybeBypa
+};
+
// A test network delegate that exercises the bypass logic of the data
// reduction proxy.
class TestDataReductionProxyNetworkDelegate : public net::NetworkDelegate {
public:
TestDataReductionProxyNetworkDelegate(
- TestDataReductionProxyParams* test_params)
- : net::NetworkDelegate(), test_data_reduction_proxy_params_(test_params) {
+ TestDataReductionProxyParams* test_params,
+ TestDataReductionProxyUsageStats* usage_stats)
+ : net::NetworkDelegate(), test_data_reduction_proxy_params_(test_params),
+ test_data_reduction_proxy_usage_stats_(usage_stats) {
}
virtual int OnHeadersReceived(
@@ -66,6 +79,7 @@ class TestDataReductionProxyNetworkDelegate : public net::NetworkDelegate {
GURL* allowed_unsafe_redirect_url) OVERRIDE {
data_reduction_proxy::MaybeBypassProxyAndPrepareToRetry(
test_data_reduction_proxy_params_,
+ test_data_reduction_proxy_usage_stats_,
request,
original_response_headers,
override_response_headers);
@@ -73,6 +87,7 @@ class TestDataReductionProxyNetworkDelegate : public net::NetworkDelegate {
}
TestDataReductionProxyParams* test_data_reduction_proxy_params_;
+ DataReductionProxyUsageStats* test_data_reduction_proxy_usage_stats_;
};
// Constructs a |TestURLRequestContext| that uses a |MockSocketFactory| to
@@ -87,6 +102,7 @@ class DataReductionProxyProtocolTest : public testing::Test {
DataReductionProxyParams::kPromoAllowed,
TestDataReductionProxyParams::HAS_EVERYTHING &
~TestDataReductionProxyParams::HAS_DEV_ORIGIN));
+ usage_stats_.reset(new TestDataReductionProxyUsageStats());
}
// Sets up the |TestURLRequestContext| with the provided |ProxyService|.
@@ -96,7 +112,7 @@ class DataReductionProxyProtocolTest : public testing::Test {
proxy_service_.reset(proxy_service);
network_delegate_.reset(new TestDataReductionProxyNetworkDelegate(
- proxy_params_.get()));
+ proxy_params_.get(), usage_stats_.get()));
context_->set_client_socket_factory(&mock_socket_factory_);
context_->set_proxy_service(proxy_service_.get());
@@ -264,6 +280,7 @@ class DataReductionProxyProtocolTest : public testing::Test {
net::MockClientSocketFactory mock_socket_factory_;
scoped_ptr<ProxyService> proxy_service_;
scoped_ptr<TestDataReductionProxyParams> proxy_params_;
+ scoped_ptr<TestDataReductionProxyUsageStats> usage_stats_;
scoped_ptr<TestDataReductionProxyNetworkDelegate> network_delegate_;
net::StaticHttpUserAgentSettings http_user_agent_settings_;

Powered by Google App Engine
This is Rietveld 408576698