OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #ifndef WEBRTC_BASE_SOCKETSERVER_H_ | 11 #ifndef WEBRTC_BASE_SOCKETSERVER_H_ |
12 #define WEBRTC_BASE_SOCKETSERVER_H_ | 12 #define WEBRTC_BASE_SOCKETSERVER_H_ |
13 | 13 |
14 #include <memory> | |
15 #include "webrtc/base/socketfactory.h" | |
16 | 14 |
17 namespace rtc { | 15 // This header is deprecated and is just left here temporarily during |
18 | 16 // refactoring. See https://bugs.webrtc.org/7634 for more details. |
19 class MessageQueue; | 17 #include "webrtc/rtc_base/socketserver.h" |
20 // Needs to be forward declared because there's a circular dependency between | |
21 // NetworkMonitor and Thread. | |
22 // TODO(deadbeef): Fix this. | |
23 class NetworkBinderInterface; | |
24 | |
25 // Provides the ability to wait for activity on a set of sockets. The Thread | |
26 // class provides a nice wrapper on a socket server. | |
27 // | |
28 // The server is also a socket factory. The sockets it creates will be | |
29 // notified of asynchronous I/O from this server's Wait method. | |
30 class SocketServer : public SocketFactory { | |
31 public: | |
32 static const int kForever = -1; | |
33 | |
34 static std::unique_ptr<SocketServer> CreateDefault(); | |
35 // When the socket server is installed into a Thread, this function is | |
36 // called to allow the socket server to use the thread's message queue for | |
37 // any messaging that it might need to perform. | |
38 virtual void SetMessageQueue(MessageQueue* queue) {} | |
39 | |
40 // Sleeps until: | |
41 // 1) cms milliseconds have elapsed (unless cms == kForever) | |
42 // 2) WakeUp() is called | |
43 // While sleeping, I/O is performed if process_io is true. | |
44 virtual bool Wait(int cms, bool process_io) = 0; | |
45 | |
46 // Causes the current wait (if one is in progress) to wake up. | |
47 virtual void WakeUp() = 0; | |
48 | |
49 // A network binder will bind the created sockets to a network. | |
50 // It is only used in PhysicalSocketServer. | |
51 void set_network_binder(NetworkBinderInterface* binder) { | |
52 network_binder_ = binder; | |
53 } | |
54 NetworkBinderInterface* network_binder() const { return network_binder_; } | |
55 | |
56 private: | |
57 NetworkBinderInterface* network_binder_ = nullptr; | |
58 }; | |
59 | |
60 } // namespace rtc | |
61 | 18 |
62 #endif // WEBRTC_BASE_SOCKETSERVER_H_ | 19 #endif // WEBRTC_BASE_SOCKETSERVER_H_ |
OLD | NEW |