| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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" |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 message_histogram_(NULL), | 132 message_histogram_(NULL), |
| 133 state_(NULL), | 133 state_(NULL), |
| 134 #ifdef OS_WIN | 134 #ifdef OS_WIN |
| 135 os_modal_loop_(false), | 135 os_modal_loop_(false), |
| 136 #endif // OS_WIN | 136 #endif // OS_WIN |
| 137 next_sequence_num_(0) { | 137 next_sequence_num_(0) { |
| 138 DCHECK(!current()) << "should only have one message loop per thread"; | 138 DCHECK(!current()) << "should only have one message loop per thread"; |
| 139 lazy_tls_ptr.Pointer()->Set(this); | 139 lazy_tls_ptr.Pointer()->Set(this); |
| 140 | 140 |
| 141 message_loop_proxy_ = new base::MessageLoopProxyImpl(); | 141 message_loop_proxy_ = new base::MessageLoopProxyImpl(); |
| 142 base::SingleThreadTaskRunner::SetCurrent(message_loop_proxy_); |
| 142 | 143 |
| 143 // TODO(rvargas): Get rid of the OS guards. | 144 // TODO(rvargas): Get rid of the OS guards. |
| 144 #if defined(OS_WIN) | 145 #if defined(OS_WIN) |
| 145 #define MESSAGE_PUMP_UI new base::MessagePumpForUI() | 146 #define MESSAGE_PUMP_UI new base::MessagePumpForUI() |
| 146 #define MESSAGE_PUMP_IO new base::MessagePumpForIO() | 147 #define MESSAGE_PUMP_IO new base::MessagePumpForIO() |
| 147 #elif defined(OS_MACOSX) | 148 #elif defined(OS_MACOSX) |
| 148 #define MESSAGE_PUMP_UI base::MessagePumpMac::Create() | 149 #define MESSAGE_PUMP_UI base::MessagePumpMac::Create() |
| 149 #define MESSAGE_PUMP_IO new base::MessagePumpLibevent() | 150 #define MESSAGE_PUMP_IO new base::MessagePumpLibevent() |
| 150 #elif defined(OS_NACL) | 151 #elif defined(OS_NACL) |
| 151 // Currently NaCl doesn't have a UI or an IO MessageLoop. | 152 // Currently NaCl doesn't have a UI or an IO MessageLoop. |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 if (!did_work) | 193 if (!did_work) |
| 193 break; | 194 break; |
| 194 } | 195 } |
| 195 DCHECK(!did_work); | 196 DCHECK(!did_work); |
| 196 | 197 |
| 197 // Let interested parties have one last shot at accessing this. | 198 // Let interested parties have one last shot at accessing this. |
| 198 FOR_EACH_OBSERVER(DestructionObserver, destruction_observers_, | 199 FOR_EACH_OBSERVER(DestructionObserver, destruction_observers_, |
| 199 WillDestroyCurrentMessageLoop()); | 200 WillDestroyCurrentMessageLoop()); |
| 200 | 201 |
| 201 // Tell the message_loop_proxy that we are dying. | 202 // Tell the message_loop_proxy that we are dying. |
| 203 base::SingleThreadTaskRunner::SetCurrent(NULL); |
| 202 static_cast<base::MessageLoopProxyImpl*>(message_loop_proxy_.get())-> | 204 static_cast<base::MessageLoopProxyImpl*>(message_loop_proxy_.get())-> |
| 203 WillDestroyCurrentMessageLoop(); | 205 WillDestroyCurrentMessageLoop(); |
| 204 message_loop_proxy_ = NULL; | 206 message_loop_proxy_ = NULL; |
| 205 | 207 |
| 206 // OK, now make it so that no one can find us. | 208 // OK, now make it so that no one can find us. |
| 207 lazy_tls_ptr.Pointer()->Set(NULL); | 209 lazy_tls_ptr.Pointer()->Set(NULL); |
| 208 | 210 |
| 209 #if defined(OS_WIN) | 211 #if defined(OS_WIN) |
| 210 // If we left the high-resolution timer activated, deactivate it now. | 212 // If we left the high-resolution timer activated, deactivate it now. |
| 211 // Doing this is not-critical, it is mainly to make sure we track | 213 // Doing this is not-critical, it is mainly to make sure we track |
| (...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 794 Watcher *delegate) { | 796 Watcher *delegate) { |
| 795 return pump_libevent()->WatchFileDescriptor( | 797 return pump_libevent()->WatchFileDescriptor( |
| 796 fd, | 798 fd, |
| 797 persistent, | 799 persistent, |
| 798 static_cast<base::MessagePumpLibevent::Mode>(mode), | 800 static_cast<base::MessagePumpLibevent::Mode>(mode), |
| 799 controller, | 801 controller, |
| 800 delegate); | 802 delegate); |
| 801 } | 803 } |
| 802 | 804 |
| 803 #endif | 805 #endif |
| OLD | NEW |