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 <queue> | 8 #include <queue> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 Type type() const { return type_; } | 288 Type type() const { return type_; } |
289 | 289 |
290 // Optional call to connect the thread name with this loop. | 290 // Optional call to connect the thread name with this loop. |
291 void set_thread_name(const std::string& thread_name) { | 291 void set_thread_name(const std::string& thread_name) { |
292 DCHECK(thread_name_.empty()) << "Should not rename this thread!"; | 292 DCHECK(thread_name_.empty()) << "Should not rename this thread!"; |
293 thread_name_ = thread_name; | 293 thread_name_ = thread_name; |
294 } | 294 } |
295 const std::string& thread_name() const { return thread_name_; } | 295 const std::string& thread_name() const { return thread_name_; } |
296 | 296 |
297 // Gets the message loop proxy associated with this message loop. | 297 // Gets the message loop proxy associated with this message loop. |
| 298 // |
| 299 // NOTE: Deprecated; prefer task_runner() and the TaskRunner interfaces |
298 scoped_refptr<MessageLoopProxy> message_loop_proxy() { | 300 scoped_refptr<MessageLoopProxy> message_loop_proxy() { |
299 return message_loop_proxy_; | 301 return message_loop_proxy_; |
300 } | 302 } |
301 | 303 |
| 304 // Gets the TaskRunner associated with this message loop. |
| 305 scoped_refptr<SingleThreadTaskRunner> task_runner() { |
| 306 return message_loop_proxy_; |
| 307 } |
| 308 |
302 // Enables or disables the recursive task processing. This happens in the case | 309 // Enables or disables the recursive task processing. This happens in the case |
303 // of recursive message loops. Some unwanted message loop may occurs when | 310 // of recursive message loops. Some unwanted message loop may occurs when |
304 // using common controls or printer functions. By default, recursive task | 311 // using common controls or printer functions. By default, recursive task |
305 // processing is disabled. | 312 // processing is disabled. |
306 // | 313 // |
307 // Please utilize |ScopedNestableTaskAllower| instead of calling these methods | 314 // Please utilize |ScopedNestableTaskAllower| instead of calling these methods |
308 // directly. In general nestable message loops are to be avoided. They are | 315 // directly. In general nestable message loops are to be avoided. They are |
309 // dangerous and difficult to get right, so please use with extreme caution. | 316 // dangerous and difficult to get right, so please use with extreme caution. |
310 // | 317 // |
311 // The specific case where tasks get queued is: | 318 // The specific case where tasks get queued is: |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
646 | 653 |
647 // Do not add any member variables to MessageLoopForIO! This is important b/c | 654 // Do not add any member variables to MessageLoopForIO! This is important b/c |
648 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra | 655 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra |
649 // data that you need should be stored on the MessageLoop's pump_ instance. | 656 // data that you need should be stored on the MessageLoop's pump_ instance. |
650 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO), | 657 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO), |
651 MessageLoopForIO_should_not_have_extra_member_variables); | 658 MessageLoopForIO_should_not_have_extra_member_variables); |
652 | 659 |
653 } // namespace base | 660 } // namespace base |
654 | 661 |
655 #endif // BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_ | 662 #endif // BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_ |
OLD | NEW |