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

Side by Side Diff: net/quic/quic_alarm.cc

Issue 2158263003: Landing Recent QUIC changes until 7/18/2016 11:21:53 UTC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Running flag flipping script and rebase to master 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 unified diff | Download patch
« no previous file with comments | « net/quic/quic_alarm.h ('k') | net/quic/quic_connection.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/quic/quic_alarm.h" 5 #include "net/quic/quic_alarm.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "net/quic/quic_flags.h" 8 #include "net/quic/quic_flags.h"
9 9
10 namespace net { 10 namespace net {
(...skipping 21 matching lines...) Expand all
32 32
33 void QuicAlarm::Update(QuicTime new_deadline, QuicTime::Delta granularity) { 33 void QuicAlarm::Update(QuicTime new_deadline, QuicTime::Delta granularity) {
34 if (!new_deadline.IsInitialized()) { 34 if (!new_deadline.IsInitialized()) {
35 Cancel(); 35 Cancel();
36 return; 36 return;
37 } 37 }
38 if (std::abs((new_deadline - deadline_).ToMicroseconds()) < 38 if (std::abs((new_deadline - deadline_).ToMicroseconds()) <
39 granularity.ToMicroseconds()) { 39 granularity.ToMicroseconds()) {
40 return; 40 return;
41 } 41 }
42 Cancel(); 42 if (FLAGS_quic_change_alarms_efficiently) {
43 Set(new_deadline); 43 const bool was_set = IsSet();
44 deadline_ = new_deadline;
45 if (was_set) {
46 UpdateImpl();
47 } else {
48 SetImpl();
49 }
50 } else {
51 Cancel();
52 Set(new_deadline);
53 }
44 } 54 }
45 55
46 bool QuicAlarm::IsSet() const { 56 bool QuicAlarm::IsSet() const {
47 return deadline_.IsInitialized(); 57 return deadline_.IsInitialized();
48 } 58 }
49 59
50 void QuicAlarm::Fire() { 60 void QuicAlarm::Fire() {
51 if (!IsSet()) { 61 if (!IsSet()) {
52 return; 62 return;
53 } 63 }
54 64
55 deadline_ = QuicTime::Zero(); 65 deadline_ = QuicTime::Zero();
56 delegate_->OnAlarm(); 66 delegate_->OnAlarm();
57 } 67 }
58 68
69 void QuicAlarm::UpdateImpl() {
70 // CancelImpl and SetImpl take the new deadline by way of the deadline_
71 // member, so save and restore deadline_ before canceling.
72 const QuicTime new_deadline = deadline_;
73
74 deadline_ = QuicTime::Zero();
75 CancelImpl();
76
77 deadline_ = new_deadline;
78 SetImpl();
79 }
80
59 } // namespace net 81 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_alarm.h ('k') | net/quic/quic_connection.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698