Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(107)

Side by Side Diff: base/threading/thread.h

Issue 2484283005: Expose Thread::using_external_message_loop() to subclasses. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | base/threading/thread_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 237
238 // Called just after the message loop ends 238 // Called just after the message loop ends
239 virtual void CleanUp() {} 239 virtual void CleanUp() {}
240 240
241 static void SetThreadWasQuitProperly(bool flag); 241 static void SetThreadWasQuitProperly(bool flag);
242 static bool GetThreadWasQuitProperly(); 242 static bool GetThreadWasQuitProperly();
243 243
244 // Bind this Thread to an existing MessageLoop instead of starting a new one. 244 // Bind this Thread to an existing MessageLoop instead of starting a new one.
245 void SetMessageLoop(MessageLoop* message_loop); 245 void SetMessageLoop(MessageLoop* message_loop);
246 246
247 bool using_external_message_loop() const {
248 return using_external_message_loop_;
249 }
250
247 private: 251 private:
248 #if defined(OS_WIN) 252 #if defined(OS_WIN)
249 enum ComStatus { 253 enum ComStatus {
250 NONE, 254 NONE,
251 STA, 255 STA,
252 MTA, 256 MTA,
253 }; 257 };
254 #endif 258 #endif
255 259
256 // PlatformThread::Delegate methods: 260 // PlatformThread::Delegate methods:
(...skipping 29 matching lines...) Expand all
286 // Protects |id_| which must only be read while it's signaled. 290 // Protects |id_| which must only be read while it's signaled.
287 mutable WaitableEvent id_event_; 291 mutable WaitableEvent id_event_;
288 292
289 // The thread's MessageLoop and RunLoop. Valid only while the thread is alive. 293 // The thread's MessageLoop and RunLoop. Valid only while the thread is alive.
290 // Set by the created thread. 294 // Set by the created thread.
291 MessageLoop* message_loop_ = nullptr; 295 MessageLoop* message_loop_ = nullptr;
292 RunLoop* run_loop_ = nullptr; 296 RunLoop* run_loop_ = nullptr;
293 297
294 // True only if |message_loop_| was externally provided by |SetMessageLoop()| 298 // True only if |message_loop_| was externally provided by |SetMessageLoop()|
295 // in which case this Thread has no underlying |thread_| and should merely 299 // in which case this Thread has no underlying |thread_| and should merely
296 // drop |message_loop_| on Stop(). 300 // drop |message_loop_| on Stop(). In that event, this remains true after
301 // Stop() was invoked so that subclasses can use this state to build their own
302 // cleanup logic as required.
297 bool using_external_message_loop_ = false; 303 bool using_external_message_loop_ = false;
298 304
299 // Stores Options::timer_slack_ until the message loop has been bound to 305 // Stores Options::timer_slack_ until the message loop has been bound to
300 // a thread. 306 // a thread.
301 TimerSlack message_loop_timer_slack_ = TIMER_SLACK_NONE; 307 TimerSlack message_loop_timer_slack_ = TIMER_SLACK_NONE;
302 308
303 // The name of the thread. Used for debugging purposes. 309 // The name of the thread. Used for debugging purposes.
304 const std::string name_; 310 const std::string name_;
305 311
306 // Signaled when the created thread gets ready to use the message loop. 312 // Signaled when the created thread gets ready to use the message loop.
307 mutable WaitableEvent start_event_; 313 mutable WaitableEvent start_event_;
308 314
309 // This class is not thread-safe, use this to verify access from the owning 315 // This class is not thread-safe, use this to verify access from the owning
310 // sequence of the Thread. 316 // sequence of the Thread.
311 SequenceChecker owning_sequence_checker_; 317 SequenceChecker owning_sequence_checker_;
312 318
313 DISALLOW_COPY_AND_ASSIGN(Thread); 319 DISALLOW_COPY_AND_ASSIGN(Thread);
314 }; 320 };
315 321
316 } // namespace base 322 } // namespace base
317 323
318 #endif // BASE_THREADING_THREAD_H_ 324 #endif // BASE_THREADING_THREAD_H_
OLDNEW
« no previous file with comments | « no previous file | base/threading/thread_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698