OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2007 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2007 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 #ifndef WEBRTC_BASE_MACSOCKETSERVER_H__ | 10 #ifndef WEBRTC_BASE_MACSOCKETSERVER_H__ |
11 #define WEBRTC_BASE_MACSOCKETSERVER_H__ | 11 #define WEBRTC_BASE_MACSOCKETSERVER_H__ |
12 | 12 |
13 #include <set> | 13 #include <set> |
14 #include <CoreFoundation/CoreFoundation.h> | 14 #if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS) // Invalid on IOS |
| 15 #include <Carbon/Carbon.h> |
| 16 #endif |
15 #include "webrtc/base/physicalsocketserver.h" | 17 #include "webrtc/base/physicalsocketserver.h" |
16 | 18 |
17 namespace rtc { | 19 namespace rtc { |
18 | 20 |
19 /////////////////////////////////////////////////////////////////////////////// | 21 /////////////////////////////////////////////////////////////////////////////// |
20 // MacBaseSocketServer | 22 // MacBaseSocketServer |
21 /////////////////////////////////////////////////////////////////////////////// | 23 /////////////////////////////////////////////////////////////////////////////// |
22 class MacAsyncSocket; | 24 class MacAsyncSocket; |
23 | 25 |
24 class MacBaseSocketServer : public PhysicalSocketServer { | 26 class MacBaseSocketServer : public PhysicalSocketServer { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 | 69 |
68 // SocketServer Interface | 70 // SocketServer Interface |
69 bool Wait(int cms, bool process_io) override; | 71 bool Wait(int cms, bool process_io) override; |
70 void WakeUp() override; | 72 void WakeUp() override; |
71 void OnWakeUpCallback(); | 73 void OnWakeUpCallback(); |
72 | 74 |
73 private: | 75 private: |
74 CFRunLoopRef run_loop_; | 76 CFRunLoopRef run_loop_; |
75 CFRunLoopSourceRef wake_up_; | 77 CFRunLoopSourceRef wake_up_; |
76 }; | 78 }; |
| 79 |
| 80 #ifndef CARBON_DEPRECATED |
| 81 |
| 82 /////////////////////////////////////////////////////////////////////////////// |
| 83 // MacCarbonSocketServer |
| 84 /////////////////////////////////////////////////////////////////////////////// |
| 85 |
| 86 // Interacts with the Carbon event queue. While idle it will block, |
| 87 // waiting for events. When the socket server has work to do, it will |
| 88 // post a 'wake up' event to the queue, causing the thread to exit the |
| 89 // event loop until the next call to Wait. Other events are dispatched |
| 90 // to their target. Supports Carbon and Cocoa UI interaction. |
| 91 class MacCarbonSocketServer : public MacBaseSocketServer { |
| 92 public: |
| 93 MacCarbonSocketServer(); |
| 94 virtual ~MacCarbonSocketServer(); |
| 95 |
| 96 // SocketServer Interface |
| 97 virtual bool Wait(int cms, bool process_io); |
| 98 virtual void WakeUp(); |
| 99 |
| 100 private: |
| 101 EventQueueRef event_queue_; |
| 102 EventRef wake_up_; |
| 103 }; |
| 104 |
| 105 /////////////////////////////////////////////////////////////////////////////// |
| 106 // MacCarbonAppSocketServer |
| 107 /////////////////////////////////////////////////////////////////////////////// |
| 108 |
| 109 // Runs the Carbon application event loop on the current thread while |
| 110 // idle. When the socket server has work to do, it will post an event |
| 111 // to the queue, causing the thread to exit the event loop until the |
| 112 // next call to Wait. Other events are automatically dispatched to |
| 113 // their target. |
| 114 class MacCarbonAppSocketServer : public MacBaseSocketServer { |
| 115 public: |
| 116 MacCarbonAppSocketServer(); |
| 117 virtual ~MacCarbonAppSocketServer(); |
| 118 |
| 119 // SocketServer Interface |
| 120 virtual bool Wait(int cms, bool process_io); |
| 121 virtual void WakeUp(); |
| 122 |
| 123 private: |
| 124 static OSStatus WakeUpEventHandler(EventHandlerCallRef next, EventRef event, |
| 125 void *data); |
| 126 static void TimerHandler(EventLoopTimerRef timer, void *data); |
| 127 |
| 128 EventQueueRef event_queue_; |
| 129 EventHandlerRef event_handler_; |
| 130 EventLoopTimerRef timer_; |
| 131 }; |
| 132 |
| 133 #endif |
77 } // namespace rtc | 134 } // namespace rtc |
78 | 135 |
79 #endif // WEBRTC_BASE_MACSOCKETSERVER_H__ | 136 #endif // WEBRTC_BASE_MACSOCKETSERVER_H__ |
OLD | NEW |