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 <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 // BrowserThread ID to be reinitialized. We explicitly clear the thread ID | 145 // BrowserThread ID to be reinitialized. We explicitly clear the thread ID |
146 // here so Start() can sanity check. | 146 // here so Start() can sanity check. |
147 BrowserThreadGlobals& globals = g_globals.Get(); | 147 BrowserThreadGlobals& globals = g_globals.Get(); |
148 base::AutoLock lock(globals.lock); | 148 base::AutoLock lock(globals.lock); |
149 globals.thread_ids[identifier] = base::kInvalidThreadId; | 149 globals.thread_ids[identifier] = base::kInvalidThreadId; |
150 } | 150 } |
151 | 151 |
152 BrowserThreadImpl::BrowserThreadImpl(ID identifier, | 152 BrowserThreadImpl::BrowserThreadImpl(ID identifier, |
153 base::MessageLoop* message_loop) | 153 base::MessageLoop* message_loop) |
154 : Thread(GetThreadName(identifier)), identifier_(identifier) { | 154 : Thread(GetThreadName(identifier)), identifier_(identifier) { |
155 set_message_loop(message_loop); | 155 SetMessageLoop(message_loop); |
156 Initialize(); | 156 Initialize(); |
157 | 157 |
158 // If constructed with an explicit message loop, this is a fake BrowserThread | 158 // If constructed with an explicit message loop, this is a fake BrowserThread |
159 // which runs on the current thread. | 159 // which runs on the current thread. |
160 BrowserThreadGlobals& globals = g_globals.Get(); | 160 BrowserThreadGlobals& globals = g_globals.Get(); |
161 base::AutoLock lock(globals.lock); | 161 base::AutoLock lock(globals.lock); |
162 globals.thread_ids[identifier] = base::PlatformThread::CurrentId(); | 162 globals.thread_ids[identifier] = base::PlatformThread::CurrentId(); |
163 } | 163 } |
164 | 164 |
165 // static | 165 // static |
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
582 AtomicWord* storage = reinterpret_cast<AtomicWord*>( | 582 AtomicWord* storage = reinterpret_cast<AtomicWord*>( |
583 &globals.thread_delegates[identifier]); | 583 &globals.thread_delegates[identifier]); |
584 AtomicWord old_pointer = base::subtle::NoBarrier_AtomicExchange( | 584 AtomicWord old_pointer = base::subtle::NoBarrier_AtomicExchange( |
585 storage, reinterpret_cast<AtomicWord>(delegate)); | 585 storage, reinterpret_cast<AtomicWord>(delegate)); |
586 | 586 |
587 // This catches registration when previously registered. | 587 // This catches registration when previously registered. |
588 DCHECK(!delegate || !old_pointer); | 588 DCHECK(!delegate || !old_pointer); |
589 } | 589 } |
590 | 590 |
591 } // namespace content | 591 } // namespace content |
OLD | NEW |