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" |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 bool guaranteed_to_outlive_target_thread = | 127 bool guaranteed_to_outlive_target_thread = |
128 GetCurrentThreadIdentifier(¤t_thread) && | 128 GetCurrentThreadIdentifier(¤t_thread) && |
129 current_thread <= identifier; | 129 current_thread <= identifier; |
130 | 130 |
131 if (!guaranteed_to_outlive_target_thread) | 131 if (!guaranteed_to_outlive_target_thread) |
132 g_lock.Get().Acquire(); | 132 g_lock.Get().Acquire(); |
133 | 133 |
134 MessageLoop* message_loop = g_browser_threads[identifier] ? | 134 MessageLoop* message_loop = g_browser_threads[identifier] ? |
135 g_browser_threads[identifier]->message_loop() : NULL; | 135 g_browser_threads[identifier]->message_loop() : NULL; |
136 if (message_loop) { | 136 if (message_loop) { |
137 base::TimeDelta delay = base::TimeDelta::FromMilliseconds(delay_ms); | |
138 if (nestable) { | 137 if (nestable) { |
139 message_loop->PostDelayedTask(from_here, task, delay); | 138 message_loop->PostDelayedTask(from_here, task, delay_ms); |
140 } else { | 139 } else { |
141 message_loop->PostNonNestableDelayedTask(from_here, task, delay); | 140 message_loop->PostNonNestableDelayedTask(from_here, task, delay_ms); |
142 } | 141 } |
143 } | 142 } |
144 | 143 |
145 if (!guaranteed_to_outlive_target_thread) | 144 if (!guaranteed_to_outlive_target_thread) |
146 g_lock.Get().Release(); | 145 g_lock.Get().Release(); |
147 | 146 |
148 return !!message_loop; | 147 return !!message_loop; |
149 } | 148 } |
150 | 149 |
151 // An implementation of MessageLoopProxy to be used in conjunction | 150 // An implementation of MessageLoopProxy to be used in conjunction |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 AtomicWord* storage = reinterpret_cast<AtomicWord*>( | 308 AtomicWord* storage = reinterpret_cast<AtomicWord*>( |
310 &g_browser_thread_delegates[identifier]); | 309 &g_browser_thread_delegates[identifier]); |
311 AtomicWord old_pointer = base::subtle::NoBarrier_AtomicExchange( | 310 AtomicWord old_pointer = base::subtle::NoBarrier_AtomicExchange( |
312 storage, reinterpret_cast<AtomicWord>(delegate)); | 311 storage, reinterpret_cast<AtomicWord>(delegate)); |
313 | 312 |
314 // This catches registration when previously registered. | 313 // This catches registration when previously registered. |
315 DCHECK(!delegate || !old_pointer); | 314 DCHECK(!delegate || !old_pointer); |
316 } | 315 } |
317 | 316 |
318 } // namespace content | 317 } // namespace content |
OLD | NEW |