| OLD | NEW | 
|---|
| (Empty) |  | 
|  | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 
|  | 2 // Use of this source code is governed by a BSD-style license that can be | 
|  | 3 // found in the LICENSE file. | 
|  | 4 | 
|  | 5 #ifndef NET_SOCKET_TCP_SOCKET_WIN_H_ | 
|  | 6 #define NET_SOCKET_TCP_SOCKET_WIN_H_ | 
|  | 7 | 
|  | 8 #include <winsock2.h> | 
|  | 9 | 
|  | 10 #include "base/basictypes.h" | 
|  | 11 #include "base/compiler_specific.h" | 
|  | 12 #include "base/memory/scoped_ptr.h" | 
|  | 13 #include "base/message_loop/message_loop.h" | 
|  | 14 #include "base/threading/non_thread_safe.h" | 
|  | 15 #include "base/win/object_watcher.h" | 
|  | 16 #include "net/base/address_family.h" | 
|  | 17 #include "net/base/completion_callback.h" | 
|  | 18 #include "net/base/net_export.h" | 
|  | 19 #include "net/base/net_log.h" | 
|  | 20 | 
|  | 21 namespace net { | 
|  | 22 | 
|  | 23 class IPEndPoint; | 
|  | 24 | 
|  | 25 class NET_EXPORT TCPSocketWin : NON_EXPORTED_BASE(public base::NonThreadSafe), | 
|  | 26                                 public base::win::ObjectWatcher::Delegate  { | 
|  | 27  public: | 
|  | 28   TCPSocketWin(NetLog* net_log, const NetLog::Source& source); | 
|  | 29   virtual ~TCPSocketWin(); | 
|  | 30 | 
|  | 31   int Create(AddressFamily family); | 
|  | 32   // Takes ownership of |socket|. | 
|  | 33   int Adopt(SOCKET socket); | 
|  | 34   // Returns a socket descriptor. The ownership is transferred to the caller. | 
|  | 35   SOCKET Release(); | 
|  | 36   int Bind(const IPEndPoint& address); | 
|  | 37   int GetLocalAddress(IPEndPoint* address) const; | 
|  | 38   int Listen(int backlog); | 
|  | 39   int Accept(scoped_ptr<TCPSocketWin>* socket, | 
|  | 40              IPEndPoint* address, | 
|  | 41              const CompletionCallback& callback); | 
|  | 42   int SetDefaultOptionsForServer(); | 
|  | 43   int SetExclusiveAddrUse(); | 
|  | 44   void Close(); | 
|  | 45 | 
|  | 46   const BoundNetLog& net_log() const { return net_log_; } | 
|  | 47 | 
|  | 48   // base::ObjectWatcher::Delegate implementation. | 
|  | 49   virtual void OnObjectSignaled(HANDLE object) OVERRIDE; | 
|  | 50 | 
|  | 51  private: | 
|  | 52   int AcceptInternal(scoped_ptr<TCPSocketWin>* socket, | 
|  | 53                      IPEndPoint* address); | 
|  | 54 | 
|  | 55   SOCKET socket_; | 
|  | 56   HANDLE socket_event_; | 
|  | 57 | 
|  | 58   base::win::ObjectWatcher accept_watcher_; | 
|  | 59 | 
|  | 60   scoped_ptr<TCPSocketWin>* accept_socket_; | 
|  | 61   IPEndPoint* accept_address_; | 
|  | 62   CompletionCallback accept_callback_; | 
|  | 63 | 
|  | 64   BoundNetLog net_log_; | 
|  | 65 | 
|  | 66   DISALLOW_COPY_AND_ASSIGN(TCPSocketWin); | 
|  | 67 }; | 
|  | 68 | 
|  | 69 }  // namespace net | 
|  | 70 | 
|  | 71 #endif  // NET_SOCKET_TCP_SOCKET_WIN_H_ | 
| OLD | NEW | 
|---|