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/socket/transport_client_socket_pool.h" | 5 #include "net/socket/transport_client_socket_pool.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> |
8 | 9 |
9 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
10 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
11 #include "base/logging.h" | 12 #include "base/logging.h" |
12 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
13 #include "base/metrics/histogram_macros.h" | 14 #include "base/metrics/histogram_macros.h" |
14 #include "base/profiler/scoped_tracker.h" | 15 #include "base/profiler/scoped_tracker.h" |
15 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
16 #include "base/synchronization/lock.h" | 17 #include "base/synchronization/lock.h" |
17 #include "base/time/time.h" | 18 #include "base/time/time.h" |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 connect_duration, | 376 connect_duration, |
376 base::TimeDelta::FromMilliseconds(1), | 377 base::TimeDelta::FromMilliseconds(1), |
377 base::TimeDelta::FromMinutes(10), | 378 base::TimeDelta::FromMinutes(10), |
378 100); | 379 100); |
379 break; | 380 break; |
380 default: | 381 default: |
381 NOTREACHED(); | 382 NOTREACHED(); |
382 break; | 383 break; |
383 } | 384 } |
384 | 385 |
385 SetSocket(transport_socket_.Pass()); | 386 SetSocket(std::move(transport_socket_)); |
386 } else { | 387 } else { |
387 // Failure will be returned via |GetAdditionalErrorState|, so save | 388 // Failure will be returned via |GetAdditionalErrorState|, so save |
388 // connection attempts from both sockets for use there. | 389 // connection attempts from both sockets for use there. |
389 CopyConnectionAttemptsFromSockets(); | 390 CopyConnectionAttemptsFromSockets(); |
390 | 391 |
391 transport_socket_.reset(); | 392 transport_socket_.reset(); |
392 } | 393 } |
393 | 394 |
394 fallback_timer_.Stop(); | 395 fallback_timer_.Stop(); |
395 fallback_transport_socket_.reset(); | 396 fallback_transport_socket_.reset(); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 // case is through the successfully-connected socket.) | 446 // case is through the successfully-connected socket.) |
446 if (transport_socket_) { | 447 if (transport_socket_) { |
447 ConnectionAttempts attempts; | 448 ConnectionAttempts attempts; |
448 transport_socket_->GetConnectionAttempts(&attempts); | 449 transport_socket_->GetConnectionAttempts(&attempts); |
449 fallback_transport_socket_->AddConnectionAttempts(attempts); | 450 fallback_transport_socket_->AddConnectionAttempts(attempts); |
450 } | 451 } |
451 | 452 |
452 connect_timing_.connect_start = fallback_connect_start_time_; | 453 connect_timing_.connect_start = fallback_connect_start_time_; |
453 helper_.HistogramDuration( | 454 helper_.HistogramDuration( |
454 TransportConnectJobHelper::CONNECTION_LATENCY_IPV4_WINS_RACE); | 455 TransportConnectJobHelper::CONNECTION_LATENCY_IPV4_WINS_RACE); |
455 SetSocket(fallback_transport_socket_.Pass()); | 456 SetSocket(std::move(fallback_transport_socket_)); |
456 helper_.set_next_state(TransportConnectJobHelper::STATE_NONE); | 457 helper_.set_next_state(TransportConnectJobHelper::STATE_NONE); |
457 } else { | 458 } else { |
458 // Failure will be returned via |GetAdditionalErrorState|, so save | 459 // Failure will be returned via |GetAdditionalErrorState|, so save |
459 // connection attempts from both sockets for use there. | 460 // connection attempts from both sockets for use there. |
460 CopyConnectionAttemptsFromSockets(); | 461 CopyConnectionAttemptsFromSockets(); |
461 | 462 |
462 fallback_transport_socket_.reset(); | 463 fallback_transport_socket_.reset(); |
463 fallback_addresses_.reset(); | 464 fallback_addresses_.reset(); |
464 } | 465 } |
465 | 466 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
572 void TransportClientSocketPool::CancelRequest( | 573 void TransportClientSocketPool::CancelRequest( |
573 const std::string& group_name, | 574 const std::string& group_name, |
574 ClientSocketHandle* handle) { | 575 ClientSocketHandle* handle) { |
575 base_.CancelRequest(group_name, handle); | 576 base_.CancelRequest(group_name, handle); |
576 } | 577 } |
577 | 578 |
578 void TransportClientSocketPool::ReleaseSocket( | 579 void TransportClientSocketPool::ReleaseSocket( |
579 const std::string& group_name, | 580 const std::string& group_name, |
580 scoped_ptr<StreamSocket> socket, | 581 scoped_ptr<StreamSocket> socket, |
581 int id) { | 582 int id) { |
582 base_.ReleaseSocket(group_name, socket.Pass(), id); | 583 base_.ReleaseSocket(group_name, std::move(socket), id); |
583 } | 584 } |
584 | 585 |
585 void TransportClientSocketPool::FlushWithError(int error) { | 586 void TransportClientSocketPool::FlushWithError(int error) { |
586 base_.FlushWithError(error); | 587 base_.FlushWithError(error); |
587 } | 588 } |
588 | 589 |
589 void TransportClientSocketPool::CloseIdleSockets() { | 590 void TransportClientSocketPool::CloseIdleSockets() { |
590 base_.CloseIdleSockets(); | 591 base_.CloseIdleSockets(); |
591 } | 592 } |
592 | 593 |
(...skipping 30 matching lines...) Expand all Loading... |
623 HigherLayeredPool* higher_pool) { | 624 HigherLayeredPool* higher_pool) { |
624 base_.AddHigherLayeredPool(higher_pool); | 625 base_.AddHigherLayeredPool(higher_pool); |
625 } | 626 } |
626 | 627 |
627 void TransportClientSocketPool::RemoveHigherLayeredPool( | 628 void TransportClientSocketPool::RemoveHigherLayeredPool( |
628 HigherLayeredPool* higher_pool) { | 629 HigherLayeredPool* higher_pool) { |
629 base_.RemoveHigherLayeredPool(higher_pool); | 630 base_.RemoveHigherLayeredPool(higher_pool); |
630 } | 631 } |
631 | 632 |
632 } // namespace net | 633 } // namespace net |
OLD | NEW |