blob: 3e07a452e675e115a8f38c78ad272104df355fda [file] [log] [blame]
henrike@webrtc.orgf0488722014-05-13 18:00:26 +00001/*
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
kwiberg4485ffb2016-04-26 08:14:39 -070016#include "webrtc/base/constructormagic.h"
henrike@webrtc.orgf0488722014-05-13 18:00:26 +000017#include "webrtc/base/macsocketserver.h"
18
19#ifdef __OBJC__
20@class NSTimer, MacCocoaSocketServerHelperRtc;
21#else
22class NSTimer;
23class MacCocoaSocketServerHelperRtc;
24#endif
25
26namespace rtc {
27
28// A socketserver implementation that wraps the main cocoa
29// application loop accessed through [NSApp run].
30class MacCocoaSocketServer : public MacBaseSocketServer {
31 public:
32 explicit MacCocoaSocketServer();
kwiberg@webrtc.org67186fe2015-03-09 22:21:53 +000033 ~MacCocoaSocketServer() override;
henrike@webrtc.orgf0488722014-05-13 18:00:26 +000034
kwiberg@webrtc.org67186fe2015-03-09 22:21:53 +000035 bool Wait(int cms, bool process_io) override;
36 void WakeUp() override;
henrike@webrtc.orgf0488722014-05-13 18:00:26 +000037
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
henrikg3c089d72015-09-16 05:37:44 -070044 RTC_DISALLOW_COPY_AND_ASSIGN(MacCocoaSocketServer);
henrike@webrtc.orgf0488722014-05-13 18:00:26 +000045};
46
47} // namespace rtc
48
49#endif // WEBRTC_BASE_MACCOCOASOCKETSERVER_H_