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

Side by Side Diff: components/data_reduction_proxy/browser/data_reduction_proxy_protocol_unittest.cc

Issue 332313003: Add Finch experiment for selectively bypassing proxies. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: make LOAD_NORMAL consistent 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 #include "components/data_reduction_proxy/browser/data_reduction_proxy_protocol. h" 5 #include "components/data_reduction_proxy/browser/data_reduction_proxy_protocol. h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/metrics/field_trial.h"
11 #include "base/run_loop.h" 12 #include "base/run_loop.h"
12 #include "base/strings/stringprintf.h" 13 #include "base/strings/stringprintf.h"
13 #include "components/data_reduction_proxy/browser/data_reduction_proxy_params_te st_utils.h" 14 #include "components/data_reduction_proxy/browser/data_reduction_proxy_params_te st_utils.h"
14 #include "net/base/completion_callback.h" 15 #include "net/base/completion_callback.h"
15 #include "net/base/host_port_pair.h" 16 #include "net/base/host_port_pair.h"
17 #include "net/base/load_flags.h"
16 #include "net/base/network_delegate.h" 18 #include "net/base/network_delegate.h"
17 #include "net/http/http_response_headers.h" 19 #include "net/http/http_response_headers.h"
18 #include "net/http/http_transaction_test_util.h" 20 #include "net/http/http_transaction_test_util.h"
21 #include "net/proxy/proxy_service.h"
19 #include "net/socket/socket_test_util.h" 22 #include "net/socket/socket_test_util.h"
20 #include "net/url_request/static_http_user_agent_settings.h" 23 #include "net/url_request/static_http_user_agent_settings.h"
21 #include "net/url_request/url_request.h" 24 #include "net/url_request/url_request.h"
22 #include "net/url_request/url_request_context.h" 25 #include "net/url_request/url_request_context.h"
23 #include "net/url_request/url_request_test_util.h" 26 #include "net/url_request/url_request_test_util.h"
24 #include "testing/gtest/include/gtest/gtest.h" 27 #include "testing/gtest/include/gtest/gtest.h"
25 28
26 using net::HttpResponseHeaders; 29 using net::HttpResponseHeaders;
27 using net::HostPortPair; 30 using net::HostPortPair;
28 using net::MockRead; 31 using net::MockRead;
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 607
605 EXPECT_EQ(net::URLRequestStatus::SUCCESS, r.status().status()); 608 EXPECT_EQ(net::URLRequestStatus::SUCCESS, r.status().status());
606 EXPECT_EQ(net::OK, r.status().error()); 609 EXPECT_EQ(net::OK, r.status().error());
607 610
608 EXPECT_EQ("Bypass message", d.data_received()); 611 EXPECT_EQ("Bypass message", d.data_received());
609 612
610 // We should have no entries in our bad proxy list. 613 // We should have no entries in our bad proxy list.
611 TestBadProxies(0, -1, "", ""); 614 TestBadProxies(0, -1, "", "");
612 } 615 }
613 616
617 class BadEntropyProvider : public base::FieldTrial::EntropyProvider {
618 public:
619 virtual ~BadEntropyProvider() {}
620
621 virtual double GetEntropyForTrial(const std::string& trial_name,
622 uint32 randomization_seed) const OVERRIDE {
623 return 0.5;
624 }
625 };
626
627 TEST_F(DataReductionProxyProtocolTest, OnResolveProxyHandler) {
628 int load_flags = net::LOAD_NORMAL;
629 GURL url("http://www.google.com/");
630
631 // Data reduction proxy
632 net::ProxyInfo info1;
633 info1.UseNamedProxy("proxy.googlezip.net:443");
bengr 2014/07/02 18:46:43 It would be better if we didn't have to rely on us
rcs 2014/07/02 22:53:13 Done.
634
635 // Other proxy
636 net::ProxyInfo info2;
637 info2.UseNamedProxy("proxy.com");
638
639 // Without DataCompressionProxyCriticalBypass Finch trial set, should never
640 // bypass.
641 OnResolveProxyHandler(url, load_flags, &info1);
642 EXPECT_FALSE(info1.is_direct());
643
644 OnResolveProxyHandler(url, load_flags, &info2);
645 EXPECT_FALSE(info2.is_direct());
646
647 load_flags |= net::LOAD_BYPASS_DATA_REDUCTION_PROXY;
648
649 OnResolveProxyHandler(url, load_flags, &info1);
650 EXPECT_FALSE(info1.is_direct());
651
652 OnResolveProxyHandler(url, load_flags, &info2);
653 EXPECT_FALSE(info2.is_direct());
654
655 // With Finch trial set, should only bypass if LOAD flag is set and the
656 // effective proxy is the data compression proxy.
657 base::FieldTrialList field_trial_list(new BadEntropyProvider());
658 base::FieldTrialList::CreateFieldTrial("DataCompressionProxyRollout",
659 "Enabled");
660 base::FieldTrialList::CreateFieldTrial("DataCompressionProxyCriticalBypass",
661 "Enabled");
662 EXPECT_TRUE(
663 DataReductionProxyParams::IsIncludedInCriticalPathBypassFieldTrial());
664
665 load_flags = net::LOAD_NORMAL;
666
667 OnResolveProxyHandler(url, load_flags, &info1);
668 EXPECT_FALSE(info1.is_direct());
669
670 OnResolveProxyHandler(url, load_flags, &info2);
671 EXPECT_FALSE(info2.is_direct());
672
673 load_flags |= net::LOAD_BYPASS_DATA_REDUCTION_PROXY;
674
675 OnResolveProxyHandler(url, load_flags, &info2);
676 EXPECT_FALSE(info2.is_direct());
677
678 #if defined(SPDY_PROXY_AUTH_ORIGIN)
679 OnResolveProxyHandler(url, load_flags, &info1);
680 EXPECT_TRUE(info1.is_direct());
681 #endif
682 }
683
614 } // namespace data_reduction_proxy 684 } // namespace data_reduction_proxy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698