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

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

Issue 2136563002: Remove calls to MessageLoop::current() in base. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: restore dns_config_service_posix_unittest.cc Created 4 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
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.h> 7 #include <string.h>
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "base/atomicops.h" 11 #include "base/atomicops.h"
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/lazy_instance.h" 14 #include "base/lazy_instance.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/profiler/scoped_tracker.h" 16 #include "base/profiler/scoped_tracker.h"
17 #include "base/run_loop.h"
17 #include "base/single_thread_task_runner.h" 18 #include "base/single_thread_task_runner.h"
18 #include "base/threading/platform_thread.h" 19 #include "base/threading/platform_thread.h"
19 #include "base/threading/sequenced_worker_pool.h" 20 #include "base/threading/sequenced_worker_pool.h"
20 #include "build/build_config.h" 21 #include "build/build_config.h"
21 #include "content/public/browser/browser_thread_delegate.h" 22 #include "content/public/browser/browser_thread_delegate.h"
22 #include "content/public/browser/content_browser_client.h" 23 #include "content/public/browser/content_browser_client.h"
23 #include "net/disk_cache/simple/simple_backend_impl.h" 24 #include "net/disk_cache/simple/simple_backend_impl.h"
24 25
25 #if defined(OS_ANDROID) 26 #if defined(OS_ANDROID)
26 #include "base/android/jni_android.h" 27 #include "base/android/jni_android.h"
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 reinterpret_cast<BrowserThreadDelegate*>(stored_pointer); 172 reinterpret_cast<BrowserThreadDelegate*>(stored_pointer);
172 if (delegate) 173 if (delegate)
173 delegate->Init(); 174 delegate->Init();
174 } 175 }
175 176
176 // We disable optimizations for this block of functions so the compiler doesn't 177 // We disable optimizations for this block of functions so the compiler doesn't
177 // merge them all together. 178 // merge them all together.
178 MSVC_DISABLE_OPTIMIZE() 179 MSVC_DISABLE_OPTIMIZE()
179 MSVC_PUSH_DISABLE_WARNING(4748) 180 MSVC_PUSH_DISABLE_WARNING(4748)
180 181
181 NOINLINE void BrowserThreadImpl::UIThreadRun(base::MessageLoop* message_loop) { 182 NOINLINE void BrowserThreadImpl::UIThreadRun(base::RunLoop* run_loop) {
182 volatile int line_number = __LINE__; 183 volatile int line_number = __LINE__;
183 Thread::Run(message_loop); 184 Thread::Run(run_loop);
184 CHECK_GT(line_number, 0); 185 CHECK_GT(line_number, 0);
185 } 186 }
186 187
187 NOINLINE void BrowserThreadImpl::DBThreadRun(base::MessageLoop* message_loop) { 188 NOINLINE void BrowserThreadImpl::DBThreadRun(base::RunLoop* run_loop) {
188 volatile int line_number = __LINE__; 189 volatile int line_number = __LINE__;
189 Thread::Run(message_loop); 190 Thread::Run(run_loop);
190 CHECK_GT(line_number, 0); 191 CHECK_GT(line_number, 0);
191 } 192 }
192 193
193 NOINLINE void BrowserThreadImpl::FileThreadRun( 194 NOINLINE void BrowserThreadImpl::FileThreadRun(base::RunLoop* run_loop) {
194 base::MessageLoop* message_loop) {
195 volatile int line_number = __LINE__; 195 volatile int line_number = __LINE__;
196 Thread::Run(message_loop); 196 Thread::Run(run_loop);
197 CHECK_GT(line_number, 0); 197 CHECK_GT(line_number, 0);
198 } 198 }
199 199
200 NOINLINE void BrowserThreadImpl::FileUserBlockingThreadRun( 200 NOINLINE void BrowserThreadImpl::FileUserBlockingThreadRun(
201 base::MessageLoop* message_loop) { 201 base::RunLoop* run_loop) {
202 volatile int line_number = __LINE__; 202 volatile int line_number = __LINE__;
203 Thread::Run(message_loop); 203 Thread::Run(run_loop);
204 CHECK_GT(line_number, 0); 204 CHECK_GT(line_number, 0);
205 } 205 }
206 206
207 NOINLINE void BrowserThreadImpl::ProcessLauncherThreadRun( 207 NOINLINE void BrowserThreadImpl::ProcessLauncherThreadRun(
208 base::MessageLoop* message_loop) { 208 base::RunLoop* run_loop) {
209 volatile int line_number = __LINE__; 209 volatile int line_number = __LINE__;
210 Thread::Run(message_loop); 210 Thread::Run(run_loop);
211 CHECK_GT(line_number, 0); 211 CHECK_GT(line_number, 0);
212 } 212 }
213 213
214 NOINLINE void BrowserThreadImpl::CacheThreadRun( 214 NOINLINE void BrowserThreadImpl::CacheThreadRun(base::RunLoop* run_loop) {
215 base::MessageLoop* message_loop) {
216 volatile int line_number = __LINE__; 215 volatile int line_number = __LINE__;
217 Thread::Run(message_loop); 216 Thread::Run(run_loop);
218 CHECK_GT(line_number, 0); 217 CHECK_GT(line_number, 0);
219 } 218 }
220 219
221 NOINLINE void BrowserThreadImpl::IOThreadRun(base::MessageLoop* message_loop) { 220 NOINLINE void BrowserThreadImpl::IOThreadRun(base::RunLoop* run_loop) {
222 volatile int line_number = __LINE__; 221 volatile int line_number = __LINE__;
223 Thread::Run(message_loop); 222 Thread::Run(run_loop);
224 CHECK_GT(line_number, 0); 223 CHECK_GT(line_number, 0);
225 } 224 }
226 225
227 MSVC_POP_WARNING() 226 MSVC_POP_WARNING()
228 MSVC_ENABLE_OPTIMIZE(); 227 MSVC_ENABLE_OPTIMIZE();
229 228
230 void BrowserThreadImpl::Run(base::MessageLoop* message_loop) { 229 void BrowserThreadImpl::Run(base::RunLoop* run_loop) {
231 #if defined(OS_ANDROID) 230 #if defined(OS_ANDROID)
232 // Not to reset thread name to "Thread-???" by VM, attach VM with thread name. 231 // Not to reset thread name to "Thread-???" by VM, attach VM with thread name.
233 // Though it may create unnecessary VM thread objects, keeping thread name 232 // Though it may create unnecessary VM thread objects, keeping thread name
234 // gives more benefit in debugging in the platform. 233 // gives more benefit in debugging in the platform.
235 if (!thread_name().empty()) { 234 if (!thread_name().empty()) {
236 base::android::AttachCurrentThreadWithName(thread_name()); 235 base::android::AttachCurrentThreadWithName(thread_name());
237 } 236 }
238 #endif 237 #endif
239 238
240 BrowserThread::ID thread_id = ID_COUNT; 239 BrowserThread::ID thread_id = ID_COUNT;
241 CHECK(GetCurrentThreadIdentifier(&thread_id)); 240 CHECK(GetCurrentThreadIdentifier(&thread_id));
242 CHECK_EQ(identifier_, thread_id); 241 CHECK_EQ(identifier_, thread_id);
243 CHECK_EQ(Thread::message_loop(), message_loop);
244 242
245 switch (identifier_) { 243 switch (identifier_) {
246 case BrowserThread::UI: 244 case BrowserThread::UI:
247 return UIThreadRun(message_loop); 245 return UIThreadRun(run_loop);
248 case BrowserThread::DB: 246 case BrowserThread::DB:
249 return DBThreadRun(message_loop); 247 return DBThreadRun(run_loop);
250 case BrowserThread::FILE: 248 case BrowserThread::FILE:
251 return FileThreadRun(message_loop); 249 return FileThreadRun(run_loop);
252 case BrowserThread::FILE_USER_BLOCKING: 250 case BrowserThread::FILE_USER_BLOCKING:
253 return FileUserBlockingThreadRun(message_loop); 251 return FileUserBlockingThreadRun(run_loop);
254 case BrowserThread::PROCESS_LAUNCHER: 252 case BrowserThread::PROCESS_LAUNCHER:
255 return ProcessLauncherThreadRun(message_loop); 253 return ProcessLauncherThreadRun(run_loop);
256 case BrowserThread::CACHE: 254 case BrowserThread::CACHE:
257 return CacheThreadRun(message_loop); 255 return CacheThreadRun(run_loop);
258 case BrowserThread::IO: 256 case BrowserThread::IO:
259 return IOThreadRun(message_loop); 257 return IOThreadRun(run_loop);
260 case BrowserThread::ID_COUNT: 258 case BrowserThread::ID_COUNT:
261 CHECK(false); // This shouldn't actually be reached! 259 CHECK(false); // This shouldn't actually be reached!
262 break; 260 break;
263 } 261 }
264 262
265 // |identifier_| must be set to a valid enum value in the constructor, so it 263 // |identifier_| must be set to a valid enum value in the constructor, so it
266 // should be impossible to reach here. 264 // should be impossible to reach here.
267 CHECK(false); 265 CHECK(false);
268 } 266 }
269 267
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 AtomicWord* storage = reinterpret_cast<AtomicWord*>( 545 AtomicWord* storage = reinterpret_cast<AtomicWord*>(
548 &globals.thread_delegates[identifier]); 546 &globals.thread_delegates[identifier]);
549 AtomicWord old_pointer = base::subtle::NoBarrier_AtomicExchange( 547 AtomicWord old_pointer = base::subtle::NoBarrier_AtomicExchange(
550 storage, reinterpret_cast<AtomicWord>(delegate)); 548 storage, reinterpret_cast<AtomicWord>(delegate));
551 549
552 // This catches registration when previously registered. 550 // This catches registration when previously registered.
553 DCHECK(!delegate || !old_pointer); 551 DCHECK(!delegate || !old_pointer);
554 } 552 }
555 553
556 } // namespace content 554 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698