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

Side by Side Diff: content/browser/browser_thread_impl.cc

Issue 8343062: Quick fix for memory race inherent to all subclasses of base::Thread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 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 | « no previous file | no next file » | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "content/browser/browser_thread_impl.h" 5 #include "content/browser/browser_thread_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/message_loop_proxy.h" 9 #include "base/message_loop_proxy.h"
10 #include "base/threading/thread_restrictions.h" 10 #include "base/threading/thread_restrictions.h"
(...skipping 25 matching lines...) Expand all
36 BrowserThreadImpl::BrowserThreadImpl(BrowserThread::ID identifier) 36 BrowserThreadImpl::BrowserThreadImpl(BrowserThread::ID identifier)
37 : BrowserThread(identifier) { 37 : BrowserThread(identifier) {
38 } 38 }
39 39
40 BrowserThreadImpl::BrowserThreadImpl(BrowserThread::ID identifier, 40 BrowserThreadImpl::BrowserThreadImpl(BrowserThread::ID identifier,
41 MessageLoop* message_loop) 41 MessageLoop* message_loop)
42 : BrowserThread(identifier, message_loop) { 42 : BrowserThread(identifier, message_loop) {
43 } 43 }
44 44
45 BrowserThreadImpl::~BrowserThreadImpl() { 45 BrowserThreadImpl::~BrowserThreadImpl() {
46 // Subclasses of base::Thread() (or at least the most-derived
47 // subclass) must call Stop() in their destructor, otherwise the
48 // vtable for the object can change while the thread's message loop
49 // is still running, and it uses the object's vtable (it calls the
50 // virtual method Run).
51 Stop();
46 } 52 }
47 53
48 // static 54 // static
49 bool BrowserThreadImpl::PostTaskHelper( 55 bool BrowserThreadImpl::PostTaskHelper(
50 BrowserThread::ID identifier, 56 BrowserThread::ID identifier,
51 const tracked_objects::Location& from_here, 57 const tracked_objects::Location& from_here,
52 Task* task, 58 Task* task,
53 int64 delay_ms, 59 int64 delay_ms,
54 bool nestable) { 60 bool nestable) {
55 DCHECK(identifier >= 0 && identifier < ID_COUNT); 61 DCHECK(identifier >= 0 && identifier < ID_COUNT);
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 } 380 }
375 381
376 // static 382 // static
377 scoped_refptr<base::MessageLoopProxy> 383 scoped_refptr<base::MessageLoopProxy>
378 BrowserThread::GetMessageLoopProxyForThread( 384 BrowserThread::GetMessageLoopProxyForThread(
379 ID identifier) { 385 ID identifier) {
380 scoped_refptr<base::MessageLoopProxy> proxy( 386 scoped_refptr<base::MessageLoopProxy> proxy(
381 new BrowserThreadMessageLoopProxy(identifier)); 387 new BrowserThreadMessageLoopProxy(identifier));
382 return proxy; 388 return proxy;
383 } 389 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698