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

Unified Diff: net/quic/quic_alarm.cc

Issue 2193073003: Move shared files in net/quic/ into net/quic/core/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: io_thread_unittest.cc Created 4 years, 5 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 | « net/quic/quic_alarm.h ('k') | net/quic/quic_alarm_factory.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/quic_alarm.cc
diff --git a/net/quic/quic_alarm.cc b/net/quic/quic_alarm.cc
deleted file mode 100644
index 26021fb8893b39fc01e0ee4769c603f41810f871..0000000000000000000000000000000000000000
--- a/net/quic/quic_alarm.cc
+++ /dev/null
@@ -1,81 +0,0 @@
-// Copyright 2013 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/quic_alarm.h"
-
-#include "base/logging.h"
-#include "net/quic/quic_flags.h"
-
-namespace net {
-
-QuicAlarm::QuicAlarm(QuicArenaScopedPtr<Delegate> delegate)
- : delegate_(std::move(delegate)), deadline_(QuicTime::Zero()) {}
-
-QuicAlarm::~QuicAlarm() {}
-
-void QuicAlarm::Set(QuicTime new_deadline) {
- DCHECK(!IsSet());
- DCHECK(new_deadline.IsInitialized());
- deadline_ = new_deadline;
- SetImpl();
-}
-
-void QuicAlarm::Cancel() {
- if (!IsSet()) {
- // Don't try to cancel an alarm that hasn't been set.
- return;
- }
- deadline_ = QuicTime::Zero();
- CancelImpl();
-}
-
-void QuicAlarm::Update(QuicTime new_deadline, QuicTime::Delta granularity) {
- if (!new_deadline.IsInitialized()) {
- Cancel();
- return;
- }
- if (std::abs((new_deadline - deadline_).ToMicroseconds()) <
- granularity.ToMicroseconds()) {
- return;
- }
- if (FLAGS_quic_change_alarms_efficiently) {
- const bool was_set = IsSet();
- deadline_ = new_deadline;
- if (was_set) {
- UpdateImpl();
- } else {
- SetImpl();
- }
- } else {
- Cancel();
- Set(new_deadline);
- }
-}
-
-bool QuicAlarm::IsSet() const {
- return deadline_.IsInitialized();
-}
-
-void QuicAlarm::Fire() {
- if (!IsSet()) {
- return;
- }
-
- deadline_ = QuicTime::Zero();
- delegate_->OnAlarm();
-}
-
-void QuicAlarm::UpdateImpl() {
- // CancelImpl and SetImpl take the new deadline by way of the deadline_
- // member, so save and restore deadline_ before canceling.
- const QuicTime new_deadline = deadline_;
-
- deadline_ = QuicTime::Zero();
- CancelImpl();
-
- deadline_ = new_deadline;
- SetImpl();
-}
-
-} // namespace net
« no previous file with comments | « net/quic/quic_alarm.h ('k') | net/quic/quic_alarm_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698