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 #include <utility> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
14 #include "base/metrics/histogram_macros.h" | 14 #include "base/metrics/histogram_macros.h" |
15 #include "base/profiler/scoped_tracker.h" | 15 #include "base/profiler/scoped_tracker.h" |
16 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
17 #include "base/synchronization/lock.h" | 17 #include "base/synchronization/lock.h" |
18 #include "base/time/time.h" | 18 #include "base/time/time.h" |
19 #include "base/trace_event/trace_event.h" | 19 #include "base/trace_event/trace_event.h" |
20 #include "base/values.h" | 20 #include "base/values.h" |
21 #include "net/base/ip_endpoint.h" | 21 #include "net/base/ip_endpoint.h" |
22 #include "net/base/net_errors.h" | 22 #include "net/base/net_errors.h" |
23 #include "net/log/net_log.h" | 23 #include "net/log/net_log.h" |
| 24 #include "net/log/net_log_event_type.h" |
| 25 #include "net/log/net_log_source_type.h" |
24 #include "net/socket/client_socket_factory.h" | 26 #include "net/socket/client_socket_factory.h" |
25 #include "net/socket/client_socket_handle.h" | 27 #include "net/socket/client_socket_handle.h" |
26 #include "net/socket/client_socket_pool_base.h" | 28 #include "net/socket/client_socket_pool_base.h" |
27 #include "net/socket/socket_net_log_params.h" | 29 #include "net/socket/socket_net_log_params.h" |
28 #include "net/socket/socket_performance_watcher.h" | 30 #include "net/socket/socket_performance_watcher.h" |
29 #include "net/socket/socket_performance_watcher_factory.h" | 31 #include "net/socket/socket_performance_watcher_factory.h" |
30 #include "net/socket/tcp_client_socket.h" | 32 #include "net/socket/tcp_client_socket.h" |
31 | 33 |
32 using base::TimeDelta; | 34 using base::TimeDelta; |
33 | 35 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 ClientSocketFactory* client_socket_factory, | 101 ClientSocketFactory* client_socket_factory, |
100 SocketPerformanceWatcherFactory* socket_performance_watcher_factory, | 102 SocketPerformanceWatcherFactory* socket_performance_watcher_factory, |
101 HostResolver* host_resolver, | 103 HostResolver* host_resolver, |
102 Delegate* delegate, | 104 Delegate* delegate, |
103 NetLog* net_log) | 105 NetLog* net_log) |
104 : ConnectJob(group_name, | 106 : ConnectJob(group_name, |
105 timeout_duration, | 107 timeout_duration, |
106 priority, | 108 priority, |
107 respect_limits, | 109 respect_limits, |
108 delegate, | 110 delegate, |
109 BoundNetLog::Make(net_log, NetLog::SOURCE_CONNECT_JOB)), | 111 BoundNetLog::Make(net_log, NetLogSourceType::CONNECT_JOB)), |
110 params_(params), | 112 params_(params), |
111 resolver_(host_resolver), | 113 resolver_(host_resolver), |
112 client_socket_factory_(client_socket_factory), | 114 client_socket_factory_(client_socket_factory), |
113 next_state_(STATE_NONE), | 115 next_state_(STATE_NONE), |
114 socket_performance_watcher_factory_(socket_performance_watcher_factory), | 116 socket_performance_watcher_factory_(socket_performance_watcher_factory), |
115 interval_between_connects_(CONNECT_INTERVAL_GT_20MS), | 117 interval_between_connects_(CONNECT_INTERVAL_GT_20MS), |
116 resolve_result_(OK) {} | 118 resolve_result_(OK) {} |
117 | 119 |
118 TransportConnectJob::~TransportConnectJob() { | 120 TransportConnectJob::~TransportConnectJob() { |
119 // We don't worry about cancelling the host resolution and TCP connect, since | 121 // We don't worry about cancelling the host resolution and TCP connect, since |
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
565 return base_.RequestSocket(group_name, *casted_params, priority, | 567 return base_.RequestSocket(group_name, *casted_params, priority, |
566 respect_limits, handle, callback, net_log); | 568 respect_limits, handle, callback, net_log); |
567 } | 569 } |
568 | 570 |
569 void TransportClientSocketPool::NetLogTcpClientSocketPoolRequestedSocket( | 571 void TransportClientSocketPool::NetLogTcpClientSocketPoolRequestedSocket( |
570 const BoundNetLog& net_log, | 572 const BoundNetLog& net_log, |
571 const scoped_refptr<TransportSocketParams>* casted_params) { | 573 const scoped_refptr<TransportSocketParams>* casted_params) { |
572 if (net_log.IsCapturing()) { | 574 if (net_log.IsCapturing()) { |
573 // TODO(eroman): Split out the host and port parameters. | 575 // TODO(eroman): Split out the host and port parameters. |
574 net_log.AddEvent( | 576 net_log.AddEvent( |
575 NetLog::TYPE_TCP_CLIENT_SOCKET_POOL_REQUESTED_SOCKET, | 577 NetLogEventType::TCP_CLIENT_SOCKET_POOL_REQUESTED_SOCKET, |
576 CreateNetLogHostPortPairCallback( | 578 CreateNetLogHostPortPairCallback( |
577 &casted_params->get()->destination().host_port_pair())); | 579 &casted_params->get()->destination().host_port_pair())); |
578 } | 580 } |
579 } | 581 } |
580 | 582 |
581 void TransportClientSocketPool::RequestSockets( | 583 void TransportClientSocketPool::RequestSockets( |
582 const std::string& group_name, | 584 const std::string& group_name, |
583 const void* params, | 585 const void* params, |
584 int num_sockets, | 586 int num_sockets, |
585 const BoundNetLog& net_log) { | 587 const BoundNetLog& net_log) { |
586 const scoped_refptr<TransportSocketParams>* casted_params = | 588 const scoped_refptr<TransportSocketParams>* casted_params = |
587 static_cast<const scoped_refptr<TransportSocketParams>*>(params); | 589 static_cast<const scoped_refptr<TransportSocketParams>*>(params); |
588 | 590 |
589 if (net_log.IsCapturing()) { | 591 if (net_log.IsCapturing()) { |
590 // TODO(eroman): Split out the host and port parameters. | 592 // TODO(eroman): Split out the host and port parameters. |
591 net_log.AddEvent( | 593 net_log.AddEvent( |
592 NetLog::TYPE_TCP_CLIENT_SOCKET_POOL_REQUESTED_SOCKETS, | 594 NetLogEventType::TCP_CLIENT_SOCKET_POOL_REQUESTED_SOCKETS, |
593 CreateNetLogHostPortPairCallback( | 595 CreateNetLogHostPortPairCallback( |
594 &casted_params->get()->destination().host_port_pair())); | 596 &casted_params->get()->destination().host_port_pair())); |
595 } | 597 } |
596 | 598 |
597 base_.RequestSockets(group_name, *casted_params, num_sockets, net_log); | 599 base_.RequestSockets(group_name, *casted_params, num_sockets, net_log); |
598 } | 600 } |
599 | 601 |
600 void TransportClientSocketPool::CancelRequest( | 602 void TransportClientSocketPool::CancelRequest( |
601 const std::string& group_name, | 603 const std::string& group_name, |
602 ClientSocketHandle* handle) { | 604 ClientSocketHandle* handle) { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
651 HigherLayeredPool* higher_pool) { | 653 HigherLayeredPool* higher_pool) { |
652 base_.AddHigherLayeredPool(higher_pool); | 654 base_.AddHigherLayeredPool(higher_pool); |
653 } | 655 } |
654 | 656 |
655 void TransportClientSocketPool::RemoveHigherLayeredPool( | 657 void TransportClientSocketPool::RemoveHigherLayeredPool( |
656 HigherLayeredPool* higher_pool) { | 658 HigherLayeredPool* higher_pool) { |
657 base_.RemoveHigherLayeredPool(higher_pool); | 659 base_.RemoveHigherLayeredPool(higher_pool); |
658 } | 660 } |
659 | 661 |
660 } // namespace net | 662 } // namespace net |
OLD | NEW |