OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 // | 106 // |
107 MessageLoop* message_loop() const { return message_loop_; } | 107 MessageLoop* message_loop() const { return message_loop_; } |
108 | 108 |
109 // Returns a MessageLoopProxy for this thread. Use the MessageLoopProxy's | 109 // Returns a MessageLoopProxy for this thread. Use the MessageLoopProxy's |
110 // PostTask methods to execute code on the thread. This only returns | 110 // PostTask methods to execute code on the thread. This only returns |
111 // non-NULL after a successful call to Start. After Stop has been called, | 111 // non-NULL after a successful call to Start. After Stop has been called, |
112 // this will return NULL. Callers can hold on to this even after the thread | 112 // this will return NULL. Callers can hold on to this even after the thread |
113 // is gone. | 113 // is gone. |
114 // TODO(sanjeevr): Look into merging MessageLoop and MessageLoopProxy. | 114 // TODO(sanjeevr): Look into merging MessageLoop and MessageLoopProxy. |
115 scoped_refptr<MessageLoopProxy> message_loop_proxy() const { | 115 scoped_refptr<MessageLoopProxy> message_loop_proxy() const { |
116 return message_loop_proxy_; | 116 return message_loop_->message_loop_proxy(); |
117 } | 117 } |
118 | 118 |
119 // Set the name of this thread (for display in debugger too). | 119 // Set the name of this thread (for display in debugger too). |
120 const std::string &thread_name() { return name_; } | 120 const std::string &thread_name() { return name_; } |
121 | 121 |
122 // The native thread handle. | 122 // The native thread handle. |
123 PlatformThreadHandle thread_handle() { return thread_; } | 123 PlatformThreadHandle thread_handle() { return thread_; } |
124 | 124 |
125 // The thread ID. | 125 // The thread ID. |
126 PlatformThreadId thread_id() const { return thread_id_; } | 126 PlatformThreadId thread_id() const { return thread_id_; } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 struct StartupData; | 168 struct StartupData; |
169 StartupData* startup_data_; | 169 StartupData* startup_data_; |
170 | 170 |
171 // The thread's handle. | 171 // The thread's handle. |
172 PlatformThreadHandle thread_; | 172 PlatformThreadHandle thread_; |
173 | 173 |
174 // The thread's message loop. Valid only while the thread is alive. Set | 174 // The thread's message loop. Valid only while the thread is alive. Set |
175 // by the created thread. | 175 // by the created thread. |
176 MessageLoop* message_loop_; | 176 MessageLoop* message_loop_; |
177 | 177 |
178 // A MessageLoopProxy implementation that targets this thread. This can | |
179 // outlive the thread. | |
180 scoped_refptr<MessageLoopProxy> message_loop_proxy_; | |
181 | |
182 // Our thread's ID. | 178 // Our thread's ID. |
183 PlatformThreadId thread_id_; | 179 PlatformThreadId thread_id_; |
184 | 180 |
185 // The name of the thread. Used for debugging purposes. | 181 // The name of the thread. Used for debugging purposes. |
186 std::string name_; | 182 std::string name_; |
187 | 183 |
188 friend class ThreadQuitTask; | 184 friend class ThreadQuitTask; |
189 | 185 |
190 DISALLOW_COPY_AND_ASSIGN(Thread); | 186 DISALLOW_COPY_AND_ASSIGN(Thread); |
191 }; | 187 }; |
192 | 188 |
193 } // namespace base | 189 } // namespace base |
194 | 190 |
195 #endif // BASE_THREAD_H_ | 191 #endif // BASE_THREAD_H_ |
OLD | NEW |