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

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

Issue 78863002: fix "may be used uninitialized" warnings for older compilers (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: undo changes to target_thread_outlives_current Created 7 years 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) 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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 NOINLINE void BrowserThreadImpl::IOThreadRun(base::MessageLoop* message_loop) { 160 NOINLINE void BrowserThreadImpl::IOThreadRun(base::MessageLoop* message_loop) {
161 volatile int line_number = __LINE__; 161 volatile int line_number = __LINE__;
162 Thread::Run(message_loop); 162 Thread::Run(message_loop);
163 CHECK_GT(line_number, 0); 163 CHECK_GT(line_number, 0);
164 } 164 }
165 165
166 MSVC_POP_WARNING() 166 MSVC_POP_WARNING()
167 MSVC_ENABLE_OPTIMIZE(); 167 MSVC_ENABLE_OPTIMIZE();
168 168
169 void BrowserThreadImpl::Run(base::MessageLoop* message_loop) { 169 void BrowserThreadImpl::Run(base::MessageLoop* message_loop) {
170 BrowserThread::ID thread_id; 170 BrowserThread::ID thread_id = ID_COUNT;
171 if (!GetCurrentThreadIdentifier(&thread_id)) 171 if (!GetCurrentThreadIdentifier(&thread_id))
172 return Thread::Run(message_loop); 172 return Thread::Run(message_loop);
173 173
174 switch (thread_id) { 174 switch (thread_id) {
175 case BrowserThread::UI: 175 case BrowserThread::UI:
176 return UIThreadRun(message_loop); 176 return UIThreadRun(message_loop);
177 case BrowserThread::DB: 177 case BrowserThread::DB:
178 return DBThreadRun(message_loop); 178 return DBThreadRun(message_loop);
179 case BrowserThread::FILE: 179 case BrowserThread::FILE:
180 return FileThreadRun(message_loop); 180 return FileThreadRun(message_loop);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 const base::Closure& task, 241 const base::Closure& task,
242 base::TimeDelta delay, 242 base::TimeDelta delay,
243 bool nestable) { 243 bool nestable) {
244 DCHECK(identifier >= 0 && identifier < ID_COUNT); 244 DCHECK(identifier >= 0 && identifier < ID_COUNT);
245 // Optimization: to avoid unnecessary locks, we listed the ID enumeration in 245 // Optimization: to avoid unnecessary locks, we listed the ID enumeration in
246 // order of lifetime. So no need to lock if we know that the target thread 246 // order of lifetime. So no need to lock if we know that the target thread
247 // outlives current thread. 247 // outlives current thread.
248 // Note: since the array is so small, ok to loop instead of creating a map, 248 // Note: since the array is so small, ok to loop instead of creating a map,
249 // which would require a lock because std::map isn't thread safe, defeating 249 // which would require a lock because std::map isn't thread safe, defeating
250 // the whole purpose of this optimization. 250 // the whole purpose of this optimization.
251 BrowserThread::ID current_thread; 251 BrowserThread::ID current_thread = ID_COUNT;
252 bool target_thread_outlives_current = 252 bool target_thread_outlives_current =
253 GetCurrentThreadIdentifier(&current_thread) && 253 GetCurrentThreadIdentifier(&current_thread) &&
254 current_thread >= identifier; 254 current_thread >= identifier;
255 255
256 BrowserThreadGlobals& globals = g_globals.Get(); 256 BrowserThreadGlobals& globals = g_globals.Get();
257 if (!target_thread_outlives_current) 257 if (!target_thread_outlives_current)
258 globals.lock.Acquire(); 258 globals.lock.Acquire();
259 259
260 base::MessageLoop* message_loop = 260 base::MessageLoop* message_loop =
261 globals.threads[identifier] ? globals.threads[identifier]->message_loop() 261 globals.threads[identifier] ? globals.threads[identifier]->message_loop()
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 AtomicWord* storage = reinterpret_cast<AtomicWord*>( 473 AtomicWord* storage = reinterpret_cast<AtomicWord*>(
474 &globals.thread_delegates[identifier]); 474 &globals.thread_delegates[identifier]);
475 AtomicWord old_pointer = base::subtle::NoBarrier_AtomicExchange( 475 AtomicWord old_pointer = base::subtle::NoBarrier_AtomicExchange(
476 storage, reinterpret_cast<AtomicWord>(delegate)); 476 storage, reinterpret_cast<AtomicWord>(delegate));
477 477
478 // This catches registration when previously registered. 478 // This catches registration when previously registered.
479 DCHECK(!delegate || !old_pointer); 479 DCHECK(!delegate || !old_pointer);
480 } 480 }
481 481
482 } // namespace content 482 } // namespace content
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