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 <queue> | 8 #include <queue> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 | 543 |
544 //----------------------------------------------------------------------------- | 544 //----------------------------------------------------------------------------- |
545 // MessageLoopForUI extends MessageLoop with methods that are particular to a | 545 // MessageLoopForUI extends MessageLoop with methods that are particular to a |
546 // MessageLoop instantiated with TYPE_UI. | 546 // MessageLoop instantiated with TYPE_UI. |
547 // | 547 // |
548 // This class is typically used like so: | 548 // This class is typically used like so: |
549 // MessageLoopForUI::current()->...call some method... | 549 // MessageLoopForUI::current()->...call some method... |
550 // | 550 // |
551 class BASE_EXPORT MessageLoopForUI : public MessageLoop { | 551 class BASE_EXPORT MessageLoopForUI : public MessageLoop { |
552 public: | 552 public: |
553 #if defined(OS_WIN) | |
554 typedef MessagePumpForUI::MessageFilter MessageFilter; | |
555 #endif | |
556 | |
557 MessageLoopForUI() : MessageLoop(TYPE_UI) { | 553 MessageLoopForUI() : MessageLoop(TYPE_UI) { |
558 } | 554 } |
559 | 555 |
560 // Returns the MessageLoopForUI of the current thread. | 556 // Returns the MessageLoopForUI of the current thread. |
561 static MessageLoopForUI* current() { | 557 static MessageLoopForUI* current() { |
562 MessageLoop* loop = MessageLoop::current(); | 558 MessageLoop* loop = MessageLoop::current(); |
563 DCHECK(loop); | 559 DCHECK(loop); |
564 DCHECK_EQ(MessageLoop::TYPE_UI, loop->type()); | 560 DCHECK_EQ(MessageLoop::TYPE_UI, loop->type()); |
565 return static_cast<MessageLoopForUI*>(loop); | 561 return static_cast<MessageLoopForUI*>(loop); |
566 } | 562 } |
(...skipping 18 matching lines...) Expand all Loading... |
585 #endif | 581 #endif |
586 | 582 |
587 #if !defined(OS_NACL) && (defined(TOOLKIT_GTK) || defined(USE_OZONE) || \ | 583 #if !defined(OS_NACL) && (defined(TOOLKIT_GTK) || defined(USE_OZONE) || \ |
588 defined(OS_WIN) || defined(USE_X11)) | 584 defined(OS_WIN) || defined(USE_X11)) |
589 // Please see message_pump_win/message_pump_glib for definitions of these | 585 // Please see message_pump_win/message_pump_glib for definitions of these |
590 // methods. | 586 // methods. |
591 void AddObserver(Observer* observer); | 587 void AddObserver(Observer* observer); |
592 void RemoveObserver(Observer* observer); | 588 void RemoveObserver(Observer* observer); |
593 #endif | 589 #endif |
594 | 590 |
595 #if defined(OS_WIN) | |
596 // Plese see MessagePumpForUI for definitions of this method. | |
597 void SetMessageFilter(scoped_ptr<MessageFilter> message_filter) { | |
598 pump_ui()->SetMessageFilter(message_filter.Pass()); | |
599 } | |
600 #endif | |
601 | |
602 protected: | 591 protected: |
603 #if defined(USE_X11) | 592 #if defined(USE_X11) |
604 friend class MessagePumpX11; | 593 friend class MessagePumpX11; |
605 #endif | 594 #endif |
606 #if defined(USE_OZONE) && !defined(OS_NACL) | 595 #if defined(USE_OZONE) && !defined(OS_NACL) |
607 friend class MessagePumpOzone; | 596 friend class MessagePumpOzone; |
608 #endif | 597 #endif |
609 | 598 |
610 #if !defined(OS_MACOSX) && !defined(OS_ANDROID) | 599 #if !defined(OS_MACOSX) && !defined(OS_ANDROID) |
611 // TODO(rvargas): Make this platform independent. | 600 // TODO(rvargas): Make this platform independent. |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
724 | 713 |
725 // Do not add any member variables to MessageLoopForIO! This is important b/c | 714 // Do not add any member variables to MessageLoopForIO! This is important b/c |
726 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra | 715 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra |
727 // data that you need should be stored on the MessageLoop's pump_ instance. | 716 // data that you need should be stored on the MessageLoop's pump_ instance. |
728 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO), | 717 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO), |
729 MessageLoopForIO_should_not_have_extra_member_variables); | 718 MessageLoopForIO_should_not_have_extra_member_variables); |
730 | 719 |
731 } // namespace base | 720 } // namespace base |
732 | 721 |
733 #endif // BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_ | 722 #endif // BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_ |
OLD | NEW |