| 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 10 matching lines...) Expand all Loading... |
| 21 #include "net/log/net_log_capture_mode.h" | 21 #include "net/log/net_log_capture_mode.h" |
| 22 #include "net/log/net_log_event_type.h" | 22 #include "net/log/net_log_event_type.h" |
| 23 #include "net/log/net_log_source.h" | 23 #include "net/log/net_log_source.h" |
| 24 #include "net/log/net_log_with_source.h" | 24 #include "net/log/net_log_with_source.h" |
| 25 #include "net/proxy/proxy_server.h" | 25 #include "net/proxy/proxy_server.h" |
| 26 #include "net/spdy/spdy_session.h" | 26 #include "net/spdy/spdy_session.h" |
| 27 #include "url/url_constants.h" | 27 #include "url/url_constants.h" |
| 28 | 28 |
| 29 namespace net { | 29 namespace net { |
| 30 | 30 |
| 31 // The maximum time to wait for the alternate job to complete before resuming |
| 32 // the main job. |
| 33 const int kMaxDelayTimeForMainJobSecs = 3; |
| 34 |
| 31 std::unique_ptr<base::Value> NetLogJobControllerCallback( | 35 std::unique_ptr<base::Value> NetLogJobControllerCallback( |
| 32 const GURL* url, | 36 const GURL* url, |
| 33 bool is_preconnect, | 37 bool is_preconnect, |
| 34 NetLogCaptureMode /* capture_mode */) { | 38 NetLogCaptureMode /* capture_mode */) { |
| 35 auto dict = base::MakeUnique<base::DictionaryValue>(); | 39 auto dict = base::MakeUnique<base::DictionaryValue>(); |
| 36 dict->SetString("url", url->possibly_invalid_spec()); | 40 dict->SetString("url", url->possibly_invalid_spec()); |
| 37 dict->SetBoolean("is_preconnect", is_preconnect); | 41 dict->SetBoolean("is_preconnect", is_preconnect); |
| 38 return std::move(dict); | 42 return std::move(dict); |
| 39 } | 43 } |
| 40 | 44 |
| (...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 652 } | 656 } |
| 653 } | 657 } |
| 654 | 658 |
| 655 const NetLogWithSource* HttpStreamFactoryImpl::JobController::GetNetLog( | 659 const NetLogWithSource* HttpStreamFactoryImpl::JobController::GetNetLog( |
| 656 Job* job) const { | 660 Job* job) const { |
| 657 return &net_log_; | 661 return &net_log_; |
| 658 } | 662 } |
| 659 | 663 |
| 660 void HttpStreamFactoryImpl::JobController::MaybeSetWaitTimeForMainJob( | 664 void HttpStreamFactoryImpl::JobController::MaybeSetWaitTimeForMainJob( |
| 661 const base::TimeDelta& delay) { | 665 const base::TimeDelta& delay) { |
| 662 if (main_job_is_blocked_) | 666 if (main_job_is_blocked_) { |
| 663 main_job_wait_time_ = delay; | 667 main_job_wait_time_ = std::min( |
| 668 delay, base::TimeDelta::FromSeconds(kMaxDelayTimeForMainJobSecs)); |
| 669 } |
| 664 } | 670 } |
| 665 | 671 |
| 666 bool HttpStreamFactoryImpl::JobController::HasPendingMainJob() const { | 672 bool HttpStreamFactoryImpl::JobController::HasPendingMainJob() const { |
| 667 return main_job_.get() != nullptr; | 673 return main_job_.get() != nullptr; |
| 668 } | 674 } |
| 669 | 675 |
| 670 bool HttpStreamFactoryImpl::JobController::HasPendingAltJob() const { | 676 bool HttpStreamFactoryImpl::JobController::HasPendingAltJob() const { |
| 671 return alternative_job_.get() != nullptr; | 677 return alternative_job_.get() != nullptr; |
| 672 } | 678 } |
| 673 | 679 |
| (...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1163 return; | 1169 return; |
| 1164 DCHECK(alternative_job_->alternative_proxy_server().is_valid()); | 1170 DCHECK(alternative_job_->alternative_proxy_server().is_valid()); |
| 1165 alternative_job_->Start(request_->stream_type()); | 1171 alternative_job_->Start(request_->stream_type()); |
| 1166 } | 1172 } |
| 1167 | 1173 |
| 1168 bool HttpStreamFactoryImpl::JobController::IsJobOrphaned(Job* job) const { | 1174 bool HttpStreamFactoryImpl::JobController::IsJobOrphaned(Job* job) const { |
| 1169 return !request_ || (job_bound_ && bound_job_ != job); | 1175 return !request_ || (job_bound_ && bound_job_ != job); |
| 1170 } | 1176 } |
| 1171 | 1177 |
| 1172 } // namespace net | 1178 } // namespace net |
| OLD | NEW |