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