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

Unified Diff: net/quic/chromium/quic_clock_skew_detector.cc

Issue 2487973003: GOAWAY open QUIC sessions if clock skew is detected (Closed)
Patch Set: format Created 4 years, 1 month 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
Index: net/quic/chromium/quic_clock_skew_detector.cc
diff --git a/net/quic/chromium/quic_clock_skew_detector.cc b/net/quic/chromium/quic_clock_skew_detector.cc
new file mode 100644
index 0000000000000000000000000000000000000000..efd372e6864249217d357ea066fef1224bdc44cf
--- /dev/null
+++ b/net/quic/chromium/quic_clock_skew_detector.cc
@@ -0,0 +1,33 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "net/quic/chromium/quic_clock_skew_detector.h"
+
+#include "base/metrics/histogram_macros.h"
+
+namespace net {
+
+QuicClockSkewDetector::QuicClockSkewDetector(base::TimeTicks ticks_time,
+ base::Time wall_time)
+ : last_ticks_time_(ticks_time), last_wall_time_(wall_time) {}
+
+bool QuicClockSkewDetector::ClockSkewDetected(base::TimeTicks ticks_now,
+ base::Time wall_now) {
+ base::TimeDelta ticks_delta = ticks_now - last_ticks_time_;
+ base::TimeDelta wall_delta = wall_now - last_wall_time_;
+ base::TimeDelta offset = wall_delta - ticks_delta;
+ last_wall_time_ = wall_now;
+ last_ticks_time_ = ticks_now;
+
+ UMA_HISTOGRAM_TIMES(
+ "Net.QuicClock.SkewOffset",
+ base::TimeDelta::FromMicroseconds(offset.InMicroseconds()));
+
+ if (offset < base::TimeDelta::FromSeconds(1))
+ return false;
+
+ return true;
+}
+
+} // namespace net

Powered by Google App Engine
This is Rietveld 408576698