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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/p2p/quic/quicconnectionhelper.h ('k') | webrtc/p2p/quic/quicconnectionhelper_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/p2p/quic/quicconnectionhelper.cc
diff --git a/webrtc/p2p/quic/quicconnectionhelper.cc b/webrtc/p2p/quic/quicconnectionhelper.cc
new file mode 100644
index 0000000000000000000000000000000000000000..af5b4b213bf460482dbd4069c275b4c08645e4c5
--- /dev/null
+++ b/webrtc/p2p/quic/quicconnectionhelper.cc
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2016 The WebRTC Project Authors. All rights reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#include "webrtc/p2p/quic/quicconnectionhelper.h"
+
+namespace cricket {
+
+QuicAlarm* QuicConnectionHelper::CreateAlarm(
+ net::QuicAlarm::Delegate* delegate) {
+ return new QuicAlarm(GetClock(), thread_, delegate);
+}
+
+QuicAlarm::QuicAlarm(const net::QuicClock* clock,
+ rtc::Thread* thread,
+ QuicAlarm::Delegate* delegate)
+ : net::QuicAlarm(delegate), clock_(clock), thread_(thread) {}
+
+QuicAlarm::~QuicAlarm() {}
+
+void QuicAlarm::OnMessage(rtc::Message* msg) {
+ // The alarm may have been cancelled.
+ if (!deadline().IsInitialized()) {
+ return;
+ }
+
+ // The alarm may have been re-set to a later time.
+ if (clock_->Now() < deadline()) {
+ SetImpl();
+ return;
+ }
+
+ Fire();
+}
+
+int64 QuicAlarm::GetDelay() const {
+ return deadline().Subtract(clock_->Now()).ToMilliseconds();
+}
+
+void QuicAlarm::SetImpl() {
+ DCHECK(deadline().IsInitialized());
+ CancelImpl(); // Unregister if already posted.
+
+ int64 delay_ms = GetDelay();
+ if (delay_ms < 0) {
+ delay_ms = 0;
+ }
+ thread_->PostDelayed(delay_ms, this);
+}
+
+void QuicAlarm::CancelImpl() {
+ thread_->Clear(this);
+}
+
+QuicConnectionHelper::QuicConnectionHelper(rtc::Thread* thread)
+ : thread_(thread) {}
+
+QuicConnectionHelper::~QuicConnectionHelper() {}
+
+const net::QuicClock* QuicConnectionHelper::GetClock() const {
+ return &clock_;
+}
+
+net::QuicRandom* QuicConnectionHelper::GetRandomGenerator() {
+ return net::QuicRandom::GetInstance();
+}
+
+} // namespace cricket
« 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