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