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

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

Issue 1006643002: Plumb connection attempts from (non-proxy) ConnectJobs to HttpNetworkTransaction. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 8 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 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 // working. 289 // working.
290 return alternative_service_url_.SchemeIs("https") || 290 return alternative_service_url_.SchemeIs("https") ||
291 proxy_info_.proxy_server().is_https() || 291 proxy_info_.proxy_server().is_https() ||
292 session_->params().force_spdy_always; 292 session_->params().force_spdy_always;
293 } 293 }
294 294
295 void HttpStreamFactoryImpl::Job::OnStreamReadyCallback() { 295 void HttpStreamFactoryImpl::Job::OnStreamReadyCallback() {
296 DCHECK(stream_.get()); 296 DCHECK(stream_.get());
297 DCHECK(!IsPreconnecting()); 297 DCHECK(!IsPreconnecting());
298 DCHECK(!stream_factory_->for_websockets_); 298 DCHECK(!stream_factory_->for_websockets_);
299
300 MaybeAddConnectionAttempts();
301
299 if (IsOrphaned()) { 302 if (IsOrphaned()) {
300 stream_factory_->OnOrphanedJobComplete(this); 303 stream_factory_->OnOrphanedJobComplete(this);
301 } else { 304 } else {
302 request_->Complete(was_npn_negotiated(), 305 request_->Complete(was_npn_negotiated(),
303 protocol_negotiated(), 306 protocol_negotiated(),
304 using_spdy(), 307 using_spdy(),
305 net_log_); 308 net_log_);
306 request_->OnStreamReady(this, server_ssl_config_, proxy_info_, 309 request_->OnStreamReady(this, server_ssl_config_, proxy_info_,
307 stream_.release()); 310 stream_.release());
308 } 311 }
309 // |this| may be deleted after this call. 312 // |this| may be deleted after this call.
310 } 313 }
311 314
312 void HttpStreamFactoryImpl::Job::OnWebSocketHandshakeStreamReadyCallback() { 315 void HttpStreamFactoryImpl::Job::OnWebSocketHandshakeStreamReadyCallback() {
313 DCHECK(websocket_stream_); 316 DCHECK(websocket_stream_);
314 DCHECK(!IsPreconnecting()); 317 DCHECK(!IsPreconnecting());
315 DCHECK(stream_factory_->for_websockets_); 318 DCHECK(stream_factory_->for_websockets_);
316 // An orphaned WebSocket job will be closed immediately and 319 // An orphaned WebSocket job will be closed immediately and
317 // never be ready. 320 // never be ready.
318 DCHECK(!IsOrphaned()); 321 DCHECK(!IsOrphaned());
322
323 MaybeAddConnectionAttempts();
324
319 request_->Complete(was_npn_negotiated(), 325 request_->Complete(was_npn_negotiated(),
320 protocol_negotiated(), 326 protocol_negotiated(),
321 using_spdy(), 327 using_spdy(),
322 net_log_); 328 net_log_);
323 request_->OnWebSocketHandshakeStreamReady(this, 329 request_->OnWebSocketHandshakeStreamReady(this,
324 server_ssl_config_, 330 server_ssl_config_,
325 proxy_info_, 331 proxy_info_,
326 websocket_stream_.release()); 332 websocket_stream_.release());
327 // |this| may be deleted after this call. 333 // |this| may be deleted after this call.
328 } 334 }
329 335
330 void HttpStreamFactoryImpl::Job::OnNewSpdySessionReadyCallback() { 336 void HttpStreamFactoryImpl::Job::OnNewSpdySessionReadyCallback() {
331 DCHECK(stream_.get()); 337 DCHECK(stream_.get());
332 DCHECK(!IsPreconnecting()); 338 DCHECK(!IsPreconnecting());
333 DCHECK(using_spdy()); 339 DCHECK(using_spdy());
334 // Note: an event loop iteration has passed, so |new_spdy_session_| may be 340 // Note: an event loop iteration has passed, so |new_spdy_session_| may be
335 // NULL at this point if the SpdySession closed immediately after creation. 341 // NULL at this point if the SpdySession closed immediately after creation.
336 base::WeakPtr<SpdySession> spdy_session = new_spdy_session_; 342 base::WeakPtr<SpdySession> spdy_session = new_spdy_session_;
337 new_spdy_session_.reset(); 343 new_spdy_session_.reset();
338 344
345 MaybeAddConnectionAttempts();
346
339 // TODO(jgraettinger): Notify the factory, and let that notify |request_|, 347 // TODO(jgraettinger): Notify the factory, and let that notify |request_|,
340 // rather than notifying |request_| directly. 348 // rather than notifying |request_| directly.
341 if (IsOrphaned()) { 349 if (IsOrphaned()) {
342 if (spdy_session) { 350 if (spdy_session) {
343 stream_factory_->OnNewSpdySessionReady( 351 stream_factory_->OnNewSpdySessionReady(
344 spdy_session, spdy_session_direct_, server_ssl_config_, proxy_info_, 352 spdy_session, spdy_session_direct_, server_ssl_config_, proxy_info_,
345 was_npn_negotiated(), protocol_negotiated(), using_spdy(), net_log_); 353 was_npn_negotiated(), protocol_negotiated(), using_spdy(), net_log_);
346 } 354 }
347 stream_factory_->OnOrphanedJobComplete(this); 355 stream_factory_->OnOrphanedJobComplete(this);
348 } else { 356 } else {
349 request_->OnNewSpdySessionReady( 357 request_->OnNewSpdySessionReady(
350 this, stream_.Pass(), spdy_session, spdy_session_direct_); 358 this, stream_.Pass(), spdy_session, spdy_session_direct_);
351 } 359 }
352 // |this| may be deleted after this call. 360 // |this| may be deleted after this call.
353 } 361 }
354 362
355 void HttpStreamFactoryImpl::Job::OnStreamFailedCallback(int result) { 363 void HttpStreamFactoryImpl::Job::OnStreamFailedCallback(int result) {
356 DCHECK(!IsPreconnecting()); 364 DCHECK(!IsPreconnecting());
365
366 MaybeAddConnectionAttempts();
367
357 if (IsOrphaned()) 368 if (IsOrphaned())
358 stream_factory_->OnOrphanedJobComplete(this); 369 stream_factory_->OnOrphanedJobComplete(this);
359 else 370 else
360 request_->OnStreamFailed(this, result, server_ssl_config_); 371 request_->OnStreamFailed(this, result, server_ssl_config_);
361 // |this| may be deleted after this call. 372 // |this| may be deleted after this call.
362 } 373 }
363 374
364 void HttpStreamFactoryImpl::Job::OnCertificateErrorCallback( 375 void HttpStreamFactoryImpl::Job::OnCertificateErrorCallback(
365 int result, const SSLInfo& ssl_info) { 376 int result, const SSLInfo& ssl_info) {
366 DCHECK(!IsPreconnecting()); 377 DCHECK(!IsPreconnecting());
378
379 MaybeAddConnectionAttempts();
380
367 if (IsOrphaned()) 381 if (IsOrphaned())
368 stream_factory_->OnOrphanedJobComplete(this); 382 stream_factory_->OnOrphanedJobComplete(this);
369 else 383 else
370 request_->OnCertificateError(this, result, server_ssl_config_, ssl_info); 384 request_->OnCertificateError(this, result, server_ssl_config_, ssl_info);
371 // |this| may be deleted after this call. 385 // |this| may be deleted after this call.
372 } 386 }
373 387
374 void HttpStreamFactoryImpl::Job::OnNeedsProxyAuthCallback( 388 void HttpStreamFactoryImpl::Job::OnNeedsProxyAuthCallback(
375 const HttpResponseInfo& response, 389 const HttpResponseInfo& response,
376 HttpAuthController* auth_controller) { 390 HttpAuthController* auth_controller) {
(...skipping 1120 matching lines...) Expand 10 before | Expand all | Expand 10 after
1497 std::string scheme = alternative_service_url_.scheme(); 1511 std::string scheme = alternative_service_url_.scheme();
1498 if (scheme == "ftp") 1512 if (scheme == "ftp")
1499 return ClientSocketPoolManager::FTP_GROUP; 1513 return ClientSocketPoolManager::FTP_GROUP;
1500 1514
1501 if (scheme == "https" || scheme == "wss") 1515 if (scheme == "https" || scheme == "wss")
1502 return ClientSocketPoolManager::SSL_GROUP; 1516 return ClientSocketPoolManager::SSL_GROUP;
1503 1517
1504 return ClientSocketPoolManager::NORMAL_GROUP; 1518 return ClientSocketPoolManager::NORMAL_GROUP;
1505 } 1519 }
1506 1520
1521 void HttpStreamFactoryImpl::Job::MaybeAddConnectionAttempts() {
1522 if (IsOrphaned() || !connection_)
1523 return;
1524
1525 request_->AddConnectionAttempts(connection_->connection_attempts());
1526 }
1527
1507 } // namespace net 1528 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698