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 MOJO_SERVICES_HTML_VIEWER_WEBTHREAD_IMPL_H_ | 5 #ifndef MOJO_SERVICES_HTML_VIEWER_WEBTHREAD_IMPL_H_ |
6 #define MOJO_SERVICES_HTML_VIEWER_WEBTHREAD_IMPL_H_ | 6 #define MOJO_SERVICES_HTML_VIEWER_WEBTHREAD_IMPL_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 "third_party/WebKit/public/platform/WebThread.h" | 12 #include "third_party/WebKit/public/platform/WebThread.h" |
13 | 13 |
14 namespace html_viewer { | 14 namespace html_viewer { |
15 | 15 |
16 class WebThreadBase : public blink::WebThread { | 16 class WebThreadBase : public blink::WebThread { |
17 public: | 17 public: |
18 virtual ~WebThreadBase(); | 18 ~WebThreadBase() override; |
19 | 19 |
20 virtual void addTaskObserver(TaskObserver* observer); | 20 void addTaskObserver(TaskObserver* observer) override; |
21 virtual void removeTaskObserver(TaskObserver* observer); | 21 void removeTaskObserver(TaskObserver* observer) override; |
22 | 22 |
23 virtual bool isCurrentThread() const = 0; | 23 bool isCurrentThread() const override = 0; |
24 virtual blink::PlatformThreadId threadId() const = 0; | |
25 | 24 |
26 protected: | 25 protected: |
27 WebThreadBase(); | 26 WebThreadBase(); |
28 | 27 |
29 private: | 28 private: |
30 class TaskObserverAdapter; | 29 class TaskObserverAdapter; |
31 | 30 |
32 typedef std::map<TaskObserver*, TaskObserverAdapter*> TaskObserverMap; | 31 typedef std::map<TaskObserver*, TaskObserverAdapter*> TaskObserverMap; |
33 TaskObserverMap task_observer_map_; | 32 TaskObserverMap task_observer_map_; |
34 }; | 33 }; |
35 | 34 |
36 class WebThreadImpl : public WebThreadBase { | 35 class WebThreadImpl : public WebThreadBase { |
37 public: | 36 public: |
38 explicit WebThreadImpl(const char* name); | 37 explicit WebThreadImpl(const char* name); |
39 virtual ~WebThreadImpl(); | 38 ~WebThreadImpl() override; |
40 | 39 |
41 virtual void postTask(const blink::WebTraceLocation& location, Task* task); | 40 void postTask(const blink::WebTraceLocation& location, Task* task) override; |
42 virtual void postDelayedTask(const blink::WebTraceLocation& location, | 41 void postDelayedTask(const blink::WebTraceLocation& location, |
43 Task* task, | 42 Task* task, |
44 long long delay_ms); | 43 long long delay_ms) override; |
45 | 44 |
46 virtual void enterRunLoop(); | 45 void enterRunLoop() override; |
47 virtual void exitRunLoop(); | 46 void exitRunLoop() override; |
48 | 47 |
49 base::MessageLoop* message_loop() const { return thread_->message_loop(); } | 48 base::MessageLoop* message_loop() const { return thread_->message_loop(); } |
50 | 49 |
51 virtual bool isCurrentThread() const; | 50 bool isCurrentThread() const override; |
52 virtual blink::PlatformThreadId threadId() const; | 51 blink::PlatformThreadId threadId() const override; |
53 | 52 |
54 private: | 53 private: |
55 scoped_ptr<base::Thread> thread_; | 54 scoped_ptr<base::Thread> thread_; |
56 }; | 55 }; |
57 | 56 |
58 class WebThreadImplForMessageLoop : public WebThreadBase { | 57 class WebThreadImplForMessageLoop : public WebThreadBase { |
59 public: | 58 public: |
60 explicit WebThreadImplForMessageLoop( | 59 explicit WebThreadImplForMessageLoop( |
61 base::MessageLoopProxy* message_loop); | 60 base::MessageLoopProxy* message_loop); |
62 virtual ~WebThreadImplForMessageLoop(); | 61 ~WebThreadImplForMessageLoop() override; |
63 | 62 |
64 virtual void postTask(const blink::WebTraceLocation& location, Task* task); | 63 void postTask(const blink::WebTraceLocation& location, Task* task) override; |
65 virtual void postDelayedTask(const blink::WebTraceLocation& location, | 64 void postDelayedTask(const blink::WebTraceLocation& location, |
66 Task* task, | 65 Task* task, |
67 long long delay_ms); | 66 long long delay_ms) override; |
68 | 67 |
69 virtual void enterRunLoop(); | 68 void enterRunLoop() override; |
70 virtual void exitRunLoop(); | 69 void exitRunLoop() override; |
71 | 70 |
72 private: | 71 private: |
73 virtual bool isCurrentThread() const; | 72 bool isCurrentThread() const override; |
74 virtual blink::PlatformThreadId threadId() const; | 73 blink::PlatformThreadId threadId() const override; |
75 | 74 |
76 scoped_refptr<base::MessageLoopProxy> message_loop_; | 75 scoped_refptr<base::MessageLoopProxy> message_loop_; |
77 blink::PlatformThreadId thread_id_; | 76 blink::PlatformThreadId thread_id_; |
78 }; | 77 }; |
79 | 78 |
80 } // namespace html_viewer | 79 } // namespace html_viewer |
81 | 80 |
82 #endif // MOJO_SERVICES_HTML_VIEWER_WEBTHREAD_IMPL_H_ | 81 #endif // MOJO_SERVICES_HTML_VIEWER_WEBTHREAD_IMPL_H_ |
OLD | NEW |