OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_SOCKET_WIN_H_ | 5 #ifndef NET_SOCKET_TCP_SOCKET_WIN_H_ |
6 #define NET_SOCKET_TCP_SOCKET_WIN_H_ | 6 #define NET_SOCKET_TCP_SOCKET_WIN_H_ |
7 | 7 |
8 #include <winsock2.h> | 8 #include <winsock2.h> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/threading/non_thread_safe.h" | 14 #include "base/threading/non_thread_safe.h" |
15 #include "base/win/object_watcher.h" | 15 #include "base/win/object_watcher.h" |
16 #include "net/base/address_family.h" | 16 #include "net/base/address_family.h" |
17 #include "net/base/completion_callback.h" | 17 #include "net/base/completion_callback.h" |
18 #include "net/base/net_export.h" | 18 #include "net/base/net_export.h" |
19 #include "net/base/net_log.h" | 19 #include "net/base/net_log.h" |
20 | 20 |
21 namespace net { | 21 namespace net { |
22 | 22 |
23 class AddressList; | 23 class AddressList; |
24 class IOBuffer; | 24 class IOBuffer; |
25 class IPEndPoint; | 25 class IPEndPoint; |
26 | 26 |
27 class NET_EXPORT TCPSocketWin : NON_EXPORTED_BASE(public base::NonThreadSafe), | 27 class NET_EXPORT TCPSocketWin : NON_EXPORTED_BASE(public base::NonThreadSafe), |
28 public base::win::ObjectWatcher::Delegate { | 28 public base::win::ObjectWatcher::Delegate { |
29 public: | 29 public: |
30 TCPSocketWin(NetLog* net_log, const NetLog::Source& source); | 30 TCPSocketWin(NetLog* net_log, const NetLog::Source& source); |
31 virtual ~TCPSocketWin(); | 31 virtual ~TCPSocketWin(); |
32 | 32 |
33 int Open(AddressFamily family); | 33 int Open(AddressFamily family); |
34 | 34 |
35 // Both AdoptConnectedSocket and AdoptListenSocket take ownership of an | 35 // Both AdoptConnectedSocket and AdoptListenSocket take ownership of an |
36 // existing socket. AdoptConnectedSocket takes an already connected | 36 // existing socket. AdoptConnectedSocket takes an already connected |
37 // socket. AdoptListenSocket takes a socket that is intended to accept | 37 // socket. AdoptListenSocket takes a socket that is intended to accept |
38 // connection. In some sense, AdoptListenSocket is more similar to Open. | 38 // connection. In some sense, AdoptListenSocket is more similar to Open. |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 void EndLoggingMultipleConnectAttempts(int net_error); | 92 void EndLoggingMultipleConnectAttempts(int net_error); |
93 | 93 |
94 const BoundNetLog& net_log() const { return net_log_; } | 94 const BoundNetLog& net_log() const { return net_log_; } |
95 | 95 |
96 private: | 96 private: |
97 class Core; | 97 class Core; |
98 | 98 |
99 // base::ObjectWatcher::Delegate implementation. | 99 // base::ObjectWatcher::Delegate implementation. |
100 virtual void OnObjectSignaled(HANDLE object) OVERRIDE; | 100 virtual void OnObjectSignaled(HANDLE object) OVERRIDE; |
101 | 101 |
102 int AcceptInternal(scoped_ptr<TCPSocketWin>* socket, | 102 int AcceptInternal(scoped_ptr<TCPSocketWin>* socket, IPEndPoint* address); |
103 IPEndPoint* address); | |
104 | 103 |
105 int DoConnect(); | 104 int DoConnect(); |
106 void DoConnectComplete(int result); | 105 void DoConnectComplete(int result); |
107 | 106 |
108 void LogConnectBegin(const AddressList& addresses); | 107 void LogConnectBegin(const AddressList& addresses); |
109 void LogConnectEnd(int net_error); | 108 void LogConnectEnd(int net_error); |
110 | 109 |
111 int DoRead(IOBuffer* buf, int buf_len, const CompletionCallback& callback); | 110 int DoRead(IOBuffer* buf, int buf_len, const CompletionCallback& callback); |
112 void DidCompleteConnect(); | 111 void DidCompleteConnect(); |
113 void DidCompleteWrite(); | 112 void DidCompleteWrite(); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 bool logging_multiple_connect_attempts_; | 144 bool logging_multiple_connect_attempts_; |
146 | 145 |
147 BoundNetLog net_log_; | 146 BoundNetLog net_log_; |
148 | 147 |
149 DISALLOW_COPY_AND_ASSIGN(TCPSocketWin); | 148 DISALLOW_COPY_AND_ASSIGN(TCPSocketWin); |
150 }; | 149 }; |
151 | 150 |
152 } // namespace net | 151 } // namespace net |
153 | 152 |
154 #endif // NET_SOCKET_TCP_SOCKET_WIN_H_ | 153 #endif // NET_SOCKET_TCP_SOCKET_WIN_H_ |
155 | |
OLD | NEW |