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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 // A MessageLoop has a particular type, which indicates the set of | 98 // A MessageLoop has a particular type, which indicates the set of |
99 // asynchronous events it may process in addition to tasks and timers. | 99 // asynchronous events it may process in addition to tasks and timers. |
100 // | 100 // |
101 // TYPE_DEFAULT | 101 // TYPE_DEFAULT |
102 // This type of ML only supports tasks and timers. | 102 // This type of ML only supports tasks and timers. |
103 // | 103 // |
104 // TYPE_UI | 104 // TYPE_UI |
105 // This type of ML also supports native UI events (e.g., Windows messages). | 105 // This type of ML also supports native UI events (e.g., Windows messages). |
106 // See also MessageLoopForUI. | 106 // See also MessageLoopForUI. |
107 // | 107 // |
| 108 // TYPE_UI_GPU |
| 109 // This type of ML also supports native UI events for use in the GPU |
| 110 // process. On Linux this will always be an X11 ML (as compared with the |
| 111 // sometimes-GTK ML in the browser). |
| 112 // |
108 // TYPE_IO | 113 // TYPE_IO |
109 // This type of ML also supports asynchronous IO. See also | 114 // This type of ML also supports asynchronous IO. See also |
110 // MessageLoopForIO. | 115 // MessageLoopForIO. |
111 // | 116 // |
112 // TYPE_JAVA | 117 // TYPE_JAVA |
113 // This type of ML is backed by a Java message handler which is responsible | 118 // This type of ML is backed by a Java message handler which is responsible |
114 // for running the tasks added to the ML. This is only for use on Android. | 119 // for running the tasks added to the ML. This is only for use on Android. |
115 // TYPE_JAVA behaves in essence like TYPE_UI, except during construction | 120 // TYPE_JAVA behaves in essence like TYPE_UI, except during construction |
116 // where it does not use the main thread specific pump factory. | 121 // where it does not use the main thread specific pump factory. |
117 // | 122 // |
118 enum Type { | 123 enum Type { |
119 TYPE_DEFAULT, | 124 TYPE_DEFAULT, |
120 TYPE_UI, | 125 TYPE_UI, |
| 126 #if defined(OS_LINUX) |
| 127 TYPE_GPU, |
| 128 #endif |
121 TYPE_IO, | 129 TYPE_IO, |
122 #if defined(OS_ANDROID) | 130 #if defined(OS_ANDROID) |
123 TYPE_JAVA, | 131 TYPE_JAVA, |
124 #endif // defined(OS_ANDROID) | 132 #endif // defined(OS_ANDROID) |
125 }; | 133 }; |
126 | 134 |
127 // Normally, it is not necessary to instantiate a MessageLoop. Instead, it | 135 // Normally, it is not necessary to instantiate a MessageLoop. Instead, it |
128 // is typical to make use of the current thread's MessageLoop instance. | 136 // is typical to make use of the current thread's MessageLoop instance. |
129 explicit MessageLoop(Type type = TYPE_DEFAULT); | 137 explicit MessageLoop(Type type = TYPE_DEFAULT); |
130 virtual ~MessageLoop(); | 138 virtual ~MessageLoop(); |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
550 typedef MessagePumpForUI::MessageFilter MessageFilter; | 558 typedef MessagePumpForUI::MessageFilter MessageFilter; |
551 #endif | 559 #endif |
552 | 560 |
553 MessageLoopForUI() : MessageLoop(TYPE_UI) { | 561 MessageLoopForUI() : MessageLoop(TYPE_UI) { |
554 } | 562 } |
555 | 563 |
556 // Returns the MessageLoopForUI of the current thread. | 564 // Returns the MessageLoopForUI of the current thread. |
557 static MessageLoopForUI* current() { | 565 static MessageLoopForUI* current() { |
558 MessageLoop* loop = MessageLoop::current(); | 566 MessageLoop* loop = MessageLoop::current(); |
559 DCHECK(loop); | 567 DCHECK(loop); |
560 DCHECK_EQ(MessageLoop::TYPE_UI, loop->type()); | 568 // DCHECK_EQ(MessageLoop::TYPE_UI, loop->type()); |
561 return static_cast<MessageLoopForUI*>(loop); | 569 return static_cast<MessageLoopForUI*>(loop); |
562 } | 570 } |
563 | 571 |
564 #if defined(OS_WIN) | 572 #if defined(OS_WIN) |
565 void DidProcessMessage(const MSG& message); | 573 void DidProcessMessage(const MSG& message); |
566 #endif // defined(OS_WIN) | 574 #endif // defined(OS_WIN) |
567 | 575 |
568 #if defined(OS_IOS) | 576 #if defined(OS_IOS) |
569 // On iOS, the main message loop cannot be Run(). Instead call Attach(), | 577 // On iOS, the main message loop cannot be Run(). Instead call Attach(), |
570 // which connects this MessageLoop to the UI thread's CFRunLoop and allows | 578 // which connects this MessageLoop to the UI thread's CFRunLoop and allows |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
710 | 718 |
711 // Do not add any member variables to MessageLoopForIO! This is important b/c | 719 // Do not add any member variables to MessageLoopForIO! This is important b/c |
712 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra | 720 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra |
713 // data that you need should be stored on the MessageLoop's pump_ instance. | 721 // data that you need should be stored on the MessageLoop's pump_ instance. |
714 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO), | 722 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO), |
715 MessageLoopForIO_should_not_have_extra_member_variables); | 723 MessageLoopForIO_should_not_have_extra_member_variables); |
716 | 724 |
717 } // namespace base | 725 } // namespace base |
718 | 726 |
719 #endif // BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_ | 727 #endif // BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_ |
OLD | NEW |