| 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 "mojo/services/html_viewer/webscheduler_impl.h" |
| 12 #include "third_party/WebKit/public/platform/WebThread.h" | 13 #include "third_party/WebKit/public/platform/WebThread.h" |
| 13 | 14 |
| 14 namespace html_viewer { | 15 namespace html_viewer { |
| 15 | 16 |
| 16 class WebThreadBase : public blink::WebThread { | 17 class WebThreadBase : public blink::WebThread { |
| 17 public: | 18 public: |
| 18 virtual ~WebThreadBase(); | 19 virtual ~WebThreadBase(); |
| 19 | 20 |
| 20 virtual void addTaskObserver(TaskObserver* observer); | 21 virtual void addTaskObserver(TaskObserver* observer); |
| 21 virtual void removeTaskObserver(TaskObserver* observer); | 22 virtual void removeTaskObserver(TaskObserver* observer); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 38 ~WebThreadImpl() override; | 39 ~WebThreadImpl() override; |
| 39 | 40 |
| 40 virtual void postTask(const blink::WebTraceLocation& location, Task* task); | 41 virtual void postTask(const blink::WebTraceLocation& location, Task* task); |
| 41 virtual void postDelayedTask(const blink::WebTraceLocation& location, | 42 virtual void postDelayedTask(const blink::WebTraceLocation& location, |
| 42 Task* task, | 43 Task* task, |
| 43 long long delay_ms); | 44 long long delay_ms); |
| 44 | 45 |
| 45 virtual void enterRunLoop(); | 46 virtual void enterRunLoop(); |
| 46 virtual void exitRunLoop(); | 47 virtual void exitRunLoop(); |
| 47 | 48 |
| 49 virtual blink::WebScheduler* scheduler() const; |
| 50 |
| 48 base::MessageLoop* message_loop() const { return thread_->message_loop(); } | 51 base::MessageLoop* message_loop() const { return thread_->message_loop(); } |
| 49 | 52 |
| 50 bool isCurrentThread() const override; | 53 bool isCurrentThread() const override; |
| 51 virtual blink::PlatformThreadId threadId() const; | 54 virtual blink::PlatformThreadId threadId() const; |
| 52 | 55 |
| 53 private: | 56 private: |
| 54 scoped_ptr<base::Thread> thread_; | 57 scoped_ptr<base::Thread> thread_; |
| 58 scoped_ptr<WebSchedulerImpl> web_scheduler_; |
| 55 }; | 59 }; |
| 56 | 60 |
| 57 class WebThreadImplForMessageLoop : public WebThreadBase { | 61 class WebThreadImplForMessageLoop : public WebThreadBase { |
| 58 public: | 62 public: |
| 59 explicit WebThreadImplForMessageLoop( | 63 explicit WebThreadImplForMessageLoop( |
| 60 base::MessageLoopProxy* message_loop); | 64 base::MessageLoopProxy* message_loop); |
| 61 ~WebThreadImplForMessageLoop() override; | 65 ~WebThreadImplForMessageLoop() override; |
| 62 | 66 |
| 63 virtual void postTask(const blink::WebTraceLocation& location, Task* task); | 67 virtual void postTask(const blink::WebTraceLocation& location, Task* task); |
| 64 virtual void postDelayedTask(const blink::WebTraceLocation& location, | 68 virtual void postDelayedTask(const blink::WebTraceLocation& location, |
| 65 Task* task, | 69 Task* task, |
| 66 long long delay_ms); | 70 long long delay_ms); |
| 67 | 71 |
| 68 virtual void enterRunLoop(); | 72 virtual void enterRunLoop(); |
| 69 virtual void exitRunLoop(); | 73 virtual void exitRunLoop(); |
| 70 | 74 |
| 75 virtual blink::WebScheduler* scheduler() const; |
| 76 |
| 71 private: | 77 private: |
| 72 bool isCurrentThread() const override; | 78 bool isCurrentThread() const override; |
| 73 virtual blink::PlatformThreadId threadId() const; | 79 virtual blink::PlatformThreadId threadId() const; |
| 74 | 80 |
| 75 scoped_refptr<base::MessageLoopProxy> message_loop_; | 81 scoped_refptr<base::MessageLoopProxy> message_loop_; |
| 82 scoped_ptr<WebSchedulerImpl> web_scheduler_; |
| 76 blink::PlatformThreadId thread_id_; | 83 blink::PlatformThreadId thread_id_; |
| 77 }; | 84 }; |
| 78 | 85 |
| 79 } // namespace html_viewer | 86 } // namespace html_viewer |
| 80 | 87 |
| 81 #endif // MOJO_SERVICES_HTML_VIEWER_WEBTHREAD_IMPL_H_ | 88 #endif // MOJO_SERVICES_HTML_VIEWER_WEBTHREAD_IMPL_H_ |
| OLD | NEW |