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

Unified Diff: net/http/http_stream_factory_impl_job_controller.cc

Issue 2332193003: JobController3: Move MarkAlternativeServiceBroken to job controller (Closed)
Patch Set: some nits Created 4 years, 3 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 c1efb61c4db40774d5d6e596e561b2fc464e07af..4f2d0e3bbe6e57d0eca7a2b1dae52ce53ed317c3 100644
--- a/net/http/http_stream_factory_impl_job_controller.cc
+++ b/net/http/http_stream_factory_impl_job_controller.cc
@@ -38,6 +38,8 @@ HttpStreamFactoryImpl::JobController::JobController(
request_(nullptr),
delegate_(delegate),
is_preconnect_(false),
+ alternative_service_is_broken_(false),
+ alternative_proxy_server_is_broken_(false),
job_bound_(false),
main_job_is_blocked_(false),
bound_job_(nullptr),
@@ -160,11 +162,26 @@ void HttpStreamFactoryImpl::JobController::SetPriority(
}
}
+void HttpStreamFactoryImpl::JobController::OnAlternativeServiceBroken(
+ Job* job) {
+ DCHECK_EQ(job, alternative_job_.get());
+ alternative_service_is_broken_ = true;
+ broken_alternative_service_ = job->alternative_service();
+}
+
+void HttpStreamFactoryImpl::JobController::OnAlternativeProxyServerBroken(
+ Job* job) {
+ DCHECK_EQ(job, alternative_job_.get());
+ alternative_proxy_server_is_broken_ = true;
+ broken_alternative_proxy_server_ = job->alternative_proxy_server();
+}
+
void HttpStreamFactoryImpl::JobController::OnStreamReady(
Job* job,
const SSLConfig& used_ssl_config,
const ProxyInfo& used_proxy_info) {
DCHECK(job);
+ MaybeMarkAlternativeServiceBroken();
if (job_bound_ && bound_job_ != job) {
// We have bound a job to the associated Request, |job| has been orphaned.
@@ -190,6 +207,7 @@ void HttpStreamFactoryImpl::JobController::OnBidirectionalStreamImplReady(
const SSLConfig& used_ssl_config,
const ProxyInfo& used_proxy_info) {
DCHECK(job);
+ MaybeMarkAlternativeServiceBroken();
if (job_bound_ && bound_job_ != job) {
// We have bound a job to the associated Request, |job| has been orphaned.
@@ -219,6 +237,7 @@ void HttpStreamFactoryImpl::JobController::OnWebSocketHandshakeStreamReady(
const ProxyInfo& used_proxy_info,
WebSocketHandshakeStreamBase* stream) {
DCHECK(job);
+ MaybeMarkAlternativeServiceBroken();
MarkRequestComplete(job->was_npn_negotiated(), job->negotiated_protocol(),
job->using_spdy());
@@ -256,13 +275,10 @@ void HttpStreamFactoryImpl::JobController::OnStreamFailed(
// Hey, we've got other jobs! Maybe one of them will succeed, let's just
// ignore this failure.
factory_->request_map_.erase(job);
- // Notify all the other jobs that this one failed.
if (job->job_type() == MAIN) {
- alternative_job_->MarkOtherJobComplete(*job);
main_job_.reset();
} else {
DCHECK(job->job_type() == ALTERNATIVE);
- main_job_->MarkOtherJobComplete(*job);
alternative_job_.reset();
}
return;
@@ -404,6 +420,7 @@ void HttpStreamFactoryImpl::JobController::OnNewSpdySessionReady(
bool direct) {
DCHECK(job);
DCHECK(job->using_spdy());
+ MaybeMarkAlternativeServiceBroken();
bool is_job_orphaned = job_bound_ && bound_job_ != job;
@@ -732,16 +749,8 @@ void HttpStreamFactoryImpl::JobController::OnJobSucceeded(Job* job) {
return;
}
if (!bound_job_) {
- if (main_job_ && alternative_job_) {
+ if (main_job_ && alternative_job_)
job->ReportJobSucceededForRequest();
- // Notify all the other jobs that this one succeeded.
- if (job->job_type() == MAIN) {
- alternative_job_->MarkOtherJobComplete(*job);
- } else {
- DCHECK(job->job_type() == ALTERNATIVE);
- main_job_->MarkOtherJobComplete(*job);
- }
- }
BindJob(job);
return;
}
@@ -756,6 +765,26 @@ void HttpStreamFactoryImpl::JobController::MarkRequestComplete(
request_->Complete(was_npn_negotiated, negotiated_protocol, using_spdy);
}
+void HttpStreamFactoryImpl::JobController::MaybeMarkAlternativeServiceBroken() {
+ if (!alternative_service_is_broken_ && !alternative_proxy_server_is_broken_)
+ return;
+
+ DCHECK(!alternative_service_is_broken_ ||
+ !alternative_proxy_server_is_broken_);
+ if (alternative_service_is_broken_) {
+ HistogramBrokenAlternateProtocolLocation(
+ BROKEN_ALTERNATE_PROTOCOL_LOCATION_HTTP_STREAM_FACTORY_IMPL_JOB_ALT);
+ session_->http_server_properties()->MarkAlternativeServiceBroken(
+ broken_alternative_service_);
+ } else {
+ ProxyDelegate* proxy_delegate = session_->params().proxy_delegate;
+ if (proxy_delegate)
+ proxy_delegate->OnAlternativeProxyBroken(
tbansal1 2016/09/13 05:06:45 nit: missing parenthesis.
+ broken_alternative_proxy_server_);
+ }
+ session_->quic_stream_factory()->OnTcpJobCompleted(true);
+}
+
void HttpStreamFactoryImpl::JobController::MaybeNotifyFactoryOfCompletion() {
if (!request_ && !main_job_ && !alternative_job_) {
DCHECK(!bound_job_);

Powered by Google App Engine
This is Rietveld 408576698