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