| 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_proxy_impl.h" | 5 #include "base/message_loop_proxy_impl.h" |
| 6 | 6 |
| 7 #include "base/location.h" | 7 #include "base/location.h" |
| 8 #include "base/threading/thread_restrictions.h" | 8 #include "base/threading/thread_restrictions.h" |
| 9 | 9 |
| 10 namespace base { | 10 namespace base { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 | 74 |
| 75 MessageLoopProxyImpl::MessageLoopProxyImpl() | 75 MessageLoopProxyImpl::MessageLoopProxyImpl() |
| 76 : target_message_loop_(MessageLoop::current()) { | 76 : target_message_loop_(MessageLoop::current()) { |
| 77 } | 77 } |
| 78 | 78 |
| 79 bool MessageLoopProxyImpl::PostTaskHelper( | 79 bool MessageLoopProxyImpl::PostTaskHelper( |
| 80 const tracked_objects::Location& from_here, const base::Closure& task, | 80 const tracked_objects::Location& from_here, const base::Closure& task, |
| 81 int64 delay_ms, bool nestable) { | 81 int64 delay_ms, bool nestable) { |
| 82 AutoLock lock(message_loop_lock_); | 82 AutoLock lock(message_loop_lock_); |
| 83 if (target_message_loop_) { | 83 if (target_message_loop_) { |
| 84 base::TimeDelta delay = base::TimeDelta::FromMilliseconds(delay_ms); | |
| 85 if (nestable) { | 84 if (nestable) { |
| 86 target_message_loop_->PostDelayedTask(from_here, task, delay); | 85 target_message_loop_->PostDelayedTask(from_here, task, delay_ms); |
| 87 } else { | 86 } else { |
| 88 target_message_loop_->PostNonNestableDelayedTask(from_here, task, delay); | 87 target_message_loop_->PostNonNestableDelayedTask(from_here, task, |
| 88 delay_ms); |
| 89 } | 89 } |
| 90 return true; | 90 return true; |
| 91 } | 91 } |
| 92 return false; | 92 return false; |
| 93 } | 93 } |
| 94 | 94 |
| 95 scoped_refptr<MessageLoopProxy> | 95 scoped_refptr<MessageLoopProxy> |
| 96 MessageLoopProxy::current() { | 96 MessageLoopProxy::current() { |
| 97 MessageLoop* cur_loop = MessageLoop::current(); | 97 MessageLoop* cur_loop = MessageLoop::current(); |
| 98 if (!cur_loop) | 98 if (!cur_loop) |
| 99 return NULL; | 99 return NULL; |
| 100 return cur_loop->message_loop_proxy(); | 100 return cur_loop->message_loop_proxy(); |
| 101 } | 101 } |
| 102 | 102 |
| 103 } // namespace base | 103 } // namespace base |
| OLD | NEW |