| Index: net/socket/tcp_client_socket.h
|
| diff --git a/net/socket/tcp_client_socket.h b/net/socket/tcp_client_socket.h
|
| index 295e8b68113950afda1d7f0379b840a4bfdf4c1b..0b05c36d6afbd34646246847c7754b8f13983041 100644
|
| --- a/net/socket/tcp_client_socket.h
|
| +++ b/net/socket/tcp_client_socket.h
|
| @@ -11,6 +11,8 @@
|
|
|
| #include "base/compiler_specific.h"
|
| #include "base/macros.h"
|
| +#include "base/memory/weak_ptr.h"
|
| +#include "base/power_monitor/power_observer.h"
|
| #include "net/base/address_list.h"
|
| #include "net/base/completion_callback.h"
|
| #include "net/base/net_export.h"
|
| @@ -25,7 +27,8 @@ struct NetLogSource;
|
| class SocketPerformanceWatcher;
|
|
|
| // A client socket that uses TCP as the transport layer.
|
| -class NET_EXPORT TCPClientSocket : public StreamSocket {
|
| +class NET_EXPORT TCPClientSocket : public StreamSocket,
|
| + public base::PowerObserver {
|
| public:
|
| // The IP address(es) and port number to connect to. The TCP socket will try
|
| // each IP address in the list until it succeeds in establishing a
|
| @@ -61,6 +64,7 @@ class NET_EXPORT TCPClientSocket : public StreamSocket {
|
| bool WasNpnNegotiated() const override;
|
| NextProto GetNegotiatedProtocol() const override;
|
| bool GetSSLInfo(SSLInfo* ssl_info) override;
|
| + void SetFailOnSuspend(bool disconnect_on_suspend) override;
|
|
|
| // Socket implementation.
|
| // Multiple outstanding requests are not supported.
|
| @@ -82,6 +86,9 @@ class NET_EXPORT TCPClientSocket : public StreamSocket {
|
| void AddConnectionAttempts(const ConnectionAttempts& attempts) override;
|
| int64_t GetTotalReceivedBytes() const override;
|
|
|
| + // base::PowerObserver methods:
|
| + void OnSuspend() override;
|
| +
|
| private:
|
| // State machine for connecting the socket.
|
| enum ConnectState {
|
| @@ -100,8 +107,8 @@ class NET_EXPORT TCPClientSocket : public StreamSocket {
|
| void DoDisconnect();
|
|
|
| void DidCompleteConnect(int result);
|
| - void DidCompleteRead(const CompletionCallback& callback, int result);
|
| - void DidCompleteWrite(const CompletionCallback& callback, int result);
|
| + void DidCompleteRead(int result);
|
| + void DidCompleteWrite(int result);
|
| void DidCompleteReadWrite(const CompletionCallback& callback, int result);
|
|
|
| int OpenSocket(AddressFamily family);
|
| @@ -129,8 +136,11 @@ class NET_EXPORT TCPClientSocket : public StreamSocket {
|
| // Where we are in above list. Set to -1 if uninitialized.
|
| int current_address_index_;
|
|
|
| - // External callback; called when connect is complete.
|
| + // External callbacks; called when corresponding operations are complete.
|
| + // Cleared when no such operation is pending.
|
| CompletionCallback connect_callback_;
|
| + CompletionCallback read_callback_;
|
| + CompletionCallback write_callback_;
|
|
|
| // The next state for the Connect() state machine.
|
| ConnectState next_connect_state_;
|
| @@ -148,6 +158,14 @@ class NET_EXPORT TCPClientSocket : public StreamSocket {
|
| // Total number of bytes received by the socket.
|
| int64_t total_received_bytes_;
|
|
|
| + bool disconnect_on_suspend_;
|
| + // Set to true if the socket was disconnected due to entering suspend mode.
|
| + // Once set, read/write operations return ERR_NETWORK_IO_SUSPENDED, until
|
| + // Connect() or Disconnect() is called.
|
| + bool was_disconnected_on_suspend_;
|
| +
|
| + base::WeakPtrFactory<TCPClientSocket> weak_ptr_factory_;
|
| +
|
| DISALLOW_COPY_AND_ASSIGN(TCPClientSocket);
|
| };
|
|
|
|
|