| 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::CreateJob( |
| 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 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_); | 96 DCHECK(!main_job_); |
| 92 | 97 |
| 93 if (override_main_job_url_) | 98 if (override_main_job_url_) |
| 94 origin_url = main_job_alternative_url_; | 99 origin_url = main_job_alternative_url_; |
| 95 | 100 |
| 96 main_job_ = new MockHttpStreamFactoryImplJob( | 101 main_job_ = new MockHttpStreamFactoryImplJob( |
| 97 delegate, job_type, session, request_info, priority, SSLConfig(), | 102 delegate, job_type, session, request_info, priority, proxy_info, |
| 98 SSLConfig(), destination, origin_url, enable_ip_based_pooling, nullptr); | 103 SSLConfig(), SSLConfig(), destination, origin_url, |
| 104 enable_ip_based_pooling, nullptr); |
| 99 | 105 |
| 100 return main_job_; | 106 return main_job_; |
| 101 } | 107 } |
| 102 | 108 |
| 103 HttpStreamFactoryImpl::Job* TestJobFactory::CreateJob( | 109 HttpStreamFactoryImpl::Job* TestJobFactory::CreateJob( |
| 104 HttpStreamFactoryImpl::Job::Delegate* delegate, | 110 HttpStreamFactoryImpl::Job::Delegate* delegate, |
| 105 HttpStreamFactoryImpl::JobType job_type, | 111 HttpStreamFactoryImpl::JobType job_type, |
| 106 HttpNetworkSession* session, | 112 HttpNetworkSession* session, |
| 107 const HttpRequestInfo& request_info, | 113 const HttpRequestInfo& request_info, |
| 108 RequestPriority priority, | 114 RequestPriority priority, |
| 115 ProxyInfo proxy_info, |
| 109 const SSLConfig& server_ssl_config, | 116 const SSLConfig& server_ssl_config, |
| 110 const SSLConfig& proxy_ssl_config, | 117 const SSLConfig& proxy_ssl_config, |
| 111 HostPortPair destination, | 118 HostPortPair destination, |
| 112 GURL origin_url, | 119 GURL origin_url, |
| 113 AlternativeService alternative_service, | 120 AlternativeService alternative_service, |
| 114 bool enable_ip_based_pooling, | 121 bool enable_ip_based_pooling, |
| 115 NetLog* net_log) { | 122 NetLog* net_log) { |
| 116 DCHECK(!alternative_job_); | 123 DCHECK(!alternative_job_); |
| 117 alternative_job_ = new MockHttpStreamFactoryImplJob( | 124 alternative_job_ = new MockHttpStreamFactoryImplJob( |
| 118 delegate, job_type, session, request_info, priority, SSLConfig(), | 125 delegate, job_type, session, request_info, priority, proxy_info, |
| 119 SSLConfig(), destination, origin_url, alternative_service, ProxyServer(), | 126 SSLConfig(), SSLConfig(), destination, origin_url, alternative_service, |
| 120 enable_ip_based_pooling, nullptr); | 127 ProxyServer(), enable_ip_based_pooling, nullptr); |
| 121 | 128 |
| 122 return alternative_job_; | 129 return alternative_job_; |
| 123 } | 130 } |
| 124 | 131 |
| 125 HttpStreamFactoryImpl::Job* TestJobFactory::CreateJob( | 132 HttpStreamFactoryImpl::Job* TestJobFactory::CreateJob( |
| 126 HttpStreamFactoryImpl::Job::Delegate* delegate, | 133 HttpStreamFactoryImpl::Job::Delegate* delegate, |
| 127 HttpStreamFactoryImpl::JobType job_type, | 134 HttpStreamFactoryImpl::JobType job_type, |
| 128 HttpNetworkSession* session, | 135 HttpNetworkSession* session, |
| 129 const HttpRequestInfo& request_info, | 136 const HttpRequestInfo& request_info, |
| 130 RequestPriority priority, | 137 RequestPriority priority, |
| 138 ProxyInfo proxy_info, |
| 131 const SSLConfig& server_ssl_config, | 139 const SSLConfig& server_ssl_config, |
| 132 const SSLConfig& proxy_ssl_config, | 140 const SSLConfig& proxy_ssl_config, |
| 133 HostPortPair destination, | 141 HostPortPair destination, |
| 134 GURL origin_url, | 142 GURL origin_url, |
| 135 const ProxyServer& alternative_proxy_server, | 143 const ProxyServer& alternative_proxy_server, |
| 136 bool enable_ip_based_pooling, | 144 bool enable_ip_based_pooling, |
| 137 NetLog* net_log) { | 145 NetLog* net_log) { |
| 138 DCHECK(!alternative_job_); | 146 DCHECK(!alternative_job_); |
| 139 alternative_job_ = new MockHttpStreamFactoryImplJob( | 147 alternative_job_ = new MockHttpStreamFactoryImplJob( |
| 140 delegate, job_type, session, request_info, priority, SSLConfig(), | 148 delegate, job_type, session, request_info, priority, proxy_info, |
| 141 SSLConfig(), destination, origin_url, AlternativeService(), | 149 SSLConfig(), SSLConfig(), destination, origin_url, AlternativeService(), |
| 142 alternative_proxy_server, enable_ip_based_pooling, nullptr); | 150 alternative_proxy_server, enable_ip_based_pooling, nullptr); |
| 143 | 151 |
| 144 return alternative_job_; | 152 return alternative_job_; |
| 145 } | 153 } |
| 146 | 154 |
| 147 } // namespace net | 155 } // namespace net |
| OLD | NEW |