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 16 matching lines...) Expand all Loading... |
27 | 27 |
28 // TODO(sky): these includes should not be necessary. Nuke them. | 28 // TODO(sky): these includes should not be necessary. Nuke them. |
29 #if defined(OS_WIN) | 29 #if defined(OS_WIN) |
30 #include "base/message_loop/message_pump_win.h" | 30 #include "base/message_loop/message_pump_win.h" |
31 #elif defined(OS_IOS) | 31 #elif defined(OS_IOS) |
32 #include "base/message_loop/message_pump_io_ios.h" | 32 #include "base/message_loop/message_pump_io_ios.h" |
33 #elif defined(OS_POSIX) | 33 #elif defined(OS_POSIX) |
34 #include "base/message_loop/message_pump_libevent.h" | 34 #include "base/message_loop/message_pump_libevent.h" |
35 #if !defined(OS_MACOSX) && !defined(OS_ANDROID) | 35 #if !defined(OS_MACOSX) && !defined(OS_ANDROID) |
36 | 36 |
37 #if defined(USE_GLIB) && !defined(OS_NACL) | 37 #if defined(USE_AURA) && defined(USE_X11) && !defined(OS_NACL) |
38 #include "base/message_loop/message_pump_glib.h" | 38 #include "base/message_loop/message_pump_x11.h" |
39 #elif !defined(OS_ANDROID_HOST) | 39 #elif !defined(OS_ANDROID_HOST) |
40 #include "base/message_loop/message_pump_glib.h" | 40 #define USE_GTK_MESSAGE_PUMP |
| 41 #include "base/message_loop/message_pump_gtk.h" |
| 42 #if defined(TOOLKIT_GTK) |
| 43 #include "base/message_loop/message_pump_x11.h" |
| 44 #endif |
41 #endif | 45 #endif |
42 | 46 |
43 #endif | 47 #endif |
44 #endif | 48 #endif |
45 | 49 |
46 namespace base { | 50 namespace base { |
47 | 51 |
48 class HistogramBase; | 52 class HistogramBase; |
49 class MessagePumpObserver; | 53 class MessagePumpObserver; |
50 class RunLoop; | 54 class RunLoop; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 // } | 88 // } |
85 // // Process |hr| (the result returned by DoDragDrop()). | 89 // // Process |hr| (the result returned by DoDragDrop()). |
86 // | 90 // |
87 // 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 |
88 // are stable and accessible before calling SetNestableTasksAllowed(true). | 92 // are stable and accessible before calling SetNestableTasksAllowed(true). |
89 // | 93 // |
90 class BASE_EXPORT MessageLoop : public MessagePump::Delegate { | 94 class BASE_EXPORT MessageLoop : public MessagePump::Delegate { |
91 public: | 95 public: |
92 #if defined(OS_WIN) | 96 #if defined(OS_WIN) |
93 typedef MessagePumpObserver Observer; | 97 typedef MessagePumpObserver Observer; |
| 98 #elif defined(USE_GTK_MESSAGE_PUMP) |
| 99 typedef MessagePumpGdkObserver Observer; |
94 #endif | 100 #endif |
95 | 101 |
96 // A MessageLoop has a particular type, which indicates the set of | 102 // A MessageLoop has a particular type, which indicates the set of |
97 // asynchronous events it may process in addition to tasks and timers. | 103 // asynchronous events it may process in addition to tasks and timers. |
98 // | 104 // |
99 // TYPE_DEFAULT | 105 // TYPE_DEFAULT |
100 // This type of ML only supports tasks and timers. | 106 // This type of ML only supports tasks and timers. |
101 // | 107 // |
102 // TYPE_UI | 108 // TYPE_UI |
103 // This type of ML also supports native UI events (e.g., Windows messages). | 109 // This type of ML also supports native UI events (e.g., Windows messages). |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 protected: | 406 protected: |
401 | 407 |
402 #if defined(OS_WIN) | 408 #if defined(OS_WIN) |
403 MessagePumpWin* pump_win() { | 409 MessagePumpWin* pump_win() { |
404 return static_cast<MessagePumpWin*>(pump_.get()); | 410 return static_cast<MessagePumpWin*>(pump_.get()); |
405 } | 411 } |
406 #elif defined(OS_POSIX) && !defined(OS_IOS) | 412 #elif defined(OS_POSIX) && !defined(OS_IOS) |
407 MessagePumpLibevent* pump_libevent() { | 413 MessagePumpLibevent* pump_libevent() { |
408 return static_cast<MessagePumpLibevent*>(pump_.get()); | 414 return static_cast<MessagePumpLibevent*>(pump_.get()); |
409 } | 415 } |
| 416 #if defined(TOOLKIT_GTK) |
| 417 friend class MessagePumpX11; |
| 418 MessagePumpX11* pump_gpu() { |
| 419 DCHECK_EQ(TYPE_GPU, type()); |
| 420 return static_cast<MessagePumpX11*>(pump_.get()); |
| 421 } |
| 422 #endif |
410 #endif | 423 #endif |
411 | 424 |
412 scoped_ptr<MessagePump> pump_; | 425 scoped_ptr<MessagePump> pump_; |
413 | 426 |
414 private: | 427 private: |
415 friend class internal::IncomingTaskQueue; | 428 friend class internal::IncomingTaskQueue; |
416 friend class RunLoop; | 429 friend class RunLoop; |
417 | 430 |
418 // Configures various members for the two constructors. | 431 // Configures various members for the two constructors. |
419 void Init(); | 432 void Init(); |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
573 // Please see MessagePumpLibevent for definition. | 586 // Please see MessagePumpLibevent for definition. |
574 bool WatchFileDescriptor( | 587 bool WatchFileDescriptor( |
575 int fd, | 588 int fd, |
576 bool persistent, | 589 bool persistent, |
577 MessagePumpLibevent::Mode mode, | 590 MessagePumpLibevent::Mode mode, |
578 MessagePumpLibevent::FileDescriptorWatcher* controller, | 591 MessagePumpLibevent::FileDescriptorWatcher* controller, |
579 MessagePumpLibevent::Watcher* delegate); | 592 MessagePumpLibevent::Watcher* delegate); |
580 #endif | 593 #endif |
581 | 594 |
582 protected: | 595 protected: |
| 596 #if defined(USE_X11) |
| 597 friend class MessagePumpX11; |
| 598 #endif |
| 599 |
583 #if !defined(OS_MACOSX) && !defined(OS_ANDROID) | 600 #if !defined(OS_MACOSX) && !defined(OS_ANDROID) |
584 // TODO(rvargas): Make this platform independent. | 601 // TODO(rvargas): Make this platform independent. |
585 MessagePumpForUI* pump_ui() { | 602 MessagePumpForUI* pump_ui() { |
586 return static_cast<MessagePumpForUI*>(pump_.get()); | 603 return static_cast<MessagePumpForUI*>(pump_.get()); |
587 } | 604 } |
588 #endif | 605 #endif |
589 }; | 606 }; |
590 | 607 |
591 // Do not add any member variables to MessageLoopForUI! This is important b/c | 608 // Do not add any member variables to MessageLoopForUI! This is important b/c |
592 // MessageLoopForUI is often allocated via MessageLoop(TYPE_UI). Any extra | 609 // MessageLoopForUI is often allocated via MessageLoop(TYPE_UI). Any extra |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
697 | 714 |
698 // 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 |
699 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra | 716 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra |
700 // 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. |
701 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO), | 718 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO), |
702 MessageLoopForIO_should_not_have_extra_member_variables); | 719 MessageLoopForIO_should_not_have_extra_member_variables); |
703 | 720 |
704 } // namespace base | 721 } // namespace base |
705 | 722 |
706 #endif // BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_ | 723 #endif // BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_ |
OLD | NEW |