| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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_WEBTHREAD_BASE_H_ | 5 #ifndef CONTENT_CHILD_WEBTHREAD_BASE_H_ |
| 6 #define CONTENT_CHILD_WEBTHREAD_BASE_H_ | 6 #define CONTENT_CHILD_WEBTHREAD_BASE_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/threading/thread.h" | 11 #include "base/threading/thread.h" |
| 12 #include "content/common/content_export.h" | 12 #include "content/common/content_export.h" |
| 13 #include "third_party/WebKit/public/platform/WebThread.h" | 13 #include "third_party/WebKit/public/platform/WebThread.h" |
| 14 | 14 |
| 15 namespace blink { | 15 namespace blink { |
| 16 class WebTraceLocation; | 16 class WebTraceLocation; |
| 17 } | 17 } |
| 18 | 18 |
| 19 namespace scheduler { |
| 20 class SingleThreadIdleTaskRunner; |
| 21 } |
| 22 |
| 19 namespace content { | 23 namespace content { |
| 20 class SingleThreadIdleTaskRunner; | |
| 21 | 24 |
| 22 class CONTENT_EXPORT WebThreadBase : public blink::WebThread { | 25 class CONTENT_EXPORT WebThreadBase : public blink::WebThread { |
| 23 public: | 26 public: |
| 24 virtual ~WebThreadBase(); | 27 virtual ~WebThreadBase(); |
| 25 | 28 |
| 26 // blink::WebThread implementation. | 29 // blink::WebThread implementation. |
| 27 virtual bool isCurrentThread() const; | 30 virtual bool isCurrentThread() const; |
| 28 virtual blink::PlatformThreadId threadId() const = 0; | 31 virtual blink::PlatformThreadId threadId() const = 0; |
| 29 | 32 |
| 30 virtual void postTask(const blink::WebTraceLocation& location, Task* task); | 33 virtual void postTask(const blink::WebTraceLocation& location, Task* task); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 41 | 44 |
| 42 virtual void addTaskObserver(TaskObserver* observer); | 45 virtual void addTaskObserver(TaskObserver* observer); |
| 43 virtual void removeTaskObserver(TaskObserver* observer); | 46 virtual void removeTaskObserver(TaskObserver* observer); |
| 44 | 47 |
| 45 // Returns the base::Bind-compatible task runner for posting tasks to this | 48 // Returns the base::Bind-compatible task runner for posting tasks to this |
| 46 // thread. Can be called from any thread. | 49 // thread. Can be called from any thread. |
| 47 virtual base::SingleThreadTaskRunner* TaskRunner() const = 0; | 50 virtual base::SingleThreadTaskRunner* TaskRunner() const = 0; |
| 48 | 51 |
| 49 // Returns the base::Bind-compatible task runner for posting idle tasks to | 52 // Returns the base::Bind-compatible task runner for posting idle tasks to |
| 50 // this thread. Can be called from any thread. | 53 // this thread. Can be called from any thread. |
| 51 virtual SingleThreadIdleTaskRunner* IdleTaskRunner() const = 0; | 54 virtual scheduler::SingleThreadIdleTaskRunner* IdleTaskRunner() const = 0; |
| 52 | 55 |
| 53 protected: | 56 protected: |
| 54 class TaskObserverAdapter; | 57 class TaskObserverAdapter; |
| 55 | 58 |
| 56 WebThreadBase(); | 59 WebThreadBase(); |
| 57 | 60 |
| 58 // Returns the underlying MessageLoop for this thread. Only used for entering | 61 // Returns the underlying MessageLoop for this thread. Only used for entering |
| 59 // and exiting a nested run loop. Only called on the thread that the | 62 // and exiting a nested run loop. Only called on the thread that the |
| 60 // WebThread belongs to. | 63 // WebThread belongs to. |
| 61 virtual base::MessageLoop* MessageLoop() const = 0; | 64 virtual base::MessageLoop* MessageLoop() const = 0; |
| 62 | 65 |
| 63 virtual void AddTaskObserverInternal( | 66 virtual void AddTaskObserverInternal( |
| 64 base::MessageLoop::TaskObserver* observer); | 67 base::MessageLoop::TaskObserver* observer); |
| 65 virtual void RemoveTaskObserverInternal( | 68 virtual void RemoveTaskObserverInternal( |
| 66 base::MessageLoop::TaskObserver* observer); | 69 base::MessageLoop::TaskObserver* observer); |
| 67 | 70 |
| 68 static void RunWebThreadTask(scoped_ptr<blink::WebThread::Task> task); | 71 static void RunWebThreadTask(scoped_ptr<blink::WebThread::Task> task); |
| 69 static void RunWebThreadIdleTask( | 72 static void RunWebThreadIdleTask( |
| 70 scoped_ptr<blink::WebThread::IdleTask> idle_task, | 73 scoped_ptr<blink::WebThread::IdleTask> idle_task, |
| 71 base::TimeTicks deadline); | 74 base::TimeTicks deadline); |
| 72 | 75 |
| 73 private: | 76 private: |
| 74 typedef std::map<TaskObserver*, TaskObserverAdapter*> TaskObserverMap; | 77 typedef std::map<TaskObserver*, TaskObserverAdapter*> TaskObserverMap; |
| 75 TaskObserverMap task_observer_map_; | 78 TaskObserverMap task_observer_map_; |
| 76 }; | 79 }; |
| 77 | 80 |
| 78 } // namespace content | 81 } // namespace content |
| 79 | 82 |
| 80 #endif // CONTENT_CHILD_WEBTHREAD_BASE_H_ | 83 #endif // CONTENT_CHILD_WEBTHREAD_BASE_H_ |
| OLD | NEW |