OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #include "base/message_loop.h" | 5 #include "base/message_loop.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/message_pump_default.h" | 12 #include "base/message_pump_default.h" |
13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
14 #include "base/thread_local.h" | 14 #include "base/thread_local.h" |
15 | 15 |
16 #if defined(OS_MACOSX) | 16 #if defined(OS_MACOSX) |
17 #include "base/message_pump_mac.h" | 17 #include "base/message_pump_mac.h" |
18 #endif | 18 #endif |
19 #if defined(OS_POSIX) | 19 #if defined(OS_POSIX) |
20 #include "base/message_pump_libevent.h" | 20 #include "base/message_pump_libevent.h" |
21 #endif | 21 #endif |
22 #if defined(OS_LINUX) | 22 #if defined(TOOLKIT_GTK) |
23 #include "base/message_pump_glib.h" | 23 #include "base/message_pump_glib.h" |
24 #endif | 24 #endif |
25 | 25 |
26 using base::Time; | 26 using base::Time; |
27 using base::TimeDelta; | 27 using base::TimeDelta; |
28 | 28 |
29 // A lazily created thread local storage for quick access to a thread's message | 29 // A lazily created thread local storage for quick access to a thread's message |
30 // loop, if one exists. This should be safe and free of static constructors. | 30 // loop, if one exists. This should be safe and free of static constructors. |
31 static base::LazyInstance<base::ThreadLocalPointer<MessageLoop> > lazy_tls_ptr( | 31 static base::LazyInstance<base::ThreadLocalPointer<MessageLoop> > lazy_tls_ptr( |
32 base::LINKER_INITIALIZED); | 32 base::LINKER_INITIALIZED); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 pump_ = new base::MessagePumpForIO(); | 92 pump_ = new base::MessagePumpForIO(); |
93 } else { | 93 } else { |
94 DCHECK(type_ == TYPE_UI); | 94 DCHECK(type_ == TYPE_UI); |
95 pump_ = new base::MessagePumpForUI(); | 95 pump_ = new base::MessagePumpForUI(); |
96 } | 96 } |
97 #elif defined(OS_POSIX) | 97 #elif defined(OS_POSIX) |
98 if (type_ == TYPE_UI) { | 98 if (type_ == TYPE_UI) { |
99 #if defined(OS_MACOSX) | 99 #if defined(OS_MACOSX) |
100 pump_ = base::MessagePumpMac::Create(); | 100 pump_ = base::MessagePumpMac::Create(); |
101 #elif defined(OS_LINUX) | 101 #elif defined(OS_LINUX) |
| 102 #if defined(TOOLKIT_GTK) |
102 pump_ = new base::MessagePumpForUI(); | 103 pump_ = new base::MessagePumpForUI(); |
| 104 #else |
| 105 pump_ = new base::MessagePumpDefault(); |
| 106 #endif |
103 #endif // OS_LINUX | 107 #endif // OS_LINUX |
104 } else if (type_ == TYPE_IO) { | 108 } else if (type_ == TYPE_IO) { |
105 pump_ = new base::MessagePumpLibevent(); | 109 pump_ = new base::MessagePumpLibevent(); |
106 } else { | 110 } else { |
107 pump_ = new base::MessagePumpDefault(); | 111 pump_ = new base::MessagePumpDefault(); |
108 } | 112 } |
109 #endif // OS_POSIX | 113 #endif // OS_POSIX |
110 } | 114 } |
111 | 115 |
112 MessageLoop::~MessageLoop() { | 116 MessageLoop::~MessageLoop() { |
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
608 Watcher *delegate) { | 612 Watcher *delegate) { |
609 return pump_libevent()->WatchFileDescriptor( | 613 return pump_libevent()->WatchFileDescriptor( |
610 fd, | 614 fd, |
611 persistent, | 615 persistent, |
612 static_cast<base::MessagePumpLibevent::Mode>(mode), | 616 static_cast<base::MessagePumpLibevent::Mode>(mode), |
613 controller, | 617 controller, |
614 delegate); | 618 delegate); |
615 } | 619 } |
616 | 620 |
617 #endif | 621 #endif |
OLD | NEW |