OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef WEBKIT_GLUE_WEBTHREAD_IMPL_H_ | 4 #ifndef WEBKIT_GLUE_WEBTHREAD_IMPL_H_ |
5 #define WEBKIT_GLUE_WEBTHREAD_IMPL_H_ | 5 #define WEBKIT_GLUE_WEBTHREAD_IMPL_H_ |
6 | 6 |
| 7 #include <map> |
| 8 |
7 #include "base/threading/thread.h" | 9 #include "base/threading/thread.h" |
8 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebThread.h" | 11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebThread.h" |
10 | 12 |
11 namespace webkit_glue { | 13 namespace webkit_glue { |
12 | 14 |
13 class WebThreadImpl : public WebKit::WebThread { | 15 class WebThreadBase : public WebKit::WebThread { |
14 public: | 16 public: |
15 WebThreadImpl(const char* name); | 17 virtual void addTaskObserver(TaskObserver* observer); |
| 18 virtual void removeTaskObserver(TaskObserver* observer); |
| 19 |
| 20 protected: |
| 21 virtual bool IsCurrentThread() const = 0; |
| 22 |
| 23 private: |
| 24 class TaskObserverAdapter; |
| 25 typedef std::map<TaskObserver*, TaskObserverAdapter*> TaskObserverMap; |
| 26 TaskObserverMap task_observer_map_; |
| 27 }; |
| 28 |
| 29 class WebThreadImpl : public WebThreadBase { |
| 30 public: |
| 31 explicit WebThreadImpl(const char* name); |
16 virtual ~WebThreadImpl(); | 32 virtual ~WebThreadImpl(); |
17 | 33 |
18 virtual void postTask(Task* task) OVERRIDE; | 34 virtual void postTask(Task* task) OVERRIDE; |
19 virtual void postDelayedTask(Task* task, long long delay_ms) OVERRIDE; | 35 virtual void postDelayedTask(Task* task, long long delay_ms) OVERRIDE; |
20 | 36 |
21 MessageLoop* message_loop() const { return thread_->message_loop(); } | 37 MessageLoop* message_loop() const { return thread_->message_loop(); } |
22 | 38 |
23 protected: | 39 protected: |
| 40 virtual bool IsCurrentThread() const; |
| 41 |
| 42 private: |
24 scoped_ptr<base::Thread> thread_; | 43 scoped_ptr<base::Thread> thread_; |
25 }; | 44 }; |
26 | 45 |
27 class WebThreadImplForMessageLoop : public WebKit::WebThread { | 46 class WebThreadImplForMessageLoop : public WebThreadBase { |
28 public: | 47 public: |
29 WebThreadImplForMessageLoop(base::MessageLoopProxy* message_loop); | 48 explicit WebThreadImplForMessageLoop(base::MessageLoopProxy* message_loop); |
30 virtual ~WebThreadImplForMessageLoop(); | 49 virtual ~WebThreadImplForMessageLoop(); |
31 | 50 |
32 virtual void postTask(Task* task) OVERRIDE; | 51 virtual void postTask(Task* task) OVERRIDE; |
33 virtual void postDelayedTask(Task* task, long long delay_ms) OVERRIDE; | 52 virtual void postDelayedTask(Task* task, long long delay_ms) OVERRIDE; |
34 | 53 |
35 protected: | 54 protected: |
| 55 virtual bool IsCurrentThread() const; |
| 56 |
| 57 private: |
36 scoped_refptr<base::MessageLoopProxy> message_loop_; | 58 scoped_refptr<base::MessageLoopProxy> message_loop_; |
37 }; | 59 }; |
38 | 60 |
39 } // namespace webkit_glue | 61 } // namespace webkit_glue |
40 | 62 |
41 #endif | 63 #endif |
OLD | NEW |