OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef NET_UDP_UDP_SOCKET_LIBEVENT_H_ | 5 #ifndef NET_UDP_UDP_SOCKET_LIBEVENT_H_ |
6 #define NET_UDP_UDP_SOCKET_LIBEVENT_H_ | 6 #define NET_UDP_UDP_SOCKET_LIBEVENT_H_ |
7 | 7 |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
116 private: | 116 private: |
117 static const int kInvalidSocket = -1; | 117 static const int kInvalidSocket = -1; |
118 | 118 |
119 enum SocketOptions { | 119 enum SocketOptions { |
120 SOCKET_OPTION_REUSE_ADDRESS = 1 << 0, | 120 SOCKET_OPTION_REUSE_ADDRESS = 1 << 0, |
121 SOCKET_OPTION_BROADCAST = 1 << 1 | 121 SOCKET_OPTION_BROADCAST = 1 << 1 |
122 }; | 122 }; |
123 | 123 |
124 class ReadWatcher : public MessageLoopForIO::Watcher { | 124 class ReadWatcher : public MessageLoopForIO::Watcher { |
125 public: | 125 public: |
126 explicit ReadWatcher(UDPSocketLibevent* socket) : socket_(socket) {} | 126 explicit ReadWatcher(UDPSocketLibevent* socket) : socket_(socket) {} |
mmenke
2012/08/09 15:13:35
Should these two be de-inlined?
hans
2012/08/09 15:35:42
The plugin doesn't complain about it.
| |
127 | 127 |
128 // MessageLoopForIO::Watcher methods | 128 // MessageLoopForIO::Watcher methods |
129 | 129 |
130 virtual void OnFileCanReadWithoutBlocking(int /* fd */) OVERRIDE { | 130 virtual void OnFileCanReadWithoutBlocking(int /* fd */) OVERRIDE; |
131 if (!socket_->read_callback_.is_null()) | |
132 socket_->DidCompleteRead(); | |
133 } | |
134 | 131 |
135 virtual void OnFileCanWriteWithoutBlocking(int /* fd */) OVERRIDE {} | 132 virtual void OnFileCanWriteWithoutBlocking(int /* fd */) OVERRIDE {} |
136 | 133 |
137 private: | 134 private: |
138 UDPSocketLibevent* const socket_; | 135 UDPSocketLibevent* const socket_; |
139 | 136 |
140 DISALLOW_COPY_AND_ASSIGN(ReadWatcher); | 137 DISALLOW_COPY_AND_ASSIGN(ReadWatcher); |
141 }; | 138 }; |
142 | 139 |
143 class WriteWatcher : public MessageLoopForIO::Watcher { | 140 class WriteWatcher : public MessageLoopForIO::Watcher { |
144 public: | 141 public: |
145 explicit WriteWatcher(UDPSocketLibevent* socket) : socket_(socket) {} | 142 explicit WriteWatcher(UDPSocketLibevent* socket) : socket_(socket) {} |
146 | 143 |
147 // MessageLoopForIO::Watcher methods | 144 // MessageLoopForIO::Watcher methods |
148 | 145 |
149 virtual void OnFileCanReadWithoutBlocking(int /* fd */) OVERRIDE {} | 146 virtual void OnFileCanReadWithoutBlocking(int /* fd */) OVERRIDE {} |
150 | 147 |
151 virtual void OnFileCanWriteWithoutBlocking(int /* fd */) OVERRIDE { | 148 virtual void OnFileCanWriteWithoutBlocking(int /* fd */) OVERRIDE; |
152 if (!socket_->write_callback_.is_null()) | |
153 socket_->DidCompleteWrite(); | |
154 } | |
155 | 149 |
156 private: | 150 private: |
157 UDPSocketLibevent* const socket_; | 151 UDPSocketLibevent* const socket_; |
158 | 152 |
159 DISALLOW_COPY_AND_ASSIGN(WriteWatcher); | 153 DISALLOW_COPY_AND_ASSIGN(WriteWatcher); |
160 }; | 154 }; |
161 | 155 |
162 void DoReadCallback(int rv); | 156 void DoReadCallback(int rv); |
163 void DoWriteCallback(int rv); | 157 void DoWriteCallback(int rv); |
164 void DidCompleteRead(); | 158 void DidCompleteRead(); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
236 CompletionCallback write_callback_; | 230 CompletionCallback write_callback_; |
237 | 231 |
238 BoundNetLog net_log_; | 232 BoundNetLog net_log_; |
239 | 233 |
240 DISALLOW_COPY_AND_ASSIGN(UDPSocketLibevent); | 234 DISALLOW_COPY_AND_ASSIGN(UDPSocketLibevent); |
241 }; | 235 }; |
242 | 236 |
243 } // namespace net | 237 } // namespace net |
244 | 238 |
245 #endif // NET_UDP_UDP_SOCKET_LIBEVENT_H_ | 239 #endif // NET_UDP_UDP_SOCKET_LIBEVENT_H_ |
OLD | NEW |