Chromium Code Reviews| Index: net/quic/quic_alarm.cc |
| diff --git a/net/quic/quic_alarm.cc b/net/quic/quic_alarm.cc |
| index 3067a29c35c0a76d1308b3e5712e690271970d95..26021fb8893b39fc01e0ee4769c603f41810f871 100644 |
| --- a/net/quic/quic_alarm.cc |
| +++ b/net/quic/quic_alarm.cc |
| @@ -39,8 +39,18 @@ void QuicAlarm::Update(QuicTime new_deadline, QuicTime::Delta granularity) { |
| granularity.ToMicroseconds()) { |
| return; |
| } |
| - Cancel(); |
| - Set(new_deadline); |
| + 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 { |
| @@ -56,4 +66,16 @@ void QuicAlarm::Fire() { |
| 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(); |
|
Ryan Hamilton
2016/07/19 21:13:38
Hah! So in chromium UpdateImpl is basically Cancel
|
| +} |
| + |
| } // namespace net |