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

Side by Side Diff: base/message_loop_proxy_impl.cc

Issue 5347001: Fix shutdown crash in CertVerifier by using a MessageLoopProxy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add lock.h Created 10 years, 1 month 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
« no previous file with comments | « base/message_loop_proxy.h ('k') | net/base/cert_verifier.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "base/thread_restrictions.h"
7 7
8 namespace base { 8 namespace base {
9 9
10 MessageLoopProxyImpl::MessageLoopProxyImpl() 10 MessageLoopProxyImpl::MessageLoopProxyImpl()
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 } 71 }
72 ret = true; 72 ret = true;
73 } 73 }
74 } 74 }
75 if (!ret) 75 if (!ret)
76 delete task; 76 delete task;
77 return ret; 77 return ret;
78 } 78 }
79 79
80 void MessageLoopProxyImpl::OnDestruct() const { 80 void MessageLoopProxyImpl::OnDestruct() const {
81 // We shouldn't use MessageLoop::current() since it uses LazyInstance which
82 // may be deleted by ~AtExitManager when a WorkerPool thread calls this
83 // function.
84 // http://crbug.com/63678
85 base::ThreadRestrictions::ScopedAllowSingleton allow_singleton;
81 bool delete_later = false; 86 bool delete_later = false;
82 { 87 {
83 AutoLock lock(message_loop_lock_); 88 AutoLock lock(message_loop_lock_);
84 if (target_message_loop_ && 89 if (target_message_loop_ &&
85 (MessageLoop::current() != target_message_loop_)) { 90 (MessageLoop::current() != target_message_loop_)) {
86 target_message_loop_->DeleteSoon(FROM_HERE, this); 91 target_message_loop_->DeleteSoon(FROM_HERE, this);
87 delete_later = true; 92 delete_later = true;
88 } 93 }
89 } 94 }
90 if (!delete_later) 95 if (!delete_later)
91 delete this; 96 delete this;
92 } 97 }
93 98
94 // MessageLoop::DestructionObserver implementation 99 // MessageLoop::DestructionObserver implementation
95 void MessageLoopProxyImpl::WillDestroyCurrentMessageLoop() { 100 void MessageLoopProxyImpl::WillDestroyCurrentMessageLoop() {
96 AutoLock lock(message_loop_lock_); 101 AutoLock lock(message_loop_lock_);
97 target_message_loop_ = NULL; 102 target_message_loop_ = NULL;
98 } 103 }
99 104
100 scoped_refptr<MessageLoopProxy> 105 scoped_refptr<MessageLoopProxy>
101 MessageLoopProxy::CreateForCurrentThread() { 106 MessageLoopProxy::CreateForCurrentThread() {
102 scoped_refptr<MessageLoopProxy> ret(new MessageLoopProxyImpl()); 107 scoped_refptr<MessageLoopProxy> ret(new MessageLoopProxyImpl());
103 return ret; 108 return ret;
104 } 109 }
105 110
106 } // namespace base 111 } // namespace base
OLDNEW
« no previous file with comments | « base/message_loop_proxy.h ('k') | net/base/cert_verifier.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698