OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/timers/alarm_timer_chromeos.h" | 5 #include "components/timers/alarm_timer_chromeos.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 #include <sys/timerfd.h> | 8 #include <sys/timerfd.h> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 // OnTimerFired() runs |on_timer_fired_callback_| only if the sequence number | 153 // OnTimerFired() runs |on_timer_fired_callback_| only if the sequence number |
154 // it receives from the MessageLoopForIO matches | 154 // it receives from the MessageLoopForIO matches |
155 // |origin_reset_sequence_number_|. | 155 // |origin_reset_sequence_number_|. |
156 int origin_reset_sequence_number_; | 156 int origin_reset_sequence_number_; |
157 int io_reset_sequence_number_; | 157 int io_reset_sequence_number_; |
158 | 158 |
159 DISALLOW_COPY_AND_ASSIGN(Delegate); | 159 DISALLOW_COPY_AND_ASSIGN(Delegate); |
160 }; | 160 }; |
161 | 161 |
162 AlarmTimer::Delegate::Delegate(base::Closure on_timer_fired_callback) | 162 AlarmTimer::Delegate::Delegate(base::Closure on_timer_fired_callback) |
| 163 #ifdef CLOCK_REALTIME_ALARM |
163 : alarm_fd_(timerfd_create(CLOCK_REALTIME_ALARM, 0)), | 164 : alarm_fd_(timerfd_create(CLOCK_REALTIME_ALARM, 0)), |
| 165 #else |
| 166 : alarm_fd_(-1), |
| 167 #endif |
164 on_timer_fired_callback_(on_timer_fired_callback), | 168 on_timer_fired_callback_(on_timer_fired_callback), |
165 origin_reset_sequence_number_(0), | 169 origin_reset_sequence_number_(0), |
166 io_reset_sequence_number_(0) { | 170 io_reset_sequence_number_(0) { |
167 // The call to timerfd_create above may fail. This is the only indication | 171 // The call to timerfd_create above may fail. This is the only indication |
168 // that CLOCK_REALTIME_ALARM is not supported on this system. | 172 // that CLOCK_REALTIME_ALARM is not supported on this system. |
169 DPLOG_IF(INFO, (alarm_fd_ == -1)) | 173 DPLOG_IF(INFO, (alarm_fd_ == -1)) |
170 << "CLOCK_REALTIME_ALARM not supported on this system"; | 174 << "CLOCK_REALTIME_ALARM not supported on this system"; |
171 } | 175 } |
172 | 176 |
173 AlarmTimer::Delegate::~Delegate() { | 177 AlarmTimer::Delegate::~Delegate() { |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 SimpleAlarmTimer::SimpleAlarmTimer(const tracked_objects::Location& posted_from, | 470 SimpleAlarmTimer::SimpleAlarmTimer(const tracked_objects::Location& posted_from, |
467 base::TimeDelta delay, | 471 base::TimeDelta delay, |
468 const base::Closure& user_task) | 472 const base::Closure& user_task) |
469 : AlarmTimer(posted_from, delay, user_task, false) { | 473 : AlarmTimer(posted_from, delay, user_task, false) { |
470 } | 474 } |
471 | 475 |
472 SimpleAlarmTimer::~SimpleAlarmTimer() { | 476 SimpleAlarmTimer::~SimpleAlarmTimer() { |
473 } | 477 } |
474 | 478 |
475 } // namespace timers | 479 } // namespace timers |
OLD | NEW |