| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/tools/quic/quic_epoll_connection_helper.h" | 5 #include "net/tools/quic/quic_epoll_connection_helper.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <sys/socket.h> | 8 #include <sys/socket.h> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 | 21 |
| 22 class QuicEpollAlarm : public QuicAlarm { | 22 class QuicEpollAlarm : public QuicAlarm { |
| 23 public: | 23 public: |
| 24 QuicEpollAlarm(EpollServer* epoll_server, | 24 QuicEpollAlarm(EpollServer* epoll_server, |
| 25 QuicAlarm::Delegate* delegate) | 25 QuicAlarm::Delegate* delegate) |
| 26 : QuicAlarm(delegate), | 26 : QuicAlarm(delegate), |
| 27 epoll_server_(epoll_server), | 27 epoll_server_(epoll_server), |
| 28 epoll_alarm_impl_(this) {} | 28 epoll_alarm_impl_(this) {} |
| 29 | 29 |
| 30 protected: | 30 protected: |
| 31 virtual void SetImpl() OVERRIDE { | 31 virtual void SetImpl() override { |
| 32 DCHECK(deadline().IsInitialized()); | 32 DCHECK(deadline().IsInitialized()); |
| 33 epoll_server_->RegisterAlarm( | 33 epoll_server_->RegisterAlarm( |
| 34 deadline().Subtract(QuicTime::Zero()).ToMicroseconds(), | 34 deadline().Subtract(QuicTime::Zero()).ToMicroseconds(), |
| 35 &epoll_alarm_impl_); | 35 &epoll_alarm_impl_); |
| 36 } | 36 } |
| 37 | 37 |
| 38 virtual void CancelImpl() OVERRIDE { | 38 virtual void CancelImpl() override { |
| 39 DCHECK(!deadline().IsInitialized()); | 39 DCHECK(!deadline().IsInitialized()); |
| 40 epoll_alarm_impl_.UnregisterIfRegistered(); | 40 epoll_alarm_impl_.UnregisterIfRegistered(); |
| 41 } | 41 } |
| 42 | 42 |
| 43 private: | 43 private: |
| 44 class EpollAlarmImpl : public EpollAlarm { | 44 class EpollAlarmImpl : public EpollAlarm { |
| 45 public: | 45 public: |
| 46 explicit EpollAlarmImpl(QuicEpollAlarm* alarm) : alarm_(alarm) {} | 46 explicit EpollAlarmImpl(QuicEpollAlarm* alarm) : alarm_(alarm) {} |
| 47 | 47 |
| 48 virtual int64 OnAlarm() OVERRIDE { | 48 virtual int64 OnAlarm() override { |
| 49 EpollAlarm::OnAlarm(); | 49 EpollAlarm::OnAlarm(); |
| 50 alarm_->Fire(); | 50 alarm_->Fire(); |
| 51 // Fire will take care of registering the alarm, if needed. | 51 // Fire will take care of registering the alarm, if needed. |
| 52 return 0; | 52 return 0; |
| 53 } | 53 } |
| 54 | 54 |
| 55 private: | 55 private: |
| 56 QuicEpollAlarm* alarm_; | 56 QuicEpollAlarm* alarm_; |
| 57 }; | 57 }; |
| 58 | 58 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 79 return random_generator_; | 79 return random_generator_; |
| 80 } | 80 } |
| 81 | 81 |
| 82 QuicAlarm* QuicEpollConnectionHelper::CreateAlarm( | 82 QuicAlarm* QuicEpollConnectionHelper::CreateAlarm( |
| 83 QuicAlarm::Delegate* delegate) { | 83 QuicAlarm::Delegate* delegate) { |
| 84 return new QuicEpollAlarm(epoll_server_, delegate); | 84 return new QuicEpollAlarm(epoll_server_, delegate); |
| 85 } | 85 } |
| 86 | 86 |
| 87 } // namespace tools | 87 } // namespace tools |
| 88 } // namespace net | 88 } // namespace net |
| OLD | NEW |