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

Unified Diff: net/http/http_stream_factory_impl_job_controller.cc

Issue 1952423002: JobController 2: Remove reference between HttpStreamFactoryImpl::Jobs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Job_Controller_1
Patch Set: move resume logic up to controller Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: net/http/http_stream_factory_impl_job_controller.cc
diff --git a/net/http/http_stream_factory_impl_job_controller.cc b/net/http/http_stream_factory_impl_job_controller.cc
index bd3f2e3bd7cdad801af6e1202c231e9f134b909f..21c5be5e91b45aba4d3809a813cbdd3e01265a48 100644
--- a/net/http/http_stream_factory_impl_job_controller.cc
+++ b/net/http/http_stream_factory_impl_job_controller.cc
@@ -26,6 +26,7 @@ HttpStreamFactoryImpl::JobController::JobController(
delegate_(delegate),
is_preconnect_(false),
job_bound_(false),
+ blocking_(false),
bound_job_(nullptr) {
DCHECK(factory);
}
@@ -223,6 +224,7 @@ void HttpStreamFactoryImpl::JobController::OnStreamFailed(
int status,
const SSLConfig& used_ssl_config,
SSLFailureState ssl_failure_state) {
+ MaybeResumeOtherJob(job, base::TimeDelta());
Ryan Hamilton 2016/06/29 23:12:28 Looks like the other places this is called there i
Zhongyi Shi 2016/06/30 22:53:39 Done.
if (job_bound_ && bound_job_ != job) {
// We have bound a job to the associated Request, |job| has been orphaned.
OnOrphanedJobComplete(job);
@@ -262,6 +264,8 @@ void HttpStreamFactoryImpl::JobController::OnCertificateError(
int status,
const SSLConfig& used_ssl_config,
const SSLInfo& ssl_info) {
+ MaybeResumeOtherJob(job, base::TimeDelta());
+
if (job_bound_ && bound_job_ != job) {
// We have bound a job to the associated Request, |job| has been orphaned.
OnOrphanedJobComplete(job);
@@ -283,6 +287,8 @@ void HttpStreamFactoryImpl::JobController::OnHttpsProxyTunnelResponse(
const SSLConfig& used_ssl_config,
const ProxyInfo& used_proxy_info,
HttpStream* stream) {
+ MaybeResumeOtherJob(job, base::TimeDelta());
+
if (job_bound_ && bound_job_ != job) {
// We have bound a job to the associated Request, |job| has been orphaned.
OnOrphanedJobComplete(job);
@@ -301,6 +307,8 @@ void HttpStreamFactoryImpl::JobController::OnNeedsClientAuth(
Job* job,
const SSLConfig& used_ssl_config,
SSLCertRequestInfo* cert_info) {
+ MaybeResumeOtherJob(job, base::TimeDelta());
+
if (job_bound_ && bound_job_ != job) {
// We have bound a job to the associated Request, |job| has been orphaned.
OnOrphanedJobComplete(job);
@@ -320,6 +328,7 @@ void HttpStreamFactoryImpl::JobController::OnNeedsProxyAuth(
const SSLConfig& used_ssl_config,
const ProxyInfo& used_proxy_info,
HttpAuthController* auth_controller) {
+ MaybeResumeOtherJob(job, base::TimeDelta());
Ryan Hamilton 2016/06/29 23:12:28 ditto.
Zhongyi Shi 2016/06/30 22:53:39 Done.
if (job_bound_ && bound_job_ != job) {
// We have bound a job to the associated Request, |job| has been orphaned.
OnOrphanedJobComplete(job);
@@ -399,6 +408,7 @@ void HttpStreamFactoryImpl::JobController::OnNewSpdySessionReady(
void HttpStreamFactoryImpl::JobController::OnPreconnectsComplete(Job* job) {
DCHECK_EQ(main_job_.get(), job);
+ DCHECK(!bound_job_);
main_job_.reset();
factory_->OnPreconnectsCompleteInternal();
MaybeNotifyFactoryOfCompletion();
@@ -427,6 +437,39 @@ void HttpStreamFactoryImpl::JobController::AddConnectionAttemptsToRequest(
request_->AddConnectionAttempts(attempts);
}
+void HttpStreamFactoryImpl::JobController::MaybeResumeOtherJob(
+ Job* job,
+ const base::TimeDelta& delay) {
+ DCHECK(job == main_job_.get() || job == alternative_job_.get());
+ if (!blocking_)
+ return;
+
+ if (job == alternative_job_.get() && main_job_) {
+ blocking_ = false;
+ main_job_->Resume(delay);
Ryan Hamilton 2016/06/29 23:12:28 I'm confused about when wait_time_ is used to resu
+ }
+}
+
+void HttpStreamFactoryImpl::JobController::OnInitConnectionNotSuccessful(
+ Job* job,
+ const base::TimeDelta& delay) {
+ return MaybeResumeOtherJob(job, delay);
+}
+
+bool HttpStreamFactoryImpl::JobController::ShoudWait(Job* job) const {
+ base::WeakPtrFactory<Job> ptr_factory(job);
+ if (wait_time_.is_zero()) {
+ if (job->job_type() == ALTERNATIVE || !blocking_) {
+ // There is no blocking job and there is no |wait_time_|.
+ return false;
+ }
+ } else {
+ DCHECK(job->job_type() == ALTERNATIVE || !blocking_);
+ job->ResumeAfterDelay(wait_time_);
+ }
+ return true;
+}
+
void HttpStreamFactoryImpl::JobController::SetSpdySessionKey(
Job* job,
const SpdySessionKey& spdy_session_key) {
@@ -476,6 +519,20 @@ const BoundNetLog* HttpStreamFactoryImpl::JobController::GetNetLog(
return &request_->net_log();
}
+const base::TimeDelta&
+HttpStreamFactoryImpl::JobController::wait_time_for_main_job() const {
+ return wait_time_;
+}
+
+void HttpStreamFactoryImpl::JobController::set_wait_time_for_main_job(
+ const base::TimeDelta& delay) {
+ wait_time_ = delay;
+}
+
+bool HttpStreamFactoryImpl::JobController::blocking() {
+ return blocking_;
+}
+
WebSocketHandshakeStreamBase::CreateHelper* HttpStreamFactoryImpl::
JobController::websocket_handshake_stream_create_helper() {
DCHECK(request_);
@@ -521,10 +578,7 @@ void HttpStreamFactoryImpl::JobController::CreateJobs(
alternative_service, net_log.net_log()));
AttachJob(alternative_job_.get());
- main_job_->WaitFor(alternative_job_.get());
- // Make sure to wait until we call WaitFor(), before starting
- // |alternative_job|, otherwise |alternative_job| will not notify |job|
- // appropriately.
+ blocking_ = true;
alternative_job_->Start(request_->stream_type());
}
// Even if |alternative_job| has already finished, it will not have notified

Powered by Google App Engine
This is Rietveld 408576698