OLD | NEW |
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 "base/atomicops.h" | 7 #include "base/atomicops.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
11 #include "base/message_loop_proxy.h" | 11 #include "base/message_loop_proxy.h" |
12 #include "base/threading/thread_restrictions.h" | 12 #include "base/threading/thread_restrictions.h" |
13 | 13 |
14 namespace content { | 14 namespace content { |
15 | 15 |
16 namespace { | 16 namespace { |
17 | 17 |
18 // Friendly names for the well-known threads. | 18 // Friendly names for the well-known threads. |
19 static const char* g_browser_thread_names[BrowserThread::ID_COUNT] = { | 19 static const char* g_browser_thread_names[BrowserThread::ID_COUNT] = { |
20 "", // UI (name assembled in browser_main.cc). | 20 "", // UI (name assembled in browser_main.cc). |
21 "Chrome_DBThread", // DB | 21 "Chrome_DBThread", // DB |
22 "Chrome_WebKitThread", // WEBKIT_DEPRECATED | 22 "Chrome_WebKitThread", // WEBKIT_DEPRECATED |
23 "Chrome_FileThread", // FILE | 23 "Chrome_FileThread", // FILE |
24 "Chrome_FileUserBlockingThread", // FILE_USER_BLOCKING | 24 "Chrome_FileUserBlockingThread", // FILE_USER_BLOCKING |
25 "Chrome_ProcessLauncherThread", // PROCESS_LAUNCHER | 25 "Chrome_ProcessLauncherThread", // PROCESS_LAUNCHER |
26 "Chrome_CacheThread", // CACHE | 26 "Chrome_CacheThread", // CACHE |
27 "Chrome_IOThread", // IO | 27 "Chrome_IOThread", // IO |
28 #if defined(OS_CHROMEOS) | |
29 "Chrome_WebSocketproxyThread", // WEB_SOCKET_PROXY | |
30 #endif | |
31 }; | 28 }; |
32 | 29 |
33 // This lock protects |g_browser_threads|. Do not read or modify that | 30 // This lock protects |g_browser_threads|. Do not read or modify that |
34 // array without holding this lock. Do not block while holding this | 31 // array without holding this lock. Do not block while holding this |
35 // lock. | 32 // lock. |
36 base::LazyInstance<base::Lock, | 33 base::LazyInstance<base::Lock, |
37 base::LeakyLazyInstanceTraits<base::Lock> > | 34 base::LeakyLazyInstanceTraits<base::Lock> > |
38 g_lock = LAZY_INSTANCE_INITIALIZER; | 35 g_lock = LAZY_INSTANCE_INITIALIZER; |
39 | 36 |
40 // This array is protected by |g_lock|. The threads are not owned by this | 37 // This array is protected by |g_lock|. The threads are not owned by this |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 AtomicWord* storage = reinterpret_cast<AtomicWord*>( | 308 AtomicWord* storage = reinterpret_cast<AtomicWord*>( |
312 &g_browser_thread_delegates[identifier]); | 309 &g_browser_thread_delegates[identifier]); |
313 AtomicWord old_pointer = base::subtle::NoBarrier_AtomicExchange( | 310 AtomicWord old_pointer = base::subtle::NoBarrier_AtomicExchange( |
314 storage, reinterpret_cast<AtomicWord>(delegate)); | 311 storage, reinterpret_cast<AtomicWord>(delegate)); |
315 | 312 |
316 // This catches registration when previously registered. | 313 // This catches registration when previously registered. |
317 DCHECK(!delegate || !old_pointer); | 314 DCHECK(!delegate || !old_pointer); |
318 } | 315 } |
319 | 316 |
320 } // namespace content | 317 } // namespace content |
OLD | NEW |