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 #include "base/message_loop/message_loop.h" | 5 #include "base/message_loop/message_loop.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 // A lazily created thread local storage for quick access to a thread's message | 39 // A lazily created thread local storage for quick access to a thread's message |
40 // loop, if one exists. | 40 // loop, if one exists. |
41 base::ThreadLocalPointer<MessageLoop>* GetTLSMessageLoop() { | 41 base::ThreadLocalPointer<MessageLoop>* GetTLSMessageLoop() { |
42 static auto* lazy_tls_ptr = new base::ThreadLocalPointer<MessageLoop>(); | 42 static auto* lazy_tls_ptr = new base::ThreadLocalPointer<MessageLoop>(); |
43 return lazy_tls_ptr; | 43 return lazy_tls_ptr; |
44 } | 44 } |
45 MessageLoop::MessagePumpFactory* message_pump_for_ui_factory_ = NULL; | 45 MessageLoop::MessagePumpFactory* message_pump_for_ui_factory_ = NULL; |
46 | 46 |
47 #if defined(OS_IOS) | 47 #if defined(OS_IOS) |
48 typedef MessagePumpIOSForIO MessagePumpForIO; | 48 typedef MessagePumpIOSForIO MessagePumpForIO; |
49 #elif defined(OS_NACL_SFI) | 49 #elif defined(OS_NACL_SFI) || defined(OS_FUCHSIA) |
50 typedef MessagePumpDefault MessagePumpForIO; | 50 typedef MessagePumpDefault MessagePumpForIO; |
51 #elif defined(OS_POSIX) | 51 #elif defined(OS_POSIX) |
52 typedef MessagePumpLibevent MessagePumpForIO; | 52 typedef MessagePumpLibevent MessagePumpForIO; |
53 #endif | 53 #endif |
54 | 54 |
55 #if !defined(OS_NACL_SFI) | 55 #if !defined(OS_NACL_SFI) && !defined(OS_FUCHSIA) |
56 MessagePumpForIO* ToPumpIO(MessagePump* pump) { | 56 MessagePumpForIO* ToPumpIO(MessagePump* pump) { |
57 return static_cast<MessagePumpForIO*>(pump); | 57 return static_cast<MessagePumpForIO*>(pump); |
58 } | 58 } |
59 #endif // !defined(OS_NACL_SFI) | 59 #endif // !defined(OS_NACL_SFI) |
60 | 60 |
61 std::unique_ptr<MessagePump> ReturnPump(std::unique_ptr<MessagePump> pump) { | 61 std::unique_ptr<MessagePump> ReturnPump(std::unique_ptr<MessagePump> pump) { |
62 return pump; | 62 return pump; |
63 } | 63 } |
64 | 64 |
65 } // namespace | 65 } // namespace |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 std::unique_ptr<MessagePump> MessageLoop::CreateMessagePumpForType(Type type) { | 163 std::unique_ptr<MessagePump> MessageLoop::CreateMessagePumpForType(Type type) { |
164 // TODO(rvargas): Get rid of the OS guards. | 164 // TODO(rvargas): Get rid of the OS guards. |
165 #if defined(USE_GLIB) && !defined(OS_NACL) | 165 #if defined(USE_GLIB) && !defined(OS_NACL) |
166 typedef MessagePumpGlib MessagePumpForUI; | 166 typedef MessagePumpGlib MessagePumpForUI; |
167 #elif (defined(OS_LINUX) && !defined(OS_NACL)) || defined(OS_BSD) | 167 #elif (defined(OS_LINUX) && !defined(OS_NACL)) || defined(OS_BSD) |
168 typedef MessagePumpLibevent MessagePumpForUI; | 168 typedef MessagePumpLibevent MessagePumpForUI; |
169 #endif | 169 #endif |
170 | 170 |
171 #if defined(OS_IOS) || defined(OS_MACOSX) | 171 #if defined(OS_IOS) || defined(OS_MACOSX) |
172 #define MESSAGE_PUMP_UI std::unique_ptr<MessagePump>(MessagePumpMac::Create()) | 172 #define MESSAGE_PUMP_UI std::unique_ptr<MessagePump>(MessagePumpMac::Create()) |
173 #elif defined(OS_NACL) || defined(OS_AIX) | 173 #elif defined(OS_NACL) || defined(OS_AIX) || defined(OS_FUCHSIA) |
174 // Currently NaCl doesn't have a UI MessageLoop. | 174 // Currently NaCl and AIX don't have a UI MessageLoop. |
175 // TODO(abarth): Figure out if we need this. | 175 // TODO(abarth): Figure out if we need this. |
| 176 // TODO(fuchsia): Fuchsia may require one once more UI-level things have been |
| 177 // ported. See https://crbug.com/706592. |
176 #define MESSAGE_PUMP_UI std::unique_ptr<MessagePump>() | 178 #define MESSAGE_PUMP_UI std::unique_ptr<MessagePump>() |
177 #else | 179 #else |
178 #define MESSAGE_PUMP_UI std::unique_ptr<MessagePump>(new MessagePumpForUI()) | 180 #define MESSAGE_PUMP_UI std::unique_ptr<MessagePump>(new MessagePumpForUI()) |
179 #endif | 181 #endif |
180 | 182 |
181 #if defined(OS_MACOSX) | 183 #if defined(OS_MACOSX) |
182 // Use an OS native runloop on Mac to support timer coalescing. | 184 // Use an OS native runloop on Mac to support timer coalescing. |
183 #define MESSAGE_PUMP_DEFAULT \ | 185 #define MESSAGE_PUMP_DEFAULT \ |
184 std::unique_ptr<MessagePump>(new MessagePumpCFRunLoop()) | 186 std::unique_ptr<MessagePump>(new MessagePumpCFRunLoop()) |
185 #else | 187 #else |
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
627 ToPumpIO(pump_.get())->RegisterIOHandler(file, handler); | 629 ToPumpIO(pump_.get())->RegisterIOHandler(file, handler); |
628 } | 630 } |
629 | 631 |
630 bool MessageLoopForIO::RegisterJobObject(HANDLE job, IOHandler* handler) { | 632 bool MessageLoopForIO::RegisterJobObject(HANDLE job, IOHandler* handler) { |
631 return ToPumpIO(pump_.get())->RegisterJobObject(job, handler); | 633 return ToPumpIO(pump_.get())->RegisterJobObject(job, handler); |
632 } | 634 } |
633 | 635 |
634 bool MessageLoopForIO::WaitForIOCompletion(DWORD timeout, IOHandler* filter) { | 636 bool MessageLoopForIO::WaitForIOCompletion(DWORD timeout, IOHandler* filter) { |
635 return ToPumpIO(pump_.get())->WaitForIOCompletion(timeout, filter); | 637 return ToPumpIO(pump_.get())->WaitForIOCompletion(timeout, filter); |
636 } | 638 } |
637 #elif defined(OS_POSIX) | 639 #elif defined(OS_POSIX) && !defined(OS_FUCHSIA) |
638 bool MessageLoopForIO::WatchFileDescriptor(int fd, | 640 bool MessageLoopForIO::WatchFileDescriptor(int fd, |
639 bool persistent, | 641 bool persistent, |
640 Mode mode, | 642 Mode mode, |
641 FileDescriptorWatcher* controller, | 643 FileDescriptorWatcher* controller, |
642 Watcher* delegate) { | 644 Watcher* delegate) { |
643 return ToPumpIO(pump_.get())->WatchFileDescriptor( | 645 return ToPumpIO(pump_.get())->WatchFileDescriptor( |
644 fd, | 646 fd, |
645 persistent, | 647 persistent, |
646 mode, | 648 mode, |
647 controller, | 649 controller, |
648 delegate); | 650 delegate); |
649 } | 651 } |
650 #endif | 652 #endif |
651 | 653 |
652 #endif // !defined(OS_NACL_SFI) | 654 #endif // !defined(OS_NACL_SFI) |
653 | 655 |
654 } // namespace base | 656 } // namespace base |
OLD | NEW |