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