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