henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2007 The WebRTC Project Authors. All rights reserved. |
| 3 | * |
| 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 |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
| 11 | // A libjingle compatible SocketServer for OSX/iOS/Cocoa. |
| 12 | |
| 13 | #ifndef WEBRTC_BASE_MACCOCOASOCKETSERVER_H_ |
| 14 | #define WEBRTC_BASE_MACCOCOASOCKETSERVER_H_ |
| 15 | |
kwiberg | 4485ffb | 2016-04-26 08:14:39 -0700 | [diff] [blame] | 16 | #include "webrtc/base/constructormagic.h" |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 17 | #include "webrtc/base/macsocketserver.h" |
| 18 | |
| 19 | #ifdef __OBJC__ |
| 20 | @class NSTimer, MacCocoaSocketServerHelperRtc; |
| 21 | #else |
| 22 | class NSTimer; |
| 23 | class MacCocoaSocketServerHelperRtc; |
| 24 | #endif |
| 25 | |
| 26 | namespace rtc { |
| 27 | |
| 28 | // A socketserver implementation that wraps the main cocoa |
| 29 | // application loop accessed through [NSApp run]. |
| 30 | class MacCocoaSocketServer : public MacBaseSocketServer { |
| 31 | public: |
| 32 | explicit MacCocoaSocketServer(); |
kwiberg@webrtc.org | 67186fe | 2015-03-09 22:21:53 +0000 | [diff] [blame] | 33 | ~MacCocoaSocketServer() override; |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 34 | |
kwiberg@webrtc.org | 67186fe | 2015-03-09 22:21:53 +0000 | [diff] [blame] | 35 | bool Wait(int cms, bool process_io) override; |
| 36 | void WakeUp() override; |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 37 | |
| 38 | private: |
| 39 | MacCocoaSocketServerHelperRtc* helper_; |
| 40 | NSTimer* timer_; // Weak. |
| 41 | // The count of how many times we're inside the NSApplication main loop. |
| 42 | int run_count_; |
| 43 | |
henrikg | 3c089d7 | 2015-09-16 05:37:44 -0700 | [diff] [blame] | 44 | RTC_DISALLOW_COPY_AND_ASSIGN(MacCocoaSocketServer); |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 45 | }; |
| 46 | |
| 47 | } // namespace rtc |
| 48 | |
| 49 | #endif // WEBRTC_BASE_MACCOCOASOCKETSERVER_H_ |