OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_CLIENT_SOCKET_H_ | 5 #ifndef NET_SOCKET_STREAM_SOCKET_H_ |
6 #define NET_SOCKET_CLIENT_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 ClientSocket : public Socket { | 17 class StreamSocket : public Socket { |
18 public: | 18 public: |
19 virtual ~ClientSocket() {} | 19 virtual ~StreamSocket() {} |
20 | 20 |
21 // Called to establish a connection. Returns OK if the connection could be | 21 // Called to establish a connection. Returns OK if the connection could be |
22 // established synchronously. Otherwise, ERR_IO_PENDING is returned and the | 22 // established synchronously. Otherwise, ERR_IO_PENDING is returned and the |
23 // given callback will run asynchronously when the connection is established | 23 // 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 | 24 // or when an error occurs. The result is some other error code if the |
25 // connection could not be established. | 25 // connection could not be established. |
26 // | 26 // |
27 // The socket's Read and Write methods may not be called until Connect | 27 // The socket's Read and Write methods may not be called until Connect |
28 // succeeds. | 28 // succeeds. |
29 // | 29 // |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 // Gets the NetLog for this socket. | 64 // Gets the NetLog for this socket. |
65 virtual const BoundNetLog& NetLog() const = 0; | 65 virtual const BoundNetLog& NetLog() const = 0; |
66 | 66 |
67 // Set the annotation to indicate this socket was created for speculative | 67 // Set the annotation to indicate this socket was created for speculative |
68 // reasons. This call is generally forwarded to a basic TCPClientSocket*, | 68 // reasons. This call is generally forwarded to a basic TCPClientSocket*, |
69 // where a UseHistory can be updated. | 69 // where a UseHistory can be updated. |
70 virtual void SetSubresourceSpeculation() = 0; | 70 virtual void SetSubresourceSpeculation() = 0; |
71 virtual void SetOmniboxSpeculation() = 0; | 71 virtual void SetOmniboxSpeculation() = 0; |
72 | 72 |
73 // Returns true if the underlying transport socket ever had any reads or | 73 // Returns true if the underlying transport socket ever had any reads or |
74 // writes. ClientSockets layered on top of transport sockets should forward | 74 // writes. StreamSockets layered on top of transport sockets should forward |
75 // this call to the transport socket. | 75 // this call to the transport socket. |
76 virtual bool WasEverUsed() const = 0; | 76 virtual bool WasEverUsed() const = 0; |
77 | 77 |
78 // Returns true if the underlying transport socket is using TCP FastOpen. | 78 // 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. | 79 // TCP FastOpen is an experiment with sending data in the TCP SYN packet. |
80 virtual bool UsingTCPFastOpen() const = 0; | 80 virtual bool UsingTCPFastOpen() const = 0; |
81 | 81 |
82 protected: | 82 protected: |
83 // The following class is only used to gather statistics about the history of | 83 // 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 | 84 // a socket. It is only instantiated and used in basic sockets, such as |
85 // TCPClientSocket* instances. Other classes that are derived from | 85 // TCPClientSocket* instances. Other classes that are derived from |
86 // ClientSocket should forward any potential settings to their underlying | 86 // StreamSocket should forward any potential settings to their underlying |
87 // transport sockets. | 87 // transport sockets. |
88 class UseHistory { | 88 class UseHistory { |
89 public: | 89 public: |
90 UseHistory(); | 90 UseHistory(); |
91 ~UseHistory(); | 91 ~UseHistory(); |
92 | 92 |
93 // Resets the state of UseHistory and emits histograms for the | 93 // Resets the state of UseHistory and emits histograms for the |
94 // current state. | 94 // current state. |
95 void Reset(); | 95 void Reset(); |
96 | 96 |
(...skipping 26 matching lines...) Expand all Loading... |
123 | 123 |
124 // Logs a SOCKET_BYTES_RECEIVED or SOCKET_BYTES_SENT event to the NetLog. | 124 // 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 | 125 // Determines whether to log the received bytes or not, based on the current |
126 // logging level. | 126 // logging level. |
127 void LogByteTransfer(const BoundNetLog& net_log, NetLog::EventType event_type, | 127 void LogByteTransfer(const BoundNetLog& net_log, NetLog::EventType event_type, |
128 int byte_count, char* bytes) const; | 128 int byte_count, char* bytes) const; |
129 }; | 129 }; |
130 | 130 |
131 } // namespace net | 131 } // namespace net |
132 | 132 |
133 #endif // NET_SOCKET_CLIENT_SOCKET_H_ | 133 #endif // NET_SOCKET_STREAM_SOCKET_H_ |
OLD | NEW |