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

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

Issue 2595413002: Race preconnects to HTTP2 proxies that support alternate proxies
Patch Set: ps Created 3 years, 11 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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.h" 5 #include "net/http/http_stream_factory_impl_job.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 DCHECK(!alternative_proxy_server_.is_valid() || 218 DCHECK(!alternative_proxy_server_.is_valid() ||
219 !(IsSpdyAlternative() || IsQuicAlternative())); 219 !(IsSpdyAlternative() || IsQuicAlternative()));
220 // If either the alternative service protocol is specified or if the 220 // If either the alternative service protocol is specified or if the
221 // alternative proxy server is valid, then the job type must be set to 221 // alternative proxy server is valid, then the job type must be set to
222 // either ALTERNATIVE or PRECONNECT. 222 // either ALTERNATIVE or PRECONNECT.
223 DCHECK((alternative_service_.protocol == kProtoUnknown && 223 DCHECK((alternative_service_.protocol == kProtoUnknown &&
224 !alternative_proxy_server_.is_valid()) || 224 !alternative_proxy_server_.is_valid()) ||
225 (job_type_ == ALTERNATIVE || job_type_ == PRECONNECT)); 225 (job_type_ == ALTERNATIVE || job_type_ == PRECONNECT));
226 // If the alternative proxy server is valid, then the job type must be 226 // If the alternative proxy server is valid, then the job type must be
227 // set to ALTERNATIVE. 227 // set to ALTERNATIVE.
228 DCHECK(!alternative_proxy_server_.is_valid() || job_type_ == ALTERNATIVE); 228 DCHECK(!alternative_proxy_server_.is_valid() || job_type_ != MAIN);
229 229
230 if (IsSpdyAlternative()) { 230 if (IsSpdyAlternative()) {
231 DCHECK(origin_url_.SchemeIs(url::kHttpsScheme)); 231 DCHECK(origin_url_.SchemeIs(url::kHttpsScheme));
232 } 232 }
233 if (IsQuicAlternative()) { 233 if (IsQuicAlternative()) {
234 DCHECK(session_->params().enable_quic); 234 DCHECK(session_->params().enable_quic);
235 using_quic_ = true; 235 using_quic_ = true;
236 } 236 }
237 } 237 }
238 238
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 return session_->proxy_service()->GetLoadState(pac_request_); 289 return session_->proxy_service()->GetLoadState(pac_request_);
290 case STATE_INIT_CONNECTION_COMPLETE: 290 case STATE_INIT_CONNECTION_COMPLETE:
291 case STATE_CREATE_STREAM_COMPLETE: 291 case STATE_CREATE_STREAM_COMPLETE:
292 return using_quic_ ? LOAD_STATE_CONNECTING : connection_->GetLoadState(); 292 return using_quic_ ? LOAD_STATE_CONNECTING : connection_->GetLoadState();
293 default: 293 default:
294 return LOAD_STATE_IDLE; 294 return LOAD_STATE_IDLE;
295 } 295 }
296 } 296 }
297 297
298 void HttpStreamFactoryImpl::Job::Resume() { 298 void HttpStreamFactoryImpl::Job::Resume() {
299 DCHECK_EQ(job_type_, MAIN); 299 DCHECK(job_type_ == MAIN || job_type_ == PRECONNECT);
300 DCHECK_EQ(next_state_, STATE_WAIT_COMPLETE); 300 DCHECK_EQ(next_state_, STATE_WAIT_COMPLETE);
301 OnIOComplete(OK); 301 OnIOComplete(OK);
302 } 302 }
303 303
304 void HttpStreamFactoryImpl::Job::Orphan() { 304 void HttpStreamFactoryImpl::Job::Orphan() {
305 net_log_.AddEvent(NetLogEventType::HTTP_STREAM_JOB_ORPHANED); 305 net_log_.AddEvent(NetLogEventType::HTTP_STREAM_JOB_ORPHANED);
306 306
307 if (delegate_->for_websockets()) { 307 if (delegate_->for_websockets()) {
308 // We cancel this job because a WebSocketHandshakeStream can't be created 308 // We cancel this job because a WebSocketHandshakeStream can't be created
309 // without a WebSocketHandshakeStreamBase::CreateHelper which is stored in 309 // without a WebSocketHandshakeStreamBase::CreateHelper which is stored in
310 // the Request class and isn't retrievable by this job. 310 // the Request class and isn't retrievable by this job.
311 if (connection_ && connection_->socket()) { 311 if (connection_ && connection_->socket()) {
312 connection_->socket()->Disconnect(); 312 connection_->socket()->Disconnect();
313 } 313 }
314 delegate_->OnOrphanedJobComplete(this); 314 delegate_->OnOrphanedJobComplete(this);
315 } 315 }
316 // |this| may be deleted after this call. 316 // |this| may be deleted after this call.
317 } 317 }
318 318
319 void HttpStreamFactoryImpl::Job::SetPriority(RequestPriority priority) { 319 void HttpStreamFactoryImpl::Job::SetPriority(RequestPriority priority) {
320 priority_ = priority; 320 priority_ = priority;
321 // TODO(akalin): Propagate this to |connection_| and maybe the 321 // TODO(akalin): Propagate this to |connection_| and maybe the
322 // preconnect state. 322 // preconnect state.
323 } 323 }
324 324
325 void HttpStreamFactoryImpl::Job::RestrictNumStreamsToOne() {
326 DCHECK_EQ(PRECONNECT, job_type_);
327 num_streams_ = 1;
328 }
329
325 bool HttpStreamFactoryImpl::Job::was_alpn_negotiated() const { 330 bool HttpStreamFactoryImpl::Job::was_alpn_negotiated() const {
326 return was_alpn_negotiated_; 331 return was_alpn_negotiated_;
327 } 332 }
328 333
329 NextProto HttpStreamFactoryImpl::Job::negotiated_protocol() const { 334 NextProto HttpStreamFactoryImpl::Job::negotiated_protocol() const {
330 return negotiated_protocol_; 335 return negotiated_protocol_;
331 } 336 }
332 337
333 bool HttpStreamFactoryImpl::Job::using_spdy() const { 338 bool HttpStreamFactoryImpl::Job::using_spdy() const {
334 return using_spdy_; 339 return using_spdy_;
(...skipping 1170 matching lines...) Expand 10 before | Expand all | Expand 10 after
1505 1510
1506 ConnectionAttempts socket_attempts = connection_->connection_attempts(); 1511 ConnectionAttempts socket_attempts = connection_->connection_attempts();
1507 if (connection_->socket()) { 1512 if (connection_->socket()) {
1508 connection_->socket()->GetConnectionAttempts(&socket_attempts); 1513 connection_->socket()->GetConnectionAttempts(&socket_attempts);
1509 } 1514 }
1510 1515
1511 delegate_->AddConnectionAttemptsToRequest(this, socket_attempts); 1516 delegate_->AddConnectionAttemptsToRequest(this, socket_attempts);
1512 } 1517 }
1513 1518
1514 } // namespace net 1519 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698