OLD | NEW |
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 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 NET_HTTP_HTTP_STREAM_FACTORY_TEST_UTIL_H_ | 5 #ifndef NET_HTTP_HTTP_STREAM_FACTORY_TEST_UTIL_H_ |
6 #define NET_HTTP_HTTP_STREAM_FACTORY_TEST_UTIL_H_ | 6 #define NET_HTTP_HTTP_STREAM_FACTORY_TEST_UTIL_H_ |
7 | 7 |
8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #include "net/http/http_stream.h" | 9 #include "net/http/http_stream.h" |
10 #include "net/http/http_stream_factory.h" | 10 #include "net/http/http_stream_factory.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 DISALLOW_COPY_AND_ASSIGN(MockHttpStreamRequestDelegate); | 90 DISALLOW_COPY_AND_ASSIGN(MockHttpStreamRequestDelegate); |
91 }; | 91 }; |
92 | 92 |
93 class MockHttpStreamFactoryImplJob : public HttpStreamFactoryImpl::Job { | 93 class MockHttpStreamFactoryImplJob : public HttpStreamFactoryImpl::Job { |
94 public: | 94 public: |
95 MockHttpStreamFactoryImplJob(HttpStreamFactoryImpl::Job::Delegate* delegate, | 95 MockHttpStreamFactoryImplJob(HttpStreamFactoryImpl::Job::Delegate* delegate, |
96 HttpStreamFactoryImpl::JobType job_type, | 96 HttpStreamFactoryImpl::JobType job_type, |
97 HttpNetworkSession* session, | 97 HttpNetworkSession* session, |
98 const HttpRequestInfo& request_info, | 98 const HttpRequestInfo& request_info, |
99 RequestPriority priority, | 99 RequestPriority priority, |
| 100 ProxyInfo proxy_info, |
100 const SSLConfig& server_ssl_config, | 101 const SSLConfig& server_ssl_config, |
101 const SSLConfig& proxy_ssl_config, | 102 const SSLConfig& proxy_ssl_config, |
102 HostPortPair destination, | 103 HostPortPair destination, |
103 GURL origin_url, | 104 GURL origin_url, |
104 bool enable_ip_based_pooling, | 105 bool enable_ip_based_pooling, |
105 NetLog* net_log); | 106 NetLog* net_log); |
106 | 107 |
107 MockHttpStreamFactoryImplJob(HttpStreamFactoryImpl::Job::Delegate* delegate, | 108 MockHttpStreamFactoryImplJob(HttpStreamFactoryImpl::Job::Delegate* delegate, |
108 HttpStreamFactoryImpl::JobType job_type, | 109 HttpStreamFactoryImpl::JobType job_type, |
109 HttpNetworkSession* session, | 110 HttpNetworkSession* session, |
110 const HttpRequestInfo& request_info, | 111 const HttpRequestInfo& request_info, |
111 RequestPriority priority, | 112 RequestPriority priority, |
| 113 ProxyInfo proxy_info, |
112 const SSLConfig& server_ssl_config, | 114 const SSLConfig& server_ssl_config, |
113 const SSLConfig& proxy_ssl_config, | 115 const SSLConfig& proxy_ssl_config, |
114 HostPortPair destination, | 116 HostPortPair destination, |
115 GURL origin_url, | 117 GURL origin_url, |
116 AlternativeService alternative_service, | 118 AlternativeService alternative_service, |
117 const ProxyServer& alternative_proxy_server, | 119 const ProxyServer& alternative_proxy_server, |
118 bool enable_ip_based_pooling, | 120 bool enable_ip_based_pooling, |
119 NetLog* net_log); | 121 NetLog* net_log); |
120 | 122 |
121 ~MockHttpStreamFactoryImplJob() override; | 123 ~MockHttpStreamFactoryImplJob() override; |
122 | 124 |
123 MOCK_METHOD0(Resume, void()); | 125 MOCK_METHOD0(Resume, void()); |
124 | 126 |
125 MOCK_METHOD0(Orphan, void()); | 127 MOCK_METHOD0(Orphan, void()); |
126 }; | 128 }; |
127 | 129 |
128 // JobFactory for creating MockHttpStreamFactoryImplJobs. | 130 // JobFactory for creating MockHttpStreamFactoryImplJobs. |
129 class TestJobFactory : public HttpStreamFactoryImpl::JobFactory { | 131 class TestJobFactory : public HttpStreamFactoryImpl::JobFactory { |
130 public: | 132 public: |
131 TestJobFactory(); | 133 TestJobFactory(); |
132 ~TestJobFactory() override; | 134 ~TestJobFactory() override; |
133 | 135 |
134 HttpStreamFactoryImpl::Job* CreateJob( | 136 HttpStreamFactoryImpl::Job* CreateMainJob( |
135 HttpStreamFactoryImpl::Job::Delegate* delegate, | 137 HttpStreamFactoryImpl::Job::Delegate* delegate, |
136 HttpStreamFactoryImpl::JobType job_type, | 138 HttpStreamFactoryImpl::JobType job_type, |
137 HttpNetworkSession* session, | 139 HttpNetworkSession* session, |
138 const HttpRequestInfo& request_info, | 140 const HttpRequestInfo& request_info, |
139 RequestPriority priority, | 141 RequestPriority priority, |
| 142 const ProxyInfo& proxy_info, |
140 const SSLConfig& server_ssl_config, | 143 const SSLConfig& server_ssl_config, |
141 const SSLConfig& proxy_ssl_config, | 144 const SSLConfig& proxy_ssl_config, |
142 HostPortPair destination, | 145 HostPortPair destination, |
143 GURL origin_url, | 146 GURL origin_url, |
144 bool enable_ip_based_pooling, | 147 bool enable_ip_based_pooling, |
145 NetLog* net_log) override; | 148 NetLog* net_log) override; |
146 | 149 |
147 HttpStreamFactoryImpl::Job* CreateJob( | 150 HttpStreamFactoryImpl::Job* CreateAltSvcJob( |
148 HttpStreamFactoryImpl::Job::Delegate* delegate, | 151 HttpStreamFactoryImpl::Job::Delegate* delegate, |
149 HttpStreamFactoryImpl::JobType job_type, | 152 HttpStreamFactoryImpl::JobType job_type, |
150 HttpNetworkSession* session, | 153 HttpNetworkSession* session, |
151 const HttpRequestInfo& request_info, | 154 const HttpRequestInfo& request_info, |
152 RequestPriority priority, | 155 RequestPriority priority, |
| 156 const ProxyInfo& proxy_info, |
153 const SSLConfig& server_ssl_config, | 157 const SSLConfig& server_ssl_config, |
154 const SSLConfig& proxy_ssl_config, | 158 const SSLConfig& proxy_ssl_config, |
155 HostPortPair destination, | 159 HostPortPair destination, |
156 GURL origin_url, | 160 GURL origin_url, |
157 AlternativeService alternative_service, | 161 AlternativeService alternative_service, |
158 bool enable_ip_based_pooling, | 162 bool enable_ip_based_pooling, |
159 NetLog* net_log) override; | 163 NetLog* net_log) override; |
160 | 164 |
161 HttpStreamFactoryImpl::Job* CreateJob( | 165 HttpStreamFactoryImpl::Job* CreateAltProxyJob( |
162 HttpStreamFactoryImpl::Job::Delegate* delegate, | 166 HttpStreamFactoryImpl::Job::Delegate* delegate, |
163 HttpStreamFactoryImpl::JobType job_type, | 167 HttpStreamFactoryImpl::JobType job_type, |
164 HttpNetworkSession* session, | 168 HttpNetworkSession* session, |
165 const HttpRequestInfo& request_info, | 169 const HttpRequestInfo& request_info, |
166 RequestPriority priority, | 170 RequestPriority priority, |
| 171 const ProxyInfo& proxy_info, |
167 const SSLConfig& server_ssl_config, | 172 const SSLConfig& server_ssl_config, |
168 const SSLConfig& proxy_ssl_config, | 173 const SSLConfig& proxy_ssl_config, |
169 HostPortPair destination, | 174 HostPortPair destination, |
170 GURL origin_url, | 175 GURL origin_url, |
171 const ProxyServer& alternative_proxy_server, | 176 const ProxyServer& alternative_proxy_server, |
172 bool enable_ip_based_pooling, | 177 bool enable_ip_based_pooling, |
173 NetLog* net_log) override; | 178 NetLog* net_log) override; |
174 | 179 |
175 MockHttpStreamFactoryImplJob* main_job() const { return main_job_; } | 180 MockHttpStreamFactoryImplJob* main_job() const { return main_job_; } |
176 MockHttpStreamFactoryImplJob* alternative_job() const { | 181 MockHttpStreamFactoryImplJob* alternative_job() const { |
177 return alternative_job_; | 182 return alternative_job_; |
178 } | 183 } |
179 | 184 |
180 void UseDifferentURLForMainJob(GURL url) { | 185 void UseDifferentURLForMainJob(GURL url) { |
181 override_main_job_url_ = true; | 186 override_main_job_url_ = true; |
182 main_job_alternative_url_ = url; | 187 main_job_alternative_url_ = url; |
183 } | 188 } |
184 | 189 |
185 private: | 190 private: |
186 MockHttpStreamFactoryImplJob* main_job_; | 191 MockHttpStreamFactoryImplJob* main_job_; |
187 MockHttpStreamFactoryImplJob* alternative_job_; | 192 MockHttpStreamFactoryImplJob* alternative_job_; |
188 bool override_main_job_url_; | 193 bool override_main_job_url_; |
189 GURL main_job_alternative_url_; | 194 GURL main_job_alternative_url_; |
190 }; | 195 }; |
191 | 196 |
192 } // namespace net | 197 } // namespace net |
193 | 198 |
194 #endif // NET_HTTP_HTTP_STREAM_FACTORY_TEST_UTIL_H_ | 199 #endif // NET_HTTP_HTTP_STREAM_FACTORY_TEST_UTIL_H_ |
OLD | NEW |