Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(47)

Side by Side Diff: base/message_loop_proxy_impl.cc

Issue 10210008: Make MessageLoopProxy::current() usable on threads that don't have MessageLoop. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 // function. 50 // function.
51 // http://crbug.com/63678 51 // http://crbug.com/63678
52 base::ThreadRestrictions::ScopedAllowSingleton allow_singleton; 52 base::ThreadRestrictions::ScopedAllowSingleton allow_singleton;
53 AutoLock lock(message_loop_lock_); 53 AutoLock lock(message_loop_lock_);
54 return (target_message_loop_ && 54 return (target_message_loop_ &&
55 (MessageLoop::current() == target_message_loop_)); 55 (MessageLoop::current() == target_message_loop_));
56 } 56 }
57 57
58 // MessageLoop::DestructionObserver implementation 58 // MessageLoop::DestructionObserver implementation
59 void MessageLoopProxyImpl::WillDestroyCurrentMessageLoop() { 59 void MessageLoopProxyImpl::WillDestroyCurrentMessageLoop() {
60 Detach();
60 AutoLock lock(message_loop_lock_); 61 AutoLock lock(message_loop_lock_);
61 target_message_loop_ = NULL; 62 target_message_loop_ = NULL;
62 } 63 }
63 64
64 void MessageLoopProxyImpl::OnDestruct() const { 65 void MessageLoopProxyImpl::OnDestruct() const {
65 // We shouldn't use MessageLoop::current() since it uses LazyInstance which 66 // We shouldn't use MessageLoop::current() since it uses LazyInstance which
66 // may be deleted by ~AtExitManager when a WorkerPool thread calls this 67 // may be deleted by ~AtExitManager when a WorkerPool thread calls this
67 // function. 68 // function.
68 // http://crbug.com/63678 69 // http://crbug.com/63678
69 base::ThreadRestrictions::ScopedAllowSingleton allow_singleton; 70 base::ThreadRestrictions::ScopedAllowSingleton allow_singleton;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 102
102 scoped_refptr<MessageLoopProxy> 103 scoped_refptr<MessageLoopProxy>
103 MessageLoopProxy::current() { 104 MessageLoopProxy::current() {
104 MessageLoop* cur_loop = MessageLoop::current(); 105 MessageLoop* cur_loop = MessageLoop::current();
105 if (!cur_loop) 106 if (!cur_loop)
106 return NULL; 107 return NULL;
107 return cur_loop->message_loop_proxy(); 108 return cur_loop->message_loop_proxy();
108 } 109 }
109 110
110 } // namespace base 111 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698