henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2004 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 | #ifndef WEBRTC_P2P_CLIENT_SOCKETMONITOR_H_ |
| 12 | #define WEBRTC_P2P_CLIENT_SOCKETMONITOR_H_ |
| 13 | |
| 14 | #include <vector> |
| 15 | |
| 16 | #include "webrtc/p2p/base/transportchannel.h" |
| 17 | #include "webrtc/base/criticalsection.h" |
| 18 | #include "webrtc/base/sigslot.h" |
| 19 | #include "webrtc/base/thread.h" |
| 20 | |
| 21 | namespace cricket { |
| 22 | |
| 23 | class SocketMonitor : public rtc::MessageHandler, |
| 24 | public sigslot::has_slots<> { |
| 25 | public: |
| 26 | SocketMonitor(TransportChannel* channel, |
| 27 | rtc::Thread* worker_thread, |
| 28 | rtc::Thread* monitor_thread); |
| 29 | ~SocketMonitor(); |
| 30 | |
| 31 | void Start(int cms); |
| 32 | void Stop(); |
| 33 | |
| 34 | rtc::Thread* monitor_thread() { return monitoring_thread_; } |
| 35 | |
| 36 | sigslot::signal2<SocketMonitor*, |
| 37 | const std::vector<ConnectionInfo>&> SignalUpdate; |
| 38 | |
| 39 | protected: |
| 40 | void OnMessage(rtc::Message* message); |
| 41 | void PollSocket(bool poll); |
| 42 | |
| 43 | std::vector<ConnectionInfo> connection_infos_; |
| 44 | TransportChannel* channel_; |
| 45 | rtc::Thread* channel_thread_; |
| 46 | rtc::Thread* monitoring_thread_; |
| 47 | rtc::CriticalSection crit_; |
| 48 | uint32 rate_; |
| 49 | bool monitoring_; |
| 50 | }; |
| 51 | |
| 52 | } // namespace cricket |
| 53 | |
| 54 | #endif // WEBRTC_P2P_CLIENT_SOCKETMONITOR_H_ |