| 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 | |
| 120 // Called just after the message loop ends | 117 // Called just after the message loop ends |
| 121 virtual void CleanUp() {} | 118 virtual void CleanUp() {} |
| 122 | 119 |
| 123 static void SetThreadWasQuitProperly(bool flag); | 120 static void SetThreadWasQuitProperly(bool flag); |
| 124 static bool GetThreadWasQuitProperly(); | 121 static bool GetThreadWasQuitProperly(); |
| 125 | 122 |
| 126 void set_message_loop(MessageLoop* message_loop) { | 123 void set_message_loop(MessageLoop* message_loop) { |
| 127 message_loop_ = message_loop; | 124 message_loop_ = message_loop; |
| 128 } | 125 } |
| 129 | 126 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 153 std::string name_; | 150 std::string name_; |
| 154 | 151 |
| 155 friend class ThreadQuitTask; | 152 friend class ThreadQuitTask; |
| 156 | 153 |
| 157 DISALLOW_COPY_AND_ASSIGN(Thread); | 154 DISALLOW_COPY_AND_ASSIGN(Thread); |
| 158 }; | 155 }; |
| 159 | 156 |
| 160 } // namespace base | 157 } // namespace base |
| 161 | 158 |
| 162 #endif // BASE_THREAD_H_ | 159 #endif // BASE_THREAD_H_ |
| OLD | NEW |