Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(336)

Side by Side Diff: net/http/http_stream_factory_impl_job_controller.cc

Issue 2690393005: Cap the delay time for the main job when racing with QUIC for delayed (Closed)
Patch Set: add comments Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 max time to delay the main job if is delayed TCP case.
Ryan Hamilton 2017/02/15 22:26:55 nit: // The maximum time to wait for the alternate
Zhongyi Shi 2017/02/15 23:32:33 Done.
32 const base::TimeDelta kMaxDelayTimeForMainJob = base::TimeDelta::FromSeconds(3);
Ryan Hamilton 2017/02/15 22:26:55 Alas, this is a static initializer which is prohib
Zhongyi Shi 2017/02/15 23:32:33 Done.
33
31 std::unique_ptr<base::Value> NetLogJobControllerCallback( 34 std::unique_ptr<base::Value> NetLogJobControllerCallback(
32 const GURL* url, 35 const GURL* url,
33 bool is_preconnect, 36 bool is_preconnect,
34 NetLogCaptureMode /* capture_mode */) { 37 NetLogCaptureMode /* capture_mode */) {
35 auto dict = base::MakeUnique<base::DictionaryValue>(); 38 auto dict = base::MakeUnique<base::DictionaryValue>();
36 dict->SetString("url", url->possibly_invalid_spec()); 39 dict->SetString("url", url->possibly_invalid_spec());
37 dict->SetBoolean("is_preconnect", is_preconnect); 40 dict->SetBoolean("is_preconnect", is_preconnect);
38 return std::move(dict); 41 return std::move(dict);
39 } 42 }
40 43
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 } 655 }
653 } 656 }
654 657
655 const NetLogWithSource* HttpStreamFactoryImpl::JobController::GetNetLog( 658 const NetLogWithSource* HttpStreamFactoryImpl::JobController::GetNetLog(
656 Job* job) const { 659 Job* job) const {
657 return &net_log_; 660 return &net_log_;
658 } 661 }
659 662
660 void HttpStreamFactoryImpl::JobController::MaybeSetWaitTimeForMainJob( 663 void HttpStreamFactoryImpl::JobController::MaybeSetWaitTimeForMainJob(
661 const base::TimeDelta& delay) { 664 const base::TimeDelta& delay) {
662 if (main_job_is_blocked_) 665 if (main_job_is_blocked_) {
663 main_job_wait_time_ = delay; 666 main_job_wait_time_ =
667 delay > kMaxDelayTimeForMainJob ? kMaxDelayTimeForMainJob : delay;
Ryan Hamilton 2017/02/15 22:26:55 can you do: main_job_wait_time_ = std::min(delay
Zhongyi Shi 2017/02/15 23:32:33 Done.
668 }
664 } 669 }
665 670
666 bool HttpStreamFactoryImpl::JobController::HasPendingMainJob() const { 671 bool HttpStreamFactoryImpl::JobController::HasPendingMainJob() const {
667 return main_job_.get() != nullptr; 672 return main_job_.get() != nullptr;
668 } 673 }
669 674
670 bool HttpStreamFactoryImpl::JobController::HasPendingAltJob() const { 675 bool HttpStreamFactoryImpl::JobController::HasPendingAltJob() const {
671 return alternative_job_.get() != nullptr; 676 return alternative_job_.get() != nullptr;
672 } 677 }
673 678
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
1163 return; 1168 return;
1164 DCHECK(alternative_job_->alternative_proxy_server().is_valid()); 1169 DCHECK(alternative_job_->alternative_proxy_server().is_valid());
1165 alternative_job_->Start(request_->stream_type()); 1170 alternative_job_->Start(request_->stream_type());
1166 } 1171 }
1167 1172
1168 bool HttpStreamFactoryImpl::JobController::IsJobOrphaned(Job* job) const { 1173 bool HttpStreamFactoryImpl::JobController::IsJobOrphaned(Job* job) const {
1169 return !request_ || (job_bound_ && bound_job_ != job); 1174 return !request_ || (job_bound_ && bound_job_ != job);
1170 } 1175 }
1171 1176
1172 } // namespace net 1177 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698