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 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 | 368 |
369 protected: | 369 protected: |
370 virtual ~TaskObserver(); | 370 virtual ~TaskObserver(); |
371 }; | 371 }; |
372 | 372 |
373 // These functions can only be called on the same thread that |this| is | 373 // These functions can only be called on the same thread that |this| is |
374 // running on. | 374 // running on. |
375 void AddTaskObserver(TaskObserver* task_observer); | 375 void AddTaskObserver(TaskObserver* task_observer); |
376 void RemoveTaskObserver(TaskObserver* task_observer); | 376 void RemoveTaskObserver(TaskObserver* task_observer); |
377 | 377 |
378 #if defined(OS_WIN) | |
379 void set_os_modal_loop(bool os_modal_loop) { | |
380 os_modal_loop_ = os_modal_loop; | |
381 } | |
382 | |
383 bool os_modal_loop() const { | |
384 return os_modal_loop_; | |
385 } | |
386 #endif // OS_WIN | |
387 | |
388 // Can only be called from the thread that owns the MessageLoop. | 378 // Can only be called from the thread that owns the MessageLoop. |
389 bool is_running() const; | 379 bool is_running() const; |
390 | 380 |
391 // Returns true if the message loop has high resolution timers enabled. | 381 // Returns true if the message loop has high resolution timers enabled. |
392 // Provided for testing. | 382 // Provided for testing. |
393 bool HasHighResolutionTasks(); | 383 bool HasHighResolutionTasks(); |
394 | 384 |
395 // Returns true if the message loop is "idle". Provided for testing. | 385 // Returns true if the message loop is "idle". Provided for testing. |
396 bool IsIdleForTesting(); | 386 bool IsIdleForTesting(); |
397 | 387 |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 TaskQueue deferred_non_nestable_work_queue_; | 506 TaskQueue deferred_non_nestable_work_queue_; |
517 | 507 |
518 ObserverList<DestructionObserver> destruction_observers_; | 508 ObserverList<DestructionObserver> destruction_observers_; |
519 | 509 |
520 ObserverList<NestingObserver> nesting_observers_; | 510 ObserverList<NestingObserver> nesting_observers_; |
521 | 511 |
522 // A recursion block that prevents accidentally running additional tasks when | 512 // A recursion block that prevents accidentally running additional tasks when |
523 // insider a (accidentally induced?) nested message pump. | 513 // insider a (accidentally induced?) nested message pump. |
524 bool nestable_tasks_allowed_; | 514 bool nestable_tasks_allowed_; |
525 | 515 |
526 #if defined(OS_WIN) | |
527 // Should be set to true before calling Windows APIs like TrackPopupMenu, etc. | |
528 // which enter a modal message loop. | |
529 bool os_modal_loop_; | |
530 #endif | |
531 | |
532 // pump_factory_.Run() is called to create a message pump for this loop | 516 // pump_factory_.Run() is called to create a message pump for this loop |
533 // if type_ is TYPE_CUSTOM and pump_ is null. | 517 // if type_ is TYPE_CUSTOM and pump_ is null. |
534 MessagePumpFactoryCallback pump_factory_; | 518 MessagePumpFactoryCallback pump_factory_; |
535 | 519 |
536 std::string thread_name_; | 520 std::string thread_name_; |
537 // A profiling histogram showing the counts of various messages and events. | 521 // A profiling histogram showing the counts of various messages and events. |
538 HistogramBase* message_histogram_; | 522 HistogramBase* message_histogram_; |
539 | 523 |
540 RunLoop* run_loop_; | 524 RunLoop* run_loop_; |
541 | 525 |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
697 | 681 |
698 // Do not add any member variables to MessageLoopForIO! This is important b/c | 682 // Do not add any member variables to MessageLoopForIO! This is important b/c |
699 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra | 683 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra |
700 // data that you need should be stored on the MessageLoop's pump_ instance. | 684 // data that you need should be stored on the MessageLoop's pump_ instance. |
701 static_assert(sizeof(MessageLoop) == sizeof(MessageLoopForIO), | 685 static_assert(sizeof(MessageLoop) == sizeof(MessageLoopForIO), |
702 "MessageLoopForIO should not have extra member variables"); | 686 "MessageLoopForIO should not have extra member variables"); |
703 | 687 |
704 } // namespace base | 688 } // namespace base |
705 | 689 |
706 #endif // BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_ | 690 #endif // BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_ |
OLD | NEW |