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

Side by Side 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 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 #ifndef COMPONENTS_SCHEDULER_BASE_DELAYED_TASK_DELEGATE_H_
6 #define COMPONENTS_SCHEDULER_BASE_DELAYED_TASK_DELEGATE_H_
7
8 #include <map>
9
10 #include "base/macros.h"
11 #include "base/memory/ref_counted.h"
12 #include "base/time/time.h"
13 #include "components/scheduler/scheduler_export.h"
14
15 namespace scheduler {
16 namespace internal {
17 class TaskQueueImpl;
18 } // namespace internal
19
20 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.
21 : public base::RefCounted<DelayedTaskDelegate> {
22 public:
23 DelayedTaskDelegate();
24
25 // Returns the most recent cached Now, records a new cache entry if there
26 // isn't one.
27 virtual base::TimeTicks CachedNow() = 0;
28
29 // Clears the cahced Now. Causes the next call to |CachedNow| to sample Now
30 // which can be moderately expensive.
31 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.
32
33 // Schedules a call to TaskQueueImpl::MoveReadyDelayedTasksToIncomingQueue
34 // to run at |delayed_run_time|.
35 void ScheduleDelayedWork(internal::TaskQueueImpl* queue,
36 base::TimeTicks delayed_run_time);
37
38 // Cancels all scheduled callbacks to |queue|.
39 void CancelDelayedWork(internal::TaskQueueImpl* queue);
40
41 // Call TaskQueueImpl::MoveReadyDelayedTasksToIncomingQueue for each
42 // queue where the delay has elapsed.
43 void WakeupReadyDelayedQueues();
44
45 protected:
46 friend class base::RefCounted<DelayedTaskDelegate>;
47
48 virtual ~DelayedTaskDelegate();
49
50 // Function calling ScheduleDelayedWork that's suitable for use in base::Bind.
51 void ScheduleDelayedWorkTask(scoped_refptr<internal::TaskQueueImpl> queue,
52 base::TimeTicks delayed_run_time);
53
54 virtual bool BelongsToCurrentThread() const = 0;
55 virtual void PostScheduleDelayedWorkTaskOnMainThread(
56 internal::TaskQueueImpl* queue,
57 base::TimeTicks delayed_run_time) = 0;
58 virtual void ScheduleDoWork(base::TimeDelta delay) = 0;
59
60 typedef std::multimap<base::TimeTicks, internal::TaskQueueImpl*>
61 DelayedWakeupMultimap;
62
63 DelayedWakeupMultimap delayed_wakeup_multimap_;
64
65 DISALLOW_COPY_AND_ASSIGN(DelayedTaskDelegate);
66 };
67
68 } // namespace scheduler
69
70 #endif // COMPONENTS_SCHEDULER_BASE_DELAYED_TASK_DELEGATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698