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