Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(268)

Side by Side Diff: components/scheduler/base/delayed_task_delegate_impl.cc

Issue 1432263002: (reland) Adds TimeDomains to the TaskQueueManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "components/scheduler/base/delayed_task_delegate_impl.h"
6
7 #include "base/bind.h"
8 #include "components/scheduler/base/task_queue_impl.h"
9 #include "components/scheduler/base/task_queue_manager_delegate.h"
10
11 namespace scheduler {
12
13 DelayedTaskDelegateImpl::DelayedTaskDelegateImpl(
14 TaskQueueManagerDelegate* delegate, base::Closure do_work_closure)
15 : delegate_(delegate),
16 do_work_closure_(do_work_closure),
17 weak_factory_(this) {}
18
19 DelayedTaskDelegateImpl::~DelayedTaskDelegateImpl() {}
20
21 base::TimeTicks DelayedTaskDelegateImpl::CachedNow() {
22 if (cached_now_.is_null())
23 cached_now_ = delegate_->NowTicks();
24 return cached_now_;
25 }
26
27 void DelayedTaskDelegateImpl::InvalidateNowCache() {
28 cached_now_ = base::TimeTicks();
29 }
30
31 bool DelayedTaskDelegateImpl::BelongsToCurrentThread() const {
32 return delegate_ && delegate_->BelongsToCurrentThread();
33 }
34
35 void DelayedTaskDelegateImpl::PostScheduleDelayedWorkTaskOnMainThread(
36 internal::TaskQueueImpl* queue, base::TimeTicks delayed_run_time) {
37 if (!delegate_)
38 return;
39 delegate_->PostTask(
40 FROM_HERE, base::Bind(&DelayedTaskDelegateImpl::ScheduleDelayedWorkTask,
41 weak_factory_.GetWeakPtr(),
42 scoped_refptr<internal::TaskQueueImpl>(queue),
43 delayed_run_time));
44 }
45
46 void DelayedTaskDelegateImpl::ScheduleDoWork(base::TimeDelta delay) {
47 if (!delegate_)
48 return;
49 delegate_->PostDelayedTask(FROM_HERE, do_work_closure_, delay);
50 }
51
52 } // namespace scheduler
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698