| 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 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 return !high_resolution_timer_expiration_.is_null(); | 308 return !high_resolution_timer_expiration_.is_null(); |
| 309 #else | 309 #else |
| 310 return true; | 310 return true; |
| 311 #endif | 311 #endif |
| 312 } | 312 } |
| 313 | 313 |
| 314 // When we go into high resolution timer mode, we will stay in hi-res mode | 314 // When we go into high resolution timer mode, we will stay in hi-res mode |
| 315 // for at least 1s. | 315 // for at least 1s. |
| 316 static const int kHighResolutionTimerModeLeaseTimeMs = 1000; | 316 static const int kHighResolutionTimerModeLeaseTimeMs = 1000; |
| 317 | 317 |
| 318 // Asserts that the MessageLoop is "idle". |
| 319 void AssertIdle() const; |
| 320 |
| 318 //---------------------------------------------------------------------------- | 321 //---------------------------------------------------------------------------- |
| 319 protected: | 322 protected: |
| 320 struct RunState { | 323 struct RunState { |
| 321 // Used to count how many Run() invocations are on the stack. | 324 // Used to count how many Run() invocations are on the stack. |
| 322 int run_depth; | 325 int run_depth; |
| 323 | 326 |
| 324 // Used to record that Quit() was called, or that we should quit the pump | 327 // Used to record that Quit() was called, or that we should quit the pump |
| 325 // once it becomes idle. | 328 // once it becomes idle. |
| 326 bool quit_received; | 329 bool quit_received; |
| 327 | 330 |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 // insider a (accidentally induced?) nested message pump. | 457 // insider a (accidentally induced?) nested message pump. |
| 455 bool nestable_tasks_allowed_; | 458 bool nestable_tasks_allowed_; |
| 456 | 459 |
| 457 bool exception_restoration_; | 460 bool exception_restoration_; |
| 458 | 461 |
| 459 std::string thread_name_; | 462 std::string thread_name_; |
| 460 // A profiling histogram showing the counts of various messages and events. | 463 // A profiling histogram showing the counts of various messages and events. |
| 461 scoped_refptr<base::Histogram> message_histogram_; | 464 scoped_refptr<base::Histogram> message_histogram_; |
| 462 | 465 |
| 463 // A null terminated list which creates an incoming_queue of tasks that are | 466 // A null terminated list which creates an incoming_queue of tasks that are |
| 464 // aquired under a mutex for processing on this instance's thread. These tasks | 467 // acquired under a mutex for processing on this instance's thread. These task
s |
| 465 // have not yet been sorted out into items for our work_queue_ vs items that | 468 // have not yet been sorted out into items for our work_queue_ vs items that |
| 466 // will be handled by the TimerManager. | 469 // will be handled by the TimerManager. |
| 467 TaskQueue incoming_queue_; | 470 TaskQueue incoming_queue_; |
| 468 // Protect access to incoming_queue_. | 471 // Protect access to incoming_queue_. |
| 469 base::Lock incoming_queue_lock_; | 472 mutable base::Lock incoming_queue_lock_; |
| 470 | 473 |
| 471 RunState* state_; | 474 RunState* state_; |
| 472 | 475 |
| 473 #if defined(OS_WIN) | 476 #if defined(OS_WIN) |
| 474 base::TimeTicks high_resolution_timer_expiration_; | 477 base::TimeTicks high_resolution_timer_expiration_; |
| 475 #endif | 478 #endif |
| 476 | 479 |
| 477 // The next sequence number to use for delayed tasks. | 480 // The next sequence number to use for delayed tasks. |
| 478 int next_sequence_num_; | 481 int next_sequence_num_; |
| 479 | 482 |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 #endif // defined(OS_POSIX) | 600 #endif // defined(OS_POSIX) |
| 598 }; | 601 }; |
| 599 | 602 |
| 600 // Do not add any member variables to MessageLoopForIO! This is important b/c | 603 // Do not add any member variables to MessageLoopForIO! This is important b/c |
| 601 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra | 604 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra |
| 602 // data that you need should be stored on the MessageLoop's pump_ instance. | 605 // data that you need should be stored on the MessageLoop's pump_ instance. |
| 603 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO), | 606 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO), |
| 604 MessageLoopForIO_should_not_have_extra_member_variables); | 607 MessageLoopForIO_should_not_have_extra_member_variables); |
| 605 | 608 |
| 606 #endif // BASE_MESSAGE_LOOP_H_ | 609 #endif // BASE_MESSAGE_LOOP_H_ |
| OLD | NEW |