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