Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Side by Side Diff: webrtc/p2p/quic/quicconnectionhelper.cc

Issue 1648763002: Create QuicSession (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Sync webrtc/build/common.gypi to fix patch issue Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 #include "webrtc/p2p/quic/quicconnectionhelper.h"
12
13 namespace cricket {
14
15 QuicAlarm* QuicConnectionHelper::CreateAlarm(
16 net::QuicAlarm::Delegate* delegate) {
17 return new QuicAlarm(GetClock(), thread_, delegate);
18 }
19
20 QuicAlarm::QuicAlarm(const net::QuicClock* clock,
21 rtc::Thread* thread,
22 QuicAlarm::Delegate* delegate)
23 : net::QuicAlarm(delegate), clock_(clock), thread_(thread) {}
24
25 QuicAlarm::~QuicAlarm() {}
26
27 void QuicAlarm::OnMessage(rtc::Message* msg) {
28 // The alarm may have been cancelled.
29 if (!deadline().IsInitialized()) {
30 return;
31 }
32
33 // The alarm may have been re-set to a later time.
34 if (clock_->Now() < deadline()) {
35 SetImpl();
36 return;
37 }
38
39 Fire();
40 }
41
42 int64 QuicAlarm::GetDelay() const {
43 return deadline().Subtract(clock_->Now()).ToMilliseconds();
44 }
45
46 void QuicAlarm::SetImpl() {
47 DCHECK(deadline().IsInitialized());
48 CancelImpl(); // Unregister if already posted.
49
50 int64 delay_ms = GetDelay();
51 if (delay_ms < 0) {
52 delay_ms = 0;
53 }
54 thread_->PostDelayed(delay_ms, this);
55 }
56
57 void QuicAlarm::CancelImpl() {
58 thread_->Clear(this);
59 }
60
61 QuicConnectionHelper::QuicConnectionHelper(rtc::Thread* thread)
62 : thread_(thread) {}
63
64 QuicConnectionHelper::~QuicConnectionHelper() {}
65
66 const net::QuicClock* QuicConnectionHelper::GetClock() const {
67 return &clock_;
68 }
69
70 net::QuicRandom* QuicConnectionHelper::GetRandomGenerator() {
71 return net::QuicRandom::GetInstance();
72 }
73
74 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/p2p/quic/quicconnectionhelper.h ('k') | webrtc/p2p/quic/quicconnectionhelper_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698