Chromium Code Reviews| 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; | 24 blink::PlatformThreadId threadId() const override = 0; |
|
sky
2015/03/31 17:15:57
I don't think this is necessary, can you remove it
| |
| 25 | 25 |
| 26 protected: | 26 protected: |
| 27 WebThreadBase(); | 27 WebThreadBase(); |
| 28 | 28 |
| 29 private: | 29 private: |
| 30 class TaskObserverAdapter; | 30 class TaskObserverAdapter; |
| 31 | 31 |
| 32 typedef std::map<TaskObserver*, TaskObserverAdapter*> TaskObserverMap; | 32 typedef std::map<TaskObserver*, TaskObserverAdapter*> TaskObserverMap; |
| 33 TaskObserverMap task_observer_map_; | 33 TaskObserverMap task_observer_map_; |
| 34 }; | 34 }; |
| 35 | 35 |
| 36 class WebThreadImpl : public WebThreadBase { | 36 class WebThreadImpl : public WebThreadBase { |
| 37 public: | 37 public: |
| 38 explicit WebThreadImpl(const char* name); | 38 explicit WebThreadImpl(const char* name); |
| 39 virtual ~WebThreadImpl(); | 39 ~WebThreadImpl() override; |
| 40 | 40 |
| 41 virtual void postTask(const blink::WebTraceLocation& location, Task* task); | 41 void postTask(const blink::WebTraceLocation& location, Task* task) override; |
| 42 virtual void postDelayedTask(const blink::WebTraceLocation& location, | 42 void postDelayedTask(const blink::WebTraceLocation& location, |
| 43 Task* task, | 43 Task* task, |
| 44 long long delay_ms); | 44 long long delay_ms) override; |
| 45 | 45 |
| 46 virtual void enterRunLoop(); | 46 void enterRunLoop() override; |
| 47 virtual void exitRunLoop(); | 47 void exitRunLoop() override; |
| 48 | 48 |
| 49 base::MessageLoop* message_loop() const { return thread_->message_loop(); } | 49 base::MessageLoop* message_loop() const { return thread_->message_loop(); } |
| 50 | 50 |
| 51 virtual bool isCurrentThread() const; | 51 bool isCurrentThread() const override; |
| 52 virtual blink::PlatformThreadId threadId() const; | 52 blink::PlatformThreadId threadId() const override; |
| 53 | 53 |
| 54 private: | 54 private: |
| 55 scoped_ptr<base::Thread> thread_; | 55 scoped_ptr<base::Thread> thread_; |
| 56 }; | 56 }; |
| 57 | 57 |
| 58 class WebThreadImplForMessageLoop : public WebThreadBase { | 58 class WebThreadImplForMessageLoop : public WebThreadBase { |
| 59 public: | 59 public: |
| 60 explicit WebThreadImplForMessageLoop( | 60 explicit WebThreadImplForMessageLoop( |
| 61 base::MessageLoopProxy* message_loop); | 61 base::MessageLoopProxy* message_loop); |
| 62 virtual ~WebThreadImplForMessageLoop(); | 62 ~WebThreadImplForMessageLoop() override; |
| 63 | 63 |
| 64 virtual void postTask(const blink::WebTraceLocation& location, Task* task); | 64 void postTask(const blink::WebTraceLocation& location, Task* task) override; |
| 65 virtual void postDelayedTask(const blink::WebTraceLocation& location, | 65 void postDelayedTask(const blink::WebTraceLocation& location, |
| 66 Task* task, | 66 Task* task, |
| 67 long long delay_ms); | 67 long long delay_ms) override; |
| 68 | 68 |
| 69 virtual void enterRunLoop(); | 69 void enterRunLoop() override; |
| 70 virtual void exitRunLoop(); | 70 void exitRunLoop() override; |
| 71 | 71 |
| 72 private: | 72 private: |
| 73 virtual bool isCurrentThread() const; | 73 bool isCurrentThread() const override; |
| 74 virtual blink::PlatformThreadId threadId() const; | 74 blink::PlatformThreadId threadId() const override; |
| 75 | 75 |
| 76 scoped_refptr<base::MessageLoopProxy> message_loop_; | 76 scoped_refptr<base::MessageLoopProxy> message_loop_; |
| 77 blink::PlatformThreadId thread_id_; | 77 blink::PlatformThreadId thread_id_; |
| 78 }; | 78 }; |
| 79 | 79 |
| 80 } // namespace html_viewer | 80 } // namespace html_viewer |
| 81 | 81 |
| 82 #endif // MOJO_SERVICES_HTML_VIEWER_WEBTHREAD_IMPL_H_ | 82 #endif // MOJO_SERVICES_HTML_VIEWER_WEBTHREAD_IMPL_H_ |
| OLD | NEW |