| 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> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/atomicops.h" | 9 #include "base/atomicops.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 // with BrowserThread. | 179 // with BrowserThread. |
| 180 class BrowserThreadMessageLoopProxy : public base::MessageLoopProxy { | 180 class BrowserThreadMessageLoopProxy : public base::MessageLoopProxy { |
| 181 public: | 181 public: |
| 182 explicit BrowserThreadMessageLoopProxy(BrowserThread::ID identifier) | 182 explicit BrowserThreadMessageLoopProxy(BrowserThread::ID identifier) |
| 183 : id_(identifier) { | 183 : id_(identifier) { |
| 184 } | 184 } |
| 185 | 185 |
| 186 // MessageLoopProxy implementation. | 186 // MessageLoopProxy implementation. |
| 187 virtual bool PostDelayedTask( | 187 virtual bool PostDelayedTask( |
| 188 const tracked_objects::Location& from_here, | 188 const tracked_objects::Location& from_here, |
| 189 const base::Closure& task, int64 delay_ms) OVERRIDE { | |
| 190 return BrowserThread::PostDelayedTask(id_, from_here, task, delay_ms); | |
| 191 } | |
| 192 virtual bool PostDelayedTask( | |
| 193 const tracked_objects::Location& from_here, | |
| 194 const base::Closure& task, base::TimeDelta delay) OVERRIDE { | 189 const base::Closure& task, base::TimeDelta delay) OVERRIDE { |
| 195 return BrowserThread::PostDelayedTask(id_, from_here, task, delay); | 190 return BrowserThread::PostDelayedTask(id_, from_here, task, delay); |
| 196 } | 191 } |
| 197 | 192 |
| 198 virtual bool PostNonNestableDelayedTask( | 193 virtual bool PostNonNestableDelayedTask( |
| 199 const tracked_objects::Location& from_here, | 194 const tracked_objects::Location& from_here, |
| 200 const base::Closure& task, | 195 const base::Closure& task, |
| 201 int64 delay_ms) OVERRIDE { | |
| 202 return BrowserThread::PostNonNestableDelayedTask(id_, from_here, task, | |
| 203 delay_ms); | |
| 204 } | |
| 205 virtual bool PostNonNestableDelayedTask( | |
| 206 const tracked_objects::Location& from_here, | |
| 207 const base::Closure& task, | |
| 208 base::TimeDelta delay) OVERRIDE { | 196 base::TimeDelta delay) OVERRIDE { |
| 209 return BrowserThread::PostNonNestableDelayedTask(id_, from_here, task, | 197 return BrowserThread::PostNonNestableDelayedTask(id_, from_here, task, |
| 210 delay); | 198 delay); |
| 211 } | 199 } |
| 212 | 200 |
| 213 virtual bool RunsTasksOnCurrentThread() const OVERRIDE { | 201 virtual bool RunsTasksOnCurrentThread() const OVERRIDE { |
| 214 return BrowserThread::CurrentlyOn(id_); | 202 return BrowserThread::CurrentlyOn(id_); |
| 215 } | 203 } |
| 216 | 204 |
| 217 protected: | 205 protected: |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 const tracked_objects::Location& from_here, | 282 const tracked_objects::Location& from_here, |
| 295 const base::Closure& task) { | 283 const base::Closure& task) { |
| 296 return BrowserThreadImpl::PostTaskHelper( | 284 return BrowserThreadImpl::PostTaskHelper( |
| 297 identifier, from_here, task, base::TimeDelta(), true); | 285 identifier, from_here, task, base::TimeDelta(), true); |
| 298 } | 286 } |
| 299 | 287 |
| 300 // static | 288 // static |
| 301 bool BrowserThread::PostDelayedTask(ID identifier, | 289 bool BrowserThread::PostDelayedTask(ID identifier, |
| 302 const tracked_objects::Location& from_here, | 290 const tracked_objects::Location& from_here, |
| 303 const base::Closure& task, | 291 const base::Closure& task, |
| 304 int64 delay_ms) { | |
| 305 return BrowserThreadImpl::PostTaskHelper( | |
| 306 identifier, | |
| 307 from_here, | |
| 308 task, | |
| 309 base::TimeDelta::FromMilliseconds(delay_ms), | |
| 310 true); | |
| 311 } | |
| 312 | |
| 313 // static | |
| 314 bool BrowserThread::PostDelayedTask(ID identifier, | |
| 315 const tracked_objects::Location& from_here, | |
| 316 const base::Closure& task, | |
| 317 base::TimeDelta delay) { | 292 base::TimeDelta delay) { |
| 318 return BrowserThreadImpl::PostTaskHelper( | 293 return BrowserThreadImpl::PostTaskHelper( |
| 319 identifier, from_here, task, delay, true); | 294 identifier, from_here, task, delay, true); |
| 320 } | 295 } |
| 321 | 296 |
| 322 // static | 297 // static |
| 323 bool BrowserThread::PostNonNestableTask( | 298 bool BrowserThread::PostNonNestableTask( |
| 324 ID identifier, | 299 ID identifier, |
| 325 const tracked_objects::Location& from_here, | 300 const tracked_objects::Location& from_here, |
| 326 const base::Closure& task) { | 301 const base::Closure& task) { |
| 327 return BrowserThreadImpl::PostTaskHelper( | 302 return BrowserThreadImpl::PostTaskHelper( |
| 328 identifier, from_here, task, base::TimeDelta(), false); | 303 identifier, from_here, task, base::TimeDelta(), false); |
| 329 } | 304 } |
| 330 | 305 |
| 331 // static | 306 // static |
| 332 bool BrowserThread::PostNonNestableDelayedTask( | 307 bool BrowserThread::PostNonNestableDelayedTask( |
| 333 ID identifier, | 308 ID identifier, |
| 334 const tracked_objects::Location& from_here, | 309 const tracked_objects::Location& from_here, |
| 335 const base::Closure& task, | 310 const base::Closure& task, |
| 336 int64 delay_ms) { | |
| 337 return BrowserThreadImpl::PostTaskHelper( | |
| 338 identifier, | |
| 339 from_here, | |
| 340 task, | |
| 341 base::TimeDelta::FromMilliseconds(delay_ms), | |
| 342 false); | |
| 343 } | |
| 344 | |
| 345 // static | |
| 346 bool BrowserThread::PostNonNestableDelayedTask( | |
| 347 ID identifier, | |
| 348 const tracked_objects::Location& from_here, | |
| 349 const base::Closure& task, | |
| 350 base::TimeDelta delay) { | 311 base::TimeDelta delay) { |
| 351 return BrowserThreadImpl::PostTaskHelper( | 312 return BrowserThreadImpl::PostTaskHelper( |
| 352 identifier, from_here, task, delay, false); | 313 identifier, from_here, task, delay, false); |
| 353 } | 314 } |
| 354 | 315 |
| 355 // static | 316 // static |
| 356 bool BrowserThread::PostTaskAndReply( | 317 bool BrowserThread::PostTaskAndReply( |
| 357 ID identifier, | 318 ID identifier, |
| 358 const tracked_objects::Location& from_here, | 319 const tracked_objects::Location& from_here, |
| 359 const base::Closure& task, | 320 const base::Closure& task, |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 AtomicWord* storage = reinterpret_cast<AtomicWord*>( | 376 AtomicWord* storage = reinterpret_cast<AtomicWord*>( |
| 416 &globals.thread_delegates[identifier]); | 377 &globals.thread_delegates[identifier]); |
| 417 AtomicWord old_pointer = base::subtle::NoBarrier_AtomicExchange( | 378 AtomicWord old_pointer = base::subtle::NoBarrier_AtomicExchange( |
| 418 storage, reinterpret_cast<AtomicWord>(delegate)); | 379 storage, reinterpret_cast<AtomicWord>(delegate)); |
| 419 | 380 |
| 420 // This catches registration when previously registered. | 381 // This catches registration when previously registered. |
| 421 DCHECK(!delegate || !old_pointer); | 382 DCHECK(!delegate || !old_pointer); |
| 422 } | 383 } |
| 423 | 384 |
| 424 } // namespace content | 385 } // namespace content |
| OLD | NEW |