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

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

Issue 1140363002: Revert of Reland: Lazily initialize MessageLoop for faster thread startup (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 152
153 void BrowserThreadImpl::Init() { 153 void BrowserThreadImpl::Init() {
154 BrowserThreadGlobals& globals = g_globals.Get(); 154 BrowserThreadGlobals& globals = g_globals.Get();
155 155
156 using base::subtle::AtomicWord; 156 using base::subtle::AtomicWord;
157 AtomicWord* storage = 157 AtomicWord* storage =
158 reinterpret_cast<AtomicWord*>(&globals.thread_delegates[identifier_]); 158 reinterpret_cast<AtomicWord*>(&globals.thread_delegates[identifier_]);
159 AtomicWord stored_pointer = base::subtle::NoBarrier_Load(storage); 159 AtomicWord stored_pointer = base::subtle::NoBarrier_Load(storage);
160 BrowserThreadDelegate* delegate = 160 BrowserThreadDelegate* delegate =
161 reinterpret_cast<BrowserThreadDelegate*>(stored_pointer); 161 reinterpret_cast<BrowserThreadDelegate*>(stored_pointer);
162 if (delegate) 162 if (delegate) {
163 delegate->Init(); 163 delegate->Init();
164 message_loop()->PostTask(FROM_HERE,
165 base::Bind(&BrowserThreadDelegate::InitAsync,
166 // Delegate is expected to exist for the
167 // duration of the thread's lifetime
168 base::Unretained(delegate)));
169 }
164 } 170 }
165 171
166 // We disable optimizations for this block of functions so the compiler doesn't 172 // We disable optimizations for this block of functions so the compiler doesn't
167 // merge them all together. 173 // merge them all together.
168 MSVC_DISABLE_OPTIMIZE() 174 MSVC_DISABLE_OPTIMIZE()
169 MSVC_PUSH_DISABLE_WARNING(4748) 175 MSVC_PUSH_DISABLE_WARNING(4748)
170 176
171 NOINLINE void BrowserThreadImpl::UIThreadRun(base::MessageLoop* message_loop) { 177 NOINLINE void BrowserThreadImpl::UIThreadRun(base::MessageLoop* message_loop) {
172 volatile int line_number = __LINE__; 178 volatile int line_number = __LINE__;
173 Thread::Run(message_loop); 179 Thread::Run(message_loop);
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 AtomicWord* storage = reinterpret_cast<AtomicWord*>( 540 AtomicWord* storage = reinterpret_cast<AtomicWord*>(
535 &globals.thread_delegates[identifier]); 541 &globals.thread_delegates[identifier]);
536 AtomicWord old_pointer = base::subtle::NoBarrier_AtomicExchange( 542 AtomicWord old_pointer = base::subtle::NoBarrier_AtomicExchange(
537 storage, reinterpret_cast<AtomicWord>(delegate)); 543 storage, reinterpret_cast<AtomicWord>(delegate));
538 544
539 // This catches registration when previously registered. 545 // This catches registration when previously registered.
540 DCHECK(!delegate || !old_pointer); 546 DCHECK(!delegate || !old_pointer);
541 } 547 }
542 548
543 } // namespace content 549 } // namespace content
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/sync_backend_registrar_unittest.cc ('k') | content/public/browser/browser_thread_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698