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

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

Issue 1058603004: [Approach 3] Pre-allocate IncomigTaskQueue before MessageLoop for faster thread startup Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 151
152 void BrowserThreadImpl::Init() { 152 void BrowserThreadImpl::Init() {
153 BrowserThreadGlobals& globals = g_globals.Get(); 153 BrowserThreadGlobals& globals = g_globals.Get();
154 154
155 using base::subtle::AtomicWord; 155 using base::subtle::AtomicWord;
156 AtomicWord* storage = 156 AtomicWord* storage =
157 reinterpret_cast<AtomicWord*>(&globals.thread_delegates[identifier_]); 157 reinterpret_cast<AtomicWord*>(&globals.thread_delegates[identifier_]);
158 AtomicWord stored_pointer = base::subtle::NoBarrier_Load(storage); 158 AtomicWord stored_pointer = base::subtle::NoBarrier_Load(storage);
159 BrowserThreadDelegate* delegate = 159 BrowserThreadDelegate* delegate =
160 reinterpret_cast<BrowserThreadDelegate*>(stored_pointer); 160 reinterpret_cast<BrowserThreadDelegate*>(stored_pointer);
161 if (delegate) { 161 if (delegate)
162 delegate->Init(); 162 delegate->Init();
163 message_loop()->PostTask(FROM_HERE,
164 base::Bind(&BrowserThreadDelegate::InitAsync,
165 // Delegate is expected to exist for the
166 // duration of the thread's lifetime
167 base::Unretained(delegate)));
168 }
169 } 163 }
170 164
171 // We disable optimizations for this block of functions so the compiler doesn't 165 // We disable optimizations for this block of functions so the compiler doesn't
172 // merge them all together. 166 // merge them all together.
173 MSVC_DISABLE_OPTIMIZE() 167 MSVC_DISABLE_OPTIMIZE()
174 MSVC_PUSH_DISABLE_WARNING(4748) 168 MSVC_PUSH_DISABLE_WARNING(4748)
175 169
176 NOINLINE void BrowserThreadImpl::UIThreadRun(base::MessageLoop* message_loop) { 170 NOINLINE void BrowserThreadImpl::UIThreadRun(base::MessageLoop* message_loop) {
177 volatile int line_number = __LINE__; 171 volatile int line_number = __LINE__;
178 Thread::Run(message_loop); 172 Thread::Run(message_loop);
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 AtomicWord* storage = reinterpret_cast<AtomicWord*>( 524 AtomicWord* storage = reinterpret_cast<AtomicWord*>(
531 &globals.thread_delegates[identifier]); 525 &globals.thread_delegates[identifier]);
532 AtomicWord old_pointer = base::subtle::NoBarrier_AtomicExchange( 526 AtomicWord old_pointer = base::subtle::NoBarrier_AtomicExchange(
533 storage, reinterpret_cast<AtomicWord>(delegate)); 527 storage, reinterpret_cast<AtomicWord>(delegate));
534 528
535 // This catches registration when previously registered. 529 // This catches registration when previously registered.
536 DCHECK(!delegate || !old_pointer); 530 DCHECK(!delegate || !old_pointer);
537 } 531 }
538 532
539 } // namespace content 533 } // 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