| 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_LIBEVENT_H_ | 
|  | 6 #define NET_SOCKET_TCP_SOCKET_LIBEVENT_H_ | 
|  | 7 | 
|  | 8 #include "base/basictypes.h" | 
|  | 9 #include "base/compiler_specific.h" | 
|  | 10 #include "base/memory/scoped_ptr.h" | 
|  | 11 #include "base/message_loop/message_loop.h" | 
|  | 12 #include "base/threading/non_thread_safe.h" | 
|  | 13 #include "net/base/address_family.h" | 
|  | 14 #include "net/base/completion_callback.h" | 
|  | 15 #include "net/base/net_export.h" | 
|  | 16 #include "net/base/net_log.h" | 
|  | 17 | 
|  | 18 namespace net { | 
|  | 19 | 
|  | 20 class IPEndPoint; | 
|  | 21 | 
|  | 22 class NET_EXPORT TCPSocketLibevent : public base::NonThreadSafe, | 
|  | 23                                      public base::MessageLoopForIO::Watcher { | 
|  | 24  public: | 
|  | 25   TCPSocketLibevent(NetLog* net_log, const NetLog::Source& source); | 
|  | 26   virtual ~TCPSocketLibevent(); | 
|  | 27 | 
|  | 28   int Create(AddressFamily family); | 
|  | 29   // Takes ownership of |socket|. | 
|  | 30   int Adopt(int socket); | 
|  | 31   // Returns a socket file descriptor. The ownership is transferred to the | 
|  | 32   // caller. | 
|  | 33   int Release(); | 
|  | 34   int Bind(const IPEndPoint& address); | 
|  | 35   int GetLocalAddress(IPEndPoint* address) const; | 
|  | 36   int Listen(int backlog); | 
|  | 37   int Accept(scoped_ptr<TCPSocketLibevent>* socket, | 
|  | 38              IPEndPoint* address, | 
|  | 39              const CompletionCallback& callback); | 
|  | 40   int SetDefaultOptionsForServer(); | 
|  | 41   int SetAddressReuse(bool allow); | 
|  | 42   void Close(); | 
|  | 43 | 
|  | 44   const BoundNetLog& net_log() const { return net_log_; } | 
|  | 45 | 
|  | 46   // MessageLoopForIO::Watcher implementation. | 
|  | 47   virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE; | 
|  | 48   virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE; | 
|  | 49 | 
|  | 50  private: | 
|  | 51   int AcceptInternal(scoped_ptr<TCPSocketLibevent>* socket, | 
|  | 52                      IPEndPoint* address); | 
|  | 53 | 
|  | 54   int socket_; | 
|  | 55 | 
|  | 56   base::MessageLoopForIO::FileDescriptorWatcher accept_socket_watcher_; | 
|  | 57 | 
|  | 58   scoped_ptr<TCPSocketLibevent>* accept_socket_; | 
|  | 59   IPEndPoint* accept_address_; | 
|  | 60   CompletionCallback accept_callback_; | 
|  | 61 | 
|  | 62   BoundNetLog net_log_; | 
|  | 63 | 
|  | 64   DISALLOW_COPY_AND_ASSIGN(TCPSocketLibevent); | 
|  | 65 }; | 
|  | 66 | 
|  | 67 }  // namespace net | 
|  | 68 | 
|  | 69 #endif  // NET_SOCKET_TCP_SOCKET_LIBEVENT_H_ | 
| OLD | NEW | 
|---|