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> |
| 8 |
7 #include "net/proxy/proxy_info.h" | 9 #include "net/proxy/proxy_info.h" |
8 | 10 |
9 using ::testing::_; | 11 using ::testing::_; |
10 | 12 |
11 namespace net { | 13 namespace net { |
12 MockHttpStreamRequestDelegate::MockHttpStreamRequestDelegate() {} | 14 MockHttpStreamRequestDelegate::MockHttpStreamRequestDelegate() {} |
13 | 15 |
14 MockHttpStreamRequestDelegate::~MockHttpStreamRequestDelegate() {} | 16 MockHttpStreamRequestDelegate::~MockHttpStreamRequestDelegate() {} |
15 | 17 |
16 MockHttpStreamFactoryImplJob::MockHttpStreamFactoryImplJob( | 18 MockHttpStreamFactoryImplJob::MockHttpStreamFactoryImplJob( |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 | 75 |
74 MockHttpStreamFactoryImplJob::~MockHttpStreamFactoryImplJob() {} | 76 MockHttpStreamFactoryImplJob::~MockHttpStreamFactoryImplJob() {} |
75 | 77 |
76 TestJobFactory::TestJobFactory() | 78 TestJobFactory::TestJobFactory() |
77 : main_job_(nullptr), | 79 : main_job_(nullptr), |
78 alternative_job_(nullptr), | 80 alternative_job_(nullptr), |
79 override_main_job_url_(false) {} | 81 override_main_job_url_(false) {} |
80 | 82 |
81 TestJobFactory::~TestJobFactory() {} | 83 TestJobFactory::~TestJobFactory() {} |
82 | 84 |
83 HttpStreamFactoryImpl::Job* TestJobFactory::CreateMainJob( | 85 std::unique_ptr<HttpStreamFactoryImpl::Job> TestJobFactory::CreateMainJob( |
84 HttpStreamFactoryImpl::Job::Delegate* delegate, | 86 HttpStreamFactoryImpl::Job::Delegate* delegate, |
85 HttpStreamFactoryImpl::JobType job_type, | 87 HttpStreamFactoryImpl::JobType job_type, |
86 HttpNetworkSession* session, | 88 HttpNetworkSession* session, |
87 const HttpRequestInfo& request_info, | 89 const HttpRequestInfo& request_info, |
88 RequestPriority priority, | 90 RequestPriority priority, |
89 const ProxyInfo& proxy_info, | 91 const ProxyInfo& proxy_info, |
90 const SSLConfig& server_ssl_config, | 92 const SSLConfig& server_ssl_config, |
91 const SSLConfig& proxy_ssl_config, | 93 const SSLConfig& proxy_ssl_config, |
92 HostPortPair destination, | 94 HostPortPair destination, |
93 GURL origin_url, | 95 GURL origin_url, |
94 bool enable_ip_based_pooling, | 96 bool enable_ip_based_pooling, |
95 NetLog* net_log) { | 97 NetLog* net_log) { |
96 if (override_main_job_url_) | 98 if (override_main_job_url_) |
97 origin_url = main_job_alternative_url_; | 99 origin_url = main_job_alternative_url_; |
98 | 100 |
99 main_job_ = new MockHttpStreamFactoryImplJob( | 101 auto main_job = base::MakeUnique<MockHttpStreamFactoryImplJob>( |
100 delegate, job_type, session, request_info, priority, proxy_info, | 102 delegate, job_type, session, request_info, priority, proxy_info, |
101 SSLConfig(), SSLConfig(), destination, origin_url, | 103 SSLConfig(), SSLConfig(), destination, origin_url, |
102 enable_ip_based_pooling, nullptr); | 104 enable_ip_based_pooling, nullptr); |
103 | 105 |
104 return main_job_; | 106 // Keep raw pointer to Job but pass ownership. |
| 107 main_job_ = main_job.get(); |
| 108 |
| 109 return std::move(main_job); |
105 } | 110 } |
106 | 111 |
107 HttpStreamFactoryImpl::Job* TestJobFactory::CreateAltSvcJob( | 112 std::unique_ptr<HttpStreamFactoryImpl::Job> TestJobFactory::CreateAltSvcJob( |
108 HttpStreamFactoryImpl::Job::Delegate* delegate, | 113 HttpStreamFactoryImpl::Job::Delegate* delegate, |
109 HttpStreamFactoryImpl::JobType job_type, | 114 HttpStreamFactoryImpl::JobType job_type, |
110 HttpNetworkSession* session, | 115 HttpNetworkSession* session, |
111 const HttpRequestInfo& request_info, | 116 const HttpRequestInfo& request_info, |
112 RequestPriority priority, | 117 RequestPriority priority, |
113 const ProxyInfo& proxy_info, | 118 const ProxyInfo& proxy_info, |
114 const SSLConfig& server_ssl_config, | 119 const SSLConfig& server_ssl_config, |
115 const SSLConfig& proxy_ssl_config, | 120 const SSLConfig& proxy_ssl_config, |
116 HostPortPair destination, | 121 HostPortPair destination, |
117 GURL origin_url, | 122 GURL origin_url, |
118 AlternativeService alternative_service, | 123 AlternativeService alternative_service, |
119 bool enable_ip_based_pooling, | 124 bool enable_ip_based_pooling, |
120 NetLog* net_log) { | 125 NetLog* net_log) { |
121 alternative_job_ = new MockHttpStreamFactoryImplJob( | 126 auto alternative_job = base::MakeUnique<MockHttpStreamFactoryImplJob>( |
122 delegate, job_type, session, request_info, priority, proxy_info, | 127 delegate, job_type, session, request_info, priority, proxy_info, |
123 SSLConfig(), SSLConfig(), destination, origin_url, alternative_service, | 128 SSLConfig(), SSLConfig(), destination, origin_url, alternative_service, |
124 ProxyServer(), enable_ip_based_pooling, nullptr); | 129 ProxyServer(), enable_ip_based_pooling, nullptr); |
125 | 130 |
126 return alternative_job_; | 131 // Keep raw pointer to Job but pass ownership. |
| 132 alternative_job_ = alternative_job.get(); |
| 133 |
| 134 return std::move(alternative_job); |
127 } | 135 } |
128 | 136 |
129 HttpStreamFactoryImpl::Job* TestJobFactory::CreateAltProxyJob( | 137 std::unique_ptr<HttpStreamFactoryImpl::Job> TestJobFactory::CreateAltProxyJob( |
130 HttpStreamFactoryImpl::Job::Delegate* delegate, | 138 HttpStreamFactoryImpl::Job::Delegate* delegate, |
131 HttpStreamFactoryImpl::JobType job_type, | 139 HttpStreamFactoryImpl::JobType job_type, |
132 HttpNetworkSession* session, | 140 HttpNetworkSession* session, |
133 const HttpRequestInfo& request_info, | 141 const HttpRequestInfo& request_info, |
134 RequestPriority priority, | 142 RequestPriority priority, |
135 const ProxyInfo& proxy_info, | 143 const ProxyInfo& proxy_info, |
136 const SSLConfig& server_ssl_config, | 144 const SSLConfig& server_ssl_config, |
137 const SSLConfig& proxy_ssl_config, | 145 const SSLConfig& proxy_ssl_config, |
138 HostPortPair destination, | 146 HostPortPair destination, |
139 GURL origin_url, | 147 GURL origin_url, |
140 const ProxyServer& alternative_proxy_server, | 148 const ProxyServer& alternative_proxy_server, |
141 bool enable_ip_based_pooling, | 149 bool enable_ip_based_pooling, |
142 NetLog* net_log) { | 150 NetLog* net_log) { |
143 alternative_job_ = new MockHttpStreamFactoryImplJob( | 151 auto alternative_job = base::MakeUnique<MockHttpStreamFactoryImplJob>( |
144 delegate, job_type, session, request_info, priority, proxy_info, | 152 delegate, job_type, session, request_info, priority, proxy_info, |
145 SSLConfig(), SSLConfig(), destination, origin_url, AlternativeService(), | 153 SSLConfig(), SSLConfig(), destination, origin_url, AlternativeService(), |
146 alternative_proxy_server, enable_ip_based_pooling, nullptr); | 154 alternative_proxy_server, enable_ip_based_pooling, nullptr); |
147 | 155 |
148 return alternative_job_; | 156 // Keep raw pointer to Job but pass ownership. |
| 157 alternative_job_ = alternative_job.get(); |
| 158 |
| 159 return std::move(alternative_job); |
149 } | 160 } |
150 | 161 |
151 } // namespace net | 162 } // namespace net |
OLD | NEW |