| 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 "base/metrics/histogram_macros.h" | 7 #include "base/metrics/histogram_macros.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| 11 #include "net/base/host_mapping_rules.h" | 11 #include "net/base/host_mapping_rules.h" |
| 12 #include "net/base/proxy_delegate.h" | 12 #include "net/base/proxy_delegate.h" |
| 13 #include "net/http/bidirectional_stream_impl.h" | 13 #include "net/http/bidirectional_stream_impl.h" |
| 14 #include "net/http/transport_security_state.h" | 14 #include "net/http/transport_security_state.h" |
| 15 #include "net/log/net_log_event_type.h" |
| 15 #include "net/proxy/proxy_server.h" | 16 #include "net/proxy/proxy_server.h" |
| 16 #include "net/spdy/spdy_session.h" | 17 #include "net/spdy/spdy_session.h" |
| 17 | 18 |
| 18 namespace net { | 19 namespace net { |
| 19 | 20 |
| 20 // Returns parameters associated with the delay of the HTTP stream job. | 21 // Returns parameters associated with the delay of the HTTP stream job. |
| 21 std::unique_ptr<base::Value> NetLogHttpStreamJobDelayCallback( | 22 std::unique_ptr<base::Value> NetLogHttpStreamJobDelayCallback( |
| 22 base::TimeDelta delay, | 23 base::TimeDelta delay, |
| 23 NetLogCaptureMode /* capture_mode */) { | 24 NetLogCaptureMode /* capture_mode */) { |
| 24 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 25 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
| (...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 const ConnectionAttempts& attempts) { | 486 const ConnectionAttempts& attempts) { |
| 486 if (is_preconnect_ || (job_bound_ && bound_job_ != job)) | 487 if (is_preconnect_ || (job_bound_ && bound_job_ != job)) |
| 487 return; | 488 return; |
| 488 | 489 |
| 489 DCHECK(request_); | 490 DCHECK(request_); |
| 490 request_->AddConnectionAttempts(attempts); | 491 request_->AddConnectionAttempts(attempts); |
| 491 } | 492 } |
| 492 | 493 |
| 493 void HttpStreamFactoryImpl::JobController::ResumeMainJob() { | 494 void HttpStreamFactoryImpl::JobController::ResumeMainJob() { |
| 494 main_job_->net_log().AddEvent( | 495 main_job_->net_log().AddEvent( |
| 495 NetLog::TYPE_HTTP_STREAM_JOB_DELAYED, | 496 NetLogEventType::HTTP_STREAM_JOB_DELAYED, |
| 496 base::Bind(&NetLogHttpStreamJobDelayCallback, main_job_wait_time_)); | 497 base::Bind(&NetLogHttpStreamJobDelayCallback, main_job_wait_time_)); |
| 497 | 498 |
| 498 main_job_->Resume(); | 499 main_job_->Resume(); |
| 499 main_job_wait_time_ = base::TimeDelta(); | 500 main_job_wait_time_ = base::TimeDelta(); |
| 500 } | 501 } |
| 501 | 502 |
| 502 void HttpStreamFactoryImpl::JobController::MaybeResumeMainJob( | 503 void HttpStreamFactoryImpl::JobController::MaybeResumeMainJob( |
| 503 Job* job, | 504 Job* job, |
| 504 const base::TimeDelta& delay) { | 505 const base::TimeDelta& delay) { |
| 505 DCHECK(job == main_job_.get() || job == alternative_job_.get()); | 506 DCHECK(job == main_job_.get() || job == alternative_job_.get()); |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 668 DCHECK(job); | 669 DCHECK(job); |
| 669 DCHECK(job == alternative_job_.get() || job == main_job_.get()); | 670 DCHECK(job == alternative_job_.get() || job == main_job_.get()); |
| 670 DCHECK(!job_bound_); | 671 DCHECK(!job_bound_); |
| 671 DCHECK(!bound_job_); | 672 DCHECK(!bound_job_); |
| 672 | 673 |
| 673 job_bound_ = true; | 674 job_bound_ = true; |
| 674 bound_job_ = job; | 675 bound_job_ = job; |
| 675 factory_->request_map_.erase(job); | 676 factory_->request_map_.erase(job); |
| 676 | 677 |
| 677 request_->net_log().AddEvent( | 678 request_->net_log().AddEvent( |
| 678 NetLog::TYPE_HTTP_STREAM_REQUEST_BOUND_TO_JOB, | 679 NetLogEventType::HTTP_STREAM_REQUEST_BOUND_TO_JOB, |
| 679 job->net_log().source().ToEventParametersCallback()); | 680 job->net_log().source().ToEventParametersCallback()); |
| 680 job->net_log().AddEvent( | 681 job->net_log().AddEvent( |
| 681 NetLog::TYPE_HTTP_STREAM_JOB_BOUND_TO_REQUEST, | 682 NetLogEventType::HTTP_STREAM_JOB_BOUND_TO_REQUEST, |
| 682 request_->net_log().source().ToEventParametersCallback()); | 683 request_->net_log().source().ToEventParametersCallback()); |
| 683 | 684 |
| 684 OrphanUnboundJob(); | 685 OrphanUnboundJob(); |
| 685 } | 686 } |
| 686 | 687 |
| 687 void HttpStreamFactoryImpl::JobController::CancelJobs() { | 688 void HttpStreamFactoryImpl::JobController::CancelJobs() { |
| 688 DCHECK(request_); | 689 DCHECK(request_); |
| 689 RemoveRequestFromSpdySessionRequestMap(); | 690 RemoveRequestFromSpdySessionRequestMap(); |
| 690 if (job_bound_) | 691 if (job_bound_) |
| 691 return; | 692 return; |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1002 if (!session_->params().enable_quic || | 1003 if (!session_->params().enable_quic || |
| 1003 session_->quic_stream_factory()->IsQuicDisabled( | 1004 session_->quic_stream_factory()->IsQuicDisabled( |
| 1004 alternative_proxy_server->host_port_pair().port())) { | 1005 alternative_proxy_server->host_port_pair().port())) { |
| 1005 return false; | 1006 return false; |
| 1006 } | 1007 } |
| 1007 } | 1008 } |
| 1008 | 1009 |
| 1009 return true; | 1010 return true; |
| 1010 } | 1011 } |
| 1011 } | 1012 } |
| OLD | NEW |