Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(411)

Side by Side Diff: net/base/listen_socket.h

Issue 6969077: net: Add NET_API to net/base (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/memory/ref_counted.h" 29 #include "base/memory/ref_counted.h"
30 #include "net/base/net_api.h"
29 31
30 #if defined(OS_POSIX) 32 #if defined(OS_POSIX)
31 struct event; // From libevent 33 struct event; // From libevent
32 typedef int SOCKET; 34 typedef int SOCKET;
33 #endif 35 #endif
34 36
35 // Implements a raw socket interface 37 // Implements a raw socket interface
36 class ListenSocket : public base::RefCountedThreadSafe<ListenSocket>, 38 class NET_API ListenSocket : public base::RefCountedThreadSafe<ListenSocket>,
37 #if defined(OS_WIN) 39 #if defined(OS_WIN)
38 public base::win::ObjectWatcher::Delegate 40 public base::win::ObjectWatcher::Delegate {
39 #elif defined(OS_POSIX) 41 #elif defined(OS_POSIX)
40 public MessageLoopForIO::Watcher 42 public MessageLoopForIO::Watcher {
41 #endif 43 #endif
42 {
43 public: 44 public:
44 // TODO(erikkay): this delegate should really be split into two parts 45 // TODO(erikkay): this delegate should really be split into two parts
45 // to split up the listener from the connected socket. Perhaps this class 46 // to split up the listener from the connected socket. Perhaps this class
46 // should be split up similarly. 47 // should be split up similarly.
47 class ListenSocketDelegate { 48 class ListenSocketDelegate {
48 public: 49 public:
49 virtual ~ListenSocketDelegate() {} 50 virtual ~ListenSocketDelegate() {}
50 51
51 // server is the original listening Socket, connection is the new 52 // server is the original listening Socket, connection is the new
52 // Socket that was created. Ownership of connection is transferred 53 // Socket that was created. Ownership of connection is transferred
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 ListenSocketDelegate *socket_delegate_; 124 ListenSocketDelegate *socket_delegate_;
124 125
125 private: 126 private:
126 bool reads_paused_; 127 bool reads_paused_;
127 bool has_pending_reads_; 128 bool has_pending_reads_;
128 129
129 DISALLOW_COPY_AND_ASSIGN(ListenSocket); 130 DISALLOW_COPY_AND_ASSIGN(ListenSocket);
130 }; 131 };
131 132
132 #endif // NET_BASE_LISTEN_SOCKET_H_ 133 #endif // NET_BASE_LISTEN_SOCKET_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698