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

Side by Side Diff: components/data_reduction_proxy/core/browser/data_reduction_proxy_bypass_protocol_unittest.cc

Issue 1888963004: Add HttpProtocolHandler and convert everything to use it (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@remove-supports-scheme
Patch Set: rebase (needs fixing) Created 4 years, 2 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/core/browser/data_reduction_proxy_bypa ss_protocol.h" 5 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_bypa ss_protocol.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 using net::TestURLRequestContext; 62 using net::TestURLRequestContext;
63 using net::URLRequest; 63 using net::URLRequest;
64 64
65 namespace data_reduction_proxy { 65 namespace data_reduction_proxy {
66 66
67 class SimpleURLRequestInterceptor : public net::URLRequestInterceptor { 67 class SimpleURLRequestInterceptor : public net::URLRequestInterceptor {
68 public: 68 public:
69 net::URLRequestJob* MaybeInterceptRequest( 69 net::URLRequestJob* MaybeInterceptRequest(
70 net::URLRequest* request, 70 net::URLRequest* request,
71 net::NetworkDelegate* network_delegate) const override { 71 net::NetworkDelegate* network_delegate) const override {
72 return net::URLRequestHttpJob::Factory(request, network_delegate, "http"); 72 return new net::URLRequestHttpJob(
73 request, network_delegate,
74 request->context()->http_user_agent_settings());
73 } 75 }
74 }; 76 };
75 77
76 // Constructs a |TestURLRequestContext| that uses a |MockSocketFactory| to 78 // Constructs a |TestURLRequestContext| that uses a |MockSocketFactory| to
77 // simulate requests and responses. 79 // simulate requests and responses.
78 class DataReductionProxyProtocolTest : public testing::Test { 80 class DataReductionProxyProtocolTest : public testing::Test {
79 public: 81 public:
80 DataReductionProxyProtocolTest() : http_user_agent_settings_("", "") { 82 DataReductionProxyProtocolTest() : http_user_agent_settings_("", "") {
81 simple_interceptor_.reset(new SimpleURLRequestInterceptor()); 83 simple_interceptor_.reset(new SimpleURLRequestInterceptor());
82 net::URLRequestFilter::GetInstance()->AddHostnameInterceptor( 84 net::URLRequestFilter::GetInstance()->AddHostnameInterceptor(
(...skipping 28 matching lines...) Expand all
111 // to requests. 113 // to requests.
112 context_->set_http_user_agent_settings(&http_user_agent_settings_); 114 context_->set_http_user_agent_settings(&http_user_agent_settings_);
113 bypass_stats_.reset(new DataReductionProxyBypassStats( 115 bypass_stats_.reset(new DataReductionProxyBypassStats(
114 test_context_->config(), 116 test_context_->config(),
115 test_context_->unreachable_callback())); 117 test_context_->unreachable_callback()));
116 118
117 DataReductionProxyInterceptor* interceptor = 119 DataReductionProxyInterceptor* interceptor =
118 new DataReductionProxyInterceptor( 120 new DataReductionProxyInterceptor(
119 test_context_->config(), test_context_->io_data()->config_client(), 121 test_context_->config(), test_context_->io_data()->config_client(),
120 bypass_stats_.get(), test_context_->event_creator()); 122 bypass_stats_.get(), test_context_->event_creator());
121 std::unique_ptr<net::URLRequestJobFactoryImpl> job_factory_impl( 123 std::unique_ptr<net::URLRequestJobFactoryImpl> job_factory_impl =
122 new net::URLRequestJobFactoryImpl()); 124 net::URLRequestJobFactoryImpl::CreateWithHttpProtocolHandlers();
123 job_factory_.reset(new net::URLRequestInterceptingJobFactory( 125 job_factory_.reset(new net::URLRequestInterceptingJobFactory(
124 std::move(job_factory_impl), base::WrapUnique(interceptor))); 126 std::move(job_factory_impl), base::WrapUnique(interceptor)));
125 127
126 context_->set_job_factory(job_factory_.get()); 128 context_->set_job_factory(job_factory_.get());
127 context_->Init(); 129 context_->Init();
128 } 130 }
129 131
130 // Simulates a request to a data reduction proxy that may result in bypassing 132 // Simulates a request to a data reduction proxy that may result in bypassing
131 // the proxy and retrying the the request. 133 // the proxy and retrying the the request.
132 // Runs a test with the given request |method| that expects the first response 134 // Runs a test with the given request |method| that expects the first response
(...skipping 847 matching lines...) Expand 10 before | Expand all | Expand 10 after
980 982
981 EXPECT_EQ(net::OK, d.request_status()); 983 EXPECT_EQ(net::OK, d.request_status());
982 984
983 EXPECT_EQ("Bypass message", d.data_received()); 985 EXPECT_EQ("Bypass message", d.data_received());
984 986
985 // We should have no entries in our bad proxy list. 987 // We should have no entries in our bad proxy list.
986 TestBadProxies(0, -1, "", ""); 988 TestBadProxies(0, -1, "", "");
987 } 989 }
988 990
989 } // namespace data_reduction_proxy 991 } // namespace data_reduction_proxy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698