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

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

Issue 6382003: Reorder the methods in net/url_request/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Compiling net_unittests != compiling the rest of chrome Created 9 years, 11 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
« no previous file with comments | « no previous file | net/base/listen_socket.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 69
70 // NOTE: This is for unit test use only! 70 // NOTE: This is for unit test use only!
71 // Pause/Resume calling Read(). Note that ResumeReads() will also call 71 // Pause/Resume calling Read(). Note that ResumeReads() will also call
72 // Read() if there is anything to read. 72 // Read() if there is anything to read.
73 void PauseReads(); 73 void PauseReads();
74 void ResumeReads(); 74 void ResumeReads();
75 75
76 protected: 76 protected:
77 friend class base::RefCountedThreadSafe<ListenSocket>; 77 friend class base::RefCountedThreadSafe<ListenSocket>;
78 78
79 enum WaitState {
80 NOT_WAITING = 0,
81 WAITING_ACCEPT = 1,
82 WAITING_READ = 3,
83 WAITING_CLOSE = 4
84 };
85
79 static const SOCKET kInvalidSocket; 86 static const SOCKET kInvalidSocket;
80 static const int kSocketError; 87 static const int kSocketError;
81 88
82 ListenSocket(SOCKET s, ListenSocketDelegate* del); 89 ListenSocket(SOCKET s, ListenSocketDelegate* del);
83 virtual ~ListenSocket(); 90 virtual ~ListenSocket();
84 static SOCKET Listen(std::string ip, int port); 91 static SOCKET Listen(std::string ip, int port);
85 // if valid, returned SOCKET is non-blocking 92 // if valid, returned SOCKET is non-blocking
86 static SOCKET Accept(SOCKET s); 93 static SOCKET Accept(SOCKET s);
87 94
88 virtual void SendInternal(const char* bytes, int len); 95 virtual void SendInternal(const char* bytes, int len);
89 96
90 virtual void Listen(); 97 virtual void Listen();
91 virtual void Accept(); 98 virtual void Accept();
92 virtual void Read(); 99 virtual void Read();
93 virtual void Close(); 100 virtual void Close();
94 virtual void CloseSocket(SOCKET s); 101 virtual void CloseSocket(SOCKET s);
95 102
96 enum WaitState {
97 NOT_WAITING = 0,
98 WAITING_ACCEPT = 1,
99 WAITING_READ = 3,
100 WAITING_CLOSE = 4
101 };
102 // Pass any value in case of Windows, because in Windows 103 // Pass any value in case of Windows, because in Windows
103 // we are not using state. 104 // we are not using state.
104 void WatchSocket(WaitState state); 105 void WatchSocket(WaitState state);
105 void UnwatchSocket(); 106 void UnwatchSocket();
106 107
107 #if defined(OS_WIN) 108 #if defined(OS_WIN)
108 // ObjectWatcher delegate 109 // ObjectWatcher delegate
109 virtual void OnObjectSignaled(HANDLE object); 110 virtual void OnObjectSignaled(HANDLE object);
110 base::win::ObjectWatcher watcher_; 111 base::win::ObjectWatcher watcher_;
111 HANDLE socket_event_; 112 HANDLE socket_event_;
112 #elif defined(OS_POSIX) 113 #elif defined(OS_POSIX)
114 // Called by MessagePumpLibevent when the socket is ready to do I/O
115 virtual void OnFileCanReadWithoutBlocking(int fd);
116 virtual void OnFileCanWriteWithoutBlocking(int fd);
113 WaitState wait_state_; 117 WaitState wait_state_;
114 // The socket's libevent wrapper 118 // The socket's libevent wrapper
115 MessageLoopForIO::FileDescriptorWatcher watcher_; 119 MessageLoopForIO::FileDescriptorWatcher watcher_;
116 // Called by MessagePumpLibevent when the socket is ready to do I/O
117 virtual void OnFileCanReadWithoutBlocking(int fd);
118 virtual void OnFileCanWriteWithoutBlocking(int fd);
119 #endif 120 #endif
120 121
121 SOCKET socket_; 122 SOCKET socket_;
122 ListenSocketDelegate *socket_delegate_; 123 ListenSocketDelegate *socket_delegate_;
123 124
124 private: 125 private:
125 bool reads_paused_; 126 bool reads_paused_;
126 bool has_pending_reads_; 127 bool has_pending_reads_;
127 128
128 DISALLOW_COPY_AND_ASSIGN(ListenSocket); 129 DISALLOW_COPY_AND_ASSIGN(ListenSocket);
129 }; 130 };
130 131
131 #endif // NET_BASE_LISTEN_SOCKET_H_ 132 #endif // NET_BASE_LISTEN_SOCKET_H_
OLDNEW
« no previous file with comments | « no previous file | net/base/listen_socket.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698