OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "chromecast/base/alarm_manager.h" | 5 #include "chromecast/base/alarm_manager.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "base/single_thread_task_runner.h" |
8 #include "base/threading/thread_task_runner_handle.h" | 9 #include "base/threading/thread_task_runner_handle.h" |
9 #include "base/time/default_clock.h" | 10 #include "base/time/default_clock.h" |
10 #include "base/timer/timer.h" | 11 #include "base/timer/timer.h" |
11 | 12 |
12 #define MAKE_SURE_OWN_THREAD(callback, ...) \ | 13 #define MAKE_SURE_OWN_THREAD(callback, ...) \ |
13 if (!task_runner_->BelongsToCurrentThread()) { \ | 14 if (!task_runner_->BelongsToCurrentThread()) { \ |
14 task_runner_->PostTask( \ | 15 task_runner_->PostTask( \ |
15 FROM_HERE, base::Bind(&AlarmManager::callback, \ | 16 FROM_HERE, base::Bind(&AlarmManager::callback, \ |
16 weak_factory_.GetWeakPtr(), ##__VA_ARGS__)); \ | 17 weak_factory_.GetWeakPtr(), ##__VA_ARGS__)); \ |
17 return; \ | 18 return; \ |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 base::Time now = clock_->Now(); | 84 base::Time now = clock_->Now(); |
84 // Fire appropriate alarms. | 85 // Fire appropriate alarms. |
85 while ((!next_alarm_.empty()) && now >= next_alarm_.top()->time()) { | 86 while ((!next_alarm_.empty()) && now >= next_alarm_.top()->time()) { |
86 next_alarm_.top()->task_runner()->PostTask(FROM_HERE, | 87 next_alarm_.top()->task_runner()->PostTask(FROM_HERE, |
87 next_alarm_.top()->task()); | 88 next_alarm_.top()->task()); |
88 next_alarm_.pop(); | 89 next_alarm_.pop(); |
89 } | 90 } |
90 } | 91 } |
91 | 92 |
92 } // namespace chromecast | 93 } // namespace chromecast |
OLD | NEW |