OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_H_ | 5 #ifndef BASE_MESSAGE_LOOP_H_ |
6 #define BASE_MESSAGE_LOOP_H_ | 6 #define BASE_MESSAGE_LOOP_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <queue> | 9 #include <queue> |
10 #include <string> | 10 #include <string> |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 #endif | 312 #endif |
313 } | 313 } |
314 | 314 |
315 // When we go into high resolution timer mode, we will stay in hi-res mode | 315 // When we go into high resolution timer mode, we will stay in hi-res mode |
316 // for at least 1s. | 316 // for at least 1s. |
317 static const int kHighResolutionTimerModeLeaseTimeMs = 1000; | 317 static const int kHighResolutionTimerModeLeaseTimeMs = 1000; |
318 | 318 |
319 // Asserts that the MessageLoop is "idle". | 319 // Asserts that the MessageLoop is "idle". |
320 void AssertIdle() const; | 320 void AssertIdle() const; |
321 | 321 |
| 322 #if defined(OS_WIN) |
| 323 void set_os_modal_loop(bool os_modal_loop) { |
| 324 os_modal_loop_ = os_modal_loop; |
| 325 } |
| 326 |
| 327 bool os_modal_loop() const { |
| 328 return os_modal_loop_; |
| 329 } |
| 330 #endif // OS_WIN |
| 331 |
322 //---------------------------------------------------------------------------- | 332 //---------------------------------------------------------------------------- |
323 protected: | 333 protected: |
324 struct RunState { | 334 struct RunState { |
325 // Used to count how many Run() invocations are on the stack. | 335 // Used to count how many Run() invocations are on the stack. |
326 int run_depth; | 336 int run_depth; |
327 | 337 |
328 // Used to record that Quit() was called, or that we should quit the pump | 338 // Used to record that Quit() was called, or that we should quit the pump |
329 // once it becomes idle. | 339 // once it becomes idle. |
330 bool quit_received; | 340 bool quit_received; |
331 | 341 |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
469 // tasks have not yet been sorted out into items for our work_queue_ vs | 479 // tasks have not yet been sorted out into items for our work_queue_ vs |
470 // items that will be handled by the TimerManager. | 480 // items that will be handled by the TimerManager. |
471 TaskQueue incoming_queue_; | 481 TaskQueue incoming_queue_; |
472 // Protect access to incoming_queue_. | 482 // Protect access to incoming_queue_. |
473 mutable base::Lock incoming_queue_lock_; | 483 mutable base::Lock incoming_queue_lock_; |
474 | 484 |
475 RunState* state_; | 485 RunState* state_; |
476 | 486 |
477 #if defined(OS_WIN) | 487 #if defined(OS_WIN) |
478 base::TimeTicks high_resolution_timer_expiration_; | 488 base::TimeTicks high_resolution_timer_expiration_; |
| 489 // Should be set to true before calling Windows APIs like TrackPopupMenu, etc |
| 490 // which enter a modal message loop. |
| 491 bool os_modal_loop_; |
479 #endif | 492 #endif |
480 | 493 |
481 // The next sequence number to use for delayed tasks. | 494 // The next sequence number to use for delayed tasks. |
482 int next_sequence_num_; | 495 int next_sequence_num_; |
483 | 496 |
484 ObserverList<TaskObserver> task_observers_; | 497 ObserverList<TaskObserver> task_observers_; |
485 | 498 |
486 DISALLOW_COPY_AND_ASSIGN(MessageLoop); | 499 DISALLOW_COPY_AND_ASSIGN(MessageLoop); |
487 }; | 500 }; |
488 | 501 |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
613 #endif // defined(OS_POSIX) | 626 #endif // defined(OS_POSIX) |
614 }; | 627 }; |
615 | 628 |
616 // Do not add any member variables to MessageLoopForIO! This is important b/c | 629 // Do not add any member variables to MessageLoopForIO! This is important b/c |
617 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra | 630 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra |
618 // data that you need should be stored on the MessageLoop's pump_ instance. | 631 // data that you need should be stored on the MessageLoop's pump_ instance. |
619 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO), | 632 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO), |
620 MessageLoopForIO_should_not_have_extra_member_variables); | 633 MessageLoopForIO_should_not_have_extra_member_variables); |
621 | 634 |
622 #endif // BASE_MESSAGE_LOOP_H_ | 635 #endif // BASE_MESSAGE_LOOP_H_ |
OLD | NEW |