| 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 #include "net/http/http_stream_factory_test_util.h" | 5 #include "net/http/http_stream_factory_test_util.h" |
| 6 | 6 |
| 7 #include "net/proxy/proxy_info.h" | 7 #include "net/proxy/proxy_info.h" |
| 8 | 8 |
| 9 using ::testing::_; | 9 using ::testing::_; |
| 10 | 10 |
| 11 namespace net { | 11 namespace net { |
| 12 MockHttpStreamRequestDelegate::MockHttpStreamRequestDelegate() {} | 12 MockHttpStreamRequestDelegate::MockHttpStreamRequestDelegate() {} |
| 13 | 13 |
| 14 MockHttpStreamRequestDelegate::~MockHttpStreamRequestDelegate() {} | 14 MockHttpStreamRequestDelegate::~MockHttpStreamRequestDelegate() {} |
| 15 | 15 |
| 16 MockHttpStreamFactoryImplJob::MockHttpStreamFactoryImplJob( | 16 MockHttpStreamFactoryImplJob::MockHttpStreamFactoryImplJob( |
| 17 HttpStreamFactoryImpl::Job::Delegate* delegate, | 17 HttpStreamFactoryImpl::Job::Delegate* delegate, |
| 18 HttpStreamFactoryImpl::JobType job_type, | 18 HttpStreamFactoryImpl::JobType job_type, |
| 19 HttpNetworkSession* session, | 19 HttpNetworkSession* session, |
| 20 const HttpRequestInfo& request_info, | 20 const HttpRequestInfo& request_info, |
| 21 RequestPriority priority, | 21 RequestPriority priority, |
| 22 ProxyInfo proxy_info, |
| 22 const SSLConfig& server_ssl_config, | 23 const SSLConfig& server_ssl_config, |
| 23 const SSLConfig& proxy_ssl_config, | 24 const SSLConfig& proxy_ssl_config, |
| 24 HostPortPair destination, | 25 HostPortPair destination, |
| 25 GURL origin_url, | 26 GURL origin_url, |
| 26 bool enable_ip_based_pooling, | 27 bool enable_ip_based_pooling, |
| 27 NetLog* net_log) | 28 NetLog* net_log) |
| 28 : HttpStreamFactoryImpl::Job(delegate, | 29 : HttpStreamFactoryImpl::Job(delegate, |
| 29 job_type, | 30 job_type, |
| 30 session, | 31 session, |
| 31 request_info, | 32 request_info, |
| 32 priority, | 33 priority, |
| 34 proxy_info, |
| 33 server_ssl_config, | 35 server_ssl_config, |
| 34 proxy_ssl_config, | 36 proxy_ssl_config, |
| 35 destination, | 37 destination, |
| 36 origin_url, | 38 origin_url, |
| 37 enable_ip_based_pooling, | 39 enable_ip_based_pooling, |
| 38 net_log) { | 40 net_log) { |
| 39 DCHECK(!is_waiting()); | 41 DCHECK(!is_waiting()); |
| 40 } | 42 } |
| 41 | 43 |
| 42 MockHttpStreamFactoryImplJob::MockHttpStreamFactoryImplJob( | 44 MockHttpStreamFactoryImplJob::MockHttpStreamFactoryImplJob( |
| 43 HttpStreamFactoryImpl::Job::Delegate* delegate, | 45 HttpStreamFactoryImpl::Job::Delegate* delegate, |
| 44 HttpStreamFactoryImpl::JobType job_type, | 46 HttpStreamFactoryImpl::JobType job_type, |
| 45 HttpNetworkSession* session, | 47 HttpNetworkSession* session, |
| 46 const HttpRequestInfo& request_info, | 48 const HttpRequestInfo& request_info, |
| 47 RequestPriority priority, | 49 RequestPriority priority, |
| 50 ProxyInfo proxy_info, |
| 48 const SSLConfig& server_ssl_config, | 51 const SSLConfig& server_ssl_config, |
| 49 const SSLConfig& proxy_ssl_config, | 52 const SSLConfig& proxy_ssl_config, |
| 50 HostPortPair destination, | 53 HostPortPair destination, |
| 51 GURL origin_url, | 54 GURL origin_url, |
| 52 AlternativeService alternative_service, | 55 AlternativeService alternative_service, |
| 53 const ProxyServer& alternative_proxy_server, | 56 const ProxyServer& alternative_proxy_server, |
| 54 bool enable_ip_based_pooling, | 57 bool enable_ip_based_pooling, |
| 55 NetLog* net_log) | 58 NetLog* net_log) |
| 56 : HttpStreamFactoryImpl::Job(delegate, | 59 : HttpStreamFactoryImpl::Job(delegate, |
| 57 job_type, | 60 job_type, |
| 58 session, | 61 session, |
| 59 request_info, | 62 request_info, |
| 60 priority, | 63 priority, |
| 64 proxy_info, |
| 61 server_ssl_config, | 65 server_ssl_config, |
| 62 proxy_ssl_config, | 66 proxy_ssl_config, |
| 63 destination, | 67 destination, |
| 64 origin_url, | 68 origin_url, |
| 65 alternative_service, | 69 alternative_service, |
| 66 alternative_proxy_server, | 70 alternative_proxy_server, |
| 67 enable_ip_based_pooling, | 71 enable_ip_based_pooling, |
| 68 net_log) {} | 72 net_log) {} |
| 69 | 73 |
| 70 MockHttpStreamFactoryImplJob::~MockHttpStreamFactoryImplJob() {} | 74 MockHttpStreamFactoryImplJob::~MockHttpStreamFactoryImplJob() {} |
| 71 | 75 |
| 72 TestJobFactory::TestJobFactory() | 76 TestJobFactory::TestJobFactory() |
| 73 : main_job_(nullptr), | 77 : main_job_(nullptr), |
| 74 alternative_job_(nullptr), | 78 alternative_job_(nullptr), |
| 75 override_main_job_url_(false) {} | 79 override_main_job_url_(false) {} |
| 76 | 80 |
| 77 TestJobFactory::~TestJobFactory() {} | 81 TestJobFactory::~TestJobFactory() {} |
| 78 | 82 |
| 79 HttpStreamFactoryImpl::Job* TestJobFactory::CreateJob( | 83 HttpStreamFactoryImpl::Job* TestJobFactory::CreateMainJob( |
| 80 HttpStreamFactoryImpl::Job::Delegate* delegate, | 84 HttpStreamFactoryImpl::Job::Delegate* delegate, |
| 81 HttpStreamFactoryImpl::JobType job_type, | 85 HttpStreamFactoryImpl::JobType job_type, |
| 82 HttpNetworkSession* session, | 86 HttpNetworkSession* session, |
| 83 const HttpRequestInfo& request_info, | 87 const HttpRequestInfo& request_info, |
| 84 RequestPriority priority, | 88 RequestPriority priority, |
| 89 const ProxyInfo& proxy_info, |
| 85 const SSLConfig& server_ssl_config, | 90 const SSLConfig& server_ssl_config, |
| 86 const SSLConfig& proxy_ssl_config, | 91 const SSLConfig& proxy_ssl_config, |
| 87 HostPortPair destination, | 92 HostPortPair destination, |
| 88 GURL origin_url, | 93 GURL origin_url, |
| 89 bool enable_ip_based_pooling, | 94 bool enable_ip_based_pooling, |
| 90 NetLog* net_log) { | 95 NetLog* net_log) { |
| 91 DCHECK(!main_job_); | |
| 92 | |
| 93 if (override_main_job_url_) | 96 if (override_main_job_url_) |
| 94 origin_url = main_job_alternative_url_; | 97 origin_url = main_job_alternative_url_; |
| 95 | 98 |
| 96 main_job_ = new MockHttpStreamFactoryImplJob( | 99 main_job_ = new MockHttpStreamFactoryImplJob( |
| 97 delegate, job_type, session, request_info, priority, SSLConfig(), | 100 delegate, job_type, session, request_info, priority, proxy_info, |
| 98 SSLConfig(), destination, origin_url, enable_ip_based_pooling, nullptr); | 101 SSLConfig(), SSLConfig(), destination, origin_url, |
| 102 enable_ip_based_pooling, nullptr); |
| 99 | 103 |
| 100 return main_job_; | 104 return main_job_; |
| 101 } | 105 } |
| 102 | 106 |
| 103 HttpStreamFactoryImpl::Job* TestJobFactory::CreateJob( | 107 HttpStreamFactoryImpl::Job* TestJobFactory::CreateAltSvcJob( |
| 104 HttpStreamFactoryImpl::Job::Delegate* delegate, | 108 HttpStreamFactoryImpl::Job::Delegate* delegate, |
| 105 HttpStreamFactoryImpl::JobType job_type, | 109 HttpStreamFactoryImpl::JobType job_type, |
| 106 HttpNetworkSession* session, | 110 HttpNetworkSession* session, |
| 107 const HttpRequestInfo& request_info, | 111 const HttpRequestInfo& request_info, |
| 108 RequestPriority priority, | 112 RequestPriority priority, |
| 113 const ProxyInfo& proxy_info, |
| 109 const SSLConfig& server_ssl_config, | 114 const SSLConfig& server_ssl_config, |
| 110 const SSLConfig& proxy_ssl_config, | 115 const SSLConfig& proxy_ssl_config, |
| 111 HostPortPair destination, | 116 HostPortPair destination, |
| 112 GURL origin_url, | 117 GURL origin_url, |
| 113 AlternativeService alternative_service, | 118 AlternativeService alternative_service, |
| 114 bool enable_ip_based_pooling, | 119 bool enable_ip_based_pooling, |
| 115 NetLog* net_log) { | 120 NetLog* net_log) { |
| 116 DCHECK(!alternative_job_); | |
| 117 alternative_job_ = new MockHttpStreamFactoryImplJob( | 121 alternative_job_ = new MockHttpStreamFactoryImplJob( |
| 118 delegate, job_type, session, request_info, priority, SSLConfig(), | 122 delegate, job_type, session, request_info, priority, proxy_info, |
| 119 SSLConfig(), destination, origin_url, alternative_service, ProxyServer(), | 123 SSLConfig(), SSLConfig(), destination, origin_url, alternative_service, |
| 120 enable_ip_based_pooling, nullptr); | 124 ProxyServer(), enable_ip_based_pooling, nullptr); |
| 121 | 125 |
| 122 return alternative_job_; | 126 return alternative_job_; |
| 123 } | 127 } |
| 124 | 128 |
| 125 HttpStreamFactoryImpl::Job* TestJobFactory::CreateJob( | 129 HttpStreamFactoryImpl::Job* TestJobFactory::CreateAltProxyJob( |
| 126 HttpStreamFactoryImpl::Job::Delegate* delegate, | 130 HttpStreamFactoryImpl::Job::Delegate* delegate, |
| 127 HttpStreamFactoryImpl::JobType job_type, | 131 HttpStreamFactoryImpl::JobType job_type, |
| 128 HttpNetworkSession* session, | 132 HttpNetworkSession* session, |
| 129 const HttpRequestInfo& request_info, | 133 const HttpRequestInfo& request_info, |
| 130 RequestPriority priority, | 134 RequestPriority priority, |
| 135 const ProxyInfo& proxy_info, |
| 131 const SSLConfig& server_ssl_config, | 136 const SSLConfig& server_ssl_config, |
| 132 const SSLConfig& proxy_ssl_config, | 137 const SSLConfig& proxy_ssl_config, |
| 133 HostPortPair destination, | 138 HostPortPair destination, |
| 134 GURL origin_url, | 139 GURL origin_url, |
| 135 const ProxyServer& alternative_proxy_server, | 140 const ProxyServer& alternative_proxy_server, |
| 136 bool enable_ip_based_pooling, | 141 bool enable_ip_based_pooling, |
| 137 NetLog* net_log) { | 142 NetLog* net_log) { |
| 138 DCHECK(!alternative_job_); | |
| 139 alternative_job_ = new MockHttpStreamFactoryImplJob( | 143 alternative_job_ = new MockHttpStreamFactoryImplJob( |
| 140 delegate, job_type, session, request_info, priority, SSLConfig(), | 144 delegate, job_type, session, request_info, priority, proxy_info, |
| 141 SSLConfig(), destination, origin_url, AlternativeService(), | 145 SSLConfig(), SSLConfig(), destination, origin_url, AlternativeService(), |
| 142 alternative_proxy_server, enable_ip_based_pooling, nullptr); | 146 alternative_proxy_server, enable_ip_based_pooling, nullptr); |
| 143 | 147 |
| 144 return alternative_job_; | 148 return alternative_job_; |
| 145 } | 149 } |
| 146 | 150 |
| 147 } // namespace net | 151 } // namespace net |
| OLD | NEW |