| 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 #include "net/quic/quic_flags.h" | 8 #include "net/quic/quic_flags.h" |
| 9 | 9 |
| 10 namespace net { | 10 namespace net { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 bool QuicAlarm::IsSet() const { | 46 bool QuicAlarm::IsSet() const { |
| 47 return deadline_.IsInitialized(); | 47 return deadline_.IsInitialized(); |
| 48 } | 48 } |
| 49 | 49 |
| 50 void QuicAlarm::Fire() { | 50 void QuicAlarm::Fire() { |
| 51 if (!IsSet()) { | 51 if (!IsSet()) { |
| 52 return; | 52 return; |
| 53 } | 53 } |
| 54 | 54 |
| 55 deadline_ = QuicTime::Zero(); | 55 deadline_ = QuicTime::Zero(); |
| 56 QuicTime new_deadline = delegate_->OnAlarm(); | 56 delegate_->OnAlarm(); |
| 57 // delegate_->OnAlarm() might call Set(), in which case deadline_ | |
| 58 // will already contain the new value, so don't overwrite it. Also, | |
| 59 // OnAlarm() might delete |this| so check |deadline| before | |
| 60 // |deadline_|. | |
| 61 if (new_deadline.IsInitialized() && !IsSet()) { | |
| 62 Set(new_deadline); | |
| 63 } | |
| 64 } | 57 } |
| 65 | 58 |
| 66 } // namespace net | 59 } // namespace net |
| OLD | NEW |