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

Side by Side Diff: content/child/scheduler/child_scheduler.h

Issue 1089833002: Introduce ChildScheduler as common base interface for WorkerScheduler and RendererScheduler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix nits Created 5 years, 8 months 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
« no previous file with comments | « no previous file | content/child/scheduler/null_worker_scheduler.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_CHILD_SCHEDULER_WORKER_SCHEDULER_H_ 5 #ifndef CONTENT_CHILD_SCHEDULER_CHILD_SCHEDULER_H_
6 #define CONTENT_CHILD_SCHEDULER_WORKER_SCHEDULER_H_ 6 #define CONTENT_CHILD_SCHEDULER_CHILD_SCHEDULER_H_
7 7
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "content/child/scheduler/single_thread_idle_task_runner.h" 9 #include "content/child/scheduler/single_thread_idle_task_runner.h"
10 #include "content/common/content_export.h" 10 #include "content/common/content_export.h"
11 11
12 namespace base { 12 namespace base {
13 class MessageLoop; 13 class MessageLoop;
14 } 14 }
15 15
16 namespace content { 16 namespace content {
17 17
18 class CONTENT_EXPORT WorkerScheduler { 18 class CONTENT_EXPORT ChildScheduler {
19 public: 19 public:
20 virtual ~WorkerScheduler(); 20 virtual ~ChildScheduler() { }
21 static scoped_ptr<WorkerScheduler> Create(base::MessageLoop* message_loop);
22
23 // Must be called before the scheduler can be used. Does any post construction
24 // initialization needed such as initializing idle period detection.
25 virtual void Init() = 0;
26 21
27 // Returns the default task runner. 22 // Returns the default task runner.
28 virtual scoped_refptr<base::SingleThreadTaskRunner> DefaultTaskRunner() = 0; 23 virtual scoped_refptr<base::SingleThreadTaskRunner> DefaultTaskRunner() = 0;
29 24
30 // Returns the idle task runner. Tasks posted to this runner may be reordered 25 // Returns the idle task runner. Tasks posted to this runner may be reordered
31 // relative to other task types and may be starved for an arbitrarily long 26 // relative to other task types and may be starved for an arbitrarily long
32 // time if no idle time is available. 27 // time if no idle time is available.
33 virtual scoped_refptr<SingleThreadIdleTaskRunner> IdleTaskRunner() = 0; 28 virtual scoped_refptr<SingleThreadIdleTaskRunner> IdleTaskRunner() = 0;
34 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
35 // Returns true if a currently running idle task could exceed its deadline 37 // Returns true if a currently running idle task could exceed its deadline
36 // without impacting user experience too much. This should only be used if 38 // without impacting user experience too much. This should only be used if
37 // there is a task which cannot be pre-empted and is likely to take longer 39 // there is a task which cannot be pre-empted and is likely to take longer
38 // than the largest expected idle task deadline. It should NOT be polled to 40 // than the largest expected idle task deadline. It should NOT be polled to
39 // check whether more work can be performed on the current idle task after 41 // check whether more work can be performed on the current idle task after
40 // its deadline has expired - post a new idle task for the continuation of the 42 // its deadline has expired - post a new idle task for the continuation of the
41 // work in this case. 43 // work in this case.
42 // Must be called from the worker's thread. 44 // Must be called from the thread this scheduler was created on.
43 virtual bool CanExceedIdleDeadlineIfRequired() const = 0; 45 virtual bool CanExceedIdleDeadlineIfRequired() const = 0;
44 46
45 // Adds or removes a task observer from the scheduler. The observer will be 47 // Adds or removes a task observer from the scheduler. The observer will be
46 // notified before and after every executed task. These functions can only be 48 // notified before and after every executed task. These functions can only be
47 // called on the main thread. 49 // called on the thread this scheduler was created on.
48 virtual void AddTaskObserver( 50 virtual void AddTaskObserver(
49 base::MessageLoop::TaskObserver* task_observer) = 0; 51 base::MessageLoop::TaskObserver* task_observer) = 0;
50 virtual void RemoveTaskObserver( 52 virtual void RemoveTaskObserver(
51 base::MessageLoop::TaskObserver* task_observer) = 0; 53 base::MessageLoop::TaskObserver* task_observer) = 0;
52 54
53 // Shuts down the scheduler by dropping any remaining pending work in the work 55 // Shuts down the scheduler by dropping any remaining pending work in the work
54 // queues. After this call any work posted to the task runners will be 56 // queues. After this call any work posted to the task runners will be
55 // silently dropped. 57 // silently dropped.
56 virtual void Shutdown() = 0; 58 virtual void Shutdown() = 0;
57 59
58 protected: 60 protected:
59 WorkerScheduler(); 61 ChildScheduler() { }
60 DISALLOW_COPY_AND_ASSIGN(WorkerScheduler); 62 DISALLOW_COPY_AND_ASSIGN(ChildScheduler);
61 }; 63 };
62 64
63 } // namespace content 65 } // namespace content
64 66
65 #endif // CONTENT_CHILD_SCHEDULER_WORKER_SCHEDULER_H_ 67 #endif // CONTENT_CHILD_SCHEDULER_CHILD_SCHEDULER_H_
OLDNEW
« no previous file with comments | « no previous file | content/child/scheduler/null_worker_scheduler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698