Chromium Code Reviews| 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/message_loop_proxy_impl.h" | 5 #include "base/message_loop/message_loop_proxy_impl.h" |
| 6 | 6 |
| 7 #include "base/location.h" | 7 #include "base/location.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/message_loop/incoming_task_queue.h" | 9 #include "base/message_loop/incoming_task_queue.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| 11 | 11 |
| 12 namespace base { | 12 namespace base { |
| 13 namespace internal { | 13 namespace internal { |
| 14 | 14 |
| 15 MessageLoopProxyImpl::MessageLoopProxyImpl( | 15 MessageLoopProxyImpl::MessageLoopProxyImpl( |
| 16 scoped_refptr<IncomingTaskQueue> incoming_queue) | 16 scoped_refptr<IncomingTaskQueue> incoming_queue) |
| 17 : incoming_queue_(incoming_queue), | 17 : incoming_queue_(incoming_queue), |
| 18 valid_thread_id_(PlatformThread::CurrentId()) { | 18 valid_thread_id_(kInvalidThreadId) { |
| 19 } | |
| 20 | |
| 21 void MessageLoopProxyImpl::BindToCurrentThread() { | |
| 22 DCHECK_EQ(kInvalidThreadId, valid_thread_id_); | |
| 23 valid_thread_id_ = PlatformThread::CurrentId(); | |
| 19 } | 24 } |
| 20 | 25 |
| 21 bool MessageLoopProxyImpl::PostDelayedTask( | 26 bool MessageLoopProxyImpl::PostDelayedTask( |
| 22 const tracked_objects::Location& from_here, | 27 const tracked_objects::Location& from_here, |
| 23 const base::Closure& task, | 28 const base::Closure& task, |
| 24 base::TimeDelta delay) { | 29 base::TimeDelta delay) { |
| 25 DCHECK(!task.is_null()) << from_here.ToString(); | 30 DCHECK(!task.is_null()) << from_here.ToString(); |
|
Nico
2015/04/27 22:49:34
DCHECK_NE(valid_thread_id_, kInvalidThreadId);
(
kinuko
2015/04/28 15:43:25
Done.
| |
| 26 return incoming_queue_->AddToIncomingQueue(from_here, task, delay, true); | 31 return incoming_queue_->AddToIncomingQueue(from_here, task, delay, true); |
| 27 } | 32 } |
| 28 | 33 |
| 29 bool MessageLoopProxyImpl::PostNonNestableDelayedTask( | 34 bool MessageLoopProxyImpl::PostNonNestableDelayedTask( |
| 30 const tracked_objects::Location& from_here, | 35 const tracked_objects::Location& from_here, |
| 31 const base::Closure& task, | 36 const base::Closure& task, |
| 32 base::TimeDelta delay) { | 37 base::TimeDelta delay) { |
| 33 DCHECK(!task.is_null()) << from_here.ToString(); | 38 DCHECK(!task.is_null()) << from_here.ToString(); |
|
Nico
2015/04/27 22:49:34
DCHECK_NE(valid_thread_id_, kInvalidThreadId);
(
kinuko
2015/04/28 15:43:25
Done.
| |
| 34 return incoming_queue_->AddToIncomingQueue(from_here, task, delay, false); | 39 return incoming_queue_->AddToIncomingQueue(from_here, task, delay, false); |
| 35 } | 40 } |
| 36 | 41 |
| 37 bool MessageLoopProxyImpl::RunsTasksOnCurrentThread() const { | 42 bool MessageLoopProxyImpl::RunsTasksOnCurrentThread() const { |
|
Nico
2015/04/27 22:49:34
DCHECK_NE(valid_thread_id_, kInvalidThreadId);
(
kinuko
2015/04/28 15:43:25
Done.
| |
| 38 return valid_thread_id_ == PlatformThread::CurrentId(); | 43 return valid_thread_id_ == PlatformThread::CurrentId(); |
| 39 } | 44 } |
| 40 | 45 |
| 41 MessageLoopProxyImpl::~MessageLoopProxyImpl() { | 46 MessageLoopProxyImpl::~MessageLoopProxyImpl() { |
| 42 } | 47 } |
| 43 | 48 |
| 44 } // namespace internal | 49 } // namespace internal |
| 45 | 50 |
| 46 scoped_refptr<MessageLoopProxy> | 51 scoped_refptr<MessageLoopProxy> |
| 47 MessageLoopProxy::current() { | 52 MessageLoopProxy::current() { |
| 48 MessageLoop* cur_loop = MessageLoop::current(); | 53 MessageLoop* cur_loop = MessageLoop::current(); |
| 49 if (!cur_loop) | 54 if (!cur_loop) |
| 50 return NULL; | 55 return NULL; |
| 51 return cur_loop->message_loop_proxy(); | 56 return cur_loop->message_loop_proxy(); |
| 52 } | 57 } |
| 53 | 58 |
| 54 } // namespace base | 59 } // namespace base |
| OLD | NEW |