| OLD | NEW |
| 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 | 8 |
| 9 namespace net { | 9 namespace net { |
| 10 | 10 |
| 11 QuicAlarm::QuicAlarm(Delegate* delegate) | 11 QuicAlarm::QuicAlarm(Delegate* delegate) |
| 12 : delegate_(delegate), | 12 : delegate_(delegate), deadline_(QuicTime::Zero()) { |
| 13 deadline_(QuicTime::Zero()) { | |
| 14 } | 13 } |
| 15 | 14 |
| 16 QuicAlarm::~QuicAlarm() {} | 15 QuicAlarm::~QuicAlarm() { |
| 16 } |
| 17 | 17 |
| 18 void QuicAlarm::Set(QuicTime deadline) { | 18 void QuicAlarm::Set(QuicTime deadline) { |
| 19 DCHECK(!IsSet()); | 19 DCHECK(!IsSet()); |
| 20 DCHECK(deadline.IsInitialized()); | 20 DCHECK(deadline.IsInitialized()); |
| 21 deadline_ = deadline; | 21 deadline_ = deadline; |
| 22 SetImpl(); | 22 SetImpl(); |
| 23 } | 23 } |
| 24 | 24 |
| 25 void QuicAlarm::Cancel() { | 25 void QuicAlarm::Cancel() { |
| 26 deadline_ = QuicTime::Zero(); | 26 deadline_ = QuicTime::Zero(); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 39 deadline_ = QuicTime::Zero(); | 39 deadline_ = QuicTime::Zero(); |
| 40 QuicTime deadline = delegate_->OnAlarm(); | 40 QuicTime deadline = delegate_->OnAlarm(); |
| 41 // delegate_->OnAlarm() might call Set(), in which case deadline_ will | 41 // delegate_->OnAlarm() might call Set(), in which case deadline_ will |
| 42 // already contain the new value, so don't overwrite it. | 42 // already contain the new value, so don't overwrite it. |
| 43 if (!deadline_.IsInitialized() && deadline.IsInitialized()) { | 43 if (!deadline_.IsInitialized() && deadline.IsInitialized()) { |
| 44 Set(deadline); | 44 Set(deadline); |
| 45 } | 45 } |
| 46 } | 46 } |
| 47 | 47 |
| 48 } // namespace net | 48 } // namespace net |
| OLD | NEW |