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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: components/scheduler/base/delayed_task_delegate_impl.cc
diff --git a/components/scheduler/base/delayed_task_delegate_impl.cc b/components/scheduler/base/delayed_task_delegate_impl.cc
new file mode 100644
index 0000000000000000000000000000000000000000..3bfb3b2b3ca604fe185a33a717583203a9459f1c
--- /dev/null
+++ b/components/scheduler/base/delayed_task_delegate_impl.cc
@@ -0,0 +1,52 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/scheduler/base/delayed_task_delegate_impl.h"
+
+#include "base/bind.h"
+#include "components/scheduler/base/task_queue_impl.h"
+#include "components/scheduler/base/task_queue_manager_delegate.h"
+
+namespace scheduler {
+
+DelayedTaskDelegateImpl::DelayedTaskDelegateImpl(
+ TaskQueueManagerDelegate* delegate, base::Closure do_work_closure)
+ : delegate_(delegate),
+ do_work_closure_(do_work_closure),
+ weak_factory_(this) {}
+
+DelayedTaskDelegateImpl::~DelayedTaskDelegateImpl() {}
+
+base::TimeTicks DelayedTaskDelegateImpl::CachedNow() {
+ if (cached_now_.is_null())
+ cached_now_ = delegate_->NowTicks();
+ return cached_now_;
+}
+
+void DelayedTaskDelegateImpl::InvalidateNowCache() {
+ cached_now_ = base::TimeTicks();
+}
+
+bool DelayedTaskDelegateImpl::BelongsToCurrentThread() const {
+ return delegate_ && delegate_->BelongsToCurrentThread();
+}
+
+void DelayedTaskDelegateImpl::PostScheduleDelayedWorkTaskOnMainThread(
+ internal::TaskQueueImpl* queue, base::TimeTicks delayed_run_time) {
+ if (!delegate_)
+ return;
+ delegate_->PostTask(
+ FROM_HERE, base::Bind(&DelayedTaskDelegateImpl::ScheduleDelayedWorkTask,
+ weak_factory_.GetWeakPtr(),
+ scoped_refptr<internal::TaskQueueImpl>(queue),
+ delayed_run_time));
+}
+
+void DelayedTaskDelegateImpl::ScheduleDoWork(base::TimeDelta delay) {
+ if (!delegate_)
+ return;
+ delegate_->PostDelayedTask(FROM_HERE, do_work_closure_, delay);
+}
+
+} // namespace scheduler

Powered by Google App Engine
This is Rietveld 408576698