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

Unified 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: Fix bug where tasks posted to a worker thread did not always run when the thread was shutdown 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 side-by-side diff with in-line comments
Download patch
Index: content/child/scheduler/worker_scheduler.h
diff --git a/content/renderer/scheduler/renderer_scheduler.h b/content/child/scheduler/worker_scheduler.h
similarity index 42%
copy from content/renderer/scheduler/renderer_scheduler.h
copy to content/child/scheduler/worker_scheduler.h
index 924c4b19fdca881c9efbab5b6a02f5216b5aebc9..6d906267b89523825a058f4a852c2b6abb2fe9ba 100644
--- a/content/renderer/scheduler/renderer_scheduler.h
+++ b/content/child/scheduler/worker_scheduler.h
@@ -1,76 +1,37 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
+// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CONTENT_RENDERER_SCHEDULER_RENDERER_SCHEDULER_H_
-#define CONTENT_RENDERER_SCHEDULER_RENDERER_SCHEDULER_H_
+#ifndef CONTENT_CHILD_SCHEDULER_WORKER_SCHEDULER_H_
+#define CONTENT_CHILD_SCHEDULER_WORKER_SCHEDULER_H_
#include "base/message_loop/message_loop.h"
#include "content/child/scheduler/single_thread_idle_task_runner.h"
#include "content/common/content_export.h"
-#include "third_party/WebKit/public/web/WebInputEvent.h"
-namespace cc {
-struct BeginFrameArgs;
+namespace base {
+class MessageLoop;
}
namespace content {
-class CONTENT_EXPORT RendererScheduler {
+class CONTENT_EXPORT WorkerScheduler {
public:
- virtual ~RendererScheduler();
- static scoped_ptr<RendererScheduler> Create();
+ virtual ~WorkerScheduler();
+ static scoped_ptr<WorkerScheduler> Create(base::MessageLoop* message_loop);
+
+ // Must be called before the scheduler can be used. Does any post construction
+ // initialization needed such as initializing idle period detection.
+ virtual void Init() = 0;
// Returns the default task runner.
virtual scoped_refptr<base::SingleThreadTaskRunner> DefaultTaskRunner() = 0;
- // Returns the compositor task runner.
- virtual scoped_refptr<base::SingleThreadTaskRunner>
- CompositorTaskRunner() = 0;
-
// Returns the idle task runner. Tasks posted to this runner may be reordered
// relative to other task types and may be starved for an arbitrarily long
// time if no idle time is available.
virtual scoped_refptr<SingleThreadIdleTaskRunner> IdleTaskRunner() = 0;
- // Returns the loading task runner. This queue is intended for tasks related
- // to resource dispatch, foreground HTML parsing, etc...
- virtual scoped_refptr<base::SingleThreadTaskRunner> LoadingTaskRunner() = 0;
-
- // Called to notify about the start of an extended period where no frames
- // need to be drawn. Must be called from the main thread.
- virtual void BeginFrameNotExpectedSoon() = 0;
-
- // Called to notify about the start of a new frame. Must be called from the
- // main thread.
- virtual void WillBeginFrame(const cc::BeginFrameArgs& args) = 0;
-
- // Called to notify that a previously begun frame was committed. Must be
- // called from the main thread.
- virtual void DidCommitFrameToCompositor() = 0;
-
- // Tells the scheduler that the system received an input event. Called by the
- // compositor (impl) thread.
- virtual void DidReceiveInputEventOnCompositorThread(
- const blink::WebInputEvent& web_input_event) = 0;
-
- // Tells the scheduler that the system is displaying an input animation (e.g.
- // a fling). Called by the compositor (impl) thread.
- virtual void DidAnimateForInputOnCompositorThread() = 0;
-
- // Returns true if the scheduler has reason to believe that high priority work
- // may soon arrive on the main thread, e.g., if gesture events were observed
- // recently.
- // Must be called from the main thread.
- virtual bool IsHighPriorityWorkAnticipated() = 0;
-
- // Returns true if there is high priority work pending on the main thread
- // and the caller should yield to let the scheduler service that work. Note
- // that this is a stricter condition than |IsHighPriorityWorkAnticipated|,
- // restricted to the case where real work is pending.
- // Must be called from the main thread.
- virtual bool ShouldYieldForHighPriorityWork() = 0;
-
// Returns true if a currently running idle task could exceed its deadline
// without impacting user experience too much. This should only be used if
// there is a task which cannot be pre-empted and is likely to take longer
@@ -78,7 +39,7 @@ class CONTENT_EXPORT RendererScheduler {
// check whether more work can be performed on the current idle task after
// its deadline has expired - post a new idle task for the continuation of the
// work in this case.
- // Must be called from the main thread.
+ // Must be called from the worker's thread.
virtual bool CanExceedIdleDeadlineIfRequired() const = 0;
// Adds or removes a task observer from the scheduler. The observer will be
@@ -95,10 +56,10 @@ class CONTENT_EXPORT RendererScheduler {
virtual void Shutdown() = 0;
protected:
- RendererScheduler();
- DISALLOW_COPY_AND_ASSIGN(RendererScheduler);
+ WorkerScheduler();
+ DISALLOW_COPY_AND_ASSIGN(WorkerScheduler);
};
} // namespace content
-#endif // CONTENT_RENDERER_SCHEDULER_RENDERER_SCHEDULER_H_
+#endif // CONTENT_CHILD_SCHEDULER_WORKER_SCHEDULER_H_

Powered by Google App Engine
This is Rietveld 408576698