OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_H_ | 5 #ifndef BASE_MESSAGE_LOOP_H_ |
6 #define BASE_MESSAGE_LOOP_H_ | 6 #define BASE_MESSAGE_LOOP_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <queue> | 9 #include <queue> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/lock.h" | 13 #include "base/lock.h" |
14 #include "base/message_pump.h" | 14 #include "base/message_pump.h" |
15 #include "base/observer_list.h" | 15 #include "base/observer_list.h" |
16 #include "base/ref_counted.h" | 16 #include "base/ref_counted.h" |
17 #include "base/task.h" | 17 #include "base/task.h" |
18 | 18 |
19 #if defined(OS_WIN) | 19 #if defined(OS_WIN) |
20 // We need this to declare base::MessagePumpWin::Dispatcher, which we should | 20 // We need this to declare base::MessagePumpWin::Dispatcher, which we should |
21 // really just eliminate. | 21 // really just eliminate. |
22 #include "base/message_pump_win.h" | 22 #include "base/message_pump_win.h" |
23 #elif defined(OS_POSIX) | 23 #elif defined(OS_POSIX) |
24 #include "base/message_pump_libevent.h" | 24 #include "base/message_pump_libevent.h" |
25 #if !defined(OS_MACOSX) | 25 #if !defined(OS_MACOSX) |
26 #include "base/message_pump_glib.h" | 26 #include "base/message_pump_glib.h" |
27 #endif | 27 #endif |
28 #endif | 28 #endif |
| 29 #if defined(TOUCH_UI) |
| 30 #include "base/message_pump_glib_x_dispatch.h" |
| 31 #endif |
29 | 32 |
30 namespace base { | 33 namespace base { |
31 class Histogram; | 34 class Histogram; |
32 } | 35 } |
33 | 36 |
34 // A MessageLoop is used to process events for a particular thread. There is | 37 // A MessageLoop is used to process events for a particular thread. There is |
35 // at most one MessageLoop instance per thread. | 38 // at most one MessageLoop instance per thread. |
36 // | 39 // |
37 // Events include at a minimum Task instances submitted to PostTask or those | 40 // Events include at a minimum Task instances submitted to PostTask or those |
38 // managed by TimerManager. Depending on the type of message pump used by the | 41 // managed by TimerManager. Depending on the type of message pump used by the |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 | 286 |
284 // These functions can only be called on the same thread that |this| is | 287 // These functions can only be called on the same thread that |this| is |
285 // running on. | 288 // running on. |
286 void AddTaskObserver(TaskObserver* task_observer); | 289 void AddTaskObserver(TaskObserver* task_observer); |
287 void RemoveTaskObserver(TaskObserver* task_observer); | 290 void RemoveTaskObserver(TaskObserver* task_observer); |
288 | 291 |
289 #if defined(OS_WIN) | 292 #if defined(OS_WIN) |
290 typedef base::MessagePumpWin::Dispatcher Dispatcher; | 293 typedef base::MessagePumpWin::Dispatcher Dispatcher; |
291 typedef base::MessagePumpForUI::Observer Observer; | 294 typedef base::MessagePumpForUI::Observer Observer; |
292 #elif !defined(OS_MACOSX) | 295 #elif !defined(OS_MACOSX) |
| 296 #if defined(TOUCH_UI) |
| 297 typedef base::MessagePumpGlibXDispatcher Dispatcher; |
| 298 #else |
293 typedef base::MessagePumpForUI::Dispatcher Dispatcher; | 299 typedef base::MessagePumpForUI::Dispatcher Dispatcher; |
| 300 #endif |
294 typedef base::MessagePumpForUI::Observer Observer; | 301 typedef base::MessagePumpForUI::Observer Observer; |
295 #endif | 302 #endif |
296 | 303 |
297 // Returns true if the message loop has high resolution timers enabled. | 304 // Returns true if the message loop has high resolution timers enabled. |
298 // Provided for testing. | 305 // Provided for testing. |
299 bool high_resolution_timers_enabled() { | 306 bool high_resolution_timers_enabled() { |
300 #if defined(OS_WIN) | 307 #if defined(OS_WIN) |
301 return !high_resolution_timer_expiration_.is_null(); | 308 return !high_resolution_timer_expiration_.is_null(); |
302 #else | 309 #else |
303 return true; | 310 return true; |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
599 #endif // defined(OS_POSIX) | 606 #endif // defined(OS_POSIX) |
600 }; | 607 }; |
601 | 608 |
602 // Do not add any member variables to MessageLoopForIO! This is important b/c | 609 // Do not add any member variables to MessageLoopForIO! This is important b/c |
603 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra | 610 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra |
604 // data that you need should be stored on the MessageLoop's pump_ instance. | 611 // data that you need should be stored on the MessageLoop's pump_ instance. |
605 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO), | 612 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO), |
606 MessageLoopForIO_should_not_have_extra_member_variables); | 613 MessageLoopForIO_should_not_have_extra_member_variables); |
607 | 614 |
608 #endif // BASE_MESSAGE_LOOP_H_ | 615 #endif // BASE_MESSAGE_LOOP_H_ |
OLD | NEW |