Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/debug/alias.h" | 11 #include "base/debug/alias.h" |
| 12 #include "base/lazy_instance.h" | 12 #include "base/lazy_instance.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/message_pump_default.h" | 15 #include "base/message_pump_default.h" |
| 16 #include "base/metrics/histogram.h" | 16 #include "base/metrics/histogram.h" |
| 17 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" | 17 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" |
| 18 #include "base/threading/thread_local.h" | 18 #include "base/threading/thread_local.h" |
| 19 #include "base/time.h" | 19 #include "base/time.h" |
| 20 #include "base/tracked_objects.h" | 20 #include "base/tracked_objects.h" |
| 21 | 21 |
| 22 #if defined(OS_MACOSX) | 22 #if defined(OS_MACOSX) |
| 23 #include "base/message_pump_mac.h" | 23 #include "base/message_pump_mac.h" |
| 24 #endif | 24 #endif |
| 25 #if defined(OS_POSIX) | |
| 26 #include "base/message_pump_libevent.h" | |
| 27 #endif | |
| 28 | 25 |
| 29 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 26 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 30 #include <gdk/gdk.h> | 27 #include <gdk/gdk.h> |
| 31 #include <gdk/gdkx.h> | 28 #include <gdk/gdkx.h> |
| 29 #include "base/message_pump_libevent.h" | |
| 32 #if defined(TOUCH_UI) | 30 #if defined(TOUCH_UI) |
| 33 #include "base/message_pump_x.h" | 31 #include "base/message_pump_x.h" |
| 34 #else | 32 #else |
| 35 #include "base/message_pump_gtk.h" | 33 #include "base/message_pump_gtk.h" |
| 36 #endif // defined(TOUCH_UI) | 34 #endif // defined(TOUCH_UI) |
| 37 #endif // defined(OS_POSIX) && !defined(OS_MACOSX) | 35 #endif // defined(OS_POSIX) && !defined(OS_MACOSX) |
| 38 | 36 |
| 39 using base::TimeDelta; | 37 using base::TimeDelta; |
| 40 using base::TimeTicks; | 38 using base::TimeTicks; |
| 41 | 39 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 169 next_sequence_num_(0) { | 167 next_sequence_num_(0) { |
| 170 DCHECK(!current()) << "should only have one message loop per thread"; | 168 DCHECK(!current()) << "should only have one message loop per thread"; |
| 171 lazy_tls_ptr.Pointer()->Set(this); | 169 lazy_tls_ptr.Pointer()->Set(this); |
| 172 | 170 |
| 173 // TODO(rvargas): Get rid of the OS guards. | 171 // TODO(rvargas): Get rid of the OS guards. |
| 174 #if defined(OS_WIN) | 172 #if defined(OS_WIN) |
| 175 #define MESSAGE_PUMP_UI new base::MessagePumpForUI() | 173 #define MESSAGE_PUMP_UI new base::MessagePumpForUI() |
| 176 #define MESSAGE_PUMP_IO new base::MessagePumpForIO() | 174 #define MESSAGE_PUMP_IO new base::MessagePumpForIO() |
| 177 #elif defined(OS_MACOSX) | 175 #elif defined(OS_MACOSX) |
| 178 #define MESSAGE_PUMP_UI base::MessagePumpMac::Create() | 176 #define MESSAGE_PUMP_UI base::MessagePumpMac::Create() |
| 179 #define MESSAGE_PUMP_IO new base::MessagePumpLibevent() | 177 #define MESSAGE_PUMP_IO base::MessagePumpMac::Create() |
|
Mark Mentovai
2011/06/29 01:21:21
As I mentioned last week, I don’t really want to m
| |
| 180 #elif defined(TOUCH_UI) | 178 #elif defined(TOUCH_UI) |
| 181 #define MESSAGE_PUMP_UI new base::MessagePumpX() | 179 #define MESSAGE_PUMP_UI new base::MessagePumpX() |
| 182 #define MESSAGE_PUMP_IO new base::MessagePumpLibevent() | 180 #define MESSAGE_PUMP_IO new base::MessagePumpLibevent() |
| 183 #elif defined(OS_NACL) | 181 #elif defined(OS_NACL) |
| 184 // Currently NaCl doesn't have a UI or an IO MessageLoop. | 182 // Currently NaCl doesn't have a UI or an IO MessageLoop. |
| 185 // TODO(abarth): Figure out if we need these. | 183 // TODO(abarth): Figure out if we need these. |
| 186 #define MESSAGE_PUMP_UI NULL | 184 #define MESSAGE_PUMP_UI NULL |
| 187 #define MESSAGE_PUMP_IO NULL | 185 #define MESSAGE_PUMP_IO NULL |
| 188 #elif defined(OS_POSIX) // POSIX but not MACOSX. | 186 #elif defined(OS_POSIX) // POSIX but not MACOSX. |
| 189 #define MESSAGE_PUMP_UI new base::MessagePumpGtk() | 187 #define MESSAGE_PUMP_UI new base::MessagePumpGtk() |
| (...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 849 #if defined(OS_WIN) | 847 #if defined(OS_WIN) |
| 850 | 848 |
| 851 void MessageLoopForIO::RegisterIOHandler(HANDLE file, IOHandler* handler) { | 849 void MessageLoopForIO::RegisterIOHandler(HANDLE file, IOHandler* handler) { |
| 852 pump_io()->RegisterIOHandler(file, handler); | 850 pump_io()->RegisterIOHandler(file, handler); |
| 853 } | 851 } |
| 854 | 852 |
| 855 bool MessageLoopForIO::WaitForIOCompletion(DWORD timeout, IOHandler* filter) { | 853 bool MessageLoopForIO::WaitForIOCompletion(DWORD timeout, IOHandler* filter) { |
| 856 return pump_io()->WaitForIOCompletion(timeout, filter); | 854 return pump_io()->WaitForIOCompletion(timeout, filter); |
| 857 } | 855 } |
| 858 | 856 |
| 857 #elif defined(OS_MACOSX) | |
| 858 | |
| 859 bool MessageLoopForIO::WatchFileDescriptor(int fd, | |
| 860 bool persistent, | |
| 861 Mode mode, | |
| 862 FileDescriptorWatcher *controller, | |
| 863 Watcher *delegate) { | |
| 864 return pump_mac()->WatchFileDescriptor( | |
| 865 fd, | |
| 866 persistent, | |
| 867 static_cast<base::MessagePumpCFRunLoopBase::Mode>(mode), | |
| 868 controller, | |
| 869 delegate); | |
| 870 } | |
| 871 | |
| 859 #elif defined(OS_POSIX) && !defined(OS_NACL) | 872 #elif defined(OS_POSIX) && !defined(OS_NACL) |
| 860 | 873 |
| 861 bool MessageLoopForIO::WatchFileDescriptor(int fd, | 874 bool MessageLoopForIO::WatchFileDescriptor(int fd, |
| 862 bool persistent, | 875 bool persistent, |
| 863 Mode mode, | 876 Mode mode, |
| 864 FileDescriptorWatcher *controller, | 877 FileDescriptorWatcher *controller, |
| 865 Watcher *delegate) { | 878 Watcher *delegate) { |
| 866 return pump_libevent()->WatchFileDescriptor( | 879 return pump_libevent()->WatchFileDescriptor( |
| 867 fd, | 880 fd, |
| 868 persistent, | 881 persistent, |
| 869 static_cast<base::MessagePumpLibevent::Mode>(mode), | 882 static_cast<base::MessagePumpLibevent::Mode>(mode), |
| 870 controller, | 883 controller, |
| 871 delegate); | 884 delegate); |
| 872 } | 885 } |
| 873 | 886 |
| 874 #endif | 887 #endif |
| OLD | NEW |