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 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
573 // which connects this MessageLoop to the UI thread's CFRunLoop and allows | 573 // which connects this MessageLoop to the UI thread's CFRunLoop and allows |
574 // PostTask() to work. | 574 // PostTask() to work. |
575 void Attach(); | 575 void Attach(); |
576 #endif | 576 #endif |
577 | 577 |
578 #if defined(OS_ANDROID) | 578 #if defined(OS_ANDROID) |
579 // On Android, the UI message loop is handled by Java side. So Run() should | 579 // On Android, the UI message loop is handled by Java side. So Run() should |
580 // never be called. Instead use Start(), which will forward all the native UI | 580 // never be called. Instead use Start(), which will forward all the native UI |
581 // events to the Java message loop. | 581 // events to the Java message loop. |
582 void Start(); | 582 void Start(); |
583 #elif !defined(OS_MACOSX) | 583 #endif |
584 | 584 |
| 585 #if !defined(OS_NACL) && (defined(TOOLKIT_GTK) || defined(USE_OZONE) || \ |
| 586 defined(OS_WIN) || defined(USE_X11)) |
585 // Please see message_pump_win/message_pump_glib for definitions of these | 587 // Please see message_pump_win/message_pump_glib for definitions of these |
586 // methods. | 588 // methods. |
587 void AddObserver(Observer* observer); | 589 void AddObserver(Observer* observer); |
588 void RemoveObserver(Observer* observer); | 590 void RemoveObserver(Observer* observer); |
| 591 #endif |
589 | 592 |
590 #if defined(OS_WIN) | 593 #if defined(OS_WIN) |
591 // Plese see MessagePumpForUI for definitions of this method. | 594 // Plese see MessagePumpForUI for definitions of this method. |
592 void SetMessageFilter(scoped_ptr<MessageFilter> message_filter) { | 595 void SetMessageFilter(scoped_ptr<MessageFilter> message_filter) { |
593 pump_ui()->SetMessageFilter(message_filter.Pass()); | 596 pump_ui()->SetMessageFilter(message_filter.Pass()); |
594 } | 597 } |
595 #endif | 598 #endif |
596 | 599 |
597 protected: | 600 protected: |
598 #if defined(USE_X11) | 601 #if defined(USE_X11) |
599 friend class MessagePumpX11; | 602 friend class MessagePumpX11; |
600 #endif | 603 #endif |
601 #if defined(USE_OZONE) && !defined(OS_NACL) | 604 #if defined(USE_OZONE) && !defined(OS_NACL) |
602 friend class MessagePumpOzone; | 605 friend class MessagePumpOzone; |
603 #endif | 606 #endif |
604 | 607 |
| 608 #if !defined(OS_MACOSX) && !defined(OS_ANDROID) |
605 // TODO(rvargas): Make this platform independent. | 609 // TODO(rvargas): Make this platform independent. |
606 MessagePumpForUI* pump_ui() { | 610 MessagePumpForUI* pump_ui() { |
607 return static_cast<MessagePumpForUI*>(pump_.get()); | 611 return static_cast<MessagePumpForUI*>(pump_.get()); |
608 } | 612 } |
609 #endif // !defined(OS_MACOSX) | 613 #endif |
610 }; | 614 }; |
611 | 615 |
612 // Do not add any member variables to MessageLoopForUI! This is important b/c | 616 // Do not add any member variables to MessageLoopForUI! This is important b/c |
613 // MessageLoopForUI is often allocated via MessageLoop(TYPE_UI). Any extra | 617 // MessageLoopForUI is often allocated via MessageLoop(TYPE_UI). Any extra |
614 // 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. |
615 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForUI), | 619 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForUI), |
616 MessageLoopForUI_should_not_have_extra_member_variables); | 620 MessageLoopForUI_should_not_have_extra_member_variables); |
617 | 621 |
618 //----------------------------------------------------------------------------- | 622 //----------------------------------------------------------------------------- |
619 // MessageLoopForIO extends MessageLoop with methods that are particular to a | 623 // MessageLoopForIO extends MessageLoop with methods that are particular to a |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
713 | 717 |
714 // Do not add any member variables to MessageLoopForIO! This is important b/c | 718 // Do not add any member variables to MessageLoopForIO! This is important b/c |
715 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra | 719 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra |
716 // data that you need should be stored on the MessageLoop's pump_ instance. | 720 // data that you need should be stored on the MessageLoop's pump_ instance. |
717 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO), | 721 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO), |
718 MessageLoopForIO_should_not_have_extra_member_variables); | 722 MessageLoopForIO_should_not_have_extra_member_variables); |
719 | 723 |
720 } // namespace base | 724 } // namespace base |
721 | 725 |
722 #endif // BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_ | 726 #endif // BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_ |
OLD | NEW |