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

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: Created 4 years, 7 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 6b648d3cc3771b74a0491c66bf0d806dda4faaeb..28ab37d2145005abeb398166f48ea31b6cd5061e 100644
--- a/net/http/http_stream_factory_impl_job_controller.cc
+++ b/net/http/http_stream_factory_impl_job_controller.cc
@@ -16,11 +16,14 @@ HttpStreamFactoryImpl::JobController::JobController(
: factory_(factory),
request_(NULL),
main_job_(NULL),
- alternative_job_(NULL) {
+ alternative_job_(NULL),
+ racing_(false) {
DCHECK(factory);
}
HttpStreamFactoryImpl::JobController::~JobController() {
+ DCHECK(jobs_.empty());
+ DCHECK(!bound_job_.get());
std::set<const Job*> tmp_job_set;
tmp_job_set.swap(orphaned_job_set_);
STLDeleteContainerPointers(tmp_job_set.begin(), tmp_job_set.end());
@@ -59,9 +62,9 @@ void HttpStreamFactoryImpl::JobController::Start(
GURL origin_url =
factory_->ApplyHostMappingRules(request_info.url, &destination);
- main_job_ =
- new Job(this, session, request_info, priority, server_ssl_config,
- proxy_ssl_config, destination, origin_url, net_log.net_log());
+ main_job_ = new Job(this, NON_ALTERNATIVE, session, request_info, priority,
+ server_ssl_config, proxy_ssl_config, destination,
+ origin_url, net_log.net_log());
jobs_.insert(main_job_);
AttachJob(main_job_);
@@ -81,16 +84,12 @@ void HttpStreamFactoryImpl::JobController::Start(
&alternative_destination));
alternative_job_ =
- new Job(this, session, request_info, priority, server_ssl_config,
- proxy_ssl_config, alternative_destination, origin_url,
- alternative_service, net_log.net_log());
+ new Job(this, ALTERNATIVE, session, request_info, priority,
+ server_ssl_config, proxy_ssl_config, alternative_destination,
+ origin_url, alternative_service, net_log.net_log());
jobs_.insert(alternative_job_);
AttachJob(alternative_job_);
-
- main_job_->WaitFor(alternative_job_);
- // Make sure to wait until we call WaitFor(), before starting
- // |alternative_job|, otherwise |alternative_job| will not notify |job|
- // appropriately.
+ racing_ = true;
alternative_job_->Start(request_);
}
// Even if |alternative_job| has already finished, it will not have notified
@@ -133,9 +132,9 @@ void HttpStreamFactoryImpl::JobController::Preconnect(
// priority currently makes sense for preconnects. The priority for
// preconnects is currently ignored (see RequestSocketsForPool()), but could
// be used at some point for proxy resolution or something.
- main_job_ = new Job(this, session, request_info, IDLE, server_ssl_config,
- proxy_ssl_config, destination, origin_url,
- alternative_service, session->net_log());
+ main_job_ = new Job(this, PRECONNECT, session, request_info, IDLE,
+ server_ssl_config, proxy_ssl_config, destination,
+ origin_url, alternative_service, session->net_log());
jobs_.insert(main_job_);
main_job_->Preconnect(num_streams);
}
@@ -340,6 +339,7 @@ void HttpStreamFactoryImpl::JobController::OnStreamFailed(
// ignore this failure.
jobs_.erase(job);
factory_->request_map_.erase(job);
+ DCHECK_EQ(jobs_.size(), 1u);
// Notify all the other jobs that this one failed.
for (std::set<Job*>::iterator it = jobs_.begin(); it != jobs_.end(); ++it)
(*it)->MarkOtherJobComplete(*job);
@@ -479,6 +479,18 @@ void HttpStreamFactoryImpl::JobController::OnOrphanedJobComplete(
MaybeNotifyFactoryOfCompletion();
}
+void HttpStreamFactoryImpl::JobController::OnJobDeletion(Job* job) {
+ DCHECK(!ContainsKey(jobs_, job));
+ DCHECK(job);
+ if (job == main_job_) {
+ main_job_ = NULL;
Ryan Hamilton 2016/05/06 21:33:14 nullptr is cool now, NULL is *so* 2015 :>
Zhongyi Shi 2016/05/13 00:31:25 Acknowledged.
+ } else if (job == alternative_job_) {
+ alternative_job_ = NULL;
+ } else {
+ NOTREACHED();
+ }
+}
+
void HttpStreamFactoryImpl::JobController::AddConnectionAttemptsToRequest(
const ConnectionAttempts& attempts) {
DCHECK(request_);
@@ -506,6 +518,20 @@ void HttpStreamFactoryImpl::JobController::MaybeNotifyFactoryOfCompletion() {
}
}
+void HttpStreamFactoryImpl::JobController::MaybeResumeOtherJob(
+ Job* job,
+ const base::TimeDelta& delay) {
+ if (!racing_)
+ return;
+
+ if (job == alternative_job_ && main_job_) {
+ main_job_->Resume(delay);
+ } else if (job != main_job_ && job != alternative_job_) {
+ NOTREACHED();
+ }
+ racing_ = false;
+}
+
const BoundNetLog& HttpStreamFactoryImpl::JobController::GetNetLogFromRequest()
const {
DCHECK(request_);

Powered by Google App Engine
This is Rietveld 408576698