| 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 std::unique_ptr<MessagePump> MessageLoop::CreateMessagePumpForType(Type type) { | 161 std::unique_ptr<MessagePump> MessageLoop::CreateMessagePumpForType(Type type) { |
| 162 // TODO(rvargas): Get rid of the OS guards. | 162 // TODO(rvargas): Get rid of the OS guards. |
| 163 #if defined(USE_GLIB) && !defined(OS_NACL) | 163 #if defined(USE_GLIB) && !defined(OS_NACL) |
| 164 typedef MessagePumpGlib MessagePumpForUI; | 164 typedef MessagePumpGlib MessagePumpForUI; |
| 165 #elif (defined(OS_LINUX) && !defined(OS_NACL)) || defined(OS_BSD) | 165 #elif (defined(OS_LINUX) && !defined(OS_NACL)) || defined(OS_BSD) |
| 166 typedef MessagePumpLibevent MessagePumpForUI; | 166 typedef MessagePumpLibevent MessagePumpForUI; |
| 167 #endif | 167 #endif |
| 168 | 168 |
| 169 #if defined(OS_IOS) || defined(OS_MACOSX) | 169 #if defined(OS_IOS) || defined(OS_MACOSX) |
| 170 #define MESSAGE_PUMP_UI std::unique_ptr<MessagePump>(MessagePumpMac::Create()) | 170 #define MESSAGE_PUMP_UI std::unique_ptr<MessagePump>(MessagePumpMac::Create()) |
| 171 #elif defined(OS_NACL) | 171 #elif defined(OS_NACL) || defined(OS_FUCHSIA) |
| 172 // Currently NaCl doesn't have a UI MessageLoop. | 172 // Currently NaCl doesn't have a UI MessageLoop. |
| 173 // TODO(abarth): Figure out if we need this. | 173 // TODO(abarth): Figure out if we need this. |
| 174 #define MESSAGE_PUMP_UI std::unique_ptr<MessagePump>() | 174 #define MESSAGE_PUMP_UI std::unique_ptr<MessagePump>() |
| 175 #else | 175 #else |
| 176 #define MESSAGE_PUMP_UI std::unique_ptr<MessagePump>(new MessagePumpForUI()) | 176 #define MESSAGE_PUMP_UI std::unique_ptr<MessagePump>(new MessagePumpForUI()) |
| 177 #endif | 177 #endif |
| 178 | 178 |
| 179 #if defined(OS_MACOSX) | 179 #if defined(OS_MACOSX) |
| 180 // Use an OS native runloop on Mac to support timer coalescing. | 180 // Use an OS native runloop on Mac to support timer coalescing. |
| 181 #define MESSAGE_PUMP_DEFAULT \ | 181 #define MESSAGE_PUMP_DEFAULT \ |
| (...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 648 ToPumpIO(pump_.get())->RegisterIOHandler(file, handler); | 648 ToPumpIO(pump_.get())->RegisterIOHandler(file, handler); |
| 649 } | 649 } |
| 650 | 650 |
| 651 bool MessageLoopForIO::RegisterJobObject(HANDLE job, IOHandler* handler) { | 651 bool MessageLoopForIO::RegisterJobObject(HANDLE job, IOHandler* handler) { |
| 652 return ToPumpIO(pump_.get())->RegisterJobObject(job, handler); | 652 return ToPumpIO(pump_.get())->RegisterJobObject(job, handler); |
| 653 } | 653 } |
| 654 | 654 |
| 655 bool MessageLoopForIO::WaitForIOCompletion(DWORD timeout, IOHandler* filter) { | 655 bool MessageLoopForIO::WaitForIOCompletion(DWORD timeout, IOHandler* filter) { |
| 656 return ToPumpIO(pump_.get())->WaitForIOCompletion(timeout, filter); | 656 return ToPumpIO(pump_.get())->WaitForIOCompletion(timeout, filter); |
| 657 } | 657 } |
| 658 #elif defined(OS_POSIX) | 658 #elif defined(OS_POSIX) && !defined(OS_FUCHSIA) |
| 659 bool MessageLoopForIO::WatchFileDescriptor(int fd, | 659 bool MessageLoopForIO::WatchFileDescriptor(int fd, |
| 660 bool persistent, | 660 bool persistent, |
| 661 Mode mode, | 661 Mode mode, |
| 662 FileDescriptorWatcher* controller, | 662 FileDescriptorWatcher* controller, |
| 663 Watcher* delegate) { | 663 Watcher* delegate) { |
| 664 return ToPumpIO(pump_.get())->WatchFileDescriptor( | 664 return ToPumpIO(pump_.get())->WatchFileDescriptor( |
| 665 fd, | 665 fd, |
| 666 persistent, | 666 persistent, |
| 667 mode, | 667 mode, |
| 668 controller, | 668 controller, |
| 669 delegate); | 669 delegate); |
| 670 } | 670 } |
| 671 #endif | 671 #endif |
| 672 | 672 |
| 673 #endif // !defined(OS_NACL_SFI) | 673 #endif // !defined(OS_NACL_SFI) |
| 674 | 674 |
| 675 } // namespace base | 675 } // namespace base |
| OLD | NEW |