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

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

Issue 1096203006: Collect all ConnectionAttempts from both sockets in TransportConnectJob. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@domrel_serverip1
Patch Set: Document why Do*ConnectComplete don't delete other socket Created 5 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 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 origin_url_.SchemeIs("https") || 290 return origin_url_.SchemeIs("https") ||
291 proxy_info_.proxy_server().is_https() || IsSpdyAlternate(); 291 proxy_info_.proxy_server().is_https() || IsSpdyAlternate();
292 } 292 }
293 293
294 void HttpStreamFactoryImpl::Job::OnStreamReadyCallback() { 294 void HttpStreamFactoryImpl::Job::OnStreamReadyCallback() {
295 DCHECK(stream_.get()); 295 DCHECK(stream_.get());
296 DCHECK(!IsPreconnecting()); 296 DCHECK(!IsPreconnecting());
297 DCHECK(!stream_factory_->for_websockets_); 297 DCHECK(!stream_factory_->for_websockets_);
298 298
299 MaybeCopyConnectionAttemptsFromClientSocketHandleToRequest(); 299 MaybeCopyConnectionAttempts();
300 300
301 if (IsOrphaned()) { 301 if (IsOrphaned()) {
302 stream_factory_->OnOrphanedJobComplete(this); 302 stream_factory_->OnOrphanedJobComplete(this);
303 } else { 303 } else {
304 request_->Complete(was_npn_negotiated(), 304 request_->Complete(was_npn_negotiated(),
305 protocol_negotiated(), 305 protocol_negotiated(),
306 using_spdy(), 306 using_spdy(),
307 net_log_); 307 net_log_);
308 request_->OnStreamReady(this, server_ssl_config_, proxy_info_, 308 request_->OnStreamReady(this, server_ssl_config_, proxy_info_,
309 stream_.release()); 309 stream_.release());
310 } 310 }
311 // |this| may be deleted after this call. 311 // |this| may be deleted after this call.
312 } 312 }
313 313
314 void HttpStreamFactoryImpl::Job::OnWebSocketHandshakeStreamReadyCallback() { 314 void HttpStreamFactoryImpl::Job::OnWebSocketHandshakeStreamReadyCallback() {
315 DCHECK(websocket_stream_); 315 DCHECK(websocket_stream_);
316 DCHECK(!IsPreconnecting()); 316 DCHECK(!IsPreconnecting());
317 DCHECK(stream_factory_->for_websockets_); 317 DCHECK(stream_factory_->for_websockets_);
318 // An orphaned WebSocket job will be closed immediately and 318 // An orphaned WebSocket job will be closed immediately and
319 // never be ready. 319 // never be ready.
320 DCHECK(!IsOrphaned()); 320 DCHECK(!IsOrphaned());
321 321
322 MaybeCopyConnectionAttemptsFromClientSocketHandleToRequest(); 322 MaybeCopyConnectionAttempts();
323 323
324 request_->Complete(was_npn_negotiated(), 324 request_->Complete(was_npn_negotiated(),
325 protocol_negotiated(), 325 protocol_negotiated(),
326 using_spdy(), 326 using_spdy(),
327 net_log_); 327 net_log_);
328 request_->OnWebSocketHandshakeStreamReady(this, 328 request_->OnWebSocketHandshakeStreamReady(this,
329 server_ssl_config_, 329 server_ssl_config_,
330 proxy_info_, 330 proxy_info_,
331 websocket_stream_.release()); 331 websocket_stream_.release());
332 // |this| may be deleted after this call. 332 // |this| may be deleted after this call.
333 } 333 }
334 334
335 void HttpStreamFactoryImpl::Job::OnNewSpdySessionReadyCallback() { 335 void HttpStreamFactoryImpl::Job::OnNewSpdySessionReadyCallback() {
336 DCHECK(stream_.get()); 336 DCHECK(stream_.get());
337 DCHECK(!IsPreconnecting()); 337 DCHECK(!IsPreconnecting());
338 DCHECK(using_spdy()); 338 DCHECK(using_spdy());
339 // Note: an event loop iteration has passed, so |new_spdy_session_| may be 339 // Note: an event loop iteration has passed, so |new_spdy_session_| may be
340 // NULL at this point if the SpdySession closed immediately after creation. 340 // NULL at this point if the SpdySession closed immediately after creation.
341 base::WeakPtr<SpdySession> spdy_session = new_spdy_session_; 341 base::WeakPtr<SpdySession> spdy_session = new_spdy_session_;
342 new_spdy_session_.reset(); 342 new_spdy_session_.reset();
343 343
344 MaybeCopyConnectionAttemptsFromClientSocketHandleToRequest(); 344 MaybeCopyConnectionAttempts();
345 345
346 // TODO(jgraettinger): Notify the factory, and let that notify |request_|, 346 // TODO(jgraettinger): Notify the factory, and let that notify |request_|,
347 // rather than notifying |request_| directly. 347 // rather than notifying |request_| directly.
348 if (IsOrphaned()) { 348 if (IsOrphaned()) {
349 if (spdy_session) { 349 if (spdy_session) {
350 stream_factory_->OnNewSpdySessionReady( 350 stream_factory_->OnNewSpdySessionReady(
351 spdy_session, spdy_session_direct_, server_ssl_config_, proxy_info_, 351 spdy_session, spdy_session_direct_, server_ssl_config_, proxy_info_,
352 was_npn_negotiated(), protocol_negotiated(), using_spdy(), net_log_); 352 was_npn_negotiated(), protocol_negotiated(), using_spdy(), net_log_);
353 } 353 }
354 stream_factory_->OnOrphanedJobComplete(this); 354 stream_factory_->OnOrphanedJobComplete(this);
355 } else { 355 } else {
356 request_->OnNewSpdySessionReady( 356 request_->OnNewSpdySessionReady(
357 this, stream_.Pass(), spdy_session, spdy_session_direct_); 357 this, stream_.Pass(), spdy_session, spdy_session_direct_);
358 } 358 }
359 // |this| may be deleted after this call. 359 // |this| may be deleted after this call.
360 } 360 }
361 361
362 void HttpStreamFactoryImpl::Job::OnStreamFailedCallback(int result) { 362 void HttpStreamFactoryImpl::Job::OnStreamFailedCallback(int result) {
363 DCHECK(!IsPreconnecting()); 363 DCHECK(!IsPreconnecting());
364 364
365 MaybeCopyConnectionAttemptsFromClientSocketHandleToRequest(); 365 MaybeCopyConnectionAttempts();
366 366
367 if (IsOrphaned()) 367 if (IsOrphaned())
368 stream_factory_->OnOrphanedJobComplete(this); 368 stream_factory_->OnOrphanedJobComplete(this);
369 else 369 else
370 request_->OnStreamFailed(this, result, server_ssl_config_); 370 request_->OnStreamFailed(this, result, server_ssl_config_);
371 // |this| may be deleted after this call. 371 // |this| may be deleted after this call.
372 } 372 }
373 373
374 void HttpStreamFactoryImpl::Job::OnCertificateErrorCallback( 374 void HttpStreamFactoryImpl::Job::OnCertificateErrorCallback(
375 int result, const SSLInfo& ssl_info) { 375 int result, const SSLInfo& ssl_info) {
376 DCHECK(!IsPreconnecting()); 376 DCHECK(!IsPreconnecting());
377 377
378 MaybeCopyConnectionAttemptsFromClientSocketHandleToRequest(); 378 MaybeCopyConnectionAttempts();
379 379
380 if (IsOrphaned()) 380 if (IsOrphaned())
381 stream_factory_->OnOrphanedJobComplete(this); 381 stream_factory_->OnOrphanedJobComplete(this);
382 else 382 else
383 request_->OnCertificateError(this, result, server_ssl_config_, ssl_info); 383 request_->OnCertificateError(this, result, server_ssl_config_, ssl_info);
384 // |this| may be deleted after this call. 384 // |this| may be deleted after this call.
385 } 385 }
386 386
387 void HttpStreamFactoryImpl::Job::OnNeedsProxyAuthCallback( 387 void HttpStreamFactoryImpl::Job::OnNeedsProxyAuthCallback(
388 const HttpResponseInfo& response, 388 const HttpResponseInfo& response,
(...skipping 1116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1505 std::string scheme = origin_url_.scheme(); 1505 std::string scheme = origin_url_.scheme();
1506 if (scheme == "https" || scheme == "wss" || IsSpdyAlternate()) 1506 if (scheme == "https" || scheme == "wss" || IsSpdyAlternate())
1507 return ClientSocketPoolManager::SSL_GROUP; 1507 return ClientSocketPoolManager::SSL_GROUP;
1508 1508
1509 if (scheme == "ftp") 1509 if (scheme == "ftp")
1510 return ClientSocketPoolManager::FTP_GROUP; 1510 return ClientSocketPoolManager::FTP_GROUP;
1511 1511
1512 return ClientSocketPoolManager::NORMAL_GROUP; 1512 return ClientSocketPoolManager::NORMAL_GROUP;
1513 } 1513 }
1514 1514
1515 void HttpStreamFactoryImpl::Job:: 1515 void HttpStreamFactoryImpl::Job::MaybeCopyConnectionAttempts() {
Randy Smith (Not in Mondays) 2015/05/12 20:11:09 Is there any way the state machine would allow thi
Deprecated (see juliatuttle) 2015/05/13 18:22:29 It can be called twice if we do RestartWithAuth, b
1516 MaybeCopyConnectionAttemptsFromClientSocketHandleToRequest() {
1517 if (IsOrphaned() || !connection_) 1516 if (IsOrphaned() || !connection_)
1518 return; 1517 return;
1519 1518
1520 request_->AddConnectionAttempts(connection_->connection_attempts()); 1519 if (connection_->socket()) {
1520 ConnectionAttempts socket_attempts;
1521 connection_->socket()->GetConnectionAttempts(&socket_attempts);
1522 request_->AddConnectionAttempts(socket_attempts);
1523 } else {
1524 request_->AddConnectionAttempts(connection_->connection_attempts());
1525 }
1521 } 1526 }
1522 1527
1523 } // namespace net 1528 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698