| OLD | NEW |
| (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_CHILD_CHILD_SCHEDULER_H_ | |
| 6 #define COMPONENTS_SCHEDULER_CHILD_CHILD_SCHEDULER_H_ | |
| 7 | |
| 8 #include "base/macros.h" | |
| 9 #include "base/message_loop/message_loop.h" | |
| 10 #include "components/scheduler/base/task_queue.h" | |
| 11 #include "components/scheduler/child/single_thread_idle_task_runner.h" | |
| 12 #include "components/scheduler/scheduler_export.h" | |
| 13 | |
| 14 namespace base { | |
| 15 class MessageLoop; | |
| 16 } | |
| 17 | |
| 18 namespace scheduler { | |
| 19 class TaskQueue; | |
| 20 | |
| 21 class SCHEDULER_EXPORT ChildScheduler { | |
| 22 public: | |
| 23 virtual ~ChildScheduler() {} | |
| 24 | |
| 25 // Returns the default task runner. | |
| 26 virtual scoped_refptr<TaskQueue> DefaultTaskRunner() = 0; | |
| 27 | |
| 28 // Returns the idle task runner. Tasks posted to this runner may be reordered | |
| 29 // relative to other task types and may be starved for an arbitrarily long | |
| 30 // time if no idle time is available. | |
| 31 virtual scoped_refptr<SingleThreadIdleTaskRunner> IdleTaskRunner() = 0; | |
| 32 | |
| 33 // Returns true if there is high priority work pending on the main thread | |
| 34 // and the caller should yield to let the scheduler service that work. Note | |
| 35 // that this is a stricter condition than |IsHighPriorityWorkAnticipated|, | |
| 36 // restricted to the case where real work is pending. | |
| 37 // Must be called from the thread this scheduler was created on. | |
| 38 virtual bool ShouldYieldForHighPriorityWork() = 0; | |
| 39 | |
| 40 // Returns true if a currently running idle task could exceed its deadline | |
| 41 // without impacting user experience too much. This should only be used if | |
| 42 // there is a task which cannot be pre-empted and is likely to take longer | |
| 43 // than the largest expected idle task deadline. It should NOT be polled to | |
| 44 // check whether more work can be performed on the current idle task after | |
| 45 // its deadline has expired - post a new idle task for the continuation of the | |
| 46 // work in this case. | |
| 47 // Must be called from the thread this scheduler was created on. | |
| 48 virtual bool CanExceedIdleDeadlineIfRequired() const = 0; | |
| 49 | |
| 50 // Adds or removes a task observer from the scheduler. The observer will be | |
| 51 // notified before and after every executed task. These functions can only be | |
| 52 // called on the thread this scheduler was created on. | |
| 53 virtual void AddTaskObserver( | |
| 54 base::MessageLoop::TaskObserver* task_observer) = 0; | |
| 55 virtual void RemoveTaskObserver( | |
| 56 base::MessageLoop::TaskObserver* task_observer) = 0; | |
| 57 | |
| 58 // Shuts down the scheduler by dropping any remaining pending work in the work | |
| 59 // queues. After this call any work posted to the task runners will be | |
| 60 // silently dropped. | |
| 61 virtual void Shutdown() = 0; | |
| 62 | |
| 63 protected: | |
| 64 ChildScheduler() {} | |
| 65 DISALLOW_COPY_AND_ASSIGN(ChildScheduler); | |
| 66 }; | |
| 67 | |
| 68 } // namespace scheduler | |
| 69 | |
| 70 #endif // COMPONENTS_SCHEDULER_CHILD_CHILD_SCHEDULER_H_ | |
| OLD | NEW |