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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 // MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current()); | 86 // MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current()); |
87 // hr = DoDragDrop(...); // Implicitly runs a modal message loop. | 87 // hr = DoDragDrop(...); // Implicitly runs a modal message loop. |
88 // } | 88 // } |
89 // // Process |hr| (the result returned by DoDragDrop()). | 89 // // Process |hr| (the result returned by DoDragDrop()). |
90 // | 90 // |
91 // Please be SURE your task is reentrant (nestable) and all global variables | 91 // Please be SURE your task is reentrant (nestable) and all global variables |
92 // are stable and accessible before calling SetNestableTasksAllowed(true). | 92 // are stable and accessible before calling SetNestableTasksAllowed(true). |
93 // | 93 // |
94 class BASE_EXPORT MessageLoop : public MessagePump::Delegate { | 94 class BASE_EXPORT MessageLoop : public MessagePump::Delegate { |
95 public: | 95 public: |
96 | 96 #if defined(OS_WIN) |
97 #if defined(USE_AURA) | |
98 typedef MessagePumpObserver Observer; | 97 typedef MessagePumpObserver Observer; |
99 #elif defined(USE_GTK_MESSAGE_PUMP) | 98 #elif defined(USE_GTK_MESSAGE_PUMP) |
100 typedef MessagePumpGdkObserver Observer; | 99 typedef MessagePumpGdkObserver Observer; |
101 #endif | 100 #endif |
102 | 101 |
103 // A MessageLoop has a particular type, which indicates the set of | 102 // A MessageLoop has a particular type, which indicates the set of |
104 // asynchronous events it may process in addition to tasks and timers. | 103 // asynchronous events it may process in addition to tasks and timers. |
105 // | 104 // |
106 // TYPE_DEFAULT | 105 // TYPE_DEFAULT |
107 // This type of ML only supports tasks and timers. | 106 // This type of ML only supports tasks and timers. |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
570 void Attach(); | 569 void Attach(); |
571 #endif | 570 #endif |
572 | 571 |
573 #if defined(OS_ANDROID) | 572 #if defined(OS_ANDROID) |
574 // On Android, the UI message loop is handled by Java side. So Run() should | 573 // On Android, the UI message loop is handled by Java side. So Run() should |
575 // never be called. Instead use Start(), which will forward all the native UI | 574 // never be called. Instead use Start(), which will forward all the native UI |
576 // events to the Java message loop. | 575 // events to the Java message loop. |
577 void Start(); | 576 void Start(); |
578 #endif | 577 #endif |
579 | 578 |
580 #if !defined(OS_NACL) && (defined(TOOLKIT_GTK) || \ | 579 #if !defined(OS_NACL) && defined(OS_WIN) |
581 defined(OS_WIN) || defined(USE_X11)) | 580 // Please see message_pump_win for definitions of these methods. |
582 // Please see message_pump_win/message_pump_glib for definitions of these | |
583 // methods. | |
584 void AddObserver(Observer* observer); | 581 void AddObserver(Observer* observer); |
585 void RemoveObserver(Observer* observer); | 582 void RemoveObserver(Observer* observer); |
586 #endif | 583 #endif |
587 | 584 |
588 #if defined(USE_OZONE) | 585 #if defined(USE_OZONE) |
589 // Please see MessagePumpLibevent for definition. | 586 // Please see MessagePumpLibevent for definition. |
590 bool WatchFileDescriptor( | 587 bool WatchFileDescriptor( |
591 int fd, | 588 int fd, |
592 bool persistent, | 589 bool persistent, |
593 MessagePumpLibevent::Mode mode, | 590 MessagePumpLibevent::Mode mode, |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
717 | 714 |
718 // Do not add any member variables to MessageLoopForIO! This is important b/c | 715 // Do not add any member variables to MessageLoopForIO! This is important b/c |
719 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra | 716 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra |
720 // data that you need should be stored on the MessageLoop's pump_ instance. | 717 // data that you need should be stored on the MessageLoop's pump_ instance. |
721 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO), | 718 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO), |
722 MessageLoopForIO_should_not_have_extra_member_variables); | 719 MessageLoopForIO_should_not_have_extra_member_variables); |
723 | 720 |
724 } // namespace base | 721 } // namespace base |
725 | 722 |
726 #endif // BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_ | 723 #endif // BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_ |
OLD | NEW |