Chromium Code Reviews| 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/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 183 explicit BrowserThreadMessageLoopProxy(BrowserThread::ID identifier) | 183 explicit BrowserThreadMessageLoopProxy(BrowserThread::ID identifier) |
| 184 : id_(identifier) { | 184 : id_(identifier) { |
| 185 } | 185 } |
| 186 | 186 |
| 187 // MessageLoopProxy implementation. | 187 // MessageLoopProxy implementation. |
| 188 virtual bool PostDelayedTask( | 188 virtual bool PostDelayedTask( |
| 189 const tracked_objects::Location& from_here, | 189 const tracked_objects::Location& from_here, |
| 190 const base::Closure& task, int64 delay_ms) OVERRIDE{ | 190 const base::Closure& task, int64 delay_ms) OVERRIDE{ |
| 191 return BrowserThread::PostDelayedTask(id_, from_here, task, delay_ms); | 191 return BrowserThread::PostDelayedTask(id_, from_here, task, delay_ms); |
| 192 } | 192 } |
| 193 virtual bool PostDelayedTask( | |
| 194 const tracked_objects::Location& from_here, | |
| 195 const base::Closure& task, base::TimeDelta delay) OVERRIDE{ | |
|
jar (doing other things)
2012/02/25 02:00:22
nits: space before the curly. Probably one argume
| |
| 196 return BrowserThread::PostDelayedTask(id_, from_here, task, delay); | |
| 197 } | |
| 193 | 198 |
| 194 virtual bool PostNonNestableDelayedTask( | 199 virtual bool PostNonNestableDelayedTask( |
| 195 const tracked_objects::Location& from_here, | 200 const tracked_objects::Location& from_here, |
| 196 const base::Closure& task, | 201 const base::Closure& task, |
| 197 int64 delay_ms) OVERRIDE { | 202 int64 delay_ms) OVERRIDE { |
| 198 return BrowserThread::PostNonNestableDelayedTask(id_, from_here, task, | 203 return BrowserThread::PostNonNestableDelayedTask(id_, from_here, task, |
| 199 delay_ms); | 204 delay_ms); |
| 200 } | 205 } |
| 206 virtual bool PostNonNestableDelayedTask( | |
| 207 const tracked_objects::Location& from_here, | |
| 208 const base::Closure& task, | |
| 209 base::TimeDelta delay) OVERRIDE { | |
| 210 return BrowserThread::PostNonNestableDelayedTask(id_, from_here, task, | |
| 211 delay); | |
| 212 } | |
| 201 | 213 |
| 202 virtual bool RunsTasksOnCurrentThread() const OVERRIDE { | 214 virtual bool RunsTasksOnCurrentThread() const OVERRIDE { |
| 203 return BrowserThread::CurrentlyOn(id_); | 215 return BrowserThread::CurrentlyOn(id_); |
| 204 } | 216 } |
| 205 | 217 |
| 206 private: | 218 private: |
| 207 BrowserThread::ID id_; | 219 BrowserThread::ID id_; |
| 208 DISALLOW_COPY_AND_ASSIGN(BrowserThreadMessageLoopProxy); | 220 DISALLOW_COPY_AND_ASSIGN(BrowserThreadMessageLoopProxy); |
| 209 }; | 221 }; |
| 210 | 222 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 272 // static | 284 // static |
| 273 bool BrowserThread::PostDelayedTask(ID identifier, | 285 bool BrowserThread::PostDelayedTask(ID identifier, |
| 274 const tracked_objects::Location& from_here, | 286 const tracked_objects::Location& from_here, |
| 275 const base::Closure& task, | 287 const base::Closure& task, |
| 276 int64 delay_ms) { | 288 int64 delay_ms) { |
| 277 return BrowserThreadImpl::PostTaskHelper( | 289 return BrowserThreadImpl::PostTaskHelper( |
| 278 identifier, from_here, task, delay_ms, true); | 290 identifier, from_here, task, delay_ms, true); |
| 279 } | 291 } |
| 280 | 292 |
| 281 // static | 293 // static |
| 294 bool BrowserThread::PostDelayedTask(ID identifier, | |
| 295 const tracked_objects::Location& from_here, | |
| 296 const base::Closure& task, | |
| 297 base::TimeDelta delay) { | |
| 298 return BrowserThreadImpl::PostTaskHelper( | |
| 299 identifier, from_here, task, delay.InMilliseconds(), true); | |
|
jar (doing other things)
2012/02/25 02:00:22
I was a bit surprised you converted to ms here, an
| |
| 300 } | |
| 301 | |
| 302 // static | |
| 282 bool BrowserThread::PostNonNestableTask( | 303 bool BrowserThread::PostNonNestableTask( |
| 283 ID identifier, | 304 ID identifier, |
| 284 const tracked_objects::Location& from_here, | 305 const tracked_objects::Location& from_here, |
| 285 const base::Closure& task) { | 306 const base::Closure& task) { |
| 286 return BrowserThreadImpl::PostTaskHelper( | 307 return BrowserThreadImpl::PostTaskHelper( |
| 287 identifier, from_here, task, 0, false); | 308 identifier, from_here, task, 0, false); |
| 288 } | 309 } |
| 289 | 310 |
| 290 // static | 311 // static |
| 291 bool BrowserThread::PostNonNestableDelayedTask( | 312 bool BrowserThread::PostNonNestableDelayedTask( |
| 292 ID identifier, | 313 ID identifier, |
| 293 const tracked_objects::Location& from_here, | 314 const tracked_objects::Location& from_here, |
| 294 const base::Closure& task, | 315 const base::Closure& task, |
| 295 int64 delay_ms) { | 316 int64 delay_ms) { |
| 296 return BrowserThreadImpl::PostTaskHelper( | 317 return BrowserThreadImpl::PostTaskHelper( |
| 297 identifier, from_here, task, delay_ms, false); | 318 identifier, from_here, task, delay_ms, false); |
| 298 } | 319 } |
| 299 | 320 |
| 300 // static | 321 // static |
| 322 bool BrowserThread::PostNonNestableDelayedTask( | |
| 323 ID identifier, | |
| 324 const tracked_objects::Location& from_here, | |
| 325 const base::Closure& task, | |
| 326 base::TimeDelta delay) { | |
| 327 return BrowserThreadImpl::PostTaskHelper( | |
| 328 identifier, from_here, task, delay.InMilliseconds(), false); | |
| 329 } | |
| 330 | |
| 331 // static | |
| 301 bool BrowserThread::PostTaskAndReply( | 332 bool BrowserThread::PostTaskAndReply( |
| 302 ID identifier, | 333 ID identifier, |
| 303 const tracked_objects::Location& from_here, | 334 const tracked_objects::Location& from_here, |
| 304 const base::Closure& task, | 335 const base::Closure& task, |
| 305 const base::Closure& reply) { | 336 const base::Closure& reply) { |
| 306 return GetMessageLoopProxyForThread(identifier)->PostTaskAndReply(from_here, | 337 return GetMessageLoopProxyForThread(identifier)->PostTaskAndReply(from_here, |
| 307 task, | 338 task, |
| 308 reply); | 339 reply); |
| 309 } | 340 } |
| 310 | 341 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 354 AtomicWord* storage = reinterpret_cast<AtomicWord*>( | 385 AtomicWord* storage = reinterpret_cast<AtomicWord*>( |
| 355 &globals.thread_delegates[identifier]); | 386 &globals.thread_delegates[identifier]); |
| 356 AtomicWord old_pointer = base::subtle::NoBarrier_AtomicExchange( | 387 AtomicWord old_pointer = base::subtle::NoBarrier_AtomicExchange( |
| 357 storage, reinterpret_cast<AtomicWord>(delegate)); | 388 storage, reinterpret_cast<AtomicWord>(delegate)); |
| 358 | 389 |
| 359 // This catches registration when previously registered. | 390 // This catches registration when previously registered. |
| 360 DCHECK(!delegate || !old_pointer); | 391 DCHECK(!delegate || !old_pointer); |
| 361 } | 392 } |
| 362 | 393 |
| 363 } // namespace content | 394 } // namespace content |
| OLD | NEW |