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_IMPL_H_ | 5 #ifndef CONTENT_CHILD_WEBTHREAD_IMPL_H_ |
6 #define CONTENT_CHILD_WEBTHREAD_IMPL_H_ | 6 #define CONTENT_CHILD_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" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 virtual void setSharedTimerFiredFunction( | 57 virtual void setSharedTimerFiredFunction( |
58 SharedTimerFunction timerFunction) OVERRIDE; | 58 SharedTimerFunction timerFunction) OVERRIDE; |
59 virtual void setSharedTimerFireInterval(double interval_seconds) OVERRIDE; | 59 virtual void setSharedTimerFireInterval(double interval_seconds) OVERRIDE; |
60 virtual void stopSharedTimer() OVERRIDE; | 60 virtual void stopSharedTimer() OVERRIDE; |
61 | 61 |
62 private: | 62 private: |
63 void OnTimeout() { | 63 void OnTimeout() { |
64 if (shared_timer_function_) | 64 if (shared_timer_function_) |
65 shared_timer_function_(); | 65 shared_timer_function_(); |
66 } | 66 } |
67 base::OneShotTimer<WebThreadImpl> shared_timer_; | 67 // The shared timer is a scoped_ptr, so it can be deleted on the same |
| 68 // thread that created it. |
| 69 scoped_ptr<base::OneShotTimer<WebThreadImpl> > shared_timer_; |
68 SharedTimerFunction shared_timer_function_; | 70 SharedTimerFunction shared_timer_function_; |
69 | 71 |
70 scoped_ptr<base::Thread> thread_; | 72 scoped_ptr<base::Thread> thread_; |
71 }; | 73 }; |
72 | 74 |
73 class WebThreadImplForMessageLoop : public WebThreadBase { | 75 class WebThreadImplForMessageLoop : public WebThreadBase { |
74 public: | 76 public: |
75 CONTENT_EXPORT explicit WebThreadImplForMessageLoop( | 77 CONTENT_EXPORT explicit WebThreadImplForMessageLoop( |
76 base::MessageLoopProxy* message_loop); | 78 base::MessageLoopProxy* message_loop); |
77 CONTENT_EXPORT virtual ~WebThreadImplForMessageLoop(); | 79 CONTENT_EXPORT virtual ~WebThreadImplForMessageLoop(); |
78 | 80 |
79 virtual void postTask(Task* task) OVERRIDE; | 81 virtual void postTask(Task* task) OVERRIDE; |
80 virtual void postDelayedTask(Task* task, long long delay_ms) OVERRIDE; | 82 virtual void postDelayedTask(Task* task, long long delay_ms) OVERRIDE; |
81 | 83 |
82 virtual void enterRunLoop() OVERRIDE; | 84 virtual void enterRunLoop() OVERRIDE; |
83 virtual void exitRunLoop() OVERRIDE; | 85 virtual void exitRunLoop() OVERRIDE; |
84 | 86 |
85 private: | 87 private: |
86 virtual bool isCurrentThread() const OVERRIDE; | 88 virtual bool isCurrentThread() const OVERRIDE; |
87 scoped_refptr<base::MessageLoopProxy> message_loop_; | 89 scoped_refptr<base::MessageLoopProxy> message_loop_; |
88 }; | 90 }; |
89 | 91 |
90 } // namespace content | 92 } // namespace content |
91 | 93 |
92 #endif // CONTENT_CHILD_WEBTHREAD_IMPL_H_ | 94 #endif // CONTENT_CHILD_WEBTHREAD_IMPL_H_ |
OLD | NEW |