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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 scoped_refptr<base::SingleThreadTaskRunner> origin_task_runner_; | 138 scoped_refptr<base::SingleThreadTaskRunner> origin_task_runner_; |
139 | 139 |
140 // Callback that should be run when the timer fires. | 140 // Callback that should be run when the timer fires. |
141 base::Closure on_timer_fired_callback_; | 141 base::Closure on_timer_fired_callback_; |
142 | 142 |
143 // Hook used by tests to be notified when the timer has fired and a task has | 143 // Hook used by tests to be notified when the timer has fired and a task has |
144 // been queued in the MessageLoop. | 144 // been queued in the MessageLoop. |
145 base::Closure on_timer_fired_callback_for_test_; | 145 base::Closure on_timer_fired_callback_for_test_; |
146 | 146 |
147 // Manages watching file descriptors. | 147 // Manages watching file descriptors. |
148 scoped_ptr<base::MessageLoopForIO::FileDescriptorWatcher> fd_watcher_; | 148 std::unique_ptr<base::MessageLoopForIO::FileDescriptorWatcher> fd_watcher_; |
149 | 149 |
150 // The sequence numbers of the last Reset() call handled respectively on | 150 // The sequence numbers of the last Reset() call handled respectively on |
151 // |origin_task_runner_| and on the MessageLoopForIO used for watching the | 151 // |origin_task_runner_| and on the MessageLoopForIO used for watching the |
152 // timer file descriptor. Note that these can be the same MessageLoop. | 152 // timer file descriptor. Note that these can be the same MessageLoop. |
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 |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 } | 419 } |
420 | 420 |
421 void AlarmTimer::OnTimerFired() { | 421 void AlarmTimer::OnTimerFired() { |
422 if (!base::Timer::IsRunning()) | 422 if (!base::Timer::IsRunning()) |
423 return; | 423 return; |
424 | 424 |
425 DCHECK(pending_task_.get()); | 425 DCHECK(pending_task_.get()); |
426 | 426 |
427 // Take ownership of the pending user task, which is going to be cleared by | 427 // Take ownership of the pending user task, which is going to be cleared by |
428 // the Stop() or Reset() functions below. | 428 // the Stop() or Reset() functions below. |
429 scoped_ptr<base::PendingTask> pending_user_task(std::move(pending_task_)); | 429 std::unique_ptr<base::PendingTask> pending_user_task( |
| 430 std::move(pending_task_)); |
430 | 431 |
431 // Re-schedule or stop the timer as requested. | 432 // Re-schedule or stop the timer as requested. |
432 if (base::Timer::is_repeating()) | 433 if (base::Timer::is_repeating()) |
433 Reset(); | 434 Reset(); |
434 else | 435 else |
435 Stop(); | 436 Stop(); |
436 | 437 |
437 TRACE_TASK_EXECUTION("AlarmTimer::OnTimerFired", *pending_user_task); | 438 TRACE_TASK_EXECUTION("AlarmTimer::OnTimerFired", *pending_user_task); |
438 | 439 |
439 // Now run the user task. | 440 // Now run the user task. |
(...skipping 26 matching lines...) Expand all Loading... |
466 SimpleAlarmTimer::SimpleAlarmTimer(const tracked_objects::Location& posted_from, | 467 SimpleAlarmTimer::SimpleAlarmTimer(const tracked_objects::Location& posted_from, |
467 base::TimeDelta delay, | 468 base::TimeDelta delay, |
468 const base::Closure& user_task) | 469 const base::Closure& user_task) |
469 : AlarmTimer(posted_from, delay, user_task, false) { | 470 : AlarmTimer(posted_from, delay, user_task, false) { |
470 } | 471 } |
471 | 472 |
472 SimpleAlarmTimer::~SimpleAlarmTimer() { | 473 SimpleAlarmTimer::~SimpleAlarmTimer() { |
473 } | 474 } |
474 | 475 |
475 } // namespace timers | 476 } // namespace timers |
OLD | NEW |