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 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 // insider a (accidentally induced?) nested message pump. | 458 // insider a (accidentally induced?) nested message pump. |
459 bool nestable_tasks_allowed_; | 459 bool nestable_tasks_allowed_; |
460 | 460 |
461 bool exception_restoration_; | 461 bool exception_restoration_; |
462 | 462 |
463 std::string thread_name_; | 463 std::string thread_name_; |
464 // A profiling histogram showing the counts of various messages and events. | 464 // A profiling histogram showing the counts of various messages and events. |
465 scoped_refptr<base::Histogram> message_histogram_; | 465 scoped_refptr<base::Histogram> message_histogram_; |
466 | 466 |
467 // A null terminated list which creates an incoming_queue of tasks that are | 467 // A null terminated list which creates an incoming_queue of tasks that are |
468 // acquired under a mutex for processing on this instance's thread. These task
s | 468 // acquired under a mutex for processing on this instance's thread. These |
469 // have not yet been sorted out into items for our work_queue_ vs items that | 469 // tasks have not yet been sorted out into items for our work_queue_ vs |
470 // will be handled by the TimerManager. | 470 // items that will be handled by the TimerManager. |
471 TaskQueue incoming_queue_; | 471 TaskQueue incoming_queue_; |
472 // Protect access to incoming_queue_. | 472 // Protect access to incoming_queue_. |
473 mutable base::Lock incoming_queue_lock_; | 473 mutable base::Lock incoming_queue_lock_; |
474 | 474 |
475 RunState* state_; | 475 RunState* state_; |
476 | 476 |
477 #if defined(OS_WIN) | 477 #if defined(OS_WIN) |
478 base::TimeTicks high_resolution_timer_expiration_; | 478 base::TimeTicks high_resolution_timer_expiration_; |
479 #endif | 479 #endif |
480 | 480 |
(...skipping 21 matching lines...) Expand all Loading... |
502 static MessageLoopForUI* current() { | 502 static MessageLoopForUI* current() { |
503 MessageLoop* loop = MessageLoop::current(); | 503 MessageLoop* loop = MessageLoop::current(); |
504 DCHECK_EQ(MessageLoop::TYPE_UI, loop->type()); | 504 DCHECK_EQ(MessageLoop::TYPE_UI, loop->type()); |
505 return static_cast<MessageLoopForUI*>(loop); | 505 return static_cast<MessageLoopForUI*>(loop); |
506 } | 506 } |
507 | 507 |
508 #if defined(OS_WIN) | 508 #if defined(OS_WIN) |
509 void DidProcessMessage(const MSG& message); | 509 void DidProcessMessage(const MSG& message); |
510 #endif // defined(OS_WIN) | 510 #endif // defined(OS_WIN) |
511 | 511 |
512 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 512 #if defined(USE_X11) |
513 Display* get_display(); | 513 // Returns the Xlib Display that backs the MessagePump for this MessageLoop. |
514 #endif | 514 // |
| 515 // This allows for raw access to the X11 server in situations where our |
| 516 // abstractions do not provide enough power. |
| 517 // |
| 518 // Be careful how this is used. The MessagePump in general expects |
| 519 // exclusive access to the Display. Calling things like XNextEvent() will |
| 520 // likely break things in subtle, hard to detect, ways. |
| 521 Display* GetDisplay(); |
| 522 #endif // defined(OS_X11) |
515 | 523 |
516 #if !defined(OS_MACOSX) | 524 #if !defined(OS_MACOSX) |
517 // Please see message_pump_win/message_pump_glib for definitions of these | 525 // Please see message_pump_win/message_pump_glib for definitions of these |
518 // methods. | 526 // methods. |
519 void AddObserver(Observer* observer); | 527 void AddObserver(Observer* observer); |
520 void RemoveObserver(Observer* observer); | 528 void RemoveObserver(Observer* observer); |
521 void Run(Dispatcher* dispatcher); | 529 void Run(Dispatcher* dispatcher); |
522 | 530 |
523 protected: | 531 protected: |
524 // TODO(rvargas): Make this platform independent. | 532 // TODO(rvargas): Make this platform independent. |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
605 #endif // defined(OS_POSIX) | 613 #endif // defined(OS_POSIX) |
606 }; | 614 }; |
607 | 615 |
608 // Do not add any member variables to MessageLoopForIO! This is important b/c | 616 // Do not add any member variables to MessageLoopForIO! This is important b/c |
609 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra | 617 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra |
610 // data that you need should be stored on the MessageLoop's pump_ instance. | 618 // data that you need should be stored on the MessageLoop's pump_ instance. |
611 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO), | 619 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO), |
612 MessageLoopForIO_should_not_have_extra_member_variables); | 620 MessageLoopForIO_should_not_have_extra_member_variables); |
613 | 621 |
614 #endif // BASE_MESSAGE_LOOP_H_ | 622 #endif // BASE_MESSAGE_LOOP_H_ |
OLD | NEW |