| 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 #if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS) // Invalid on IOS | 14 #include <CoreFoundation/CoreFoundation.h> |
| 15 #include <Carbon/Carbon.h> | |
| 16 #endif | |
| 17 #include "webrtc/base/physicalsocketserver.h" | 15 #include "webrtc/base/physicalsocketserver.h" |
| 18 | 16 |
| 19 namespace rtc { | 17 namespace rtc { |
| 20 | 18 |
| 21 /////////////////////////////////////////////////////////////////////////////// | 19 /////////////////////////////////////////////////////////////////////////////// |
| 22 // MacBaseSocketServer | 20 // MacBaseSocketServer |
| 23 /////////////////////////////////////////////////////////////////////////////// | 21 /////////////////////////////////////////////////////////////////////////////// |
| 24 class MacAsyncSocket; | 22 class MacAsyncSocket; |
| 25 | 23 |
| 26 class MacBaseSocketServer : public PhysicalSocketServer { | 24 class MacBaseSocketServer : public PhysicalSocketServer { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 | 67 |
| 70 // SocketServer Interface | 68 // SocketServer Interface |
| 71 bool Wait(int cms, bool process_io) override; | 69 bool Wait(int cms, bool process_io) override; |
| 72 void WakeUp() override; | 70 void WakeUp() override; |
| 73 void OnWakeUpCallback(); | 71 void OnWakeUpCallback(); |
| 74 | 72 |
| 75 private: | 73 private: |
| 76 CFRunLoopRef run_loop_; | 74 CFRunLoopRef run_loop_; |
| 77 CFRunLoopSourceRef wake_up_; | 75 CFRunLoopSourceRef wake_up_; |
| 78 }; | 76 }; |
| 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 | |
| 134 } // namespace rtc | 77 } // namespace rtc |
| 135 | 78 |
| 136 #endif // WEBRTC_BASE_MACSOCKETSERVER_H__ | 79 #endif // WEBRTC_BASE_MACSOCKETSERVER_H__ |
| OLD | NEW |