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

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

Issue 1033643004: Add a WorkerScheduler and a WebThreadImplForWorker (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: InitOnThread needed to call Init() 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
OLDNEW
1 // Copyright 2014 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_RENDERER_SCHEDULER_RENDERER_SCHEDULER_H_ 5 #ifndef CONTENT_CHILD_SCHEDULER_WORKER_SCHEDULER_H_
6 #define CONTENT_RENDERER_SCHEDULER_RENDERER_SCHEDULER_H_ 6 #define CONTENT_CHILD_SCHEDULER_WORKER_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 #include "third_party/WebKit/public/web/WebInputEvent.h"
12 11
13 namespace cc { 12 namespace base {
14 struct BeginFrameArgs; 13 class MessageLoop;
15 } 14 }
16 15
17 namespace content { 16 namespace content {
18 17
19 class CONTENT_EXPORT RendererScheduler { 18 class CONTENT_EXPORT WorkerScheduler {
20 public: 19 public:
21 virtual ~RendererScheduler(); 20 virtual ~WorkerScheduler();
22 static scoped_ptr<RendererScheduler> Create(); 21 static scoped_ptr<WorkerScheduler> Create(base::MessageLoop* message_loop);
23 22
24 // Returns the default task runner. 23 // Returns the default task runner.
25 virtual scoped_refptr<base::SingleThreadTaskRunner> DefaultTaskRunner() = 0; 24 virtual scoped_refptr<base::SingleThreadTaskRunner> DefaultTaskRunner() = 0;
26 25
27 // Returns the compositor task runner.
28 virtual scoped_refptr<base::SingleThreadTaskRunner>
29 CompositorTaskRunner() = 0;
30
31 // Returns the idle task runner. Tasks posted to this runner may be reordered 26 // Returns the idle task runner. Tasks posted to this runner may be reordered
32 // relative to other task types and may be starved for an arbitrarily long 27 // relative to other task types and may be starved for an arbitrarily long
33 // time if no idle time is available. 28 // time if no idle time is available.
34 virtual scoped_refptr<SingleThreadIdleTaskRunner> IdleTaskRunner() = 0; 29 virtual scoped_refptr<SingleThreadIdleTaskRunner> IdleTaskRunner() = 0;
35 30
36 // Returns the loading task runner. This queue is intended for tasks related
37 // to resource dispatch, foreground HTML parsing, etc...
38 virtual scoped_refptr<base::SingleThreadTaskRunner> LoadingTaskRunner() = 0;
39
40 // Called to notify about the start of an extended period where no frames
41 // need to be drawn. Must be called from the main thread.
42 virtual void BeginFrameNotExpectedSoon() = 0;
43
44 // Called to notify about the start of a new frame. Must be called from the
45 // main thread.
46 virtual void WillBeginFrame(const cc::BeginFrameArgs& args) = 0;
47
48 // Called to notify that a previously begun frame was committed. Must be
49 // called from the main thread.
50 virtual void DidCommitFrameToCompositor() = 0;
51
52 // Tells the scheduler that the system received an input event. Called by the
53 // compositor (impl) thread.
54 virtual void DidReceiveInputEventOnCompositorThread(
55 const blink::WebInputEvent& web_input_event) = 0;
56
57 // Tells the scheduler that the system is displaying an input animation (e.g.
58 // a fling). Called by the compositor (impl) thread.
59 virtual void DidAnimateForInputOnCompositorThread() = 0;
60
61 // Returns true if the scheduler has reason to believe that high priority work
62 // may soon arrive on the main thread, e.g., if gesture events were observed
63 // recently.
64 // Must be called from the main thread.
65 virtual bool IsHighPriorityWorkAnticipated() = 0;
66
67 // Returns true if there is high priority work pending on the main thread
68 // and the caller should yield to let the scheduler service that work. Note
69 // that this is a stricter condition than |IsHighPriorityWorkAnticipated|,
70 // restricted to the case where real work is pending.
71 // Must be called from the main thread.
72 virtual bool ShouldYieldForHighPriorityWork() = 0;
73
74 // Returns true if a currently running idle task could exceed its deadline 31 // Returns true if a currently running idle task could exceed its deadline
75 // without impacting user experience too much. This should only be used if 32 // without impacting user experience too much. This should only be used if
76 // there is a task which cannot be pre-empted and is likely to take longer 33 // there is a task which cannot be pre-empted and is likely to take longer
77 // than the largest expected idle task deadline. It should NOT be polled to 34 // than the largest expected idle task deadline. It should NOT be polled to
78 // check whether more work can be performed on the current idle task after 35 // check whether more work can be performed on the current idle task after
79 // its deadline has expired - post a new idle task for the continuation of the 36 // its deadline has expired - post a new idle task for the continuation of the
80 // work in this case. 37 // work in this case.
81 // Must be called from the main thread. 38 // Must be called from the main thread.
82 virtual bool CanExceedIdleDeadlineIfRequired() const = 0; 39 virtual bool CanExceedIdleDeadlineIfRequired() const = 0;
83 40
84 // Adds or removes a task observer from the scheduler. The observer will be 41 // Adds or removes a task observer from the scheduler. The observer will be
85 // notified before and after every executed task. These functions can only be 42 // notified before and after every executed task. These functions can only be
86 // called on the main thread. 43 // called on the main thread.
87 virtual void AddTaskObserver( 44 virtual void AddTaskObserver(
88 base::MessageLoop::TaskObserver* task_observer) = 0; 45 base::MessageLoop::TaskObserver* task_observer) = 0;
89 virtual void RemoveTaskObserver( 46 virtual void RemoveTaskObserver(
90 base::MessageLoop::TaskObserver* task_observer) = 0; 47 base::MessageLoop::TaskObserver* task_observer) = 0;
91 48
49 // Does any post construction initilaziation needed such as initiaiting long
Sami 2015/04/02 10:19:46 Could you add a note that needs to be called befor
alex clarke (OOO till 29th) 2015/04/02 15:19:28 Done.
50 // idle periods.
51 virtual void Init() = 0;
52
92 // Shuts down the scheduler by dropping any remaining pending work in the work 53 // Shuts down the scheduler by dropping any remaining pending work in the work
93 // queues. After this call any work posted to the task runners will be 54 // queues. After this call any work posted to the task runners will be
94 // silently dropped. 55 // silently dropped.
95 virtual void Shutdown() = 0; 56 virtual void Shutdown() = 0;
96 57
97 protected: 58 protected:
98 RendererScheduler(); 59 WorkerScheduler();
99 DISALLOW_COPY_AND_ASSIGN(RendererScheduler); 60 DISALLOW_COPY_AND_ASSIGN(WorkerScheduler);
100 }; 61 };
101 62
102 } // namespace content 63 } // namespace content
103 64
104 #endif // CONTENT_RENDERER_SCHEDULER_RENDERER_SCHEDULER_H_ 65 #endif // CONTENT_CHILD_SCHEDULER_WORKER_SCHEDULER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698