OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2016 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_QUIC_QUICCONNECTIONHELPER_H_ |
| 12 #define WEBRTC_P2P_QUIC_QUICCONNECTIONHELPER_H_ |
| 13 |
| 14 #include "net/quic/crypto/quic_random.h" |
| 15 #include "net/quic/quic_alarm.h" |
| 16 #include "net/quic/quic_clock.h" |
| 17 #include "net/quic/quic_connection.h" |
| 18 #include "webrtc/base/thread.h" |
| 19 |
| 20 namespace cricket { |
| 21 |
| 22 // An alarm which will go off at a scheduled time, and execute the |OnAlarm| |
| 23 // method of the delegate. |
| 24 class QuicAlarm : public net::QuicAlarm, public rtc::MessageHandler { |
| 25 public: |
| 26 QuicAlarm(const net::QuicClock* clock, |
| 27 rtc::Thread* thread, |
| 28 QuicAlarm::Delegate* delegate); |
| 29 |
| 30 ~QuicAlarm() override; |
| 31 |
| 32 // rtc::MessageHandler override. |
| 33 void OnMessage(rtc::Message* msg) override; |
| 34 |
| 35 // Helper method to get the delay in ms for posting task. |
| 36 int64 GetDelay() const; |
| 37 |
| 38 protected: |
| 39 // net::QuicAlarm overrides. |
| 40 void SetImpl() override; |
| 41 void CancelImpl() override; |
| 42 |
| 43 private: |
| 44 const net::QuicClock* clock_; |
| 45 rtc::Thread* thread_; |
| 46 }; |
| 47 |
| 48 // Helper methods for QuicConnection timing and random number generation. |
| 49 class QuicConnectionHelper : public net::QuicConnectionHelperInterface { |
| 50 public: |
| 51 explicit QuicConnectionHelper(rtc::Thread* thread); |
| 52 ~QuicConnectionHelper() override; |
| 53 |
| 54 // QuicConnectionHelperInterface overrides. |
| 55 const net::QuicClock* GetClock() const override; |
| 56 net::QuicRandom* GetRandomGenerator() override; |
| 57 QuicAlarm* CreateAlarm(net::QuicAlarm::Delegate* delegate) override; |
| 58 |
| 59 private: |
| 60 net::QuicClock clock_; |
| 61 rtc::Thread* thread_; |
| 62 }; |
| 63 |
| 64 } // namespace cricket |
| 65 |
| 66 #endif // WEBRTC_P2P_QUIC_QUICCONNECTIONHELPER_H_ |
OLD | NEW |