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