OLD | NEW |
---|---|
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_STREAM_SOCKET_H_ | 5 #ifndef NET_SOCKET_STREAM_SOCKET_H_ |
6 #define NET_SOCKET_STREAM_SOCKET_H_ | 6 #define NET_SOCKET_STREAM_SOCKET_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "net/base/net_log.h" | 9 #include "net/base/net_log.h" |
10 #include "net/socket/socket.h" | 10 #include "net/socket/socket.h" |
11 | 11 |
12 namespace net { | 12 namespace net { |
13 | 13 |
14 class AddressList; | 14 class AddressList; |
15 class IPEndPoint; | 15 class IPEndPoint; |
16 | 16 |
17 class NET_TEST StreamSocket : public Socket { | 17 class NET_TEST StreamSocket : public Socket { |
18 public: | 18 public: |
19 StreamSocket() : num_bytes_read_(0) {} | |
20 | |
19 virtual ~StreamSocket() {} | 21 virtual ~StreamSocket() {} |
20 | 22 |
21 // Called to establish a connection. Returns OK if the connection could be | 23 // Called to establish a connection. Returns OK if the connection could be |
22 // established synchronously. Otherwise, ERR_IO_PENDING is returned and the | 24 // established synchronously. Otherwise, ERR_IO_PENDING is returned and the |
23 // given callback will run asynchronously when the connection is established | 25 // given callback will run asynchronously when the connection is established |
24 // or when an error occurs. The result is some other error code if the | 26 // or when an error occurs. The result is some other error code if the |
25 // connection could not be established. | 27 // connection could not be established. |
26 // | 28 // |
27 // The socket's Read and Write methods may not be called until Connect | 29 // The socket's Read and Write methods may not be called until Connect |
28 // succeeds. | 30 // succeeds. |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
72 | 74 |
73 // Returns true if the underlying transport socket ever had any reads or | 75 // Returns true if the underlying transport socket ever had any reads or |
74 // writes. StreamSockets layered on top of transport sockets should forward | 76 // writes. StreamSockets layered on top of transport sockets should forward |
75 // this call to the transport socket. | 77 // this call to the transport socket. |
76 virtual bool WasEverUsed() const = 0; | 78 virtual bool WasEverUsed() const = 0; |
77 | 79 |
78 // Returns true if the underlying transport socket is using TCP FastOpen. | 80 // Returns true if the underlying transport socket is using TCP FastOpen. |
79 // TCP FastOpen is an experiment with sending data in the TCP SYN packet. | 81 // TCP FastOpen is an experiment with sending data in the TCP SYN packet. |
80 virtual bool UsingTCPFastOpen() const = 0; | 82 virtual bool UsingTCPFastOpen() const = 0; |
81 | 83 |
84 // Returns the number of bytes successfully written to this socket. | |
willchan no longer on Chromium
2011/06/06 10:57:36
This should be virtual int NumBytesRead() const =
Gagan
2011/06/06 20:27:10
Done.
| |
85 virtual int NumBytesRead() const { return num_bytes_read_; } | |
86 | |
87 // Returns the RTT of this socket. | |
88 virtual double GetRTTMs() const { return rtt_ms_; } | |
willchan no longer on Chromium
2011/06/06 10:57:36
virtual double GetRTTInMs() const = 0;
Gagan
2011/06/06 20:27:10
Done.
| |
89 | |
82 protected: | 90 protected: |
83 // The following class is only used to gather statistics about the history of | 91 // The following class is only used to gather statistics about the history of |
84 // a socket. It is only instantiated and used in basic sockets, such as | 92 // a socket. It is only instantiated and used in basic sockets, such as |
85 // TCPClientSocket* instances. Other classes that are derived from | 93 // TCPClientSocket* instances. Other classes that are derived from |
86 // StreamSocket should forward any potential settings to their underlying | 94 // StreamSocket should forward any potential settings to their underlying |
87 // transport sockets. | 95 // transport sockets. |
88 class UseHistory { | 96 class UseHistory { |
89 public: | 97 public: |
90 UseHistory(); | 98 UseHistory(); |
91 ~UseHistory(); | 99 ~UseHistory(); |
(...skipping 27 matching lines...) Expand all Loading... | |
119 bool omnibox_speculation_; | 127 bool omnibox_speculation_; |
120 bool subresource_speculation_; | 128 bool subresource_speculation_; |
121 DISALLOW_COPY_AND_ASSIGN(UseHistory); | 129 DISALLOW_COPY_AND_ASSIGN(UseHistory); |
122 }; | 130 }; |
123 | 131 |
124 // Logs a SOCKET_BYTES_RECEIVED or SOCKET_BYTES_SENT event to the NetLog. | 132 // Logs a SOCKET_BYTES_RECEIVED or SOCKET_BYTES_SENT event to the NetLog. |
125 // Determines whether to log the received bytes or not, based on the current | 133 // Determines whether to log the received bytes or not, based on the current |
126 // logging level. | 134 // logging level. |
127 void LogByteTransfer(const BoundNetLog& net_log, NetLog::EventType event_type, | 135 void LogByteTransfer(const BoundNetLog& net_log, NetLog::EventType event_type, |
128 int byte_count, char* bytes) const; | 136 int byte_count, char* bytes) const; |
137 | |
138 int num_bytes_read_; | |
willchan no longer on Chromium
2011/06/06 10:57:36
Don't add any concrete member variables into this
Gagan
2011/06/06 20:27:10
Done.
| |
139 double rtt_ms_; | |
129 }; | 140 }; |
130 | 141 |
131 } // namespace net | 142 } // namespace net |
132 | 143 |
133 #endif // NET_SOCKET_STREAM_SOCKET_H_ | 144 #endif // NET_SOCKET_STREAM_SOCKET_H_ |
OLD | NEW |