OLD | NEW |
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 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 // TODO(ricea): Add "wss" back to this list when SPDY WebSocket support is | 288 // TODO(ricea): Add "wss" back to this list when SPDY WebSocket support is |
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 |
| 299 MaybeCopyConnectionAttemptsFromClientSocketHandleToRequest(); |
| 300 |
298 if (IsOrphaned()) { | 301 if (IsOrphaned()) { |
299 stream_factory_->OnOrphanedJobComplete(this); | 302 stream_factory_->OnOrphanedJobComplete(this); |
300 } else { | 303 } else { |
301 request_->Complete(was_npn_negotiated(), | 304 request_->Complete(was_npn_negotiated(), |
302 protocol_negotiated(), | 305 protocol_negotiated(), |
303 using_spdy(), | 306 using_spdy(), |
304 net_log_); | 307 net_log_); |
305 request_->OnStreamReady(this, server_ssl_config_, proxy_info_, | 308 request_->OnStreamReady(this, server_ssl_config_, proxy_info_, |
306 stream_.release()); | 309 stream_.release()); |
307 } | 310 } |
308 // |this| may be deleted after this call. | 311 // |this| may be deleted after this call. |
309 } | 312 } |
310 | 313 |
311 void HttpStreamFactoryImpl::Job::OnWebSocketHandshakeStreamReadyCallback() { | 314 void HttpStreamFactoryImpl::Job::OnWebSocketHandshakeStreamReadyCallback() { |
312 DCHECK(websocket_stream_); | 315 DCHECK(websocket_stream_); |
313 DCHECK(!IsPreconnecting()); | 316 DCHECK(!IsPreconnecting()); |
314 DCHECK(stream_factory_->for_websockets_); | 317 DCHECK(stream_factory_->for_websockets_); |
315 // An orphaned WebSocket job will be closed immediately and | 318 // An orphaned WebSocket job will be closed immediately and |
316 // never be ready. | 319 // never be ready. |
317 DCHECK(!IsOrphaned()); | 320 DCHECK(!IsOrphaned()); |
| 321 |
| 322 MaybeCopyConnectionAttemptsFromClientSocketHandleToRequest(); |
| 323 |
318 request_->Complete(was_npn_negotiated(), | 324 request_->Complete(was_npn_negotiated(), |
319 protocol_negotiated(), | 325 protocol_negotiated(), |
320 using_spdy(), | 326 using_spdy(), |
321 net_log_); | 327 net_log_); |
322 request_->OnWebSocketHandshakeStreamReady(this, | 328 request_->OnWebSocketHandshakeStreamReady(this, |
323 server_ssl_config_, | 329 server_ssl_config_, |
324 proxy_info_, | 330 proxy_info_, |
325 websocket_stream_.release()); | 331 websocket_stream_.release()); |
326 // |this| may be deleted after this call. | 332 // |this| may be deleted after this call. |
327 } | 333 } |
328 | 334 |
329 void HttpStreamFactoryImpl::Job::OnNewSpdySessionReadyCallback() { | 335 void HttpStreamFactoryImpl::Job::OnNewSpdySessionReadyCallback() { |
330 DCHECK(stream_.get()); | 336 DCHECK(stream_.get()); |
331 DCHECK(!IsPreconnecting()); | 337 DCHECK(!IsPreconnecting()); |
332 DCHECK(using_spdy()); | 338 DCHECK(using_spdy()); |
333 // 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 |
334 // NULL at this point if the SpdySession closed immediately after creation. | 340 // NULL at this point if the SpdySession closed immediately after creation. |
335 base::WeakPtr<SpdySession> spdy_session = new_spdy_session_; | 341 base::WeakPtr<SpdySession> spdy_session = new_spdy_session_; |
336 new_spdy_session_.reset(); | 342 new_spdy_session_.reset(); |
337 | 343 |
| 344 MaybeCopyConnectionAttemptsFromClientSocketHandleToRequest(); |
| 345 |
338 // TODO(jgraettinger): Notify the factory, and let that notify |request_|, | 346 // TODO(jgraettinger): Notify the factory, and let that notify |request_|, |
339 // rather than notifying |request_| directly. | 347 // rather than notifying |request_| directly. |
340 if (IsOrphaned()) { | 348 if (IsOrphaned()) { |
341 if (spdy_session) { | 349 if (spdy_session) { |
342 stream_factory_->OnNewSpdySessionReady( | 350 stream_factory_->OnNewSpdySessionReady( |
343 spdy_session, spdy_session_direct_, server_ssl_config_, proxy_info_, | 351 spdy_session, spdy_session_direct_, server_ssl_config_, proxy_info_, |
344 was_npn_negotiated(), protocol_negotiated(), using_spdy(), net_log_); | 352 was_npn_negotiated(), protocol_negotiated(), using_spdy(), net_log_); |
345 } | 353 } |
346 stream_factory_->OnOrphanedJobComplete(this); | 354 stream_factory_->OnOrphanedJobComplete(this); |
347 } else { | 355 } else { |
348 request_->OnNewSpdySessionReady( | 356 request_->OnNewSpdySessionReady( |
349 this, stream_.Pass(), spdy_session, spdy_session_direct_); | 357 this, stream_.Pass(), spdy_session, spdy_session_direct_); |
350 } | 358 } |
351 // |this| may be deleted after this call. | 359 // |this| may be deleted after this call. |
352 } | 360 } |
353 | 361 |
354 void HttpStreamFactoryImpl::Job::OnStreamFailedCallback(int result) { | 362 void HttpStreamFactoryImpl::Job::OnStreamFailedCallback(int result) { |
355 DCHECK(!IsPreconnecting()); | 363 DCHECK(!IsPreconnecting()); |
| 364 |
| 365 MaybeCopyConnectionAttemptsFromClientSocketHandleToRequest(); |
| 366 |
356 if (IsOrphaned()) | 367 if (IsOrphaned()) |
357 stream_factory_->OnOrphanedJobComplete(this); | 368 stream_factory_->OnOrphanedJobComplete(this); |
358 else | 369 else |
359 request_->OnStreamFailed(this, result, server_ssl_config_); | 370 request_->OnStreamFailed(this, result, server_ssl_config_); |
360 // |this| may be deleted after this call. | 371 // |this| may be deleted after this call. |
361 } | 372 } |
362 | 373 |
363 void HttpStreamFactoryImpl::Job::OnCertificateErrorCallback( | 374 void HttpStreamFactoryImpl::Job::OnCertificateErrorCallback( |
364 int result, const SSLInfo& ssl_info) { | 375 int result, const SSLInfo& ssl_info) { |
365 DCHECK(!IsPreconnecting()); | 376 DCHECK(!IsPreconnecting()); |
| 377 |
| 378 MaybeCopyConnectionAttemptsFromClientSocketHandleToRequest(); |
| 379 |
366 if (IsOrphaned()) | 380 if (IsOrphaned()) |
367 stream_factory_->OnOrphanedJobComplete(this); | 381 stream_factory_->OnOrphanedJobComplete(this); |
368 else | 382 else |
369 request_->OnCertificateError(this, result, server_ssl_config_, ssl_info); | 383 request_->OnCertificateError(this, result, server_ssl_config_, ssl_info); |
370 // |this| may be deleted after this call. | 384 // |this| may be deleted after this call. |
371 } | 385 } |
372 | 386 |
373 void HttpStreamFactoryImpl::Job::OnNeedsProxyAuthCallback( | 387 void HttpStreamFactoryImpl::Job::OnNeedsProxyAuthCallback( |
374 const HttpResponseInfo& response, | 388 const HttpResponseInfo& response, |
375 HttpAuthController* auth_controller) { | 389 HttpAuthController* auth_controller) { |
(...skipping 1094 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1470 std::string scheme = origin_url_.scheme(); | 1484 std::string scheme = origin_url_.scheme(); |
1471 if (scheme == "https" || scheme == "wss" || IsSpdyAlternate()) | 1485 if (scheme == "https" || scheme == "wss" || IsSpdyAlternate()) |
1472 return ClientSocketPoolManager::SSL_GROUP; | 1486 return ClientSocketPoolManager::SSL_GROUP; |
1473 | 1487 |
1474 if (scheme == "ftp") | 1488 if (scheme == "ftp") |
1475 return ClientSocketPoolManager::FTP_GROUP; | 1489 return ClientSocketPoolManager::FTP_GROUP; |
1476 | 1490 |
1477 return ClientSocketPoolManager::NORMAL_GROUP; | 1491 return ClientSocketPoolManager::NORMAL_GROUP; |
1478 } | 1492 } |
1479 | 1493 |
| 1494 void HttpStreamFactoryImpl::Job:: |
| 1495 MaybeCopyConnectionAttemptsFromClientSocketHandleToRequest() { |
| 1496 if (IsOrphaned() || !connection_) |
| 1497 return; |
| 1498 |
| 1499 request_->AddConnectionAttempts(connection_->connection_attempts()); |
| 1500 } |
| 1501 |
1480 } // namespace net | 1502 } // namespace net |
OLD | NEW |