| Index: components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate_unittest.cc
|
| diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate_unittest.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate_unittest.cc
|
| index 2549758d94cfa1f7d64e75d2e9515e76ed4e6b4b..fe69c111390312dfb352b2f49e1d19769553921e 100644
|
| --- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate_unittest.cc
|
| +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate_unittest.cc
|
| @@ -77,64 +77,99 @@ const char kOtherProxy[] = "testproxy:17";
|
| const char kTestURL[] = "http://www.google.com/";
|
| const char kSecureTestURL[] = "https://www.google.com/";
|
|
|
| -const std::string kReceivedValidOCLHistogramName =
|
| +const char kReceivedValidOCLHistogramName[] =
|
| "Net.HttpContentLengthWithValidOCL";
|
| -const std::string kOriginalValidOCLHistogramName =
|
| +const char kOriginalValidOCLHistogramName[] =
|
| "Net.HttpOriginalContentLengthWithValidOCL";
|
| -const std::string kDifferenceValidOCLHistogramName =
|
| +const char kDifferenceValidOCLHistogramName[] =
|
| "Net.HttpContentLengthDifferenceWithValidOCL";
|
|
|
| +// HTTP original content length
|
| +const char kOriginalInsecureDirectHistogramName[] =
|
| + "Net.HttpOriginalContentLength.Http.Direct";
|
| +const char kOriginalInsecureViaDRPHistogramName[] =
|
| + "Net.HttpOriginalContentLength.Http.ViaDRP";
|
| +const char kOriginalInsecureBypassedHistogramName[] =
|
| + "Net.HttpOriginalContentLength.Http.BypassedDRP";
|
| +const char kOriginalInsecureOtherHistogramName[] =
|
| + "Net.HttpOriginalContentLength.Http.Other";
|
| +// HTTP video original content length
|
| +const char kOriginalVideoInsecureDirectHistogramName[] =
|
| + "Net.HttpOriginalContentLength.Http.Direct.Video";
|
| +const char kOriginalVideoInsecureViaDRPHistogramName[] =
|
| + "Net.HttpOriginalContentLength.Http.ViaDRP.Video";
|
| +const char kOriginalVideoInsecureBypassedHistogramName[] =
|
| + "Net.HttpOriginalContentLength.Http.BypassedDRP.Video";
|
| +const char kOriginalVideoInsecureOtherHistogramName[] =
|
| + "Net.HttpOriginalContentLength.Http.Other.Video";
|
| +// HTTPS original content length
|
| +const char kOriginalSecureDirectHistogramName[] =
|
| + "Net.HttpOriginalContentLength.Https.Direct";
|
| +const char kOriginalSecureViaDRPHistogramName[] =
|
| + "Net.HttpOriginalContentLength.Https.ViaDRP";
|
| +const char kOriginalSecureBypassedHistogramName[] =
|
| + "Net.HttpOriginalContentLength.Https.BypassedDRP";
|
| +const char kOriginalSecureOtherHistogramName[] =
|
| + "Net.HttpOriginalContentLength.Https.Other";
|
| +// HTTPS video original content length
|
| +const char kOriginalVideoSecureDirectHistogramName[] =
|
| + "Net.HttpOriginalContentLength.Https.Direct.Video";
|
| +const char kOriginalVideoSecureViaDRPHistogramName[] =
|
| + "Net.HttpOriginalContentLength.Https.ViaDRP.Video";
|
| +const char kOriginalVideoSecureBypassedHistogramName[] =
|
| + "Net.HttpOriginalContentLength.Https.BypassedDRP.Video";
|
| +const char kOriginalVideoSecureOtherHistogramName[] =
|
| + "Net.HttpOriginalContentLength.Https.Other.Video";
|
| +
|
| // Lo-Fi histograms.
|
| -const std::string kReceivedValidOCLLoFiOnHistogramName =
|
| +const char kReceivedValidOCLLoFiOnHistogramName[] =
|
| "Net.HttpContentLengthWithValidOCL.LoFiOn";
|
| -const std::string kOriginalValidOCLLoFiOnHistogramName =
|
| +const char kOriginalValidOCLLoFiOnHistogramName[] =
|
| "Net.HttpOriginalContentLengthWithValidOCL.LoFiOn";
|
| -const std::string kDifferenceValidOCLLoFiOnHistogramName =
|
| +const char kDifferenceValidOCLLoFiOnHistogramName[] =
|
| "Net.HttpContentLengthDifferenceWithValidOCL.LoFiOn";
|
|
|
| -const std::string kReceivedHistogramName = "Net.HttpContentLength";
|
| -const std::string kReceivedInsecureDirectHistogramName =
|
| +const char kReceivedHistogramName[] = "Net.HttpContentLength";
|
| +const char kReceivedInsecureDirectHistogramName[] =
|
| "Net.HttpContentLength.Http.Direct";
|
| -const std::string kReceivedInsecureViaDRPHistogramName =
|
| +const char kReceivedInsecureViaDRPHistogramName[] =
|
| "Net.HttpContentLength.Http.ViaDRP";
|
| -const std::string kReceivedInsecureBypassedHistogramName =
|
| +const char kReceivedInsecureBypassedHistogramName[] =
|
| "Net.HttpContentLength.Http.BypassedDRP";
|
| -const std::string kReceivedInsecureOtherHistogramName =
|
| +const char kReceivedInsecureOtherHistogramName[] =
|
| "Net.HttpContentLength.Http.Other";
|
| -const std::string kReceivedSecureDirectHistogramName =
|
| +const char kReceivedSecureDirectHistogramName[] =
|
| "Net.HttpContentLength.Https.Direct";
|
| -const std::string kReceivedSecureViaDRPHistogramName =
|
| +const char kReceivedSecureViaDRPHistogramName[] =
|
| "Net.HttpContentLength.Https.ViaDRP";
|
| -const std::string kReceivedSecureBypassedHistogramName =
|
| +const char kReceivedSecureBypassedHistogramName[] =
|
| "Net.HttpContentLength.Https.BypassedDRP";
|
| -const std::string kReceivedSecureOtherHistogramName =
|
| - "Net.HttpContentLength.Https.Other";
|
| -const std::string kReceivedSecureOtheristogramName =
|
| +const char kReceivedSecureOtherHistogramName[] =
|
| "Net.HttpContentLength.Https.Other";
|
| -const std::string kReceivedVideoInsecureDirectHistogramName =
|
| +const char kReceivedVideoInsecureDirectHistogramName[] =
|
| "Net.HttpContentLength.Http.Direct.Video";
|
| -const std::string kReceivedVideoInsecureViaDRPHistogramName =
|
| +const char kReceivedVideoInsecureViaDRPHistogramName[] =
|
| "Net.HttpContentLength.Http.ViaDRP.Video";
|
| -const std::string kReceivedVideoInsecureBypassedHistogramName =
|
| +const char kReceivedVideoInsecureBypassedHistogramName[] =
|
| "Net.HttpContentLength.Http.BypassedDRP.Video";
|
| -const std::string kReceivedVideoInsecureOtherHistogramName =
|
| +const char kReceivedVideoInsecureOtherHistogramName[] =
|
| "Net.HttpContentLength.Http.Other.Video";
|
| -const std::string kReceivedVideoSecureDirectHistogramName =
|
| +const char kReceivedVideoSecureDirectHistogramName[] =
|
| "Net.HttpContentLength.Https.Direct.Video";
|
| -const std::string kReceivedVideoSecureViaDRPHistogramName =
|
| +const char kReceivedVideoSecureViaDRPHistogramName[] =
|
| "Net.HttpContentLength.Https.ViaDRP.Video";
|
| -const std::string kReceivedVideoSecureBypassedHistogramName =
|
| +const char kReceivedVideoSecureBypassedHistogramName[] =
|
| "Net.HttpContentLength.Https.BypassedDRP.Video";
|
| -const std::string kReceivedVideoSecureOtherHistogramName =
|
| +const char kReceivedVideoSecureOtherHistogramName[] =
|
| "Net.HttpContentLength.Https.Other.Video";
|
| -const std::string kOriginalHistogramName = "Net.HttpOriginalContentLength";
|
| -const std::string kDifferenceHistogramName = "Net.HttpContentLengthDifference";
|
| -const std::string kFreshnessLifetimeHistogramName =
|
| +const char kOriginalHistogramName[] = "Net.HttpOriginalContentLength";
|
| +const char kDifferenceHistogramName[] = "Net.HttpContentLengthDifference";
|
| +const char kFreshnessLifetimeHistogramName[] =
|
| "Net.HttpContentFreshnessLifetime";
|
| -const std::string kCacheableHistogramName = "Net.HttpContentLengthCacheable";
|
| -const std::string kCacheable4HoursHistogramName =
|
| +const char kCacheableHistogramName[] = "Net.HttpContentLengthCacheable";
|
| +const char kCacheable4HoursHistogramName[] =
|
| "Net.HttpContentLengthCacheable4Hours";
|
| -const std::string kCacheable24HoursHistogramName =
|
| +const char kCacheable24HoursHistogramName[] =
|
| "Net.HttpContentLengthCacheable24Hours";
|
| const int64_t kResponseContentLength = 100;
|
| const int64_t kOriginalContentLength = 200;
|
| @@ -292,9 +327,7 @@ enum ProxyTestConfig { USE_SECURE_PROXY, USE_INSECURE_PROXY, BYPASS_PROXY };
|
| class DataReductionProxyNetworkDelegateTest : public testing::Test {
|
| public:
|
| DataReductionProxyNetworkDelegateTest()
|
| - : context_(true),
|
| - context_storage_(&context_),
|
| - lofi_decider_(nullptr),
|
| + : lofi_decider_(nullptr),
|
| lofi_ui_service_(nullptr),
|
| ssl_socket_data_provider_(net::ASYNC, net::OK) {
|
| ssl_socket_data_provider_.next_proto = net::kProtoHTTP11;
|
| @@ -317,13 +350,18 @@ class DataReductionProxyNetworkDelegateTest : public testing::Test {
|
| net::ProxyServer::SCHEME_HTTP);
|
| break;
|
| }
|
| + context_.reset(new net::TestURLRequestContext(true));
|
| + context_storage_.reset(new net::URLRequestContextStorage(context_.get()));
|
| proxy_service_ =
|
| net::ProxyService::CreateFixedFromPacResult(proxy_server.ToPacString());
|
| - context_.set_proxy_service(proxy_service_.get());
|
| + context_->set_proxy_service(proxy_service_.get());
|
| +
|
| + mock_socket_factory_.reset(new net::MockClientSocketFactory());
|
| +
|
| DataReductionProxyTestContext::Builder builder;
|
| builder = builder.WithClient(kClient)
|
| - .WithMockClientSocketFactory(&mock_socket_factory_)
|
| - .WithURLRequestContext(&context_);
|
| + .WithMockClientSocketFactory(mock_socket_factory_.get())
|
| + .WithURLRequestContext(context_.get());
|
|
|
| if (proxy_config != BYPASS_PROXY) {
|
| builder = builder.WithProxiesForHttp({DataReductionProxyServer(
|
| @@ -332,8 +370,8 @@ class DataReductionProxyNetworkDelegateTest : public testing::Test {
|
|
|
| test_context_ = builder.Build();
|
|
|
| - context_.set_client_socket_factory(&mock_socket_factory_);
|
| - test_context_->AttachToURLRequestContext(&context_storage_);
|
| + context_->set_client_socket_factory(mock_socket_factory_.get());
|
| + test_context_->AttachToURLRequestContext(context_storage_.get());
|
|
|
| std::unique_ptr<TestLoFiDecider> lofi_decider(new TestLoFiDecider());
|
| lofi_decider_ = lofi_decider.get();
|
| @@ -343,9 +381,9 @@ class DataReductionProxyNetworkDelegateTest : public testing::Test {
|
| lofi_ui_service_ = lofi_ui_service.get();
|
| test_context_->io_data()->set_lofi_ui_service(std::move(lofi_ui_service));
|
|
|
| - context_.set_enable_brotli(enable_brotli_globally);
|
| - context_.set_network_quality_estimator(&test_network_quality_estimator_);
|
| - context_.Init();
|
| + context_->set_enable_brotli(enable_brotli_globally);
|
| + context_->set_network_quality_estimator(&test_network_quality_estimator_);
|
| + context_->Init();
|
|
|
| test_context_->EnableDataReductionProxyWithSecureProxyCheckSuccess();
|
| }
|
| @@ -399,7 +437,7 @@ class DataReductionProxyNetworkDelegateTest : public testing::Test {
|
| io_data()->test_request_options()->GetHeaderValueForTesting() +
|
| std::string("\r\n\r\n");
|
|
|
| - mock_socket_factory_.AddSSLSocketDataProvider(&ssl_socket_data_provider_);
|
| + mock_socket_factory_->AddSSLSocketDataProvider(&ssl_socket_data_provider_);
|
|
|
| for (net::EffectiveConnectionType effective_connection_type :
|
| effective_connection_types) {
|
| @@ -420,7 +458,7 @@ class DataReductionProxyNetworkDelegateTest : public testing::Test {
|
| socket_ = base::MakeUnique<net::StaticSocketDataProvider>(
|
| reads_list->data(), reads_list->size(), writes_list->data(),
|
| writes_list->size());
|
| - mock_socket_factory_.AddSocketDataProvider(socket_.get());
|
| + mock_socket_factory_->AddSocketDataProvider(socket_.get());
|
| }
|
|
|
| static void VerifyHeaders(bool expected_data_reduction_proxy_used,
|
| @@ -469,10 +507,10 @@ class DataReductionProxyNetworkDelegateTest : public testing::Test {
|
| net::MockRead(response_body.c_str()),
|
| net::MockRead(net::SYNCHRONOUS, net::OK)};
|
| net::StaticSocketDataProvider socket(reads, arraysize(reads), nullptr, 0);
|
| - mock_socket_factory_.AddSocketDataProvider(&socket);
|
| + mock_socket_factory_->AddSocketDataProvider(&socket);
|
|
|
| net::TestDelegate delegate;
|
| - std::unique_ptr<net::URLRequest> request = context_.CreateRequest(
|
| + std::unique_ptr<net::URLRequest> request = context_->CreateRequest(
|
| url, net::IDLE, &delegate, TRAFFIC_ANNOTATION_FOR_TESTS);
|
| if (request_headers)
|
| request->SetExtraRequestHeaders(*request_headers);
|
| @@ -525,7 +563,7 @@ class DataReductionProxyNetworkDelegateTest : public testing::Test {
|
| std::string(base::checked_cast<size_t>(response_body_size), ' ');
|
| }
|
|
|
| - mock_socket_factory_.AddSSLSocketDataProvider(&ssl_socket_data_provider_);
|
| + mock_socket_factory_->AddSSLSocketDataProvider(&ssl_socket_data_provider_);
|
|
|
| net::MockRead reads[] = {net::MockRead(response_headers.c_str()),
|
| net::MockRead(response_body.c_str()),
|
| @@ -583,10 +621,10 @@ class DataReductionProxyNetworkDelegateTest : public testing::Test {
|
| net::MockWrite writes[] = {net::MockWrite(mock_write.c_str())};
|
| net::StaticSocketDataProvider socket(reads, arraysize(reads), writes,
|
| arraysize(writes));
|
| - mock_socket_factory_.AddSocketDataProvider(&socket);
|
| + mock_socket_factory_->AddSocketDataProvider(&socket);
|
|
|
| net::TestDelegate delegate;
|
| - std::unique_ptr<net::URLRequest> request = context_.CreateRequest(
|
| + std::unique_ptr<net::URLRequest> request = context_->CreateRequest(
|
| url, net::IDLE, &delegate, TRAFFIC_ANNOTATION_FOR_TESTS);
|
| if (request_headers)
|
| request->SetExtraRequestHeaders(*request_headers);
|
| @@ -650,7 +688,7 @@ class DataReductionProxyNetworkDelegateTest : public testing::Test {
|
| std::string response_body =
|
| std::string(base::checked_cast<size_t>(response_body_size), ' ');
|
|
|
| - mock_socket_factory_.AddSSLSocketDataProvider(&ssl_socket_data_provider_);
|
| + mock_socket_factory_->AddSSLSocketDataProvider(&ssl_socket_data_provider_);
|
|
|
| net::MockRead redirect_reads[] = {
|
| net::MockRead("HTTP/1.1 302 Redirect\r\n"),
|
| @@ -693,10 +731,10 @@ class DataReductionProxyNetworkDelegateTest : public testing::Test {
|
| arraysize(redirect_writes));
|
| }
|
|
|
| - mock_socket_factory_.AddSocketDataProvider(socket.get());
|
| + mock_socket_factory_->AddSocketDataProvider(socket.get());
|
|
|
| net::TestDelegate delegate;
|
| - std::unique_ptr<net::URLRequest> request = context_.CreateRequest(
|
| + std::unique_ptr<net::URLRequest> request = context_->CreateRequest(
|
| url, net::IDLE, &delegate, TRAFFIC_ANNOTATION_FOR_TESTS);
|
| if (!page_id_value.empty()) {
|
| request->SetLoadFlags(request->load_flags() |
|
| @@ -719,7 +757,7 @@ class DataReductionProxyNetworkDelegateTest : public testing::Test {
|
| effective_connection_type);
|
|
|
| net::TestDelegate delegate;
|
| - std::unique_ptr<net::URLRequest> request = context_.CreateRequest(
|
| + std::unique_ptr<net::URLRequest> request = context_->CreateRequest(
|
| GURL(kTestURL), net::IDLE, &delegate, TRAFFIC_ANNOTATION_FOR_TESTS);
|
|
|
| request->Start();
|
| @@ -773,13 +811,13 @@ class DataReductionProxyNetworkDelegateTest : public testing::Test {
|
| }
|
|
|
| net::MockClientSocketFactory* mock_socket_factory() {
|
| - return &mock_socket_factory_;
|
| + return mock_socket_factory_.get();
|
| }
|
|
|
| - net::TestURLRequestContext* context() { return &context_; }
|
| + net::TestURLRequestContext* context() { return context_.get(); }
|
|
|
| net::NetworkDelegate* network_delegate() const {
|
| - return context_.network_delegate();
|
| + return context_->network_delegate();
|
| }
|
|
|
| TestDataReductionProxyParams* params() const {
|
| @@ -806,10 +844,10 @@ class DataReductionProxyNetworkDelegateTest : public testing::Test {
|
|
|
| private:
|
| base::MessageLoopForIO message_loop_;
|
| - net::MockClientSocketFactory mock_socket_factory_;
|
| + std::unique_ptr<net::MockClientSocketFactory> mock_socket_factory_;
|
| std::unique_ptr<net::ProxyService> proxy_service_;
|
| - net::TestURLRequestContext context_;
|
| - net::URLRequestContextStorage context_storage_;
|
| + std::unique_ptr<net::TestURLRequestContext> context_;
|
| + std::unique_ptr<net::URLRequestContextStorage> context_storage_;
|
|
|
| TestLoFiDecider* lofi_decider_;
|
| TestLoFiUIService* lofi_ui_service_;
|
| @@ -1229,6 +1267,8 @@ TEST_F(DataReductionProxyNetworkDelegateTest, NetHistograms) {
|
| kResponseContentLength, 1);
|
| histogram_tester.ExpectUniqueSample(kOriginalValidOCLHistogramName,
|
| kOriginalContentLength, 1);
|
| + histogram_tester.ExpectUniqueSample(kOriginalInsecureViaDRPHistogramName,
|
| + kOriginalContentLength, 1);
|
| histogram_tester.ExpectUniqueSample(
|
| kDifferenceValidOCLHistogramName,
|
| kOriginalContentLength - kResponseContentLength, 1);
|
| @@ -1376,46 +1416,192 @@ TEST_F(DataReductionProxyNetworkDelegateTest, NetVideoHistograms) {
|
| histogram_tester.ExpectTotalCount(kReceivedVideoSecureOtherHistogramName, 0);
|
| }
|
|
|
| -TEST_F(DataReductionProxyNetworkDelegateTest, NetSSLHistograms) {
|
| - Init(BYPASS_PROXY, false);
|
| +struct ExpectedHistogram {
|
| + const std::string name;
|
| + int64_t value;
|
| +};
|
|
|
| - base::HistogramTester histogram_tester;
|
| +bool operator<(const ExpectedHistogram& hist1, const ExpectedHistogram& hist2) {
|
| + return hist1.name < hist2.name;
|
| +}
|
|
|
| - // Check https
|
| - std::string secure_response_headers =
|
| - "HTTP/1.1 200 OK\r\n"
|
| - "Date: Wed, 28 Nov 2007 09:40:09 GMT\r\n"
|
| - "Expires: Mon, 24 Nov 2014 12:45:26 GMT\r\n"
|
| - "Via: 1.1 Chrome-Compression-Proxy\r\n"
|
| - "x-original-content-length: " +
|
| - base::Int64ToString(kOriginalContentLength) + "\r\n\r\n";
|
| +TEST_F(DataReductionProxyNetworkDelegateTest, DetailedNetHistograms) {
|
| + // List of all the histograms we're concerned with.
|
| + // Each test case can define interesting histograms from this list.
|
| + // Any histogram not called out in an invidual test will have an expected
|
| + // count of 0 samples.
|
| + const std::set<std::string> all_new_net_histograms{
|
| + // HTTP received content length
|
| + kReceivedInsecureDirectHistogramName,
|
| + kReceivedInsecureViaDRPHistogramName,
|
| + kReceivedInsecureBypassedHistogramName,
|
| + kReceivedInsecureOtherHistogramName,
|
| + // HTTP video received content length
|
| + kReceivedVideoInsecureDirectHistogramName,
|
| + kReceivedVideoInsecureViaDRPHistogramName,
|
| + kReceivedVideoInsecureBypassedHistogramName,
|
| + kReceivedVideoInsecureOtherHistogramName,
|
| + // HTTPS received content length
|
| + kReceivedSecureDirectHistogramName, kReceivedSecureViaDRPHistogramName,
|
| + kReceivedSecureBypassedHistogramName, kReceivedSecureOtherHistogramName,
|
| + // HTTPS video received content length
|
| + kReceivedVideoSecureDirectHistogramName,
|
| + kReceivedVideoSecureViaDRPHistogramName,
|
| + kReceivedVideoSecureBypassedHistogramName,
|
| + kReceivedVideoSecureOtherHistogramName,
|
| + // HTTP Original content length
|
| + kOriginalInsecureDirectHistogramName,
|
| + kOriginalInsecureViaDRPHistogramName,
|
| + kOriginalInsecureBypassedHistogramName,
|
| + kOriginalInsecureOtherHistogramName,
|
| + // HTTP video Original content length
|
| + kOriginalVideoInsecureDirectHistogramName,
|
| + kOriginalVideoInsecureViaDRPHistogramName,
|
| + kOriginalVideoInsecureBypassedHistogramName,
|
| + kOriginalVideoInsecureOtherHistogramName,
|
| + // HTTPS Original content length
|
| + kOriginalSecureDirectHistogramName, kOriginalSecureViaDRPHistogramName,
|
| + kOriginalSecureBypassedHistogramName, kOriginalSecureOtherHistogramName,
|
| + // HTTPS video Original content length
|
| + kOriginalVideoSecureDirectHistogramName,
|
| + kOriginalVideoSecureViaDRPHistogramName,
|
| + kOriginalVideoSecureBypassedHistogramName,
|
| + kOriginalVideoSecureOtherHistogramName,
|
| + };
|
|
|
| - mock_socket_factory()->AddSSLSocketDataProvider(ssl_socket_data_provider());
|
| - FetchURLRequest(GURL(kSecureTestURL), nullptr, secure_response_headers,
|
| - kResponseContentLength, 0);
|
| + const struct {
|
| + const std::string name;
|
| + bool is_video;
|
| + bool is_https;
|
| + ProxyTestConfig proxy_config;
|
| + int64_t original_content_length;
|
| + int64_t content_length;
|
| + // Any histogram listed in all_new_net_histograms but not here should have
|
| + // no samples.
|
| + const std::set<ExpectedHistogram> expected_histograms;
|
| + } tests[] = {
|
| + {"HTTP nonvideo request via DRP",
|
| + false,
|
| + false,
|
| + USE_INSECURE_PROXY,
|
| + kOriginalContentLength,
|
| + kResponseContentLength,
|
| + {
|
| + {kReceivedInsecureViaDRPHistogramName, kResponseContentLength},
|
| + {kOriginalInsecureViaDRPHistogramName, kOriginalContentLength},
|
| + }},
|
| + {"HTTP video request via DRP",
|
| + true,
|
| + false,
|
| + USE_INSECURE_PROXY,
|
| + kOriginalContentLength,
|
| + kResponseContentLength,
|
| + {
|
| + {kReceivedInsecureViaDRPHistogramName, kResponseContentLength},
|
| + {kOriginalInsecureViaDRPHistogramName, kOriginalContentLength},
|
| + {kReceivedVideoInsecureViaDRPHistogramName, kResponseContentLength},
|
| + {kOriginalVideoInsecureViaDRPHistogramName, kOriginalContentLength},
|
| + }},
|
| + {"DRP not configured for http",
|
| + false,
|
| + false,
|
| + BYPASS_PROXY,
|
| + kOriginalContentLength,
|
| + kResponseContentLength,
|
| + {
|
| + {kReceivedInsecureOtherHistogramName, kResponseContentLength},
|
| + {kOriginalInsecureOtherHistogramName, kResponseContentLength},
|
| + }},
|
| + {"DRP not configured for http video",
|
| + true,
|
| + false,
|
| + BYPASS_PROXY,
|
| + kOriginalContentLength,
|
| + kResponseContentLength,
|
| + {
|
| + {kReceivedInsecureOtherHistogramName, kResponseContentLength},
|
| + {kOriginalInsecureOtherHistogramName, kResponseContentLength},
|
| + {kReceivedVideoInsecureOtherHistogramName, kResponseContentLength},
|
| + {kOriginalVideoInsecureOtherHistogramName, kResponseContentLength},
|
| + }},
|
| + {"nonvideo over https",
|
| + false,
|
| + true,
|
| + BYPASS_PROXY,
|
| + kOriginalContentLength,
|
| + kResponseContentLength,
|
| + {
|
| + {kReceivedSecureDirectHistogramName, kResponseContentLength},
|
| + {kOriginalSecureDirectHistogramName, kResponseContentLength},
|
| + }},
|
| + {"video over https",
|
| + true,
|
| + true,
|
| + BYPASS_PROXY,
|
| + kOriginalContentLength,
|
| + kResponseContentLength,
|
| + {
|
| + {kReceivedSecureDirectHistogramName, kResponseContentLength},
|
| + {kOriginalSecureDirectHistogramName, kResponseContentLength},
|
| + {kReceivedVideoSecureDirectHistogramName, kResponseContentLength},
|
| + {kOriginalVideoSecureDirectHistogramName, kResponseContentLength},
|
| + }},
|
| + };
|
|
|
| - histogram_tester.ExpectTotalCount(kReceivedInsecureDirectHistogramName, 0);
|
| - histogram_tester.ExpectTotalCount(kReceivedInsecureViaDRPHistogramName, 0);
|
| - histogram_tester.ExpectTotalCount(kReceivedInsecureBypassedHistogramName, 0);
|
| - histogram_tester.ExpectTotalCount(kReceivedInsecureOtherHistogramName, 0);
|
| - histogram_tester.ExpectTotalCount(kReceivedSecureViaDRPHistogramName, 0);
|
| - histogram_tester.ExpectTotalCount(kReceivedSecureBypassedHistogramName, 0);
|
| - histogram_tester.ExpectTotalCount(kReceivedSecureOtherHistogramName, 0);
|
| - histogram_tester.ExpectUniqueSample(kReceivedSecureDirectHistogramName,
|
| - kResponseContentLength, 1);
|
| - histogram_tester.ExpectTotalCount(kReceivedVideoInsecureViaDRPHistogramName,
|
| - 0);
|
| - histogram_tester.ExpectTotalCount(kReceivedVideoInsecureDirectHistogramName,
|
| - 0);
|
| - histogram_tester.ExpectTotalCount(kReceivedVideoInsecureBypassedHistogramName,
|
| - 0);
|
| - histogram_tester.ExpectTotalCount(kReceivedVideoInsecureOtherHistogramName,
|
| - 0);
|
| - histogram_tester.ExpectTotalCount(kReceivedVideoSecureViaDRPHistogramName, 0);
|
| - histogram_tester.ExpectTotalCount(kReceivedVideoSecureDirectHistogramName, 0);
|
| - histogram_tester.ExpectTotalCount(kReceivedVideoSecureBypassedHistogramName,
|
| - 0);
|
| - histogram_tester.ExpectTotalCount(kReceivedVideoSecureOtherHistogramName, 0);
|
| + for (const auto& test : tests) {
|
| + LOG(INFO) << "NetHistograms: " << test.name;
|
| + Init(test.proxy_config, false);
|
| + base::HistogramTester histogram_tester;
|
| +
|
| + GURL test_url = GURL(kTestURL);
|
| +
|
| + if (test.is_https) {
|
| + test_url = GURL(kSecureTestURL);
|
| + mock_socket_factory()->AddSSLSocketDataProvider(
|
| + ssl_socket_data_provider());
|
| + }
|
| +
|
| + std::string via_header = "";
|
| + std::string ocl_header = "";
|
| +
|
| + if (test.proxy_config == USE_INSECURE_PROXY) {
|
| + via_header = "Via: 1.1 Chrome-Compression-Proxy\r\n";
|
| + ocl_header = "x-original-content-length: " +
|
| + base::Int64ToString(kOriginalContentLength) + "\r\n";
|
| + }
|
| + if (test.is_video) {
|
| + // Check video
|
| + std::string video_response_headers =
|
| + "HTTP/1.1 200 OK\r\n"
|
| + "Date: Wed, 28 Nov 2007 09:40:09 GMT\r\n"
|
| + "Expires: Mon, 24 Nov 2014 12:45:26 GMT\r\n"
|
| + "Content-Type: video/mp4\r\n" +
|
| + via_header + ocl_header + "\r\n";
|
| +
|
| + FetchURLRequest(test_url, nullptr, video_response_headers,
|
| + kResponseContentLength, 0);
|
| + } else {
|
| + // Check https
|
| + std::string response_headers =
|
| + "HTTP/1.1 200 OK\r\n"
|
| + "Date: Wed, 28 Nov 2007 09:40:09 GMT\r\n"
|
| + "Expires: Mon, 24 Nov 2014 12:45:26 GMT\r\n" +
|
| + via_header + ocl_header + "\r\n\r\n";
|
| +
|
| + FetchURLRequest(test_url, nullptr, response_headers,
|
| + kResponseContentLength, 0);
|
| + }
|
| +
|
| + for (const auto& histogram : all_new_net_histograms) {
|
| + auto expected_it = test.expected_histograms.find({histogram, 0});
|
| + if (expected_it == test.expected_histograms.end()) {
|
| + histogram_tester.ExpectTotalCount(histogram, 0);
|
| + } else {
|
| + histogram_tester.ExpectUniqueSample(expected_it->name,
|
| + expected_it->value, 1);
|
| + }
|
| + }
|
| + }
|
| }
|
|
|
| TEST_F(DataReductionProxyNetworkDelegateTest, OnCompletedInternalLoFi) {
|
|
|