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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "net/quic/chromium/quic_clock_skew_detector.h"
6
7 #include "base/metrics/histogram_macros.h"
8
9 namespace net {
10
11 QuicClockSkewDetector::QuicClockSkewDetector(base::TimeTicks ticks_time,
12 base::Time wall_time)
13 : last_ticks_time_(ticks_time), last_wall_time_(wall_time) {}
14
15 bool QuicClockSkewDetector::ClockSkewDetected(base::TimeTicks ticks_now,
16 base::Time wall_now) {
17 base::TimeDelta ticks_delta = ticks_now - last_ticks_time_;
18 base::TimeDelta wall_delta = wall_now - last_wall_time_;
19 base::TimeDelta offset = wall_delta - ticks_delta;
20 last_wall_time_ = wall_now;
21 last_ticks_time_ = ticks_now;
22
23 UMA_HISTOGRAM_TIMES(
24 "Net.QuicClock.SkewOffset",
25 base::TimeDelta::FromMicroseconds(offset.InMicroseconds()));
26
27 if (offset < base::TimeDelta::FromSeconds(1))
28 return false;
29
30 return true;
31 }
32
33 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698