Rename GetIconID to GetIconId
[chromium-blink-merge.git] / components / scheduler / child / webthread_base.h
blobadc92771681e5d175fdd3861ab83b7e5d65adac5
1 // Copyright 2014 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.
5 #ifndef COMPONENTS_SCHEDULER_CHILD_WEBTHREAD_BASE_H_
6 #define COMPONENTS_SCHEDULER_CHILD_WEBTHREAD_BASE_H_
8 #include <map>
10 #include "base/memory/scoped_ptr.h"
11 #include "base/threading/thread.h"
12 #include "components/scheduler/scheduler_export.h"
13 #include "third_party/WebKit/public/platform/WebThread.h"
15 namespace blink {
16 class WebTraceLocation;
19 namespace scheduler {
20 class SingleThreadIdleTaskRunner;
22 class SCHEDULER_EXPORT WebThreadBase : public blink::WebThread {
23 public:
24 virtual ~WebThreadBase();
26 // blink::WebThread implementation.
27 virtual bool isCurrentThread() const;
28 virtual blink::PlatformThreadId threadId() const = 0;
30 virtual void postTask(const blink::WebTraceLocation& location, Task* task);
31 virtual void postDelayedTask(const blink::WebTraceLocation& location,
32 Task* task,
33 long long delay_ms);
34 virtual void postIdleTask(const blink::WebTraceLocation& location,
35 IdleTask* idle_task);
36 virtual void postIdleTaskAfterWakeup(const blink::WebTraceLocation& location,
37 IdleTask* idle_task);
39 virtual void addTaskObserver(TaskObserver* observer);
40 virtual void removeTaskObserver(TaskObserver* observer);
42 // Returns the base::Bind-compatible task runner for posting tasks to this
43 // thread. Can be called from any thread.
44 virtual base::SingleThreadTaskRunner* TaskRunner() const = 0;
46 // Returns the base::Bind-compatible task runner for posting idle tasks to
47 // this thread. Can be called from any thread.
48 virtual scheduler::SingleThreadIdleTaskRunner* IdleTaskRunner() const = 0;
50 protected:
51 class TaskObserverAdapter;
53 WebThreadBase();
55 virtual void AddTaskObserverInternal(
56 base::MessageLoop::TaskObserver* observer);
57 virtual void RemoveTaskObserverInternal(
58 base::MessageLoop::TaskObserver* observer);
60 static void RunWebThreadTask(scoped_ptr<blink::WebThread::Task> task);
61 static void RunWebThreadIdleTask(
62 scoped_ptr<blink::WebThread::IdleTask> idle_task,
63 base::TimeTicks deadline);
65 private:
66 typedef std::map<TaskObserver*, TaskObserverAdapter*> TaskObserverMap;
67 TaskObserverMap task_observer_map_;
70 } // namespace scheduler
72 #endif // COMPONENTS_SCHEDULER_CHILD_WEBTHREAD_BASE_H_