OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ios/web/web_thread_impl.h" | 5 #include "ios/web/web_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 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 | 328 |
329 // static | 329 // static |
330 bool WebThread::PostBlockingPoolTask(const tracked_objects::Location& from_here, | 330 bool WebThread::PostBlockingPoolTask(const tracked_objects::Location& from_here, |
331 const base::Closure& task) { | 331 const base::Closure& task) { |
332 return g_globals.Get().blocking_pool->PostWorkerTask(from_here, task); | 332 return g_globals.Get().blocking_pool->PostWorkerTask(from_here, task); |
333 } | 333 } |
334 | 334 |
335 // static | 335 // static |
336 bool WebThread::PostBlockingPoolTaskAndReply( | 336 bool WebThread::PostBlockingPoolTaskAndReply( |
337 const tracked_objects::Location& from_here, | 337 const tracked_objects::Location& from_here, |
338 const base::Closure& task, | 338 base::Closure task, |
339 const base::Closure& reply) { | 339 base::Closure reply) { |
340 return g_globals.Get().blocking_pool->PostTaskAndReply(from_here, task, | 340 return g_globals.Get().blocking_pool->PostTaskAndReply( |
341 reply); | 341 from_here, std::move(task), std::move(reply)); |
342 } | 342 } |
343 | 343 |
344 // static | 344 // static |
345 bool WebThread::PostBlockingPoolSequencedTask( | 345 bool WebThread::PostBlockingPoolSequencedTask( |
346 const std::string& sequence_token_name, | 346 const std::string& sequence_token_name, |
347 const tracked_objects::Location& from_here, | 347 const tracked_objects::Location& from_here, |
348 const base::Closure& task) { | 348 const base::Closure& task) { |
349 return g_globals.Get().blocking_pool->PostNamedSequencedWorkerTask( | 349 return g_globals.Get().blocking_pool->PostNamedSequencedWorkerTask( |
350 sequence_token_name, from_here, task); | 350 sequence_token_name, from_here, task); |
351 } | 351 } |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 const tracked_objects::Location& from_here, | 433 const tracked_objects::Location& from_here, |
434 const base::Closure& task, | 434 const base::Closure& task, |
435 base::TimeDelta delay) { | 435 base::TimeDelta delay) { |
436 return WebThreadImpl::PostTaskHelper(identifier, from_here, task, delay, | 436 return WebThreadImpl::PostTaskHelper(identifier, from_here, task, delay, |
437 false); | 437 false); |
438 } | 438 } |
439 | 439 |
440 // static | 440 // static |
441 bool WebThread::PostTaskAndReply(ID identifier, | 441 bool WebThread::PostTaskAndReply(ID identifier, |
442 const tracked_objects::Location& from_here, | 442 const tracked_objects::Location& from_here, |
443 const base::Closure& task, | 443 base::Closure task, |
444 const base::Closure& reply) { | 444 base::Closure reply) { |
445 return GetTaskRunnerForThread(identifier) | 445 return GetTaskRunnerForThread(identifier) |
446 ->PostTaskAndReply(from_here, task, reply); | 446 ->PostTaskAndReply(from_here, std::move(task), std::move(reply)); |
447 } | 447 } |
448 | 448 |
449 // static | 449 // static |
450 bool WebThread::GetCurrentThreadIdentifier(ID* identifier) { | 450 bool WebThread::GetCurrentThreadIdentifier(ID* identifier) { |
451 if (g_globals == nullptr) | 451 if (g_globals == nullptr) |
452 return false; | 452 return false; |
453 | 453 |
454 base::MessageLoop* cur_message_loop = base::MessageLoop::current(); | 454 base::MessageLoop* cur_message_loop = base::MessageLoop::current(); |
455 WebThreadGlobals& globals = g_globals.Get(); | 455 WebThreadGlobals& globals = g_globals.Get(); |
456 for (int i = 0; i < ID_COUNT; ++i) { | 456 for (int i = 0; i < ID_COUNT; ++i) { |
(...skipping 20 matching lines...) Expand all Loading... |
477 AtomicWord* storage = | 477 AtomicWord* storage = |
478 reinterpret_cast<AtomicWord*>(&globals.thread_delegates[identifier]); | 478 reinterpret_cast<AtomicWord*>(&globals.thread_delegates[identifier]); |
479 AtomicWord old_pointer = base::subtle::NoBarrier_AtomicExchange( | 479 AtomicWord old_pointer = base::subtle::NoBarrier_AtomicExchange( |
480 storage, reinterpret_cast<AtomicWord>(delegate)); | 480 storage, reinterpret_cast<AtomicWord>(delegate)); |
481 | 481 |
482 // This catches registration when previously registered. | 482 // This catches registration when previously registered. |
483 DCHECK(!delegate || !old_pointer); | 483 DCHECK(!delegate || !old_pointer); |
484 } | 484 } |
485 | 485 |
486 } // namespace web | 486 } // namespace web |
OLD | NEW |