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