Lines Matching refs:base
29 class RtcAlarmIOThread : public base::Thread {
33 StartWithOptions(base::Thread::Options(base::MessageLoop::TYPE_IO, 0))); in RtcAlarmIOThread()
38 base::LazyInstance<RtcAlarmIOThread> g_io_thread = LAZY_INSTANCE_INITIALIZER;
45 : public base::MessageLoop::DestructionObserver {
50 MessageLoopObserver(base::MessageLoop* message_loop, in MessageLoopObserver()
51 base::Closure on_will_be_destroyed_callback) in MessageLoopObserver()
75 base::MessageLoop* message_loop_;
78 base::Closure on_will_be_destroyed_callback_;
94 : public base::RefCountedThreadSafe<AlarmTimer::Delegate>,
95 public base::MessageLoopForIO::Watcher {
99 explicit Delegate(base::Closure on_timer_fired_callback);
107 void Reset(base::TimeDelta delay);
116 void SetTimerFiredCallbackForTest(base::Closure test_callback);
123 friend class base::RefCountedThreadSafe<Delegate>;
128 void ResetImpl(base::TimeDelta delay, int reset_sequence_number);
138 scoped_refptr<base::SingleThreadTaskRunner> origin_task_runner_;
141 base::Closure on_timer_fired_callback_;
145 base::Closure on_timer_fired_callback_for_test_;
148 scoped_ptr<base::MessageLoopForIO::FileDescriptorWatcher> fd_watcher_;
162 AlarmTimer::Delegate::Delegate(base::Closure on_timer_fired_callback) in Delegate()
182 void AlarmTimer::Delegate::Reset(base::TimeDelta delay) { in Reset()
186 origin_task_runner_ = base::ThreadTaskRunnerHandle::Get(); in Reset()
197 if (delay <= base::TimeDelta::FromMicroseconds(0)) { in Reset()
201 delay = base::TimeDelta::FromMicroseconds(0); in Reset()
204 base::Bind(&Delegate::OnTimerFired, scoped_refptr<Delegate>(this), in Reset()
209 if (base::MessageLoopForIO::IsCurrent()) { in Reset()
214 base::Bind(&Delegate::ResetImpl, scoped_refptr<Delegate>(this), delay, in Reset()
221 if (!base::MessageLoopForIO::IsCurrent()) { in Stop()
223 FROM_HERE, base::Bind(&Delegate::Stop, scoped_refptr<Delegate>(this))); in Stop()
243 if (!base::ReadFromFD(alarm_fd_, val, sizeof(uint64_t))) in OnFileCanReadWithoutBlocking()
252 base::Bind(&Delegate::OnTimerFired, scoped_refptr<Delegate>(this), in OnFileCanReadWithoutBlocking()
262 base::Closure test_callback) { in SetTimerFiredCallbackForTest()
266 void AlarmTimer::Delegate::ResetImpl(base::TimeDelta delay, in ResetImpl()
268 DCHECK(base::MessageLoopForIO::IsCurrent()); in ResetImpl()
277 fd_watcher_.reset(new base::MessageLoopForIO::FileDescriptorWatcher); in ResetImpl()
280 if (!base::MessageLoopForIO::current()->WatchFileDescriptor( in ResetImpl()
281 alarm_fd_, false, base::MessageLoopForIO::WATCH_READ, in ResetImpl()
293 (delay.InMicroseconds() % base::Time::kMicrosecondsPerSecond) * in ResetImpl()
294 base::Time::kNanosecondsPerMicrosecond; in ResetImpl()
307 base::Bind(&Delegate::OnTimerFired, scoped_refptr<Delegate>(this), in OnTimerFired()
325 : base::Timer(retain_user_task, is_repeating), in AlarmTimer()
333 base::TimeDelta delay, in AlarmTimer()
334 const base::Closure& user_task, in AlarmTimer()
336 : base::Timer(posted_from, delay, user_task, is_repeating), in AlarmTimer()
347 void AlarmTimer::SetTimerFiredCallbackForTest(base::Closure test_callback) { in SetTimerFiredCallbackForTest()
353 base::Bind(&AlarmTimer::OnTimerFired, weak_factory_.GetWeakPtr()))); in Init()
358 if (!base::Timer::is_running()) in Stop()
362 base::Timer::Stop(); in Stop()
367 base::Timer::set_is_running(false); in Stop()
375 if (!base::Timer::retain_user_task()) in Stop()
376 base::Timer::set_user_task(base::Closure()); in Stop()
381 base::Timer::Reset(); in Reset()
385 DCHECK(!base::Timer::user_task().is_null()); in Reset()
392 origin_message_loop_ = base::MessageLoop::current(); in Reset()
395 base::Bind(&AlarmTimer::WillDestroyCurrentMessageLoop, in Reset()
400 if (base::Timer::GetCurrentDelay() > base::TimeDelta::FromMicroseconds(0)) { in Reset()
401 base::Timer::set_desired_run_time(base::TimeTicks::Now() + in Reset()
402 base::Timer::GetCurrentDelay()); in Reset()
403 pending_task_.reset(new base::PendingTask( in Reset()
404 base::Timer::posted_from(), base::Timer::user_task(), in Reset()
405 base::Timer::desired_run_time(), true /* nestable */)); in Reset()
407 base::Timer::set_desired_run_time(base::TimeTicks()); in Reset()
408 pending_task_.reset(new base::PendingTask(base::Timer::posted_from(), in Reset()
409 base::Timer::user_task())); in Reset()
411 base::MessageLoop::current()->task_annotator()->DidQueueTask( in Reset()
415 delegate_->Reset(base::Timer::GetCurrentDelay()); in Reset()
416 base::Timer::set_is_running(true); in Reset()
424 if (!base::Timer::IsRunning()) in OnTimerFired()
431 scoped_ptr<base::PendingTask> pending_user_task(std::move(pending_task_)); in OnTimerFired()
434 if (base::Timer::is_repeating()) in OnTimerFired()
442 base::MessageLoop::current()->task_annotator()->RunTask("AlarmTimer::Reset", in OnTimerFired()
457 base::TimeDelta delay, in RepeatingAlarmTimer()
458 const base::Closure& user_task) in RepeatingAlarmTimer()
469 base::TimeDelta delay, in SimpleAlarmTimer()
470 const base::Closure& user_task) in SimpleAlarmTimer()