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

Unified Diff: components/scheduler/base/delayed_task_delegate.h

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.h
diff --git a/components/scheduler/base/delayed_task_delegate.h b/components/scheduler/base/delayed_task_delegate.h
new file mode 100644
index 0000000000000000000000000000000000000000..e9d65b26f7ea09944e76dfdb58fabdc59308576e
--- /dev/null
+++ b/components/scheduler/base/delayed_task_delegate.h
@@ -0,0 +1,70 @@
+// 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.
+
+#ifndef COMPONENTS_SCHEDULER_BASE_DELAYED_TASK_DELEGATE_H_
+#define COMPONENTS_SCHEDULER_BASE_DELAYED_TASK_DELEGATE_H_
+
+#include <map>
+
+#include "base/macros.h"
+#include "base/memory/ref_counted.h"
+#include "base/time/time.h"
+#include "components/scheduler/scheduler_export.h"
+
+namespace scheduler {
+namespace internal {
+class TaskQueueImpl;
+} // namespace internal
+
+class SCHEDULER_EXPORT DelayedTaskDelegate
Sami 2015/11/17 10:31:06 This class exposes public functions that deal with
alex clarke (OOO till 29th) 2015/11/18 15:30:15 We made them private as discussed offline.
+ : public base::RefCounted<DelayedTaskDelegate> {
+ public:
+ DelayedTaskDelegate();
+
+ // Returns the most recent cached Now, records a new cache entry if there
+ // isn't one.
+ virtual base::TimeTicks CachedNow() = 0;
+
+ // Clears the cahced Now. Causes the next call to |CachedNow| to sample Now
+ // which can be moderately expensive.
+ virtual void InvalidateNowCache() = 0;
Sami 2015/11/17 10:31:06 I kinda prefer the earlier way of passing around a
alex clarke (OOO till 29th) 2015/11/18 15:30:15 Done.
+
+ // Schedules a call to TaskQueueImpl::MoveReadyDelayedTasksToIncomingQueue
+ // to run at |delayed_run_time|.
+ void ScheduleDelayedWork(internal::TaskQueueImpl* queue,
+ base::TimeTicks delayed_run_time);
+
+ // Cancels all scheduled callbacks to |queue|.
+ void CancelDelayedWork(internal::TaskQueueImpl* queue);
+
+ // Call TaskQueueImpl::MoveReadyDelayedTasksToIncomingQueue for each
+ // queue where the delay has elapsed.
+ void WakeupReadyDelayedQueues();
+
+ protected:
+ friend class base::RefCounted<DelayedTaskDelegate>;
+
+ virtual ~DelayedTaskDelegate();
+
+ // Function calling ScheduleDelayedWork that's suitable for use in base::Bind.
+ void ScheduleDelayedWorkTask(scoped_refptr<internal::TaskQueueImpl> queue,
+ base::TimeTicks delayed_run_time);
+
+ virtual bool BelongsToCurrentThread() const = 0;
+ virtual void PostScheduleDelayedWorkTaskOnMainThread(
+ internal::TaskQueueImpl* queue,
+ base::TimeTicks delayed_run_time) = 0;
+ virtual void ScheduleDoWork(base::TimeDelta delay) = 0;
+
+ typedef std::multimap<base::TimeTicks, internal::TaskQueueImpl*>
+ DelayedWakeupMultimap;
+
+ DelayedWakeupMultimap delayed_wakeup_multimap_;
+
+ DISALLOW_COPY_AND_ASSIGN(DelayedTaskDelegate);
+};
+
+} // namespace scheduler
+
+#endif // COMPONENTS_SCHEDULER_BASE_DELAYED_TASK_DELEGATE_H_

Powered by Google App Engine
This is Rietveld 408576698