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 |
11 #include "base/base_export.h" | 11 #include "base/base_export.h" |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/callback_forward.h" | 13 #include "base/callback_forward.h" |
14 #include "base/location.h" | 14 #include "base/location.h" |
15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
17 #include "base/message_loop/incoming_task_queue.h" | 17 #include "base/message_loop/incoming_task_queue.h" |
18 #include "base/message_loop/message_loop_proxy.h" | 18 #include "base/message_loop/message_loop_proxy.h" |
19 #include "base/message_loop/message_loop_proxy_impl.h" | 19 #include "base/message_loop/message_loop_proxy_impl.h" |
20 #include "base/message_loop/message_pump.h" | 20 #include "base/message_loop/message_pump.h" |
21 #include "base/observer_list.h" | 21 #include "base/observer_list.h" |
22 #include "base/pending_task.h" | 22 #include "base/pending_task.h" |
23 #include "base/sequenced_task_runner_helpers.h" | 23 #include "base/sequenced_task_runner_helpers.h" |
24 #include "base/synchronization/lock.h" | 24 #include "base/synchronization/lock.h" |
25 #include "base/time/time.h" | 25 #include "base/time/time.h" |
26 #include "base/tracking_info.h" | 26 #include "base/tracking_info.h" |
27 | 27 |
28 // TODO(sky): these includes should not be necessary. Nuke them. | |
29 #if defined(OS_WIN) | 28 #if defined(OS_WIN) |
| 29 // We need this to declare base::MessagePumpWin::Dispatcher, which we should |
| 30 // really just eliminate. |
30 #include "base/message_loop/message_pump_win.h" | 31 #include "base/message_loop/message_pump_win.h" |
31 #elif defined(OS_IOS) | 32 #elif defined(OS_IOS) |
32 #include "base/message_loop/message_pump_io_ios.h" | 33 #include "base/message_loop/message_pump_io_ios.h" |
33 #elif defined(OS_POSIX) | 34 #elif defined(OS_POSIX) |
34 #include "base/message_loop/message_pump_libevent.h" | 35 #include "base/message_loop/message_pump_libevent.h" |
35 #if !defined(OS_MACOSX) && !defined(OS_ANDROID) | 36 #if !defined(OS_MACOSX) && !defined(OS_ANDROID) |
36 | 37 |
37 #if defined(USE_AURA) && defined(USE_X11) && !defined(OS_NACL) | 38 #if defined(USE_AURA) && defined(USE_X11) && !defined(OS_NACL) |
38 #include "base/message_loop/message_pump_x11.h" | 39 #include "base/message_loop/message_pump_x11.h" |
39 #elif defined(USE_OZONE) && !defined(OS_NACL) | 40 #elif defined(USE_OZONE) && !defined(OS_NACL) |
40 #include "base/message_loop/message_pump_ozone.h" | 41 #include "base/message_loop/message_pump_ozone.h" |
41 #else | 42 #else |
42 #define USE_GTK_MESSAGE_PUMP | 43 #define USE_GTK_MESSAGE_PUMP |
43 #include "base/message_loop/message_pump_gtk.h" | 44 #include "base/message_loop/message_pump_gtk.h" |
44 #if defined(TOOLKIT_GTK) | 45 #if defined(TOOLKIT_GTK) |
45 #include "base/message_loop/message_pump_x11.h" | 46 #include "base/message_loop/message_pump_x11.h" |
46 #endif | 47 #endif |
47 #endif | 48 #endif |
48 | 49 |
49 #endif | 50 #endif |
50 #endif | 51 #endif |
51 | 52 |
52 namespace base { | 53 namespace base { |
53 | 54 |
54 class HistogramBase; | 55 class HistogramBase; |
| 56 class MessagePumpDispatcher; |
55 class MessagePumpObserver; | 57 class MessagePumpObserver; |
56 class RunLoop; | 58 class RunLoop; |
57 class ThreadTaskRunnerHandle; | 59 class ThreadTaskRunnerHandle; |
58 #if defined(OS_ANDROID) | 60 #if defined(OS_ANDROID) |
59 class MessagePumpForUI; | 61 class MessagePumpForUI; |
60 #endif | 62 #endif |
61 class WaitableEvent; | 63 class WaitableEvent; |
62 | 64 |
63 // A MessageLoop is used to process events for a particular thread. There is | 65 // A MessageLoop is used to process events for a particular thread. There is |
64 // at most one MessageLoop instance per thread. | 66 // at most one MessageLoop instance per thread. |
(...skipping 23 matching lines...) Expand all Loading... |
88 // } | 90 // } |
89 // // Process |hr| (the result returned by DoDragDrop()). | 91 // // Process |hr| (the result returned by DoDragDrop()). |
90 // | 92 // |
91 // Please be SURE your task is reentrant (nestable) and all global variables | 93 // Please be SURE your task is reentrant (nestable) and all global variables |
92 // are stable and accessible before calling SetNestableTasksAllowed(true). | 94 // are stable and accessible before calling SetNestableTasksAllowed(true). |
93 // | 95 // |
94 class BASE_EXPORT MessageLoop : public MessagePump::Delegate { | 96 class BASE_EXPORT MessageLoop : public MessagePump::Delegate { |
95 public: | 97 public: |
96 | 98 |
97 #if defined(USE_AURA) | 99 #if defined(USE_AURA) |
| 100 typedef MessagePumpDispatcher Dispatcher; |
98 typedef MessagePumpObserver Observer; | 101 typedef MessagePumpObserver Observer; |
99 #elif defined(USE_GTK_MESSAGE_PUMP) | 102 #elif defined(USE_GTK_MESSAGE_PUMP) |
100 typedef MessagePumpGdkObserver Observer; | 103 typedef MessagePumpGdkObserver Observer; |
101 #endif | 104 #endif |
102 | 105 |
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. |
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
714 | 717 |
715 // 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 |
716 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra | 719 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra |
717 // 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. |
718 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO), | 721 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO), |
719 MessageLoopForIO_should_not_have_extra_member_variables); | 722 MessageLoopForIO_should_not_have_extra_member_variables); |
720 | 723 |
721 } // namespace base | 724 } // namespace base |
722 | 725 |
723 #endif // BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_ | 726 #endif // BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_ |
OLD | NEW |