| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2016 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2016 The WebRTC Project Authors. All rights reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #ifndef WEBRTC_P2P_QUIC_QUICCONNECTIONHELPER_H_ | 11 #ifndef WEBRTC_P2P_QUIC_QUICCONNECTIONHELPER_H_ |
| 12 #define WEBRTC_P2P_QUIC_QUICCONNECTIONHELPER_H_ | 12 #define WEBRTC_P2P_QUIC_QUICCONNECTIONHELPER_H_ |
| 13 | 13 |
| 14 #include "net/quic/crypto/quic_random.h" | 14 #include "net/quic/crypto/quic_random.h" |
| 15 #include "net/quic/quic_alarm.h" | 15 #include "net/quic/quic_alarm.h" |
| 16 #include "net/quic/quic_clock.h" | 16 #include "net/quic/quic_clock.h" |
| 17 #include "net/quic/quic_connection.h" | 17 #include "net/quic/quic_connection.h" |
| 18 #include "net/quic/quic_simple_buffer_allocator.h" |
| 18 #include "webrtc/base/thread.h" | 19 #include "webrtc/base/thread.h" |
| 19 | 20 |
| 20 namespace cricket { | 21 namespace cricket { |
| 21 | 22 |
| 22 // An alarm which will go off at a scheduled time, and execute the |OnAlarm| | 23 // An alarm which will go off at a scheduled time, and execute the |OnAlarm| |
| 23 // method of the delegate. | 24 // method of the delegate. |
| 24 class QuicAlarm : public net::QuicAlarm, public rtc::MessageHandler { | 25 class QuicAlarm : public net::QuicAlarm, public rtc::MessageHandler { |
| 25 public: | 26 public: |
| 26 QuicAlarm(const net::QuicClock* clock, | 27 QuicAlarm(const net::QuicClock* clock, |
| 27 rtc::Thread* thread, | 28 rtc::Thread* thread, |
| 28 QuicAlarm::Delegate* delegate); | 29 net::QuicArenaScopedPtr<net::QuicAlarm::Delegate> delegate); |
| 29 | 30 |
| 30 ~QuicAlarm() override; | 31 ~QuicAlarm() override; |
| 31 | 32 |
| 32 // rtc::MessageHandler override. | 33 // rtc::MessageHandler override. |
| 33 void OnMessage(rtc::Message* msg) override; | 34 void OnMessage(rtc::Message* msg) override; |
| 34 | 35 |
| 35 // Helper method to get the delay in ms for posting task. | 36 // Helper method to get the delay in ms for posting task. |
| 36 int64 GetDelay() const; | 37 int64_t GetDelay() const; |
| 37 | 38 |
| 38 protected: | 39 protected: |
| 39 // net::QuicAlarm overrides. | 40 // net::QuicAlarm overrides. |
| 40 void SetImpl() override; | 41 void SetImpl() override; |
| 41 void CancelImpl() override; | 42 void CancelImpl() override; |
| 42 | 43 |
| 43 private: | 44 private: |
| 44 const net::QuicClock* clock_; | 45 const net::QuicClock* clock_; |
| 45 rtc::Thread* thread_; | 46 rtc::Thread* thread_; |
| 46 }; | 47 }; |
| 47 | 48 |
| 48 // Helper methods for QuicConnection timing and random number generation. | 49 // Helper methods for QuicConnection timing and random number generation. |
| 49 class QuicConnectionHelper : public net::QuicConnectionHelperInterface { | 50 class QuicConnectionHelper : public net::QuicConnectionHelperInterface { |
| 50 public: | 51 public: |
| 51 explicit QuicConnectionHelper(rtc::Thread* thread); | 52 explicit QuicConnectionHelper(rtc::Thread* thread); |
| 52 ~QuicConnectionHelper() override; | 53 ~QuicConnectionHelper() override; |
| 53 | 54 |
| 54 // QuicConnectionHelperInterface overrides. | 55 // QuicConnectionHelperInterface overrides. |
| 55 const net::QuicClock* GetClock() const override; | 56 const net::QuicClock* GetClock() const override; |
| 56 net::QuicRandom* GetRandomGenerator() override; | 57 net::QuicRandom* GetRandomGenerator() override; |
| 57 QuicAlarm* CreateAlarm(net::QuicAlarm::Delegate* delegate) override; | 58 QuicAlarm* CreateAlarm(net::QuicAlarm::Delegate* delegate) override; |
| 59 net::QuicArenaScopedPtr<net::QuicAlarm> CreateAlarm( |
| 60 net::QuicArenaScopedPtr<QuicAlarm::Delegate> delegate, |
| 61 net::QuicConnectionArena* arena) override; |
| 62 net::QuicBufferAllocator* GetBufferAllocator() override; |
| 58 | 63 |
| 59 private: | 64 private: |
| 60 net::QuicClock clock_; | 65 net::QuicClock clock_; |
| 66 net::SimpleBufferAllocator buffer_allocator_; |
| 61 rtc::Thread* thread_; | 67 rtc::Thread* thread_; |
| 62 }; | 68 }; |
| 63 | 69 |
| 64 } // namespace cricket | 70 } // namespace cricket |
| 65 | 71 |
| 66 #endif // WEBRTC_P2P_QUIC_QUICCONNECTIONHELPER_H_ | 72 #endif // WEBRTC_P2P_QUIC_QUICCONNECTIONHELPER_H_ |
| OLD | NEW |