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