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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 just after the message loop ends | 117 // Called just after the message loop ends |
118 virtual void CleanUp() {} | 118 virtual void CleanUp() {} |
119 | 119 |
120 static void SetThreadWasQuitProperly(bool flag); | 120 static void SetThreadWasQuitProperly(bool flag); |
121 static bool GetThreadWasQuitProperly(); | 121 static bool GetThreadWasQuitProperly(); |
122 | 122 |
| 123 void set_message_loop(MessageLoop* message_loop) { |
| 124 message_loop_ = message_loop; |
| 125 } |
| 126 |
123 private: | 127 private: |
124 // PlatformThread::Delegate methods: | 128 // PlatformThread::Delegate methods: |
125 virtual void ThreadMain(); | 129 virtual void ThreadMain(); |
126 | 130 |
127 // We piggy-back on the startup_data_ member to know if we successfully | 131 // We piggy-back on the startup_data_ member to know if we successfully |
128 // started the thread. This way we know that we need to call Join. | 132 // started the thread. This way we know that we need to call Join. |
129 bool thread_was_started() const { return startup_data_ != NULL; } | 133 bool thread_was_started() const { return startup_data_ != NULL; } |
130 | 134 |
131 // Used to pass data to ThreadMain. | 135 // Used to pass data to ThreadMain. |
132 struct StartupData; | 136 struct StartupData; |
(...skipping 13 matching lines...) Expand all Loading... |
146 std::string name_; | 150 std::string name_; |
147 | 151 |
148 friend class ThreadQuitTask; | 152 friend class ThreadQuitTask; |
149 | 153 |
150 DISALLOW_COPY_AND_ASSIGN(Thread); | 154 DISALLOW_COPY_AND_ASSIGN(Thread); |
151 }; | 155 }; |
152 | 156 |
153 } // namespace base | 157 } // namespace base |
154 | 158 |
155 #endif // BASE_THREAD_H_ | 159 #endif // BASE_THREAD_H_ |
OLD | NEW |