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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 GetCurrentThreadIdentifier(¤t_thread) && | 155 GetCurrentThreadIdentifier(¤t_thread) && |
156 current_thread <= identifier; | 156 current_thread <= identifier; |
157 | 157 |
158 BrowserThreadGlobals& globals = g_globals.Get(); | 158 BrowserThreadGlobals& globals = g_globals.Get(); |
159 if (!guaranteed_to_outlive_target_thread) | 159 if (!guaranteed_to_outlive_target_thread) |
160 globals.lock.Acquire(); | 160 globals.lock.Acquire(); |
161 | 161 |
162 MessageLoop* message_loop = globals.threads[identifier] ? | 162 MessageLoop* message_loop = globals.threads[identifier] ? |
163 globals.threads[identifier]->message_loop() : NULL; | 163 globals.threads[identifier]->message_loop() : NULL; |
164 if (message_loop) { | 164 if (message_loop) { |
| 165 base::TimeDelta delay = base::TimeDelta::FromMilliseconds(delay_ms); |
165 if (nestable) { | 166 if (nestable) { |
166 message_loop->PostDelayedTask(from_here, task, delay_ms); | 167 message_loop->PostDelayedTask(from_here, task, delay); |
167 } else { | 168 } else { |
168 message_loop->PostNonNestableDelayedTask(from_here, task, delay_ms); | 169 message_loop->PostNonNestableDelayedTask(from_here, task, delay); |
169 } | 170 } |
170 } | 171 } |
171 | 172 |
172 if (!guaranteed_to_outlive_target_thread) | 173 if (!guaranteed_to_outlive_target_thread) |
173 globals.lock.Release(); | 174 globals.lock.Release(); |
174 | 175 |
175 return !!message_loop; | 176 return !!message_loop; |
176 } | 177 } |
177 | 178 |
178 // An implementation of MessageLoopProxy to be used in conjunction | 179 // An implementation of MessageLoopProxy to be used in conjunction |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 AtomicWord* storage = reinterpret_cast<AtomicWord*>( | 363 AtomicWord* storage = reinterpret_cast<AtomicWord*>( |
363 &globals.thread_delegates[identifier]); | 364 &globals.thread_delegates[identifier]); |
364 AtomicWord old_pointer = base::subtle::NoBarrier_AtomicExchange( | 365 AtomicWord old_pointer = base::subtle::NoBarrier_AtomicExchange( |
365 storage, reinterpret_cast<AtomicWord>(delegate)); | 366 storage, reinterpret_cast<AtomicWord>(delegate)); |
366 | 367 |
367 // This catches registration when previously registered. | 368 // This catches registration when previously registered. |
368 DCHECK(!delegate || !old_pointer); | 369 DCHECK(!delegate || !old_pointer); |
369 } | 370 } |
370 | 371 |
371 } // namespace content | 372 } // namespace content |
OLD | NEW |