OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_THREADING_THREAD_H_ | 5 #ifndef BASE_THREADING_THREAD_H_ |
6 #define BASE_THREADING_THREAD_H_ | 6 #define BASE_THREADING_THREAD_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 | 238 |
239 // Returns the thread ID. Should not be called before the first Start*() | 239 // Returns the thread ID. Should not be called before the first Start*() |
240 // call. Keeps on returning the same ID even after a Stop() call. The next | 240 // call. Keeps on returning the same ID even after a Stop() call. The next |
241 // Start*() call renews the ID. | 241 // Start*() call renews the ID. |
242 // | 242 // |
243 // WARNING: This function will block if the thread hasn't started yet. | 243 // WARNING: This function will block if the thread hasn't started yet. |
244 // | 244 // |
245 // This method is thread-safe. | 245 // This method is thread-safe. |
246 PlatformThreadId GetThreadId() const; | 246 PlatformThreadId GetThreadId() const; |
247 | 247 |
| 248 // Returns the current thread handle. If called before Start*() returns or |
| 249 // after Stop() returns, an empty thread handle will be returned. |
| 250 // |
| 251 // This method is thread-safe. |
| 252 // |
| 253 // TODO(robliao): Remove this when it no longer needs to be temporarily |
| 254 // exposed for http://crbug.com/717380. |
| 255 PlatformThreadHandle GetThreadHandle() const; |
| 256 |
248 // Returns true if the thread has been started, and not yet stopped. | 257 // Returns true if the thread has been started, and not yet stopped. |
249 bool IsRunning() const; | 258 bool IsRunning() const; |
250 | 259 |
251 protected: | 260 protected: |
252 // Called just prior to starting the message loop | 261 // Called just prior to starting the message loop |
253 virtual void Init() {} | 262 virtual void Init() {} |
254 | 263 |
255 // Called to start the run loop | 264 // Called to start the run loop |
256 virtual void Run(RunLoop* run_loop); | 265 virtual void Run(RunLoop* run_loop); |
257 | 266 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 // This class is not thread-safe, use this to verify access from the owning | 344 // This class is not thread-safe, use this to verify access from the owning |
336 // sequence of the Thread. | 345 // sequence of the Thread. |
337 SequenceChecker owning_sequence_checker_; | 346 SequenceChecker owning_sequence_checker_; |
338 | 347 |
339 DISALLOW_COPY_AND_ASSIGN(Thread); | 348 DISALLOW_COPY_AND_ASSIGN(Thread); |
340 }; | 349 }; |
341 | 350 |
342 } // namespace base | 351 } // namespace base |
343 | 352 |
344 #endif // BASE_THREADING_THREAD_H_ | 353 #endif // BASE_THREADING_THREAD_H_ |
OLD | NEW |