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

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

Issue 18618004: Change BrowserThreadDelegate to run Init() async. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 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 "content/browser/browser_thread_impl.h" 5 #include "content/browser/browser_thread_impl.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/atomicops.h" 9 #include "base/atomicops.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 96
97 void BrowserThreadImpl::Init() { 97 void BrowserThreadImpl::Init() {
98 BrowserThreadGlobals& globals = g_globals.Get(); 98 BrowserThreadGlobals& globals = g_globals.Get();
99 99
100 using base::subtle::AtomicWord; 100 using base::subtle::AtomicWord;
101 AtomicWord* storage = 101 AtomicWord* storage =
102 reinterpret_cast<AtomicWord*>(&globals.thread_delegates[identifier_]); 102 reinterpret_cast<AtomicWord*>(&globals.thread_delegates[identifier_]);
103 AtomicWord stored_pointer = base::subtle::NoBarrier_Load(storage); 103 AtomicWord stored_pointer = base::subtle::NoBarrier_Load(storage);
104 BrowserThreadDelegate* delegate = 104 BrowserThreadDelegate* delegate =
105 reinterpret_cast<BrowserThreadDelegate*>(stored_pointer); 105 reinterpret_cast<BrowserThreadDelegate*>(stored_pointer);
106 if (delegate) 106 if (delegate) {
107 delegate->Init(); 107 message_loop()->PostTask(
108 FROM_HERE,
109 base::Bind(&BrowserThreadDelegate::Init, base::Unretained(delegate)));
jam 2013/07/11 20:57:13 what guarantee do we have now that BrowserThreadDe
110 }
108 } 111 }
109 112
110 // We disable optimizations for this block of functions so the compiler doesn't 113 // We disable optimizations for this block of functions so the compiler doesn't
111 // merge them all together. 114 // merge them all together.
112 MSVC_DISABLE_OPTIMIZE() 115 MSVC_DISABLE_OPTIMIZE()
113 MSVC_PUSH_DISABLE_WARNING(4748) 116 MSVC_PUSH_DISABLE_WARNING(4748)
114 117
115 NOINLINE void BrowserThreadImpl::UIThreadRun(base::MessageLoop* message_loop) { 118 NOINLINE void BrowserThreadImpl::UIThreadRun(base::MessageLoop* message_loop) {
116 volatile int line_number = __LINE__; 119 volatile int line_number = __LINE__;
117 Thread::Run(message_loop); 120 Thread::Run(message_loop);
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 AtomicWord* storage = reinterpret_cast<AtomicWord*>( 480 AtomicWord* storage = reinterpret_cast<AtomicWord*>(
478 &globals.thread_delegates[identifier]); 481 &globals.thread_delegates[identifier]);
479 AtomicWord old_pointer = base::subtle::NoBarrier_AtomicExchange( 482 AtomicWord old_pointer = base::subtle::NoBarrier_AtomicExchange(
480 storage, reinterpret_cast<AtomicWord>(delegate)); 483 storage, reinterpret_cast<AtomicWord>(delegate));
481 484
482 // This catches registration when previously registered. 485 // This catches registration when previously registered.
483 DCHECK(!delegate || !old_pointer); 486 DCHECK(!delegate || !old_pointer);
484 } 487 }
485 488
486 } // namespace content 489 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698