| 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 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 NetLogSourceType::HTTP_STREAM_JOB_CONTROLLER)), | 67 NetLogSourceType::HTTP_STREAM_JOB_CONTROLLER)), |
| 68 ptr_factory_(this) { | 68 ptr_factory_(this) { |
| 69 DCHECK(factory); | 69 DCHECK(factory); |
| 70 net_log_.BeginEvent(NetLogEventType::HTTP_STREAM_JOB_CONTROLLER, | 70 net_log_.BeginEvent(NetLogEventType::HTTP_STREAM_JOB_CONTROLLER, |
| 71 base::Bind(&NetLogJobControllerCallback, | 71 base::Bind(&NetLogJobControllerCallback, |
| 72 &request_info.url, is_preconnect)); | 72 &request_info.url, is_preconnect)); |
| 73 } | 73 } |
| 74 | 74 |
| 75 HttpStreamFactoryImpl::JobController::~JobController() { | 75 HttpStreamFactoryImpl::JobController::~JobController() { |
| 76 main_job_.reset(); | 76 main_job_.reset(); |
| 77 if (alternative_job_.get()) { |
| 78 alternative_job_->net_log().AddEvent( |
| 79 NetLogEventType::ALT_JOB_DELETED_ON_DESTRUCT_JOB_CONTROLLER); |
| 80 } |
| 77 alternative_job_.reset(); | 81 alternative_job_.reset(); |
| 78 bound_job_ = nullptr; | 82 bound_job_ = nullptr; |
| 79 net_log_.EndEvent(NetLogEventType::HTTP_STREAM_JOB_CONTROLLER); | 83 net_log_.EndEvent(NetLogEventType::HTTP_STREAM_JOB_CONTROLLER); |
| 80 } | 84 } |
| 81 | 85 |
| 82 bool HttpStreamFactoryImpl::JobController::for_websockets() { | 86 bool HttpStreamFactoryImpl::JobController::for_websockets() { |
| 83 return factory_->for_websockets_; | 87 return factory_->for_websockets_; |
| 84 } | 88 } |
| 85 | 89 |
| 86 HttpStreamFactoryImpl::Request* HttpStreamFactoryImpl::JobController::Start( | 90 HttpStreamFactoryImpl::Request* HttpStreamFactoryImpl::JobController::Start( |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 request_ = nullptr; | 174 request_ = nullptr; |
| 171 if (bound_job_) { | 175 if (bound_job_) { |
| 172 if (bound_job_->job_type() == MAIN) { | 176 if (bound_job_->job_type() == MAIN) { |
| 173 main_job_.reset(); | 177 main_job_.reset(); |
| 174 // |alternative_job_| can be non-null if |main_job_| is resumed after | 178 // |alternative_job_| can be non-null if |main_job_| is resumed after |
| 175 // |main_job_wait_time_| has elapsed. Allow |alternative_job_| to run to | 179 // |main_job_wait_time_| has elapsed. Allow |alternative_job_| to run to |
| 176 // completion, rather than resetting it. OnOrphanedJobComplete() will | 180 // completion, rather than resetting it. OnOrphanedJobComplete() will |
| 177 // clean up |this| when the job completes. | 181 // clean up |this| when the job completes. |
| 178 } else { | 182 } else { |
| 179 DCHECK(bound_job_->job_type() == ALTERNATIVE); | 183 DCHECK(bound_job_->job_type() == ALTERNATIVE); |
| 184 if (alternative_job_) { |
| 185 alternative_job_->net_log().AddEvent( |
| 186 NetLogEventType::ALT_JOB_DELETED_ON_REQUEST_COMPLETE_AND_BOUND); |
| 187 } |
| 180 alternative_job_.reset(); | 188 alternative_job_.reset(); |
| 181 } | 189 } |
| 182 bound_job_ = nullptr; | 190 bound_job_ = nullptr; |
| 183 } | 191 } |
| 184 MaybeNotifyFactoryOfCompletion(); | 192 MaybeNotifyFactoryOfCompletion(); |
| 185 } | 193 } |
| 186 | 194 |
| 187 int HttpStreamFactoryImpl::JobController::RestartTunnelWithProxyAuth() { | 195 int HttpStreamFactoryImpl::JobController::RestartTunnelWithProxyAuth() { |
| 188 DCHECK(bound_job_); | 196 DCHECK(bound_job_); |
| 189 return bound_job_->RestartTunnelWithProxyAuth(); | 197 return bound_job_->RestartTunnelWithProxyAuth(); |
| 190 } | 198 } |
| 191 | 199 |
| 192 void HttpStreamFactoryImpl::JobController::SetPriority( | 200 void HttpStreamFactoryImpl::JobController::SetPriority( |
| 193 RequestPriority priority) { | 201 RequestPriority priority) { |
| 194 if (main_job_) { | 202 if (main_job_) { |
| 195 main_job_->SetPriority(priority); | 203 main_job_->SetPriority(priority); |
| 196 } | 204 } |
| 197 if (alternative_job_) { | 205 if (alternative_job_) { |
| 198 alternative_job_->SetPriority(priority); | 206 alternative_job_->SetPriority(priority); |
| 199 } | 207 } |
| 200 } | 208 } |
| 201 | 209 |
| 202 void HttpStreamFactoryImpl::JobController::OnStreamReady( | 210 void HttpStreamFactoryImpl::JobController::OnStreamReady( |
| 203 Job* job, | 211 Job* job, |
| 204 const SSLConfig& used_ssl_config) { | 212 const SSLConfig& used_ssl_config) { |
| 213 job->net_log().AddEvent( |
| 214 NetLogEventType::HTTP_STREAM_JOB_ON_STREAM_READY, |
| 215 NetLog::BoolCallback("is_orphaned", IsJobOrphaned(job))); |
| 205 DCHECK(job); | 216 DCHECK(job); |
| 206 | 217 |
| 207 factory_->OnStreamReady(job->proxy_info(), privacy_mode_); | 218 factory_->OnStreamReady(job->proxy_info(), privacy_mode_); |
| 208 | 219 |
| 209 if (IsJobOrphaned(job)) { | 220 if (IsJobOrphaned(job)) { |
| 210 // We have bound a job to the associated Request, |job| has been orphaned. | 221 // We have bound a job to the associated Request, |job| has been orphaned. |
| 211 OnOrphanedJobComplete(job); | 222 OnOrphanedJobComplete(job); |
| 212 return; | 223 return; |
| 213 } | 224 } |
| 214 std::unique_ptr<HttpStream> stream = job->ReleaseStream(); | 225 std::unique_ptr<HttpStream> stream = job->ReleaseStream(); |
| 215 DCHECK(stream); | 226 DCHECK(stream); |
| 216 | 227 |
| 217 MarkRequestComplete(job->was_alpn_negotiated(), job->negotiated_protocol(), | 228 MarkRequestComplete(job->was_alpn_negotiated(), job->negotiated_protocol(), |
| 218 job->using_spdy()); | 229 job->using_spdy()); |
| 219 | 230 |
| 220 if (!request_) | 231 if (!request_) |
| 221 return; | 232 return; |
| 222 DCHECK(!factory_->for_websockets_); | 233 DCHECK(!factory_->for_websockets_); |
| 223 DCHECK_EQ(HttpStreamRequest::HTTP_STREAM, request_->stream_type()); | 234 DCHECK_EQ(HttpStreamRequest::HTTP_STREAM, request_->stream_type()); |
| 224 OnJobSucceeded(job); | 235 OnJobSucceeded(job); |
| 225 request_->OnStreamReady(used_ssl_config, job->proxy_info(), stream.release()); | 236 request_->OnStreamReady(used_ssl_config, job->proxy_info(), stream.release()); |
| 226 } | 237 } |
| 227 | 238 |
| 228 void HttpStreamFactoryImpl::JobController::OnBidirectionalStreamImplReady( | 239 void HttpStreamFactoryImpl::JobController::OnBidirectionalStreamImplReady( |
| 229 Job* job, | 240 Job* job, |
| 230 const SSLConfig& used_ssl_config, | 241 const SSLConfig& used_ssl_config, |
| 231 const ProxyInfo& used_proxy_info) { | 242 const ProxyInfo& used_proxy_info) { |
| 232 DCHECK(job); | 243 DCHECK(job); |
| 244 job->net_log().AddEvent( |
| 245 NetLogEventType::HTTP_STREAM_JOB_ON_BI_STREAN_IMPL_READY, |
| 246 NetLog::BoolCallback("is_orphaned", IsJobOrphaned(job))); |
| 233 | 247 |
| 234 if (IsJobOrphaned(job)) { | 248 if (IsJobOrphaned(job)) { |
| 235 // We have bound a job to the associated Request, |job| has been orphaned. | 249 // We have bound a job to the associated Request, |job| has been orphaned. |
| 236 OnOrphanedJobComplete(job); | 250 OnOrphanedJobComplete(job); |
| 237 return; | 251 return; |
| 238 } | 252 } |
| 239 | 253 |
| 240 MarkRequestComplete(job->was_alpn_negotiated(), job->negotiated_protocol(), | 254 MarkRequestComplete(job->was_alpn_negotiated(), job->negotiated_protocol(), |
| 241 job->using_spdy()); | 255 job->using_spdy()); |
| 242 | 256 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 270 | 284 |
| 271 OnJobSucceeded(job); | 285 OnJobSucceeded(job); |
| 272 request_->OnWebSocketHandshakeStreamReady(used_ssl_config, used_proxy_info, | 286 request_->OnWebSocketHandshakeStreamReady(used_ssl_config, used_proxy_info, |
| 273 stream); | 287 stream); |
| 274 } | 288 } |
| 275 | 289 |
| 276 void HttpStreamFactoryImpl::JobController::OnStreamFailed( | 290 void HttpStreamFactoryImpl::JobController::OnStreamFailed( |
| 277 Job* job, | 291 Job* job, |
| 278 int status, | 292 int status, |
| 279 const SSLConfig& used_ssl_config) { | 293 const SSLConfig& used_ssl_config) { |
| 294 job->net_log().AddEvent( |
| 295 NetLogEventType::HTTP_STREAM_JOB_ON_STREAM_FAILED, |
| 296 NetLog::BoolCallback("is_orphaned", IsJobOrphaned(job))); |
| 280 if (job->job_type() == ALTERNATIVE) { | 297 if (job->job_type() == ALTERNATIVE) { |
| 281 DCHECK_EQ(alternative_job_.get(), job); | 298 DCHECK_EQ(alternative_job_.get(), job); |
| 282 OnAlternativeJobFailed(status); | 299 OnAlternativeJobFailed(status); |
| 283 } | 300 } |
| 284 | 301 |
| 285 MaybeResumeMainJob(job, base::TimeDelta()); | 302 MaybeResumeMainJob(job, base::TimeDelta()); |
| 286 | 303 |
| 287 if (IsJobOrphaned(job)) { | 304 if (IsJobOrphaned(job)) { |
| 288 // We have bound a job to the associated Request, |job| has been orphaned. | 305 // We have bound a job to the associated Request, |job| has been orphaned. |
| 289 OnOrphanedJobComplete(job); | 306 OnOrphanedJobComplete(job); |
| 290 return; | 307 return; |
| 291 } | 308 } |
| 292 | 309 |
| 293 if (!request_) | 310 if (!request_) { |
| 294 return; | 311 return; |
| 312 } |
| 295 DCHECK_NE(OK, status); | 313 DCHECK_NE(OK, status); |
| 296 DCHECK(job); | 314 DCHECK(job); |
| 297 | 315 |
| 298 if (!bound_job_) { | 316 if (!bound_job_) { |
| 299 if (main_job_ && alternative_job_) { | 317 if (main_job_ && alternative_job_) { |
| 300 // Hey, we've got other jobs! Maybe one of them will succeed, let's just | 318 // Hey, we've got other jobs! Maybe one of them will succeed, let's just |
| 301 // ignore this failure. | 319 // ignore this failure. |
| 302 factory_->request_map_.erase(job); | 320 factory_->request_map_.erase(job); |
| 303 if (job->job_type() == MAIN) { | 321 if (job->job_type() == MAIN) { |
| 304 main_job_.reset(); | 322 main_job_.reset(); |
| 305 } else { | 323 } else { |
| 306 DCHECK(job->job_type() == ALTERNATIVE); | 324 DCHECK(job->job_type() == ALTERNATIVE); |
| 325 job->net_log().AddEvent( |
| 326 NetLogEventType::ALT_JOB_DELETED_ON_STREAM_FAILED); |
| 307 alternative_job_.reset(); | 327 alternative_job_.reset(); |
| 308 } | 328 } |
| 309 return; | 329 return; |
| 310 } else { | 330 } else { |
| 311 BindJob(job); | 331 BindJob(job); |
| 312 } | 332 } |
| 313 } | 333 } |
| 314 | 334 |
| 315 request_->OnStreamFailed(status, used_ssl_config); | 335 request_->OnStreamFailed(status, used_ssl_config); |
| 316 } | 336 } |
| 317 | 337 |
| 318 void HttpStreamFactoryImpl::JobController::OnCertificateError( | 338 void HttpStreamFactoryImpl::JobController::OnCertificateError( |
| 319 Job* job, | 339 Job* job, |
| 320 int status, | 340 int status, |
| 321 const SSLConfig& used_ssl_config, | 341 const SSLConfig& used_ssl_config, |
| 322 const SSLInfo& ssl_info) { | 342 const SSLInfo& ssl_info) { |
| 343 job->net_log().AddEvent( |
| 344 NetLogEventType::HTTP_STREAM_JOB_ON_CERTIFICATE_ERROR, |
| 345 NetLog::BoolCallback("is_orphaned", IsJobOrphaned(job))); |
| 323 MaybeResumeMainJob(job, base::TimeDelta()); | 346 MaybeResumeMainJob(job, base::TimeDelta()); |
| 324 | 347 |
| 325 if (IsJobOrphaned(job)) { | 348 if (IsJobOrphaned(job)) { |
| 326 // We have bound a job to the associated Request, |job| has been orphaned. | 349 // We have bound a job to the associated Request, |job| has been orphaned. |
| 327 OnOrphanedJobComplete(job); | 350 OnOrphanedJobComplete(job); |
| 328 return; | 351 return; |
| 329 } | 352 } |
| 330 | 353 |
| 331 if (!request_) | 354 if (!request_) |
| 332 return; | 355 return; |
| 333 DCHECK_NE(OK, status); | 356 DCHECK_NE(OK, status); |
| 334 if (!bound_job_) | 357 if (!bound_job_) |
| 335 BindJob(job); | 358 BindJob(job); |
| 336 | 359 |
| 337 request_->OnCertificateError(status, used_ssl_config, ssl_info); | 360 request_->OnCertificateError(status, used_ssl_config, ssl_info); |
| 338 } | 361 } |
| 339 | 362 |
| 340 void HttpStreamFactoryImpl::JobController::OnHttpsProxyTunnelResponse( | 363 void HttpStreamFactoryImpl::JobController::OnHttpsProxyTunnelResponse( |
| 341 Job* job, | 364 Job* job, |
| 342 const HttpResponseInfo& response_info, | 365 const HttpResponseInfo& response_info, |
| 343 const SSLConfig& used_ssl_config, | 366 const SSLConfig& used_ssl_config, |
| 344 const ProxyInfo& used_proxy_info, | 367 const ProxyInfo& used_proxy_info, |
| 345 HttpStream* stream) { | 368 HttpStream* stream) { |
| 369 job->net_log().AddEvent( |
| 370 NetLogEventType::HTTP_STREAM_JOB_ON_HTTPS_PROXY_TUNNEL_REPONSE, |
| 371 NetLog::BoolCallback("is_orphaned", IsJobOrphaned(job))); |
| 346 MaybeResumeMainJob(job, base::TimeDelta()); | 372 MaybeResumeMainJob(job, base::TimeDelta()); |
| 347 | 373 |
| 348 if (IsJobOrphaned(job)) { | 374 if (IsJobOrphaned(job)) { |
| 349 // We have bound a job to the associated Request, |job| has been orphaned. | 375 // We have bound a job to the associated Request, |job| has been orphaned. |
| 350 OnOrphanedJobComplete(job); | 376 OnOrphanedJobComplete(job); |
| 351 return; | 377 return; |
| 352 } | 378 } |
| 353 | 379 |
| 354 if (!bound_job_) | 380 if (!bound_job_) |
| 355 BindJob(job); | 381 BindJob(job); |
| 356 if (!request_) | 382 if (!request_) |
| 357 return; | 383 return; |
| 358 request_->OnHttpsProxyTunnelResponse(response_info, used_ssl_config, | 384 request_->OnHttpsProxyTunnelResponse(response_info, used_ssl_config, |
| 359 used_proxy_info, stream); | 385 used_proxy_info, stream); |
| 360 } | 386 } |
| 361 | 387 |
| 362 void HttpStreamFactoryImpl::JobController::OnNeedsClientAuth( | 388 void HttpStreamFactoryImpl::JobController::OnNeedsClientAuth( |
| 363 Job* job, | 389 Job* job, |
| 364 const SSLConfig& used_ssl_config, | 390 const SSLConfig& used_ssl_config, |
| 365 SSLCertRequestInfo* cert_info) { | 391 SSLCertRequestInfo* cert_info) { |
| 392 job->net_log().AddEvent( |
| 393 NetLogEventType::HTTP_STREAM_JOB_ON_NEEDS_CLIENT_AUTH, |
| 394 NetLog::BoolCallback("is_orphaned", IsJobOrphaned(job))); |
| 395 |
| 366 MaybeResumeMainJob(job, base::TimeDelta()); | 396 MaybeResumeMainJob(job, base::TimeDelta()); |
| 367 | 397 |
| 368 if (IsJobOrphaned(job)) { | 398 if (IsJobOrphaned(job)) { |
| 369 // We have bound a job to the associated Request, |job| has been orphaned. | 399 // We have bound a job to the associated Request, |job| has been orphaned. |
| 370 OnOrphanedJobComplete(job); | 400 OnOrphanedJobComplete(job); |
| 371 return; | 401 return; |
| 372 } | 402 } |
| 373 if (!request_) | 403 if (!request_) |
| 374 return; | 404 return; |
| 375 if (!bound_job_) | 405 if (!bound_job_) |
| 376 BindJob(job); | 406 BindJob(job); |
| 377 | 407 |
| 378 request_->OnNeedsClientAuth(used_ssl_config, cert_info); | 408 request_->OnNeedsClientAuth(used_ssl_config, cert_info); |
| 379 } | 409 } |
| 380 | 410 |
| 381 void HttpStreamFactoryImpl::JobController::OnNeedsProxyAuth( | 411 void HttpStreamFactoryImpl::JobController::OnNeedsProxyAuth( |
| 382 Job* job, | 412 Job* job, |
| 383 const HttpResponseInfo& proxy_response, | 413 const HttpResponseInfo& proxy_response, |
| 384 const SSLConfig& used_ssl_config, | 414 const SSLConfig& used_ssl_config, |
| 385 const ProxyInfo& used_proxy_info, | 415 const ProxyInfo& used_proxy_info, |
| 386 HttpAuthController* auth_controller) { | 416 HttpAuthController* auth_controller) { |
| 417 job->net_log().AddEvent( |
| 418 NetLogEventType::HTTP_STREAM_JOB_ON_NEEDS_PROXY_AUTH, |
| 419 NetLog::BoolCallback("is_orphaned", IsJobOrphaned(job))); |
| 420 |
| 387 MaybeResumeMainJob(job, base::TimeDelta()); | 421 MaybeResumeMainJob(job, base::TimeDelta()); |
| 388 | 422 |
| 389 if (IsJobOrphaned(job)) { | 423 if (IsJobOrphaned(job)) { |
| 390 // We have bound a job to the associated Request, |job| has been orphaned. | 424 // We have bound a job to the associated Request, |job| has been orphaned. |
| 391 OnOrphanedJobComplete(job); | 425 OnOrphanedJobComplete(job); |
| 392 return; | 426 return; |
| 393 } | 427 } |
| 394 | 428 |
| 395 if (!request_) | 429 if (!request_) |
| 396 return; | 430 return; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 base::Bind( | 477 base::Bind( |
| 444 &HttpStreamFactoryImpl::JobController::StartAlternativeProxyServerJob, | 478 &HttpStreamFactoryImpl::JobController::StartAlternativeProxyServerJob, |
| 445 ptr_factory_.GetWeakPtr())); | 479 ptr_factory_.GetWeakPtr())); |
| 446 } | 480 } |
| 447 | 481 |
| 448 void HttpStreamFactoryImpl::JobController::OnNewSpdySessionReady( | 482 void HttpStreamFactoryImpl::JobController::OnNewSpdySessionReady( |
| 449 Job* job, | 483 Job* job, |
| 450 const base::WeakPtr<SpdySession>& spdy_session, | 484 const base::WeakPtr<SpdySession>& spdy_session, |
| 451 bool direct) { | 485 bool direct) { |
| 452 DCHECK(job); | 486 DCHECK(job); |
| 487 |
| 488 job->net_log().AddEvent( |
| 489 NetLogEventType::HTTP_STREAM_JOB_ON_NEW_SPDY_SESSION_READY, |
| 490 NetLog::BoolCallback("is_orphaned", IsJobOrphaned(job))); |
| 453 DCHECK(job->using_spdy()); | 491 DCHECK(job->using_spdy()); |
| 454 DCHECK(!is_preconnect_); | 492 DCHECK(!is_preconnect_); |
| 455 | 493 |
| 456 bool is_job_orphaned = IsJobOrphaned(job); | 494 bool is_job_orphaned = IsJobOrphaned(job); |
| 457 | 495 |
| 458 // Cache these values in case the job gets deleted. | 496 // Cache these values in case the job gets deleted. |
| 459 const SSLConfig used_ssl_config = job->server_ssl_config(); | 497 const SSLConfig used_ssl_config = job->server_ssl_config(); |
| 460 const ProxyInfo used_proxy_info = job->proxy_info(); | 498 const ProxyInfo used_proxy_info = job->proxy_info(); |
| 461 const bool was_alpn_negotiated = job->was_alpn_negotiated(); | 499 const bool was_alpn_negotiated = job->was_alpn_negotiated(); |
| 462 const NextProto negotiated_protocol = job->negotiated_protocol(); | 500 const NextProto negotiated_protocol = job->negotiated_protocol(); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 MaybeNotifyFactoryOfCompletion(); | 556 MaybeNotifyFactoryOfCompletion(); |
| 519 } | 557 } |
| 520 | 558 |
| 521 void HttpStreamFactoryImpl::JobController::OnOrphanedJobComplete( | 559 void HttpStreamFactoryImpl::JobController::OnOrphanedJobComplete( |
| 522 const Job* job) { | 560 const Job* job) { |
| 523 if (job->job_type() == MAIN) { | 561 if (job->job_type() == MAIN) { |
| 524 DCHECK_EQ(main_job_.get(), job); | 562 DCHECK_EQ(main_job_.get(), job); |
| 525 main_job_.reset(); | 563 main_job_.reset(); |
| 526 } else { | 564 } else { |
| 527 DCHECK_EQ(alternative_job_.get(), job); | 565 DCHECK_EQ(alternative_job_.get(), job); |
| 566 job->net_log().AddEvent( |
| 567 NetLogEventType::ALT_JOB_DELETED_IN_ON_ORPHANED_JOB_COMPLETE); |
| 528 alternative_job_.reset(); | 568 alternative_job_.reset(); |
| 529 } | 569 } |
| 530 | 570 |
| 531 MaybeNotifyFactoryOfCompletion(); | 571 MaybeNotifyFactoryOfCompletion(); |
| 532 } | 572 } |
| 533 | 573 |
| 534 void HttpStreamFactoryImpl::JobController::AddConnectionAttemptsToRequest( | 574 void HttpStreamFactoryImpl::JobController::AddConnectionAttemptsToRequest( |
| 535 Job* job, | 575 Job* job, |
| 536 const ConnectionAttempts& attempts) { | 576 const ConnectionAttempts& attempts) { |
| 537 if (is_preconnect_ || (job_bound_ && bound_job_ != job)) | 577 if (is_preconnect_ || (job_bound_ && bound_job_ != job)) |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 657 | 697 |
| 658 const NetLogWithSource* HttpStreamFactoryImpl::JobController::GetNetLog( | 698 const NetLogWithSource* HttpStreamFactoryImpl::JobController::GetNetLog( |
| 659 Job* job) const { | 699 Job* job) const { |
| 660 return &net_log_; | 700 return &net_log_; |
| 661 } | 701 } |
| 662 | 702 |
| 663 void HttpStreamFactoryImpl::JobController::MaybeSetWaitTimeForMainJob( | 703 void HttpStreamFactoryImpl::JobController::MaybeSetWaitTimeForMainJob( |
| 664 const base::TimeDelta& delay) { | 704 const base::TimeDelta& delay) { |
| 665 if (main_job_is_blocked_) { | 705 if (main_job_is_blocked_) { |
| 666 main_job_wait_time_ = std::min( | 706 main_job_wait_time_ = std::min( |
| 667 delay, base::TimeDelta::FromSeconds(kMaxDelayTimeForMainJobSecs)); | 707 delay, base::TimeDelta::FromMilliseconds(kMaxDelayTimeForMainJobSecs)); |
| 668 } | 708 } |
| 669 } | 709 } |
| 670 | 710 |
| 671 bool HttpStreamFactoryImpl::JobController::HasPendingMainJob() const { | 711 bool HttpStreamFactoryImpl::JobController::HasPendingMainJob() const { |
| 672 return main_job_.get() != nullptr; | 712 return main_job_.get() != nullptr; |
| 673 } | 713 } |
| 674 | 714 |
| 675 bool HttpStreamFactoryImpl::JobController::HasPendingAltJob() const { | 715 bool HttpStreamFactoryImpl::JobController::HasPendingAltJob() const { |
| 676 return alternative_job_.get() != nullptr; | 716 return alternative_job_.get() != nullptr; |
| 677 } | 717 } |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 766 OrphanUnboundJob(); | 806 OrphanUnboundJob(); |
| 767 } | 807 } |
| 768 | 808 |
| 769 void HttpStreamFactoryImpl::JobController::CancelJobs() { | 809 void HttpStreamFactoryImpl::JobController::CancelJobs() { |
| 770 DCHECK(request_); | 810 DCHECK(request_); |
| 771 RemoveRequestFromSpdySessionRequestMap(); | 811 RemoveRequestFromSpdySessionRequestMap(); |
| 772 if (job_bound_) | 812 if (job_bound_) |
| 773 return; | 813 return; |
| 774 if (alternative_job_) { | 814 if (alternative_job_) { |
| 775 factory_->request_map_.erase(alternative_job_.get()); | 815 factory_->request_map_.erase(alternative_job_.get()); |
| 816 if (alternative_job_) { |
| 817 alternative_job_->net_log().AddEvent( |
| 818 NetLogEventType::ALT_JOB_DELETED_ON_CANCEL_JOBS); |
| 819 } |
| 776 alternative_job_.reset(); | 820 alternative_job_.reset(); |
| 777 } | 821 } |
| 778 if (main_job_) { | 822 if (main_job_) { |
| 779 factory_->request_map_.erase(main_job_.get()); | 823 factory_->request_map_.erase(main_job_.get()); |
| 780 main_job_.reset(); | 824 main_job_.reset(); |
| 781 } | 825 } |
| 782 } | 826 } |
| 783 | 827 |
| 784 void HttpStreamFactoryImpl::JobController::OrphanUnboundJob() { | 828 void HttpStreamFactoryImpl::JobController::OrphanUnboundJob() { |
| 785 DCHECK(request_); | 829 DCHECK(request_); |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1168 return; | 1212 return; |
| 1169 DCHECK(alternative_job_->alternative_proxy_server().is_valid()); | 1213 DCHECK(alternative_job_->alternative_proxy_server().is_valid()); |
| 1170 alternative_job_->Start(request_->stream_type()); | 1214 alternative_job_->Start(request_->stream_type()); |
| 1171 } | 1215 } |
| 1172 | 1216 |
| 1173 bool HttpStreamFactoryImpl::JobController::IsJobOrphaned(Job* job) const { | 1217 bool HttpStreamFactoryImpl::JobController::IsJobOrphaned(Job* job) const { |
| 1174 return !request_ || (job_bound_ && bound_job_ != job); | 1218 return !request_ || (job_bound_ && bound_job_ != job); |
| 1175 } | 1219 } |
| 1176 | 1220 |
| 1177 } // namespace net | 1221 } // namespace net |
| OLD | NEW |