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

Side by Side Diff: net/socket/tcp_client_socket.h

Issue 1376473003: Notify NQE of TCP RTT values (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix SPW since different sockets may be created on different threads Created 4 years, 9 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #ifndef NET_SOCKET_TCP_CLIENT_SOCKET_H_ 5 #ifndef NET_SOCKET_TCP_CLIENT_SOCKET_H_
6 #define NET_SOCKET_TCP_CLIENT_SOCKET_H_ 6 #define NET_SOCKET_TCP_CLIENT_SOCKET_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h"
13 #include "net/base/address_list.h" 14 #include "net/base/address_list.h"
14 #include "net/base/completion_callback.h" 15 #include "net/base/completion_callback.h"
15 #include "net/base/net_export.h" 16 #include "net/base/net_export.h"
16 #include "net/log/net_log.h" 17 #include "net/log/net_log.h"
17 #include "net/socket/connection_attempts.h" 18 #include "net/socket/connection_attempts.h"
18 #include "net/socket/stream_socket.h" 19 #include "net/socket/stream_socket.h"
19 #include "net/socket/tcp_socket.h" 20 #include "net/socket/tcp_socket.h"
20 21
21 namespace net { 22 namespace net {
22 23
24 class SocketPerformanceWatcher;
25
23 // A client socket that uses TCP as the transport layer. 26 // A client socket that uses TCP as the transport layer.
24 class NET_EXPORT TCPClientSocket : public StreamSocket { 27 class NET_EXPORT TCPClientSocket : public StreamSocket {
25 public: 28 public:
26 // The IP address(es) and port number to connect to. The TCP socket will try 29 // The IP address(es) and port number to connect to. The TCP socket will try
27 // each IP address in the list until it succeeds in establishing a 30 // each IP address in the list until it succeeds in establishing a
28 // connection. 31 // connection.
29 TCPClientSocket(const AddressList& addresses, 32 TCPClientSocket(
30 net::NetLog* net_log, 33 const AddressList& addresses,
31 const net::NetLog::Source& source); 34 scoped_ptr<SocketPerformanceWatcher> socket_performance_watcher,
35 net::NetLog* net_log,
36 const net::NetLog::Source& source);
32 37
33 // Adopts the given, connected socket and then acts as if Connect() had been 38 // Adopts the given, connected socket and then acts as if Connect() had been
34 // called. This function is used by TCPServerSocket and for testing. 39 // called. This function is used by TCPServerSocket and for testing.
35 TCPClientSocket(scoped_ptr<TCPSocket> connected_socket, 40 TCPClientSocket(scoped_ptr<TCPSocket> connected_socket,
36 const IPEndPoint& peer_address); 41 const IPEndPoint& peer_address);
37 42
38 ~TCPClientSocket() override; 43 ~TCPClientSocket() override;
39 44
40 // Binds the socket to a local IP address and port. 45 // Binds the socket to a local IP address and port.
41 int Bind(const IPEndPoint& address); 46 int Bind(const IPEndPoint& address);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 void DidCompleteRead(const CompletionCallback& callback, int result); 103 void DidCompleteRead(const CompletionCallback& callback, int result);
99 void DidCompleteWrite(const CompletionCallback& callback, int result); 104 void DidCompleteWrite(const CompletionCallback& callback, int result);
100 void DidCompleteReadWrite(const CompletionCallback& callback, int result); 105 void DidCompleteReadWrite(const CompletionCallback& callback, int result);
101 106
102 int OpenSocket(AddressFamily family); 107 int OpenSocket(AddressFamily family);
103 108
104 // Emits histograms for TCP metrics, at the time the socket is 109 // Emits histograms for TCP metrics, at the time the socket is
105 // disconnected. 110 // disconnected.
106 void EmitTCPMetricsHistogramsOnDisconnect(); 111 void EmitTCPMetricsHistogramsOnDisconnect();
107 112
113 // Socket performance statistics (such as RTT) are reported to the
114 // |socket_performance_watcher_|. May be nullptr.
115 base::WeakPtr<SocketPerformanceWatcher> socket_performance_watcher_;
116
108 scoped_ptr<TCPSocket> socket_; 117 scoped_ptr<TCPSocket> socket_;
109 118
110 // Local IP address and port we are bound to. Set to NULL if Bind() 119 // Local IP address and port we are bound to. Set to NULL if Bind()
111 // wasn't called (in that case OS chooses address/port). 120 // wasn't called (in that case OS chooses address/port).
112 scoped_ptr<IPEndPoint> bind_address_; 121 scoped_ptr<IPEndPoint> bind_address_;
113 122
114 // The list of addresses we should try in order to establish a connection. 123 // The list of addresses we should try in order to establish a connection.
115 AddressList addresses_; 124 AddressList addresses_;
116 125
117 // Where we are in above list. Set to -1 if uninitialized. 126 // Where we are in above list. Set to -1 if uninitialized.
(...skipping 11 matching lines...) Expand all
129 // Record of connectivity and transmissions, for use in speculative connection 138 // Record of connectivity and transmissions, for use in speculative connection
130 // histograms. 139 // histograms.
131 UseHistory use_history_; 140 UseHistory use_history_;
132 141
133 // Failed connection attempts made while trying to connect this socket. 142 // Failed connection attempts made while trying to connect this socket.
134 ConnectionAttempts connection_attempts_; 143 ConnectionAttempts connection_attempts_;
135 144
136 // Total number of bytes received by the socket. 145 // Total number of bytes received by the socket.
137 int64_t total_received_bytes_; 146 int64_t total_received_bytes_;
138 147
148 // True if the |socket_performance_watcher_| should be notified that the
149 // socket has been reset.
150 bool notify_reset_socket_performance_watcher_;
151
139 DISALLOW_COPY_AND_ASSIGN(TCPClientSocket); 152 DISALLOW_COPY_AND_ASSIGN(TCPClientSocket);
140 }; 153 };
141 154
142 } // namespace net 155 } // namespace net
143 156
144 #endif // NET_SOCKET_TCP_CLIENT_SOCKET_H_ 157 #endif // NET_SOCKET_TCP_CLIENT_SOCKET_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698