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