OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // TCP/IP server that handles IO asynchronously in the specified MessageLoop. | 5 // TCP/IP server that handles IO asynchronously in the specified MessageLoop. |
6 // These objects are NOT thread safe. They use WSAEVENT handles to monitor | 6 // These objects are NOT thread safe. They use WSAEVENT handles to monitor |
7 // activity in a given MessageLoop. This means that callbacks will | 7 // activity in a given MessageLoop. This means that callbacks will |
8 // happen in that loop's thread always and that all other methods (including | 8 // happen in that loop's thread always and that all other methods (including |
9 // constructors and destructors) should also be called from the same thread. | 9 // constructors and destructors) should also be called from the same thread. |
10 | 10 |
11 #ifndef NET_BASE_LISTEN_SOCKET_H_ | 11 #ifndef NET_BASE_LISTEN_SOCKET_H_ |
12 #define NET_BASE_LISTEN_SOCKET_H_ | 12 #define NET_BASE_LISTEN_SOCKET_H_ |
13 #pragma once | 13 #pragma once |
14 | 14 |
15 #include "build/build_config.h" | 15 #include "build/build_config.h" |
16 | 16 |
17 #if defined(OS_WIN) | 17 #if defined(OS_WIN) |
18 #include <winsock2.h> | 18 #include <winsock2.h> |
19 #endif | 19 #endif |
20 #include <string> | 20 #include <string> |
21 #if defined(OS_WIN) | 21 #if defined(OS_WIN) |
22 #include "base/win/object_watcher.h" | 22 #include "base/win/object_watcher.h" |
23 #elif defined(OS_POSIX) | 23 #elif defined(OS_POSIX) |
24 #include "base/message_loop.h" | 24 #include "base/message_loop.h" |
25 #endif | 25 #endif |
26 | 26 |
27 #include "base/basictypes.h" | 27 #include "base/basictypes.h" |
28 #include "base/compiler_specific.h" | 28 #include "base/compiler_specific.h" |
29 #include "base/memory/ref_counted.h" | 29 #include "base/memory/ref_counted.h" |
30 #include "net/base/net_api.h" | 30 #include "net/base/net_export.h" |
31 | 31 |
32 #if defined(OS_POSIX) | 32 #if defined(OS_POSIX) |
33 typedef int SOCKET; | 33 typedef int SOCKET; |
34 #endif | 34 #endif |
35 | 35 |
36 namespace net { | 36 namespace net { |
37 | 37 |
38 // Implements a raw socket interface | 38 // Implements a raw socket interface |
39 class NET_API ListenSocket : public base::RefCountedThreadSafe<ListenSocket>, | 39 class NET_EXPORT ListenSocket : public base::RefCountedThreadSafe<ListenSocket>, |
40 #if defined(OS_WIN) | 40 #if defined(OS_WIN) |
41 public base::win::ObjectWatcher::Delegate { | 41 public base::win::ObjectWatcher::Delegate { |
42 #elif defined(OS_POSIX) | 42 #elif defined(OS_POSIX) |
43 public MessageLoopForIO::Watcher { | 43 public MessageLoopForIO::Watcher { |
44 #endif | 44 #endif |
45 public: | 45 public: |
46 // TODO(erikkay): this delegate should really be split into two parts | 46 // TODO(erikkay): this delegate should really be split into two parts |
47 // to split up the listener from the connected socket. Perhaps this class | 47 // to split up the listener from the connected socket. Perhaps this class |
48 // should be split up similarly. | 48 // should be split up similarly. |
49 class ListenSocketDelegate { | 49 class ListenSocketDelegate { |
50 public: | 50 public: |
51 virtual ~ListenSocketDelegate() {} | 51 virtual ~ListenSocketDelegate() {} |
52 | 52 |
53 // server is the original listening Socket, connection is the new | 53 // server is the original listening Socket, connection is the new |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 private: | 126 private: |
127 bool reads_paused_; | 127 bool reads_paused_; |
128 bool has_pending_reads_; | 128 bool has_pending_reads_; |
129 | 129 |
130 DISALLOW_COPY_AND_ASSIGN(ListenSocket); | 130 DISALLOW_COPY_AND_ASSIGN(ListenSocket); |
131 }; | 131 }; |
132 | 132 |
133 } // namespace net | 133 } // namespace net |
134 | 134 |
135 #endif // NET_BASE_LISTEN_SOCKET_H_ | 135 #endif // NET_BASE_LISTEN_SOCKET_H_ |
OLD | NEW |