OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_MESSAGE_LOOP_MESSAGE_LOOP_H_ | 5 #ifndef BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_ |
6 #define BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_ | 6 #define BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <queue> | 9 #include <queue> |
10 #include <string> | 10 #include <string> |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
287 pump_->SetTimerSlack(timer_slack); | 287 pump_->SetTimerSlack(timer_slack); |
288 } | 288 } |
289 | 289 |
290 // Returns true if this loop is |type|. This allows subclasses (especially | 290 // Returns true if this loop is |type|. This allows subclasses (especially |
291 // those in tests) to specialize how they are identified. | 291 // those in tests) to specialize how they are identified. |
292 virtual bool IsType(Type type) const; | 292 virtual bool IsType(Type type) const; |
293 | 293 |
294 // Returns the type passed to the constructor. | 294 // Returns the type passed to the constructor. |
295 Type type() const { return type_; } | 295 Type type() const { return type_; } |
296 | 296 |
297 // Optional call to connect the thread name with this loop. | 297 // Returns the name of the thread this message loop is bound to. |
298 void set_thread_name(const std::string& thread_name) { | 298 const char* GetThreadName() const { return task_runner_->GetThreadName(); } |
jam
2016/05/06 16:50:23
nit: no need to have this wrapper method? i.e. cal
alokp
2016/05/07 04:14:05
Done.
| |
299 DCHECK(thread_name_.empty()) << "Should not rename this thread!"; | |
300 thread_name_ = thread_name; | |
301 } | |
302 const std::string& thread_name() const { return thread_name_; } | |
303 | 299 |
304 // Gets the TaskRunner associated with this message loop. | 300 // Gets the TaskRunner associated with this message loop. |
305 const scoped_refptr<SingleThreadTaskRunner>& task_runner() { | 301 const scoped_refptr<SingleThreadTaskRunner>& task_runner() { |
306 return task_runner_; | 302 return task_runner_; |
307 } | 303 } |
308 | 304 |
309 // Sets a new TaskRunner for this message loop. The message loop must already | 305 // Sets a new TaskRunner for this message loop. The message loop must already |
310 // have been bound to a thread prior to this call, and the task runner must | 306 // have been bound to a thread prior to this call, and the task runner must |
311 // belong to that thread. Note that changing the task runner will also affect | 307 // belong to that thread. Note that changing the task runner will also affect |
312 // the ThreadTaskRunnerHandle for the target thread. Must be called on the | 308 // the ThreadTaskRunnerHandle for the target thread. Must be called on the |
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
706 | 702 |
707 // Do not add any member variables to MessageLoopForIO! This is important b/c | 703 // Do not add any member variables to MessageLoopForIO! This is important b/c |
708 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra | 704 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra |
709 // data that you need should be stored on the MessageLoop's pump_ instance. | 705 // data that you need should be stored on the MessageLoop's pump_ instance. |
710 static_assert(sizeof(MessageLoop) == sizeof(MessageLoopForIO), | 706 static_assert(sizeof(MessageLoop) == sizeof(MessageLoopForIO), |
711 "MessageLoopForIO should not have extra member variables"); | 707 "MessageLoopForIO should not have extra member variables"); |
712 | 708 |
713 } // namespace base | 709 } // namespace base |
714 | 710 |
715 #endif // BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_ | 711 #endif // BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_ |
OLD | NEW |