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

Unified Diff: content/child/webthread_base.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/webthread_base.h
diff --git a/content/child/webthread_impl.h b/content/child/webthread_base.h
similarity index 71%
rename from content/child/webthread_impl.h
rename to content/child/webthread_base.h
index c50295253b473215cd384aa1703920626365cf6f..5d6ebb9b0f05ff1855116f80870e2d8fda1ad696 100644
--- a/content/child/webthread_impl.h
+++ b/content/child/webthread_base.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CONTENT_CHILD_WEBTHREAD_IMPL_H_
-#define CONTENT_CHILD_WEBTHREAD_IMPL_H_
+#ifndef CONTENT_CHILD_WEBTHREAD_BASE_H_
+#define CONTENT_CHILD_WEBTHREAD_BASE_H_
#include <map>
@@ -17,6 +17,7 @@ class WebTraceLocation;
}
namespace content {
+class SingleThreadIdleTaskRunner;
class CONTENT_EXPORT WebThreadBase : public blink::WebThread {
public:
@@ -30,6 +31,10 @@ class CONTENT_EXPORT WebThreadBase : public blink::WebThread {
virtual void postDelayedTask(const blink::WebTraceLocation& location,
Task* task,
long long delay_ms);
+ virtual void postIdleTask(const blink::WebTraceLocation& location,
+ IdleTask* idle_task);
+ virtual void postIdleTaskAfterWakeup(const blink::WebTraceLocation& location,
+ IdleTask* idle_task);
virtual void enterRunLoop();
virtual void exitRunLoop();
@@ -41,6 +46,10 @@ class CONTENT_EXPORT WebThreadBase : public blink::WebThread {
// thread. Can be called from any thread.
virtual base::SingleThreadTaskRunner* TaskRunner() const = 0;
+ // Returns the base::Bind-compatible task runner for posting idle tasks to
+ // this thread. Can be called from any thread.
+ virtual SingleThreadIdleTaskRunner* IdleTaskRunner() const = 0;
+
protected:
class TaskObserverAdapter;
@@ -57,29 +66,15 @@ class CONTENT_EXPORT WebThreadBase : public blink::WebThread {
base::MessageLoop::TaskObserver* observer);
static void RunWebThreadTask(scoped_ptr<blink::WebThread::Task> task);
+ static void RunWebThreadIdleTask(
+ scoped_ptr<blink::WebThread::IdleTask> idle_task,
+ base::TimeTicks deadline);
private:
typedef std::map<TaskObserver*, TaskObserverAdapter*> TaskObserverMap;
TaskObserverMap task_observer_map_;
};
-class CONTENT_EXPORT WebThreadImpl : public WebThreadBase {
- public:
- explicit WebThreadImpl(const char* name);
- virtual ~WebThreadImpl();
-
- // blink::WebThread implementation.
- blink::PlatformThreadId threadId() const override;
-
- // WebThreadBase implementation.
- base::SingleThreadTaskRunner* TaskRunner() const override;
-
- private:
- base::MessageLoop* MessageLoop() const override;
-
- scoped_ptr<base::Thread> thread_;
-};
-
-} // namespace content
+} // namespace content
-#endif // CONTENT_CHILD_WEBTHREAD_IMPL_H_
+#endif // CONTENT_CHILD_WEBTHREAD_BASE_H_

Powered by Google App Engine
This is Rietveld 408576698