| 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_impl_job_controller.h" | 5 #include "net/http/http_stream_factory_impl_job_controller.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 | 135 |
| 136 if (use_alternative_proxy) { | 136 if (use_alternative_proxy) { |
| 137 std::unique_ptr<ProxyService> proxy_service = | 137 std::unique_ptr<ProxyService> proxy_service = |
| 138 ProxyService::CreateFixedFromPacResult("HTTPS myproxy.org:443"); | 138 ProxyService::CreateFixedFromPacResult("HTTPS myproxy.org:443"); |
| 139 session_deps_.proxy_service = std::move(proxy_service); | 139 session_deps_.proxy_service = std::move(proxy_service); |
| 140 } | 140 } |
| 141 session_ = SpdySessionDependencies::SpdyCreateSession(&session_deps_); | 141 session_ = SpdySessionDependencies::SpdyCreateSession(&session_deps_); |
| 142 factory_ = | 142 factory_ = |
| 143 static_cast<HttpStreamFactoryImpl*>(session_->http_stream_factory()); | 143 static_cast<HttpStreamFactoryImpl*>(session_->http_stream_factory()); |
| 144 job_controller_ = new HttpStreamFactoryImpl::JobController( | 144 job_controller_ = new HttpStreamFactoryImpl::JobController( |
| 145 factory_, &request_delegate_, session_.get(), &job_factory_); | 145 factory_, &request_delegate_, session_.get(), &job_factory_, |
| 146 /*is_preconnect=*/false, net_log_); |
| 146 HttpStreamFactoryImplPeer::AddJobController(factory_, job_controller_); | 147 HttpStreamFactoryImplPeer::AddJobController(factory_, job_controller_); |
| 147 } | 148 } |
| 148 | 149 |
| 149 TestProxyDelegate* test_proxy_delegate() const { | 150 TestProxyDelegate* test_proxy_delegate() const { |
| 150 return test_proxy_delegate_; | 151 return test_proxy_delegate_; |
| 151 } | 152 } |
| 152 | 153 |
| 153 ~HttpStreamFactoryImplJobControllerTest() {} | 154 ~HttpStreamFactoryImplJobControllerTest() {} |
| 154 | 155 |
| 155 void SetAlternativeService(const HttpRequestInfo& request_info, | 156 void SetAlternativeService(const HttpRequestInfo& request_info, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 174 | 175 |
| 175 // Not owned by |this|. | 176 // Not owned by |this|. |
| 176 TestProxyDelegate* test_proxy_delegate_; | 177 TestProxyDelegate* test_proxy_delegate_; |
| 177 TestJobFactory job_factory_; | 178 TestJobFactory job_factory_; |
| 178 MockHttpStreamRequestDelegate request_delegate_; | 179 MockHttpStreamRequestDelegate request_delegate_; |
| 179 SpdySessionDependencies session_deps_; | 180 SpdySessionDependencies session_deps_; |
| 180 std::unique_ptr<HttpNetworkSession> session_; | 181 std::unique_ptr<HttpNetworkSession> session_; |
| 181 HttpStreamFactoryImpl* factory_; | 182 HttpStreamFactoryImpl* factory_; |
| 182 HttpStreamFactoryImpl::JobController* job_controller_; | 183 HttpStreamFactoryImpl::JobController* job_controller_; |
| 183 std::unique_ptr<HttpStreamFactoryImpl::Request> request_; | 184 std::unique_ptr<HttpStreamFactoryImpl::Request> request_; |
| 185 const NetLogWithSource net_log_; |
| 184 | 186 |
| 185 DISALLOW_COPY_AND_ASSIGN(HttpStreamFactoryImplJobControllerTest); | 187 DISALLOW_COPY_AND_ASSIGN(HttpStreamFactoryImplJobControllerTest); |
| 186 }; | 188 }; |
| 187 | 189 |
| 188 TEST_F(HttpStreamFactoryImplJobControllerTest, | 190 TEST_F(HttpStreamFactoryImplJobControllerTest, |
| 189 OnStreamFailedWithNoAlternativeJob) { | 191 OnStreamFailedWithNoAlternativeJob) { |
| 190 ProxyConfig proxy_config; | 192 ProxyConfig proxy_config; |
| 191 proxy_config.set_auto_detect(true); | 193 proxy_config.set_auto_detect(true); |
| 192 // Use asynchronous proxy resolver. | 194 // Use asynchronous proxy resolver. |
| 193 MockAsyncProxyResolverFactory* proxy_resolver_factory = | 195 MockAsyncProxyResolverFactory* proxy_resolver_factory = |
| 194 new MockAsyncProxyResolverFactory(false); | 196 new MockAsyncProxyResolverFactory(false); |
| 195 session_deps_.proxy_service.reset( | 197 session_deps_.proxy_service.reset( |
| 196 new ProxyService(base::MakeUnique<ProxyConfigServiceFixed>(proxy_config), | 198 new ProxyService(base::MakeUnique<ProxyConfigServiceFixed>(proxy_config), |
| 197 base::WrapUnique(proxy_resolver_factory), nullptr)); | 199 base::WrapUnique(proxy_resolver_factory), nullptr)); |
| 198 Initialize(false); | 200 Initialize(false); |
| 199 | 201 |
| 200 HttpRequestInfo request_info; | 202 HttpRequestInfo request_info; |
| 201 request_info.method = "GET"; | 203 request_info.method = "GET"; |
| 202 request_info.url = GURL("http://www.google.com"); | 204 request_info.url = GURL("http://www.google.com"); |
| 203 | 205 |
| 204 request_.reset( | 206 request_.reset(job_controller_->Start( |
| 205 job_controller_->Start(request_info, &request_delegate_, nullptr, | 207 request_info, &request_delegate_, nullptr, HttpStreamRequest::HTTP_STREAM, |
| 206 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, | 208 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); |
| 207 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); | |
| 208 | 209 |
| 209 EXPECT_TRUE(job_controller_->main_job()); | 210 EXPECT_TRUE(job_controller_->main_job()); |
| 210 | 211 |
| 211 // There's no other alternative job. Thus when stream failed, it should | 212 // There's no other alternative job. Thus when stream failed, it should |
| 212 // notify Request of the stream failure. | 213 // notify Request of the stream failure. |
| 213 EXPECT_CALL(request_delegate_, OnStreamFailed(ERR_FAILED, _)).Times(1); | 214 EXPECT_CALL(request_delegate_, OnStreamFailed(ERR_FAILED, _)).Times(1); |
| 214 job_controller_->OnStreamFailed(job_factory_.main_job(), ERR_FAILED, | 215 job_controller_->OnStreamFailed(job_factory_.main_job(), ERR_FAILED, |
| 215 SSLConfig()); | 216 SSLConfig()); |
| 216 } | 217 } |
| 217 | 218 |
| 218 TEST_F(HttpStreamFactoryImplJobControllerTest, | 219 TEST_F(HttpStreamFactoryImplJobControllerTest, |
| 219 OnStreamReadyWithNoAlternativeJob) { | 220 OnStreamReadyWithNoAlternativeJob) { |
| 220 ProxyConfig proxy_config; | 221 ProxyConfig proxy_config; |
| 221 proxy_config.set_auto_detect(true); | 222 proxy_config.set_auto_detect(true); |
| 222 // Use asynchronous proxy resolver. | 223 // Use asynchronous proxy resolver. |
| 223 MockAsyncProxyResolverFactory* proxy_resolver_factory = | 224 MockAsyncProxyResolverFactory* proxy_resolver_factory = |
| 224 new MockAsyncProxyResolverFactory(false); | 225 new MockAsyncProxyResolverFactory(false); |
| 225 session_deps_.proxy_service.reset( | 226 session_deps_.proxy_service.reset( |
| 226 new ProxyService(base::MakeUnique<ProxyConfigServiceFixed>(proxy_config), | 227 new ProxyService(base::MakeUnique<ProxyConfigServiceFixed>(proxy_config), |
| 227 base::WrapUnique(proxy_resolver_factory), nullptr)); | 228 base::WrapUnique(proxy_resolver_factory), nullptr)); |
| 228 Initialize(false); | 229 Initialize(false); |
| 229 | 230 |
| 230 HttpRequestInfo request_info; | 231 HttpRequestInfo request_info; |
| 231 request_info.method = "GET"; | 232 request_info.method = "GET"; |
| 232 request_info.url = GURL("http://www.google.com"); | 233 request_info.url = GURL("http://www.google.com"); |
| 233 | 234 |
| 234 request_.reset( | 235 request_.reset(job_controller_->Start( |
| 235 job_controller_->Start(request_info, &request_delegate_, nullptr, | 236 request_info, &request_delegate_, nullptr, HttpStreamRequest::HTTP_STREAM, |
| 236 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, | 237 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); |
| 237 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); | |
| 238 | 238 |
| 239 // There's no other alternative job. Thus when a stream is ready, it should | 239 // There's no other alternative job. Thus when a stream is ready, it should |
| 240 // notify Request. | 240 // notify Request. |
| 241 HttpStream* http_stream = | 241 HttpStream* http_stream = |
| 242 new HttpBasicStream(base::MakeUnique<ClientSocketHandle>(), false, false); | 242 new HttpBasicStream(base::MakeUnique<ClientSocketHandle>(), false, false); |
| 243 job_factory_.main_job()->SetStream(http_stream); | 243 job_factory_.main_job()->SetStream(http_stream); |
| 244 | 244 |
| 245 EXPECT_CALL(request_delegate_, OnStreamReady(_, _, http_stream)) | 245 EXPECT_CALL(request_delegate_, OnStreamReady(_, _, http_stream)) |
| 246 .WillOnce(Invoke(DeleteHttpStreamPointer)); | 246 .WillOnce(Invoke(DeleteHttpStreamPointer)); |
| 247 job_controller_->OnStreamReady(job_factory_.main_job(), SSLConfig()); | 247 job_controller_->OnStreamReady(job_factory_.main_job(), SSLConfig()); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 261 Initialize(false); | 261 Initialize(false); |
| 262 | 262 |
| 263 HttpRequestInfo request_info; | 263 HttpRequestInfo request_info; |
| 264 request_info.method = "GET"; | 264 request_info.method = "GET"; |
| 265 request_info.url = GURL("https://www.google.com"); | 265 request_info.url = GURL("https://www.google.com"); |
| 266 | 266 |
| 267 url::SchemeHostPort server(request_info.url); | 267 url::SchemeHostPort server(request_info.url); |
| 268 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); | 268 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); |
| 269 SetAlternativeService(request_info, alternative_service); | 269 SetAlternativeService(request_info, alternative_service); |
| 270 | 270 |
| 271 request_.reset( | 271 request_.reset(job_controller_->Start( |
| 272 job_controller_->Start(request_info, &request_delegate_, nullptr, | 272 request_info, &request_delegate_, nullptr, HttpStreamRequest::HTTP_STREAM, |
| 273 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, | 273 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); |
| 274 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); | |
| 275 EXPECT_TRUE(job_controller_->main_job()); | 274 EXPECT_TRUE(job_controller_->main_job()); |
| 276 EXPECT_TRUE(job_controller_->alternative_job()); | 275 EXPECT_TRUE(job_controller_->alternative_job()); |
| 277 | 276 |
| 278 // Reset the Request will cancel all the Jobs since there's no Job determined | 277 // Reset the Request will cancel all the Jobs since there's no Job determined |
| 279 // to serve Request yet and JobController will notify the factory to delete | 278 // to serve Request yet and JobController will notify the factory to delete |
| 280 // itself upon completion. | 279 // itself upon completion. |
| 281 request_.reset(); | 280 request_.reset(); |
| 282 VerifyBrokenAlternateProtocolMapping(request_info, false); | 281 VerifyBrokenAlternateProtocolMapping(request_info, false); |
| 283 EXPECT_TRUE(HttpStreamFactoryImplPeer::IsJobControllerDeleted(factory_)); | 282 EXPECT_TRUE(HttpStreamFactoryImplPeer::IsJobControllerDeleted(factory_)); |
| 284 } | 283 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 295 Initialize(false); | 294 Initialize(false); |
| 296 | 295 |
| 297 HttpRequestInfo request_info; | 296 HttpRequestInfo request_info; |
| 298 request_info.method = "GET"; | 297 request_info.method = "GET"; |
| 299 request_info.url = GURL("https://www.google.com"); | 298 request_info.url = GURL("https://www.google.com"); |
| 300 | 299 |
| 301 url::SchemeHostPort server(request_info.url); | 300 url::SchemeHostPort server(request_info.url); |
| 302 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); | 301 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); |
| 303 SetAlternativeService(request_info, alternative_service); | 302 SetAlternativeService(request_info, alternative_service); |
| 304 | 303 |
| 305 request_.reset( | 304 request_.reset(job_controller_->Start( |
| 306 job_controller_->Start(request_info, &request_delegate_, nullptr, | 305 request_info, &request_delegate_, nullptr, HttpStreamRequest::HTTP_STREAM, |
| 307 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, | 306 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); |
| 308 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); | |
| 309 EXPECT_TRUE(job_controller_->main_job()); | 307 EXPECT_TRUE(job_controller_->main_job()); |
| 310 EXPECT_TRUE(job_controller_->alternative_job()); | 308 EXPECT_TRUE(job_controller_->alternative_job()); |
| 311 | 309 |
| 312 // We have the main job with unknown status when the alternative job is failed | 310 // We have the main job with unknown status when the alternative job is failed |
| 313 // thus should not notify Request of the alternative job's failure. But should | 311 // thus should not notify Request of the alternative job's failure. But should |
| 314 // notify the main job to mark the alternative job failed. | 312 // notify the main job to mark the alternative job failed. |
| 315 EXPECT_CALL(request_delegate_, OnStreamFailed(_, _)).Times(0); | 313 EXPECT_CALL(request_delegate_, OnStreamFailed(_, _)).Times(0); |
| 316 job_controller_->OnStreamFailed(job_factory_.alternative_job(), ERR_FAILED, | 314 job_controller_->OnStreamFailed(job_factory_.alternative_job(), ERR_FAILED, |
| 317 SSLConfig()); | 315 SSLConfig()); |
| 318 EXPECT_TRUE(!job_controller_->alternative_job()); | 316 EXPECT_TRUE(!job_controller_->alternative_job()); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 339 Initialize(false); | 337 Initialize(false); |
| 340 | 338 |
| 341 HttpRequestInfo request_info; | 339 HttpRequestInfo request_info; |
| 342 request_info.method = "GET"; | 340 request_info.method = "GET"; |
| 343 request_info.url = GURL("https://www.google.com"); | 341 request_info.url = GURL("https://www.google.com"); |
| 344 | 342 |
| 345 url::SchemeHostPort server(request_info.url); | 343 url::SchemeHostPort server(request_info.url); |
| 346 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); | 344 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); |
| 347 SetAlternativeService(request_info, alternative_service); | 345 SetAlternativeService(request_info, alternative_service); |
| 348 | 346 |
| 349 request_.reset( | 347 request_.reset(job_controller_->Start( |
| 350 job_controller_->Start(request_info, &request_delegate_, nullptr, | 348 request_info, &request_delegate_, nullptr, HttpStreamRequest::HTTP_STREAM, |
| 351 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, | 349 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); |
| 352 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); | |
| 353 EXPECT_TRUE(job_controller_->main_job()); | 350 EXPECT_TRUE(job_controller_->main_job()); |
| 354 EXPECT_TRUE(job_controller_->alternative_job()); | 351 EXPECT_TRUE(job_controller_->alternative_job()); |
| 355 | 352 |
| 356 // Main job succeeds, starts serving Request and it should report status | 353 // Main job succeeds, starts serving Request and it should report status |
| 357 // to Request. The alternative job will mark the main job complete and gets | 354 // to Request. The alternative job will mark the main job complete and gets |
| 358 // orphaned. | 355 // orphaned. |
| 359 HttpStream* http_stream = | 356 HttpStream* http_stream = |
| 360 new HttpBasicStream(base::MakeUnique<ClientSocketHandle>(), false, false); | 357 new HttpBasicStream(base::MakeUnique<ClientSocketHandle>(), false, false); |
| 361 job_factory_.main_job()->SetStream(http_stream); | 358 job_factory_.main_job()->SetStream(http_stream); |
| 362 | 359 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 390 base::WrapUnique(proxy_resolver_factory), nullptr)); | 387 base::WrapUnique(proxy_resolver_factory), nullptr)); |
| 391 Initialize(false); | 388 Initialize(false); |
| 392 | 389 |
| 393 HttpRequestInfo request_info; | 390 HttpRequestInfo request_info; |
| 394 request_info.method = "GET"; | 391 request_info.method = "GET"; |
| 395 request_info.url = GURL("https://www.google.com"); | 392 request_info.url = GURL("https://www.google.com"); |
| 396 | 393 |
| 397 url::SchemeHostPort server(request_info.url); | 394 url::SchemeHostPort server(request_info.url); |
| 398 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); | 395 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); |
| 399 SetAlternativeService(request_info, alternative_service); | 396 SetAlternativeService(request_info, alternative_service); |
| 400 request_.reset( | 397 request_.reset(job_controller_->Start( |
| 401 job_controller_->Start(request_info, &request_delegate_, nullptr, | 398 request_info, &request_delegate_, nullptr, HttpStreamRequest::HTTP_STREAM, |
| 402 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, | 399 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); |
| 403 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); | |
| 404 EXPECT_TRUE(job_controller_->main_job()); | 400 EXPECT_TRUE(job_controller_->main_job()); |
| 405 EXPECT_TRUE(job_controller_->alternative_job()); | 401 EXPECT_TRUE(job_controller_->alternative_job()); |
| 406 EXPECT_TRUE(JobControllerPeer::main_job_is_blocked(job_controller_)); | 402 EXPECT_TRUE(JobControllerPeer::main_job_is_blocked(job_controller_)); |
| 407 | 403 |
| 408 // |alternative_job| succeeds and should report status to Request. | 404 // |alternative_job| succeeds and should report status to Request. |
| 409 HttpStream* http_stream = | 405 HttpStream* http_stream = |
| 410 new HttpBasicStream(base::MakeUnique<ClientSocketHandle>(), false, false); | 406 new HttpBasicStream(base::MakeUnique<ClientSocketHandle>(), false, false); |
| 411 job_factory_.alternative_job()->SetStream(http_stream); | 407 job_factory_.alternative_job()->SetStream(http_stream); |
| 412 EXPECT_CALL(request_delegate_, OnStreamReady(_, _, http_stream)) | 408 EXPECT_CALL(request_delegate_, OnStreamReady(_, _, http_stream)) |
| 413 .WillOnce(Invoke(DeleteHttpStreamPointer)); | 409 .WillOnce(Invoke(DeleteHttpStreamPointer)); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 440 HttpRequestInfo request_info; | 436 HttpRequestInfo request_info; |
| 441 request_info.method = "GET"; | 437 request_info.method = "GET"; |
| 442 request_info.url = GURL("https://www.google.com"); | 438 request_info.url = GURL("https://www.google.com"); |
| 443 | 439 |
| 444 url::SchemeHostPort server(request_info.url); | 440 url::SchemeHostPort server(request_info.url); |
| 445 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); | 441 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); |
| 446 SetAlternativeService(request_info, alternative_service); | 442 SetAlternativeService(request_info, alternative_service); |
| 447 // Hack to use different URL for the main job to help differentiate the proxy | 443 // Hack to use different URL for the main job to help differentiate the proxy |
| 448 // requests. | 444 // requests. |
| 449 job_factory_.UseDifferentURLForMainJob(GURL("http://www.google.com")); | 445 job_factory_.UseDifferentURLForMainJob(GURL("http://www.google.com")); |
| 450 request_.reset( | 446 request_.reset(job_controller_->Start( |
| 451 job_controller_->Start(request_info, &request_delegate_, nullptr, | 447 request_info, &request_delegate_, nullptr, HttpStreamRequest::HTTP_STREAM, |
| 452 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, | 448 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); |
| 453 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); | |
| 454 EXPECT_TRUE(job_controller_->main_job()); | 449 EXPECT_TRUE(job_controller_->main_job()); |
| 455 EXPECT_TRUE(job_controller_->alternative_job()); | 450 EXPECT_TRUE(job_controller_->alternative_job()); |
| 456 EXPECT_TRUE(JobControllerPeer::main_job_is_blocked(job_controller_)); | 451 EXPECT_TRUE(JobControllerPeer::main_job_is_blocked(job_controller_)); |
| 457 | 452 |
| 458 // Complete main job now. | 453 // Complete main job now. |
| 459 MockAsyncProxyResolver resolver; | 454 MockAsyncProxyResolver resolver; |
| 460 proxy_resolver_factory->pending_requests()[0]->CompleteNowWithForwarder( | 455 proxy_resolver_factory->pending_requests()[0]->CompleteNowWithForwarder( |
| 461 net::OK, &resolver); | 456 net::OK, &resolver); |
| 462 int main_job_request_id = | 457 int main_job_request_id = |
| 463 resolver.pending_jobs()[0]->url().SchemeIs("http") ? 0 : 1; | 458 resolver.pending_jobs()[0]->url().SchemeIs("http") ? 0 : 1; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 Initialize(false); | 500 Initialize(false); |
| 506 | 501 |
| 507 HttpRequestInfo request_info; | 502 HttpRequestInfo request_info; |
| 508 request_info.method = "GET"; | 503 request_info.method = "GET"; |
| 509 request_info.url = GURL("https://www.google.com"); | 504 request_info.url = GURL("https://www.google.com"); |
| 510 | 505 |
| 511 url::SchemeHostPort server(request_info.url); | 506 url::SchemeHostPort server(request_info.url); |
| 512 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); | 507 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); |
| 513 SetAlternativeService(request_info, alternative_service); | 508 SetAlternativeService(request_info, alternative_service); |
| 514 | 509 |
| 515 request_.reset( | 510 request_.reset(job_controller_->Start( |
| 516 job_controller_->Start(request_info, &request_delegate_, nullptr, | 511 request_info, &request_delegate_, nullptr, HttpStreamRequest::HTTP_STREAM, |
| 517 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, | 512 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); |
| 518 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); | |
| 519 EXPECT_TRUE(job_controller_->main_job()); | 513 EXPECT_TRUE(job_controller_->main_job()); |
| 520 EXPECT_TRUE(job_controller_->alternative_job()); | 514 EXPECT_TRUE(job_controller_->alternative_job()); |
| 521 | 515 |
| 522 // |main_job| fails but should not report status to Request. | 516 // |main_job| fails but should not report status to Request. |
| 523 EXPECT_CALL(request_delegate_, OnStreamFailed(_, _)).Times(0); | 517 EXPECT_CALL(request_delegate_, OnStreamFailed(_, _)).Times(0); |
| 524 | 518 |
| 525 job_controller_->OnStreamFailed(job_factory_.main_job(), ERR_FAILED, | 519 job_controller_->OnStreamFailed(job_factory_.main_job(), ERR_FAILED, |
| 526 SSLConfig()); | 520 SSLConfig()); |
| 527 | 521 |
| 528 // |alternative_job| succeeds and should report status to Request. | 522 // |alternative_job| succeeds and should report status to Request. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 549 Initialize(false); | 543 Initialize(false); |
| 550 | 544 |
| 551 HttpRequestInfo request_info; | 545 HttpRequestInfo request_info; |
| 552 request_info.method = "GET"; | 546 request_info.method = "GET"; |
| 553 request_info.url = GURL("https://www.google.com"); | 547 request_info.url = GURL("https://www.google.com"); |
| 554 | 548 |
| 555 url::SchemeHostPort server(request_info.url); | 549 url::SchemeHostPort server(request_info.url); |
| 556 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); | 550 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); |
| 557 SetAlternativeService(request_info, alternative_service); | 551 SetAlternativeService(request_info, alternative_service); |
| 558 | 552 |
| 559 request_.reset( | 553 request_.reset(job_controller_->Start( |
| 560 job_controller_->Start(request_info, &request_delegate_, nullptr, | 554 request_info, &request_delegate_, nullptr, HttpStreamRequest::HTTP_STREAM, |
| 561 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, | 555 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); |
| 562 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); | |
| 563 EXPECT_TRUE(job_controller_->main_job()); | 556 EXPECT_TRUE(job_controller_->main_job()); |
| 564 EXPECT_TRUE(job_controller_->alternative_job()); | 557 EXPECT_TRUE(job_controller_->alternative_job()); |
| 565 | 558 |
| 566 // |alternative_job| fails but should not report status to Request. | 559 // |alternative_job| fails but should not report status to Request. |
| 567 EXPECT_CALL(request_delegate_, OnStreamFailed(_, _)).Times(0); | 560 EXPECT_CALL(request_delegate_, OnStreamFailed(_, _)).Times(0); |
| 568 | 561 |
| 569 job_controller_->OnStreamFailed(job_factory_.alternative_job(), ERR_FAILED, | 562 job_controller_->OnStreamFailed(job_factory_.alternative_job(), ERR_FAILED, |
| 570 SSLConfig()); | 563 SSLConfig()); |
| 571 | 564 |
| 572 // |main_job| succeeds and should report status to Request. | 565 // |main_job| succeeds and should report status to Request. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 595 Initialize(false); | 588 Initialize(false); |
| 596 | 589 |
| 597 HttpRequestInfo request_info; | 590 HttpRequestInfo request_info; |
| 598 request_info.method = "GET"; | 591 request_info.method = "GET"; |
| 599 request_info.url = GURL("https://www.google.com"); | 592 request_info.url = GURL("https://www.google.com"); |
| 600 | 593 |
| 601 url::SchemeHostPort server(request_info.url); | 594 url::SchemeHostPort server(request_info.url); |
| 602 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); | 595 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); |
| 603 SetAlternativeService(request_info, alternative_service); | 596 SetAlternativeService(request_info, alternative_service); |
| 604 | 597 |
| 605 request_.reset( | 598 request_.reset(job_controller_->Start( |
| 606 job_controller_->Start(request_info, &request_delegate_, nullptr, | 599 request_info, &request_delegate_, nullptr, HttpStreamRequest::HTTP_STREAM, |
| 607 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, | 600 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); |
| 608 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); | |
| 609 EXPECT_TRUE(job_controller_->main_job()); | 601 EXPECT_TRUE(job_controller_->main_job()); |
| 610 EXPECT_TRUE(job_controller_->alternative_job()); | 602 EXPECT_TRUE(job_controller_->alternative_job()); |
| 611 | 603 |
| 612 // |main_job| fails but should not report status to Request. | 604 // |main_job| fails but should not report status to Request. |
| 613 // The alternative job will mark the main job complete. | 605 // The alternative job will mark the main job complete. |
| 614 EXPECT_CALL(request_delegate_, OnStreamFailed(_, _)).Times(0); | 606 EXPECT_CALL(request_delegate_, OnStreamFailed(_, _)).Times(0); |
| 615 | 607 |
| 616 job_controller_->OnStreamFailed(job_factory_.main_job(), ERR_FAILED, | 608 job_controller_->OnStreamFailed(job_factory_.main_job(), ERR_FAILED, |
| 617 SSLConfig()); | 609 SSLConfig()); |
| 618 | 610 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 643 Initialize(false); | 635 Initialize(false); |
| 644 | 636 |
| 645 HttpRequestInfo request_info; | 637 HttpRequestInfo request_info; |
| 646 request_info.method = "GET"; | 638 request_info.method = "GET"; |
| 647 request_info.url = GURL("https://www.google.com"); | 639 request_info.url = GURL("https://www.google.com"); |
| 648 | 640 |
| 649 url::SchemeHostPort server(request_info.url); | 641 url::SchemeHostPort server(request_info.url); |
| 650 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); | 642 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); |
| 651 SetAlternativeService(request_info, alternative_service); | 643 SetAlternativeService(request_info, alternative_service); |
| 652 | 644 |
| 653 request_.reset( | 645 request_.reset(job_controller_->Start( |
| 654 job_controller_->Start(request_info, &request_delegate_, nullptr, | 646 request_info, &request_delegate_, nullptr, HttpStreamRequest::HTTP_STREAM, |
| 655 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, | 647 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); |
| 656 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); | |
| 657 EXPECT_TRUE(job_controller_->main_job()); | 648 EXPECT_TRUE(job_controller_->main_job()); |
| 658 EXPECT_TRUE(job_controller_->alternative_job()); | 649 EXPECT_TRUE(job_controller_->alternative_job()); |
| 659 | 650 |
| 660 // Wait until OnStreamFailedCallback is executed on the alternative job. | 651 // Wait until OnStreamFailedCallback is executed on the alternative job. |
| 661 EXPECT_CALL(request_delegate_, OnStreamFailed(_, _)).Times(1); | 652 EXPECT_CALL(request_delegate_, OnStreamFailed(_, _)).Times(1); |
| 662 base::RunLoop().RunUntilIdle(); | 653 base::RunLoop().RunUntilIdle(); |
| 663 } | 654 } |
| 664 | 655 |
| 665 TEST_F(HttpStreamFactoryImplJobControllerTest, InvalidPortForQuic) { | 656 TEST_F(HttpStreamFactoryImplJobControllerTest, InvalidPortForQuic) { |
| 666 // Using a restricted port 101 for QUIC should fail and the alternative job | 657 // Using a restricted port 101 for QUIC should fail and the alternative job |
| 667 // should post OnStreamFailedCall on the controller to resume the main job. | 658 // should post OnStreamFailedCall on the controller to resume the main job. |
| 668 Initialize(false); | 659 Initialize(false); |
| 669 | 660 |
| 670 HttpRequestInfo request_info; | 661 HttpRequestInfo request_info; |
| 671 request_info.method = "GET"; | 662 request_info.method = "GET"; |
| 672 request_info.url = GURL("https://www.google.com"); | 663 request_info.url = GURL("https://www.google.com"); |
| 673 | 664 |
| 674 url::SchemeHostPort server(request_info.url); | 665 url::SchemeHostPort server(request_info.url); |
| 675 AlternativeService alternative_service(kProtoQUIC, server.host(), 101); | 666 AlternativeService alternative_service(kProtoQUIC, server.host(), 101); |
| 676 SetAlternativeService(request_info, alternative_service); | 667 SetAlternativeService(request_info, alternative_service); |
| 677 | 668 |
| 678 request_.reset( | 669 request_.reset(job_controller_->Start( |
| 679 job_controller_->Start(request_info, &request_delegate_, nullptr, | 670 request_info, &request_delegate_, nullptr, HttpStreamRequest::HTTP_STREAM, |
| 680 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, | 671 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); |
| 681 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); | |
| 682 | 672 |
| 683 EXPECT_TRUE(job_factory_.main_job()->is_waiting()); | 673 EXPECT_TRUE(job_factory_.main_job()->is_waiting()); |
| 684 | 674 |
| 685 // Wait until OnStreamFailedCallback is executed on the alternative job. | 675 // Wait until OnStreamFailedCallback is executed on the alternative job. |
| 686 EXPECT_CALL(*job_factory_.main_job(), Resume()).Times(1); | 676 EXPECT_CALL(*job_factory_.main_job(), Resume()).Times(1); |
| 687 base::RunLoop().RunUntilIdle(); | 677 base::RunLoop().RunUntilIdle(); |
| 688 } | 678 } |
| 689 | 679 |
| 690 TEST_F(HttpStreamFactoryImplJobControllerTest, | 680 TEST_F(HttpStreamFactoryImplJobControllerTest, |
| 691 NoAvailableSpdySessionToResumeMainJob) { | 681 NoAvailableSpdySessionToResumeMainJob) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 713 request_info.url = GURL("https://www.google.com"); | 703 request_info.url = GURL("https://www.google.com"); |
| 714 | 704 |
| 715 // Set a SPDY alternative service for the server. | 705 // Set a SPDY alternative service for the server. |
| 716 url::SchemeHostPort server(request_info.url); | 706 url::SchemeHostPort server(request_info.url); |
| 717 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); | 707 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); |
| 718 SetAlternativeService(request_info, alternative_service); | 708 SetAlternativeService(request_info, alternative_service); |
| 719 // Hack to use different URL for the main job to help differentiate the proxy | 709 // Hack to use different URL for the main job to help differentiate the proxy |
| 720 // requests. | 710 // requests. |
| 721 job_factory_.UseDifferentURLForMainJob(GURL("http://www.google.com")); | 711 job_factory_.UseDifferentURLForMainJob(GURL("http://www.google.com")); |
| 722 | 712 |
| 723 request_.reset( | 713 request_.reset(job_controller_->Start( |
| 724 job_controller_->Start(request_info, &request_delegate_, nullptr, | 714 request_info, &request_delegate_, nullptr, HttpStreamRequest::HTTP_STREAM, |
| 725 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, | 715 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); |
| 726 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); | |
| 727 // Both jobs should be created but stalled as proxy resolution not completed. | 716 // Both jobs should be created but stalled as proxy resolution not completed. |
| 728 EXPECT_TRUE(job_controller_->main_job()); | 717 EXPECT_TRUE(job_controller_->main_job()); |
| 729 EXPECT_TRUE(job_controller_->alternative_job()); | 718 EXPECT_TRUE(job_controller_->alternative_job()); |
| 730 | 719 |
| 731 MockAsyncProxyResolver resolver; | 720 MockAsyncProxyResolver resolver; |
| 732 proxy_resolver_factory->pending_requests()[0]->CompleteNowWithForwarder( | 721 proxy_resolver_factory->pending_requests()[0]->CompleteNowWithForwarder( |
| 733 net::OK, &resolver); | 722 net::OK, &resolver); |
| 734 | 723 |
| 735 // Resolve proxy for the main job which then proceed to wait for the | 724 // Resolve proxy for the main job which then proceed to wait for the |
| 736 // alternative job which is IO_PENDING. | 725 // alternative job which is IO_PENDING. |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 775 request_info.method = "GET"; | 764 request_info.method = "GET"; |
| 776 request_info.url = GURL("https://www.google.com"); | 765 request_info.url = GURL("https://www.google.com"); |
| 777 | 766 |
| 778 url::SchemeHostPort server(request_info.url); | 767 url::SchemeHostPort server(request_info.url); |
| 779 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); | 768 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); |
| 780 SetAlternativeService(request_info, alternative_service); | 769 SetAlternativeService(request_info, alternative_service); |
| 781 // Hack to use different URL for the main job to help differentiate the proxy | 770 // Hack to use different URL for the main job to help differentiate the proxy |
| 782 // requests. | 771 // requests. |
| 783 job_factory_.UseDifferentURLForMainJob(GURL("http://www.google.com")); | 772 job_factory_.UseDifferentURLForMainJob(GURL("http://www.google.com")); |
| 784 | 773 |
| 785 request_.reset( | 774 request_.reset(job_controller_->Start( |
| 786 job_controller_->Start(request_info, &request_delegate_, nullptr, | 775 request_info, &request_delegate_, nullptr, HttpStreamRequest::HTTP_STREAM, |
| 787 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, | 776 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); |
| 788 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); | |
| 789 EXPECT_TRUE(job_controller_->main_job()); | 777 EXPECT_TRUE(job_controller_->main_job()); |
| 790 EXPECT_TRUE(job_controller_->alternative_job()); | 778 EXPECT_TRUE(job_controller_->alternative_job()); |
| 791 | 779 |
| 792 MockAsyncProxyResolver resolver; | 780 MockAsyncProxyResolver resolver; |
| 793 proxy_resolver_factory->pending_requests()[0]->CompleteNowWithForwarder( | 781 proxy_resolver_factory->pending_requests()[0]->CompleteNowWithForwarder( |
| 794 net::OK, &resolver); | 782 net::OK, &resolver); |
| 795 | 783 |
| 796 // Resolve proxy for the main job which then proceed to wait for the | 784 // Resolve proxy for the main job which then proceed to wait for the |
| 797 // alternative job which is IO_PENDING. | 785 // alternative job which is IO_PENDING. |
| 798 int main_job_request_id = | 786 int main_job_request_id = |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 834 | 822 |
| 835 HttpRequestInfo request_info; | 823 HttpRequestInfo request_info; |
| 836 request_info.method = "GET"; | 824 request_info.method = "GET"; |
| 837 request_info.url = GURL("https://www.google.com"); | 825 request_info.url = GURL("https://www.google.com"); |
| 838 | 826 |
| 839 // Set a SPDY alternative service for the server. | 827 // Set a SPDY alternative service for the server. |
| 840 url::SchemeHostPort server(request_info.url); | 828 url::SchemeHostPort server(request_info.url); |
| 841 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); | 829 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); |
| 842 SetAlternativeService(request_info, alternative_service); | 830 SetAlternativeService(request_info, alternative_service); |
| 843 | 831 |
| 844 request_.reset( | 832 request_.reset(job_controller_->Start( |
| 845 job_controller_->Start(request_info, &request_delegate_, nullptr, | 833 request_info, &request_delegate_, nullptr, HttpStreamRequest::HTTP_STREAM, |
| 846 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, | 834 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); |
| 847 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); | |
| 848 EXPECT_TRUE(job_controller_->main_job()); | 835 EXPECT_TRUE(job_controller_->main_job()); |
| 849 EXPECT_TRUE(job_controller_->alternative_job()); | 836 EXPECT_TRUE(job_controller_->alternative_job()); |
| 850 | 837 |
| 851 // The alternative job stalls as host resolution hangs when creating the QUIC | 838 // The alternative job stalls as host resolution hangs when creating the QUIC |
| 852 // request and controller should resume the main job after delay. | 839 // request and controller should resume the main job after delay. |
| 853 // Verify the waiting time for delayed main job. | 840 // Verify the waiting time for delayed main job. |
| 854 EXPECT_CALL(*job_factory_.main_job(), Resume()) | 841 EXPECT_CALL(*job_factory_.main_job(), Resume()) |
| 855 .WillOnce(Invoke(testing::CreateFunctor( | 842 .WillOnce(Invoke(testing::CreateFunctor( |
| 856 &JobControllerPeer::VerifyWaitingTimeForMainJob, job_controller_, | 843 &JobControllerPeer::VerifyWaitingTimeForMainJob, job_controller_, |
| 857 base::TimeDelta::FromMicroseconds(15)))); | 844 base::TimeDelta::FromMicroseconds(15)))); |
| 858 | 845 |
| 859 base::RunLoop().RunUntilIdle(); | 846 base::RunLoop().RunUntilIdle(); |
| 860 } | 847 } |
| 861 | 848 |
| 862 // Verifies that the alternative proxy server job is not created if the URL | 849 // Verifies that the alternative proxy server job is not created if the URL |
| 863 // scheme is HTTPS. | 850 // scheme is HTTPS. |
| 864 TEST_F(HttpStreamFactoryImplJobControllerTest, HttpsURL) { | 851 TEST_F(HttpStreamFactoryImplJobControllerTest, HttpsURL) { |
| 865 // Using hanging resolver will cause the alternative job to hang indefinitely. | 852 // Using hanging resolver will cause the alternative job to hang indefinitely. |
| 866 HangingResolver* resolver = new HangingResolver(); | 853 HangingResolver* resolver = new HangingResolver(); |
| 867 session_deps_.host_resolver.reset(resolver); | 854 session_deps_.host_resolver.reset(resolver); |
| 868 | 855 |
| 869 Initialize(true); | 856 Initialize(true); |
| 870 EXPECT_TRUE(test_proxy_delegate()->alternative_proxy_server().is_quic()); | 857 EXPECT_TRUE(test_proxy_delegate()->alternative_proxy_server().is_quic()); |
| 871 | 858 |
| 872 HttpRequestInfo request_info; | 859 HttpRequestInfo request_info; |
| 873 request_info.method = "GET"; | 860 request_info.method = "GET"; |
| 874 request_info.url = GURL("https://mail.example.org/"); | 861 request_info.url = GURL("https://mail.example.org/"); |
| 875 | 862 |
| 876 request_.reset( | 863 request_.reset(job_controller_->Start( |
| 877 job_controller_->Start(request_info, &request_delegate_, nullptr, | 864 request_info, &request_delegate_, nullptr, HttpStreamRequest::HTTP_STREAM, |
| 878 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, | 865 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); |
| 879 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); | |
| 880 EXPECT_TRUE(job_controller_->main_job()); | 866 EXPECT_TRUE(job_controller_->main_job()); |
| 881 EXPECT_FALSE(job_controller_->main_job()->is_waiting()); | 867 EXPECT_FALSE(job_controller_->main_job()->is_waiting()); |
| 882 EXPECT_FALSE(job_controller_->alternative_job()); | 868 EXPECT_FALSE(job_controller_->alternative_job()); |
| 883 | 869 |
| 884 EXPECT_CALL(*job_factory_.main_job(), Resume()).Times(0); | 870 EXPECT_CALL(*job_factory_.main_job(), Resume()).Times(0); |
| 885 base::RunLoop().RunUntilIdle(); | 871 base::RunLoop().RunUntilIdle(); |
| 886 EXPECT_EQ(0, test_proxy_delegate()->get_alternative_proxy_invocations()); | 872 EXPECT_EQ(0, test_proxy_delegate()->get_alternative_proxy_invocations()); |
| 887 } | 873 } |
| 888 | 874 |
| 889 // Verifies that the alternative proxy server job is not created if the main job | 875 // Verifies that the alternative proxy server job is not created if the main job |
| 890 // does not fetch the resource through a proxy. | 876 // does not fetch the resource through a proxy. |
| 891 TEST_F(HttpStreamFactoryImplJobControllerTest, HttpURLWithNoProxy) { | 877 TEST_F(HttpStreamFactoryImplJobControllerTest, HttpURLWithNoProxy) { |
| 892 // Using hanging resolver will cause the alternative job to hang indefinitely. | 878 // Using hanging resolver will cause the alternative job to hang indefinitely. |
| 893 HangingResolver* resolver = new HangingResolver(); | 879 HangingResolver* resolver = new HangingResolver(); |
| 894 session_deps_.host_resolver.reset(resolver); | 880 session_deps_.host_resolver.reset(resolver); |
| 895 | 881 |
| 896 Initialize(false); | 882 Initialize(false); |
| 897 EXPECT_TRUE(test_proxy_delegate()->alternative_proxy_server().is_quic()); | 883 EXPECT_TRUE(test_proxy_delegate()->alternative_proxy_server().is_quic()); |
| 898 | 884 |
| 899 HttpRequestInfo request_info; | 885 HttpRequestInfo request_info; |
| 900 request_info.method = "GET"; | 886 request_info.method = "GET"; |
| 901 request_info.url = GURL("http://mail.example.org/"); | 887 request_info.url = GURL("http://mail.example.org/"); |
| 902 | 888 |
| 903 request_.reset( | 889 request_.reset(job_controller_->Start( |
| 904 job_controller_->Start(request_info, &request_delegate_, nullptr, | 890 request_info, &request_delegate_, nullptr, HttpStreamRequest::HTTP_STREAM, |
| 905 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, | 891 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); |
| 906 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); | |
| 907 EXPECT_TRUE(job_controller_->main_job()); | 892 EXPECT_TRUE(job_controller_->main_job()); |
| 908 EXPECT_FALSE(job_controller_->main_job()->is_waiting()); | 893 EXPECT_FALSE(job_controller_->main_job()->is_waiting()); |
| 909 EXPECT_FALSE(job_controller_->alternative_job()); | 894 EXPECT_FALSE(job_controller_->alternative_job()); |
| 910 | 895 |
| 911 EXPECT_CALL(*job_factory_.main_job(), Resume()).Times(0); | 896 EXPECT_CALL(*job_factory_.main_job(), Resume()).Times(0); |
| 912 base::RunLoop().RunUntilIdle(); | 897 base::RunLoop().RunUntilIdle(); |
| 913 | 898 |
| 914 EXPECT_EQ(0, test_proxy_delegate()->get_alternative_proxy_invocations()); | 899 EXPECT_EQ(0, test_proxy_delegate()->get_alternative_proxy_invocations()); |
| 915 } | 900 } |
| 916 | 901 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 930 quic_stream_factory->set_require_confirmation(false); | 915 quic_stream_factory->set_require_confirmation(false); |
| 931 ServerNetworkStats stats1; | 916 ServerNetworkStats stats1; |
| 932 stats1.srtt = base::TimeDelta::FromMicroseconds(10); | 917 stats1.srtt = base::TimeDelta::FromMicroseconds(10); |
| 933 session_->http_server_properties()->SetServerNetworkStats( | 918 session_->http_server_properties()->SetServerNetworkStats( |
| 934 url::SchemeHostPort(GURL("https://myproxy.org")), stats1); | 919 url::SchemeHostPort(GURL("https://myproxy.org")), stats1); |
| 935 | 920 |
| 936 HttpRequestInfo request_info; | 921 HttpRequestInfo request_info; |
| 937 request_info.method = "GET"; | 922 request_info.method = "GET"; |
| 938 request_info.url = GURL("http://mail.example.org/"); | 923 request_info.url = GURL("http://mail.example.org/"); |
| 939 | 924 |
| 940 request_.reset( | 925 request_.reset(job_controller_->Start( |
| 941 job_controller_->Start(request_info, &request_delegate_, nullptr, | 926 request_info, &request_delegate_, nullptr, HttpStreamRequest::HTTP_STREAM, |
| 942 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, | 927 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); |
| 943 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); | |
| 944 EXPECT_TRUE(job_controller_->main_job()); | 928 EXPECT_TRUE(job_controller_->main_job()); |
| 945 EXPECT_TRUE(job_controller_->main_job()->is_waiting()); | 929 EXPECT_TRUE(job_controller_->main_job()->is_waiting()); |
| 946 EXPECT_TRUE(job_controller_->alternative_job()); | 930 EXPECT_TRUE(job_controller_->alternative_job()); |
| 947 EXPECT_TRUE(JobControllerPeer::main_job_is_blocked(job_controller_)); | 931 EXPECT_TRUE(JobControllerPeer::main_job_is_blocked(job_controller_)); |
| 948 | 932 |
| 949 // The alternative proxy server job stalls when connecting to the alternative | 933 // The alternative proxy server job stalls when connecting to the alternative |
| 950 // proxy server, and controller should resume the main job after delay. | 934 // proxy server, and controller should resume the main job after delay. |
| 951 // Verify the waiting time for delayed main job. | 935 // Verify the waiting time for delayed main job. |
| 952 EXPECT_CALL(*job_factory_.main_job(), Resume()) | 936 EXPECT_CALL(*job_factory_.main_job(), Resume()) |
| 953 .WillOnce(Invoke(testing::CreateFunctor( | 937 .WillOnce(Invoke(testing::CreateFunctor( |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 991 quic_stream_factory->set_require_confirmation(false); | 975 quic_stream_factory->set_require_confirmation(false); |
| 992 ServerNetworkStats stats1; | 976 ServerNetworkStats stats1; |
| 993 stats1.srtt = base::TimeDelta::FromMicroseconds(300 * 1000); | 977 stats1.srtt = base::TimeDelta::FromMicroseconds(300 * 1000); |
| 994 session_->http_server_properties()->SetServerNetworkStats( | 978 session_->http_server_properties()->SetServerNetworkStats( |
| 995 url::SchemeHostPort(GURL("https://myproxy.org")), stats1); | 979 url::SchemeHostPort(GURL("https://myproxy.org")), stats1); |
| 996 | 980 |
| 997 HttpRequestInfo request_info; | 981 HttpRequestInfo request_info; |
| 998 request_info.method = "GET"; | 982 request_info.method = "GET"; |
| 999 request_info.url = GURL("http://mail.example.org/"); | 983 request_info.url = GURL("http://mail.example.org/"); |
| 1000 | 984 |
| 1001 request_.reset( | 985 request_.reset(job_controller_->Start( |
| 1002 job_controller_->Start(request_info, &request_delegate_, nullptr, | 986 request_info, &request_delegate_, nullptr, HttpStreamRequest::HTTP_STREAM, |
| 1003 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, | 987 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); |
| 1004 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); | |
| 1005 EXPECT_TRUE(job_controller_->main_job()->is_waiting()); | 988 EXPECT_TRUE(job_controller_->main_job()->is_waiting()); |
| 1006 EXPECT_TRUE(job_controller_->alternative_job()); | 989 EXPECT_TRUE(job_controller_->alternative_job()); |
| 1007 | 990 |
| 1008 EXPECT_CALL(request_delegate_, OnStreamReady(_, _, _)).Times(0); | 991 EXPECT_CALL(request_delegate_, OnStreamReady(_, _, _)).Times(0); |
| 1009 | 992 |
| 1010 // Since the alternative proxy server job is started in the next message loop, | 993 // Since the alternative proxy server job is started in the next message loop, |
| 1011 // the main job would remain blocked until the alternative proxy starts, and | 994 // the main job would remain blocked until the alternative proxy starts, and |
| 1012 // fails. | 995 // fails. |
| 1013 EXPECT_CALL(*job_factory_.main_job(), Resume()) | 996 EXPECT_CALL(*job_factory_.main_job(), Resume()) |
| 1014 .WillOnce(Invoke(testing::CreateFunctor( | 997 .WillOnce(Invoke(testing::CreateFunctor( |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1028 AlternativeProxyServerJobFailsAfterMainJobSucceeds) { | 1011 AlternativeProxyServerJobFailsAfterMainJobSucceeds) { |
| 1029 base::HistogramTester histogram_tester; | 1012 base::HistogramTester histogram_tester; |
| 1030 Initialize(true); | 1013 Initialize(true); |
| 1031 | 1014 |
| 1032 HttpRequestInfo request_info; | 1015 HttpRequestInfo request_info; |
| 1033 request_info.method = "GET"; | 1016 request_info.method = "GET"; |
| 1034 request_info.url = GURL("http://www.google.com"); | 1017 request_info.url = GURL("http://www.google.com"); |
| 1035 | 1018 |
| 1036 url::SchemeHostPort server(request_info.url); | 1019 url::SchemeHostPort server(request_info.url); |
| 1037 | 1020 |
| 1038 request_.reset( | 1021 request_.reset(job_controller_->Start( |
| 1039 job_controller_->Start(request_info, &request_delegate_, nullptr, | 1022 request_info, &request_delegate_, nullptr, HttpStreamRequest::HTTP_STREAM, |
| 1040 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, | 1023 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); |
| 1041 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); | |
| 1042 EXPECT_TRUE(job_controller_->main_job()); | 1024 EXPECT_TRUE(job_controller_->main_job()); |
| 1043 EXPECT_TRUE(job_controller_->alternative_job()); | 1025 EXPECT_TRUE(job_controller_->alternative_job()); |
| 1044 | 1026 |
| 1045 // Main job succeeds, starts serving Request and it should report status | 1027 // Main job succeeds, starts serving Request and it should report status |
| 1046 // to Request. The alternative job will mark the main job complete and gets | 1028 // to Request. The alternative job will mark the main job complete and gets |
| 1047 // orphaned. | 1029 // orphaned. |
| 1048 HttpStream* http_stream = | 1030 HttpStream* http_stream = |
| 1049 new HttpBasicStream(base::MakeUnique<ClientSocketHandle>(), false, false); | 1031 new HttpBasicStream(base::MakeUnique<ClientSocketHandle>(), false, false); |
| 1050 job_factory_.main_job()->SetStream(http_stream); | 1032 job_factory_.main_job()->SetStream(http_stream); |
| 1051 | 1033 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1092 EXPECT_FALSE(job_controller_->alternative_job()); | 1074 EXPECT_FALSE(job_controller_->alternative_job()); |
| 1093 // There is only 1 connect even though multiple streams were requested. | 1075 // There is only 1 connect even though multiple streams were requested. |
| 1094 EXPECT_EQ(1, HttpStreamFactoryImplJobPeer::GetNumStreams( | 1076 EXPECT_EQ(1, HttpStreamFactoryImplJobPeer::GetNumStreams( |
| 1095 job_controller_->main_job())); | 1077 job_controller_->main_job())); |
| 1096 | 1078 |
| 1097 base::RunLoop().RunUntilIdle(); | 1079 base::RunLoop().RunUntilIdle(); |
| 1098 EXPECT_TRUE(HttpStreamFactoryImplPeer::IsJobControllerDeleted(factory_)); | 1080 EXPECT_TRUE(HttpStreamFactoryImplPeer::IsJobControllerDeleted(factory_)); |
| 1099 } | 1081 } |
| 1100 | 1082 |
| 1101 } // namespace net | 1083 } // namespace net |
| OLD | NEW |