This source file includes following definitions.
- deadline_
- Set
- Cancel
- IsSet
- Fire
#include "net/quic/quic_alarm.h"
#include "base/logging.h"
namespace net {
QuicAlarm::QuicAlarm(Delegate* delegate)
: delegate_(delegate),
deadline_(QuicTime::Zero()) {
}
QuicAlarm::~QuicAlarm() {}
void QuicAlarm::Set(QuicTime deadline) {
DCHECK(!IsSet());
DCHECK(deadline.IsInitialized());
deadline_ = deadline;
SetImpl();
}
void QuicAlarm::Cancel() {
deadline_ = QuicTime::Zero();
CancelImpl();
}
bool QuicAlarm::IsSet() const {
return deadline_.IsInitialized();
}
void QuicAlarm::Fire() {
if (!deadline_.IsInitialized()) {
return;
}
deadline_ = QuicTime::Zero();
QuicTime deadline = delegate_->OnAlarm();
if (!deadline_.IsInitialized() && deadline.IsInitialized()) {
Set(deadline);
}
}
}