| 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 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 pump_->SetTimerSlack(timer_slack); | 284 pump_->SetTimerSlack(timer_slack); |
| 285 } | 285 } |
| 286 | 286 |
| 287 // Returns true if this loop is |type|. This allows subclasses (especially | 287 // Returns true if this loop is |type|. This allows subclasses (especially |
| 288 // those in tests) to specialize how they are identified. | 288 // those in tests) to specialize how they are identified. |
| 289 virtual bool IsType(Type type) const; | 289 virtual bool IsType(Type type) const; |
| 290 | 290 |
| 291 // Returns the type passed to the constructor. | 291 // Returns the type passed to the constructor. |
| 292 Type type() const { return type_; } | 292 Type type() const { return type_; } |
| 293 | 293 |
| 294 // Optional call to connect the thread name with this loop. | 294 // Returns the name of the thread this message loop is bound to. |
| 295 void set_thread_name(const std::string& thread_name) { | 295 std::string GetThreadName() const; |
| 296 DCHECK(thread_name_.empty()) << "Should not rename this thread!"; | |
| 297 thread_name_ = thread_name; | |
| 298 } | |
| 299 const std::string& thread_name() const { return thread_name_; } | |
| 300 | 296 |
| 301 // Gets the TaskRunner associated with this message loop. | 297 // Gets the TaskRunner associated with this message loop. |
| 302 const scoped_refptr<SingleThreadTaskRunner>& task_runner() { | 298 const scoped_refptr<SingleThreadTaskRunner>& task_runner() { |
| 303 return task_runner_; | 299 return task_runner_; |
| 304 } | 300 } |
| 305 | 301 |
| 306 // Sets a new TaskRunner for this message loop. The message loop must already | 302 // Sets a new TaskRunner for this message loop. The message loop must already |
| 307 // have been bound to a thread prior to this call, and the task runner must | 303 // have been bound to a thread prior to this call, and the task runner must |
| 308 // belong to that thread. Note that changing the task runner will also affect | 304 // belong to that thread. Note that changing the task runner will also affect |
| 309 // the ThreadTaskRunnerHandle for the target thread. Must be called on the | 305 // the ThreadTaskRunnerHandle for the target thread. Must be called on the |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 526 #if defined(OS_WIN) | 522 #if defined(OS_WIN) |
| 527 // Should be set to true before calling Windows APIs like TrackPopupMenu, etc. | 523 // Should be set to true before calling Windows APIs like TrackPopupMenu, etc. |
| 528 // which enter a modal message loop. | 524 // which enter a modal message loop. |
| 529 bool os_modal_loop_; | 525 bool os_modal_loop_; |
| 530 #endif | 526 #endif |
| 531 | 527 |
| 532 // pump_factory_.Run() is called to create a message pump for this loop | 528 // pump_factory_.Run() is called to create a message pump for this loop |
| 533 // if type_ is TYPE_CUSTOM and pump_ is null. | 529 // if type_ is TYPE_CUSTOM and pump_ is null. |
| 534 MessagePumpFactoryCallback pump_factory_; | 530 MessagePumpFactoryCallback pump_factory_; |
| 535 | 531 |
| 536 std::string thread_name_; | |
| 537 // A profiling histogram showing the counts of various messages and events. | 532 // A profiling histogram showing the counts of various messages and events. |
| 538 HistogramBase* message_histogram_; | 533 HistogramBase* message_histogram_; |
| 539 | 534 |
| 540 RunLoop* run_loop_; | 535 RunLoop* run_loop_; |
| 541 | 536 |
| 542 ObserverList<TaskObserver> task_observers_; | 537 ObserverList<TaskObserver> task_observers_; |
| 543 | 538 |
| 544 debug::TaskAnnotator task_annotator_; | 539 debug::TaskAnnotator task_annotator_; |
| 545 | 540 |
| 546 scoped_refptr<internal::IncomingTaskQueue> incoming_task_queue_; | 541 scoped_refptr<internal::IncomingTaskQueue> incoming_task_queue_; |
| 547 | 542 |
| 548 // A task runner which we haven't bound to a thread yet. | 543 // A task runner which we haven't bound to a thread yet. |
| 549 scoped_refptr<internal::MessageLoopTaskRunner> unbound_task_runner_; | 544 scoped_refptr<internal::MessageLoopTaskRunner> unbound_task_runner_; |
| 550 | 545 |
| 551 // The task runner associated with this message loop. | 546 // The task runner associated with this message loop. |
| 552 scoped_refptr<SingleThreadTaskRunner> task_runner_; | 547 scoped_refptr<SingleThreadTaskRunner> task_runner_; |
| 553 std::unique_ptr<ThreadTaskRunnerHandle> thread_task_runner_handle_; | 548 std::unique_ptr<ThreadTaskRunnerHandle> thread_task_runner_handle_; |
| 554 | 549 |
| 550 // Id of the thread this message loop is bound to. |
| 551 PlatformThreadId thread_id_; |
| 552 |
| 555 template <class T, class R> friend class base::subtle::DeleteHelperInternal; | 553 template <class T, class R> friend class base::subtle::DeleteHelperInternal; |
| 556 template <class T, class R> friend class base::subtle::ReleaseHelperInternal; | 554 template <class T, class R> friend class base::subtle::ReleaseHelperInternal; |
| 557 | 555 |
| 558 void DeleteSoonInternal(const tracked_objects::Location& from_here, | 556 void DeleteSoonInternal(const tracked_objects::Location& from_here, |
| 559 void(*deleter)(const void*), | 557 void(*deleter)(const void*), |
| 560 const void* object); | 558 const void* object); |
| 561 void ReleaseSoonInternal(const tracked_objects::Location& from_here, | 559 void ReleaseSoonInternal(const tracked_objects::Location& from_here, |
| 562 void(*releaser)(const void*), | 560 void(*releaser)(const void*), |
| 563 const void* object); | 561 const void* object); |
| 564 | 562 |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 697 | 695 |
| 698 // Do not add any member variables to MessageLoopForIO! This is important b/c | 696 // Do not add any member variables to MessageLoopForIO! This is important b/c |
| 699 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra | 697 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra |
| 700 // data that you need should be stored on the MessageLoop's pump_ instance. | 698 // data that you need should be stored on the MessageLoop's pump_ instance. |
| 701 static_assert(sizeof(MessageLoop) == sizeof(MessageLoopForIO), | 699 static_assert(sizeof(MessageLoop) == sizeof(MessageLoopForIO), |
| 702 "MessageLoopForIO should not have extra member variables"); | 700 "MessageLoopForIO should not have extra member variables"); |
| 703 | 701 |
| 704 } // namespace base | 702 } // namespace base |
| 705 | 703 |
| 706 #endif // BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_ | 704 #endif // BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_ |
| OLD | NEW |