OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 BASE_THREAD_H_ | 5 #ifndef BASE_THREAD_H_ |
6 #define BASE_THREAD_H_ | 6 #define BASE_THREAD_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 PlatformThreadId thread_id() const { return thread_id_; } | 107 PlatformThreadId thread_id() const { return thread_id_; } |
108 | 108 |
109 // Returns true if the thread has been started, and not yet stopped. | 109 // Returns true if the thread has been started, and not yet stopped. |
110 // When a thread is running, the thread_id_ is non-zero. | 110 // When a thread is running, the thread_id_ is non-zero. |
111 bool IsRunning() const { return thread_id_ != 0; } | 111 bool IsRunning() const { return thread_id_ != 0; } |
112 | 112 |
113 protected: | 113 protected: |
114 // Called just prior to starting the message loop | 114 // Called just prior to starting the message loop |
115 virtual void Init() {} | 115 virtual void Init() {} |
116 | 116 |
| 117 // Called to start the message loop |
| 118 virtual void Run(MessageLoop* message_loop); |
| 119 |
117 // Called just after the message loop ends | 120 // Called just after the message loop ends |
118 virtual void CleanUp() {} | 121 virtual void CleanUp() {} |
119 | 122 |
120 static void SetThreadWasQuitProperly(bool flag); | 123 static void SetThreadWasQuitProperly(bool flag); |
121 static bool GetThreadWasQuitProperly(); | 124 static bool GetThreadWasQuitProperly(); |
122 | 125 |
123 void set_message_loop(MessageLoop* message_loop) { | 126 void set_message_loop(MessageLoop* message_loop) { |
124 message_loop_ = message_loop; | 127 message_loop_ = message_loop; |
125 } | 128 } |
126 | 129 |
(...skipping 23 matching lines...) Expand all Loading... |
150 std::string name_; | 153 std::string name_; |
151 | 154 |
152 friend class ThreadQuitTask; | 155 friend class ThreadQuitTask; |
153 | 156 |
154 DISALLOW_COPY_AND_ASSIGN(Thread); | 157 DISALLOW_COPY_AND_ASSIGN(Thread); |
155 }; | 158 }; |
156 | 159 |
157 } // namespace base | 160 } // namespace base |
158 | 161 |
159 #endif // BASE_THREAD_H_ | 162 #endif // BASE_THREAD_H_ |
OLD | NEW |