OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include "base/thread_restrictions.h" |
6 | 7 |
7 namespace base { | 8 namespace base { |
8 | 9 |
9 MessageLoopProxyImpl::MessageLoopProxyImpl() | 10 MessageLoopProxyImpl::MessageLoopProxyImpl() |
10 : target_message_loop_(MessageLoop::current()) { | 11 : target_message_loop_(MessageLoop::current()) { |
11 target_message_loop_->AddDestructionObserver(this); | 12 target_message_loop_->AddDestructionObserver(this); |
12 } | 13 } |
13 | 14 |
14 MessageLoopProxyImpl::~MessageLoopProxyImpl() { | 15 MessageLoopProxyImpl::~MessageLoopProxyImpl() { |
15 AutoLock lock(message_loop_lock_); | 16 AutoLock lock(message_loop_lock_); |
(...skipping 22 matching lines...) Expand all Loading... |
38 } | 39 } |
39 | 40 |
40 bool MessageLoopProxyImpl::PostNonNestableDelayedTask( | 41 bool MessageLoopProxyImpl::PostNonNestableDelayedTask( |
41 const tracked_objects::Location& from_here, | 42 const tracked_objects::Location& from_here, |
42 Task* task, | 43 Task* task, |
43 int64 delay_ms) { | 44 int64 delay_ms) { |
44 return PostTaskHelper(from_here, task, delay_ms, false); | 45 return PostTaskHelper(from_here, task, delay_ms, false); |
45 } | 46 } |
46 | 47 |
47 bool MessageLoopProxyImpl::BelongsToCurrentThread() { | 48 bool MessageLoopProxyImpl::BelongsToCurrentThread() { |
| 49 // We shouldn't use MessageLoop::current() since it uses LazyInstance which |
| 50 // may be deleted by ~AtExitManager when a WorkerPool thread calls this |
| 51 // function. |
| 52 // http://crbug.com/63678 |
| 53 base::ThreadRestrictions::ScopedAllowSingleton allow_singleton; |
48 AutoLock lock(message_loop_lock_); | 54 AutoLock lock(message_loop_lock_); |
49 return (target_message_loop_ && | 55 return (target_message_loop_ && |
50 (MessageLoop::current() == target_message_loop_)); | 56 (MessageLoop::current() == target_message_loop_)); |
51 } | 57 } |
52 | 58 |
53 bool MessageLoopProxyImpl::PostTaskHelper( | 59 bool MessageLoopProxyImpl::PostTaskHelper( |
54 const tracked_objects::Location& from_here, Task* task, int64 delay_ms, | 60 const tracked_objects::Location& from_here, Task* task, int64 delay_ms, |
55 bool nestable) { | 61 bool nestable) { |
56 bool ret = false; | 62 bool ret = false; |
57 { | 63 { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 target_message_loop_ = NULL; | 97 target_message_loop_ = NULL; |
92 } | 98 } |
93 | 99 |
94 scoped_refptr<MessageLoopProxy> | 100 scoped_refptr<MessageLoopProxy> |
95 MessageLoopProxy::CreateForCurrentThread() { | 101 MessageLoopProxy::CreateForCurrentThread() { |
96 scoped_refptr<MessageLoopProxy> ret(new MessageLoopProxyImpl()); | 102 scoped_refptr<MessageLoopProxy> ret(new MessageLoopProxyImpl()); |
97 return ret; | 103 return ret; |
98 } | 104 } |
99 | 105 |
100 } // namespace base | 106 } // namespace base |
101 | |
OLD | NEW |