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 24 matching lines...) Expand all Loading... |
35 #include "base/message_loop/message_pump_libevent.h" | 35 #include "base/message_loop/message_pump_libevent.h" |
36 #if !defined(OS_MACOSX) && !defined(OS_ANDROID) | 36 #if !defined(OS_MACOSX) && !defined(OS_ANDROID) |
37 | 37 |
38 #if defined(USE_AURA) && defined(USE_X11) && !defined(OS_NACL) | 38 #if defined(USE_AURA) && defined(USE_X11) && !defined(OS_NACL) |
39 #include "base/message_loop/message_pump_x11.h" | 39 #include "base/message_loop/message_pump_x11.h" |
40 #elif defined(USE_OZONE) && !defined(OS_NACL) | 40 #elif defined(USE_OZONE) && !defined(OS_NACL) |
41 #include "base/message_loop/message_pump_ozone.h" | 41 #include "base/message_loop/message_pump_ozone.h" |
42 #else | 42 #else |
43 #define USE_GTK_MESSAGE_PUMP | 43 #define USE_GTK_MESSAGE_PUMP |
44 #include "base/message_loop/message_pump_gtk.h" | 44 #include "base/message_loop/message_pump_gtk.h" |
| 45 #if defined(TOOLKIT_GTK) |
| 46 #include "base/message_loop/message_pump_x11.h" |
| 47 #endif |
45 #endif | 48 #endif |
46 | 49 |
47 #endif | 50 #endif |
48 #endif | 51 #endif |
49 | 52 |
50 namespace base { | 53 namespace base { |
51 | 54 |
52 class HistogramBase; | 55 class HistogramBase; |
53 class MessagePumpDispatcher; | 56 class MessagePumpDispatcher; |
54 class MessagePumpObserver; | 57 class MessagePumpObserver; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 // A MessageLoop has a particular type, which indicates the set of | 106 // A MessageLoop has a particular type, which indicates the set of |
104 // asynchronous events it may process in addition to tasks and timers. | 107 // asynchronous events it may process in addition to tasks and timers. |
105 // | 108 // |
106 // TYPE_DEFAULT | 109 // TYPE_DEFAULT |
107 // This type of ML only supports tasks and timers. | 110 // This type of ML only supports tasks and timers. |
108 // | 111 // |
109 // TYPE_UI | 112 // TYPE_UI |
110 // This type of ML also supports native UI events (e.g., Windows messages). | 113 // This type of ML also supports native UI events (e.g., Windows messages). |
111 // See also MessageLoopForUI. | 114 // See also MessageLoopForUI. |
112 // | 115 // |
| 116 // TYPE_GPU |
| 117 // This type of ML also supports native UI events for use in the GPU |
| 118 // process. On Linux this will always be an X11 ML (as compared with the |
| 119 // sometimes-GTK ML in the browser process). |
| 120 // |
113 // TYPE_IO | 121 // TYPE_IO |
114 // This type of ML also supports asynchronous IO. See also | 122 // This type of ML also supports asynchronous IO. See also |
115 // MessageLoopForIO. | 123 // MessageLoopForIO. |
116 // | 124 // |
117 // TYPE_JAVA | 125 // TYPE_JAVA |
118 // This type of ML is backed by a Java message handler which is responsible | 126 // This type of ML is backed by a Java message handler which is responsible |
119 // for running the tasks added to the ML. This is only for use on Android. | 127 // for running the tasks added to the ML. This is only for use on Android. |
120 // TYPE_JAVA behaves in essence like TYPE_UI, except during construction | 128 // TYPE_JAVA behaves in essence like TYPE_UI, except during construction |
121 // where it does not use the main thread specific pump factory. | 129 // where it does not use the main thread specific pump factory. |
122 // | 130 // |
123 enum Type { | 131 enum Type { |
124 TYPE_DEFAULT, | 132 TYPE_DEFAULT, |
125 TYPE_UI, | 133 TYPE_UI, |
| 134 #if defined(TOOLKIT_GTK) |
| 135 TYPE_GPU, |
| 136 #endif |
126 TYPE_IO, | 137 TYPE_IO, |
127 #if defined(OS_ANDROID) | 138 #if defined(OS_ANDROID) |
128 TYPE_JAVA, | 139 TYPE_JAVA, |
129 #endif // defined(OS_ANDROID) | 140 #endif // defined(OS_ANDROID) |
130 }; | 141 }; |
131 | 142 |
132 // Normally, it is not necessary to instantiate a MessageLoop. Instead, it | 143 // Normally, it is not necessary to instantiate a MessageLoop. Instead, it |
133 // is typical to make use of the current thread's MessageLoop instance. | 144 // is typical to make use of the current thread's MessageLoop instance. |
134 explicit MessageLoop(Type type = TYPE_DEFAULT); | 145 explicit MessageLoop(Type type = TYPE_DEFAULT); |
135 virtual ~MessageLoop(); | 146 virtual ~MessageLoop(); |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 protected: | 420 protected: |
410 | 421 |
411 #if defined(OS_WIN) | 422 #if defined(OS_WIN) |
412 MessagePumpWin* pump_win() { | 423 MessagePumpWin* pump_win() { |
413 return static_cast<MessagePumpWin*>(pump_.get()); | 424 return static_cast<MessagePumpWin*>(pump_.get()); |
414 } | 425 } |
415 #elif defined(OS_POSIX) && !defined(OS_IOS) | 426 #elif defined(OS_POSIX) && !defined(OS_IOS) |
416 MessagePumpLibevent* pump_libevent() { | 427 MessagePumpLibevent* pump_libevent() { |
417 return static_cast<MessagePumpLibevent*>(pump_.get()); | 428 return static_cast<MessagePumpLibevent*>(pump_.get()); |
418 } | 429 } |
| 430 #if defined(TOOLKIT_GTK) |
| 431 friend class MessagePumpX11; |
| 432 MessagePumpX11* pump_gpu() { |
| 433 DCHECK_EQ(TYPE_GPU, type()); |
| 434 return static_cast<MessagePumpX11*>(pump_.get()); |
| 435 } |
| 436 #endif |
419 #endif | 437 #endif |
420 | 438 |
421 scoped_ptr<MessagePump> pump_; | 439 scoped_ptr<MessagePump> pump_; |
422 | 440 |
423 private: | 441 private: |
424 friend class internal::IncomingTaskQueue; | 442 friend class internal::IncomingTaskQueue; |
425 friend class RunLoop; | 443 friend class RunLoop; |
426 | 444 |
427 // A function to encapsulate all the exception handling capability in the | 445 // A function to encapsulate all the exception handling capability in the |
428 // stacks around the running of a main message loop. It will run the message | 446 // stacks around the running of a main message loop. It will run the message |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
592 void RemoveObserver(Observer* observer); | 610 void RemoveObserver(Observer* observer); |
593 | 611 |
594 #if defined(OS_WIN) | 612 #if defined(OS_WIN) |
595 // Plese see MessagePumpForUI for definitions of this method. | 613 // Plese see MessagePumpForUI for definitions of this method. |
596 void SetMessageFilter(scoped_ptr<MessageFilter> message_filter) { | 614 void SetMessageFilter(scoped_ptr<MessageFilter> message_filter) { |
597 pump_ui()->SetMessageFilter(message_filter.Pass()); | 615 pump_ui()->SetMessageFilter(message_filter.Pass()); |
598 } | 616 } |
599 #endif | 617 #endif |
600 | 618 |
601 protected: | 619 protected: |
602 #if defined(USE_AURA) && defined(USE_X11) && !defined(OS_NACL) | 620 #if defined(USE_X11) |
603 friend class MessagePumpX11; | 621 friend class MessagePumpX11; |
604 #endif | 622 #endif |
605 #if defined(USE_OZONE) && !defined(OS_NACL) | 623 #if defined(USE_OZONE) && !defined(OS_NACL) |
606 friend class MessagePumpOzone; | 624 friend class MessagePumpOzone; |
607 #endif | 625 #endif |
608 | 626 |
609 // TODO(rvargas): Make this platform independent. | 627 // TODO(rvargas): Make this platform independent. |
610 MessagePumpForUI* pump_ui() { | 628 MessagePumpForUI* pump_ui() { |
611 return static_cast<MessagePumpForUI*>(pump_.get()); | 629 return static_cast<MessagePumpForUI*>(pump_.get()); |
612 } | 630 } |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
717 | 735 |
718 // Do not add any member variables to MessageLoopForIO! This is important b/c | 736 // Do not add any member variables to MessageLoopForIO! This is important b/c |
719 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra | 737 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra |
720 // data that you need should be stored on the MessageLoop's pump_ instance. | 738 // data that you need should be stored on the MessageLoop's pump_ instance. |
721 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO), | 739 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO), |
722 MessageLoopForIO_should_not_have_extra_member_variables); | 740 MessageLoopForIO_should_not_have_extra_member_variables); |
723 | 741 |
724 } // namespace base | 742 } // namespace base |
725 | 743 |
726 #endif // BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_ | 744 #endif // BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_ |
OLD | NEW |