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 #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/logging.h" | 14 #include "base/logging.h" |
14 #include "base/macros.h" | 15 #include "base/macros.h" |
15 #include "base/message_loop/message_loop.h" | 16 #include "base/message_loop/message_loop.h" |
16 #include "base/profiler/scoped_tracker.h" | 17 #include "base/profiler/scoped_tracker.h" |
17 #include "base/run_loop.h" | 18 #include "base/run_loop.h" |
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 // static | 532 // static |
532 bool BrowserThread::PostBlockingPoolTask( | 533 bool BrowserThread::PostBlockingPoolTask( |
533 const tracked_objects::Location& from_here, | 534 const tracked_objects::Location& from_here, |
534 const base::Closure& task) { | 535 const base::Closure& task) { |
535 return g_globals.Get().blocking_pool->PostWorkerTask(from_here, task); | 536 return g_globals.Get().blocking_pool->PostWorkerTask(from_here, task); |
536 } | 537 } |
537 | 538 |
538 // static | 539 // static |
539 bool BrowserThread::PostBlockingPoolTaskAndReply( | 540 bool BrowserThread::PostBlockingPoolTaskAndReply( |
540 const tracked_objects::Location& from_here, | 541 const tracked_objects::Location& from_here, |
541 const base::Closure& task, | 542 base::Closure task, |
542 const base::Closure& reply) { | 543 base::Closure reply) { |
543 return g_globals.Get().blocking_pool->PostTaskAndReply( | 544 return g_globals.Get().blocking_pool->PostTaskAndReply( |
544 from_here, task, reply); | 545 from_here, std::move(task), std::move(reply)); |
545 } | 546 } |
546 | 547 |
547 // static | 548 // static |
548 bool BrowserThread::PostBlockingPoolSequencedTask( | 549 bool BrowserThread::PostBlockingPoolSequencedTask( |
549 const std::string& sequence_token_name, | 550 const std::string& sequence_token_name, |
550 const tracked_objects::Location& from_here, | 551 const tracked_objects::Location& from_here, |
551 const base::Closure& task) { | 552 const base::Closure& task) { |
552 return g_globals.Get().blocking_pool->PostNamedSequencedWorkerTask( | 553 return g_globals.Get().blocking_pool->PostNamedSequencedWorkerTask( |
553 sequence_token_name, from_here, task); | 554 sequence_token_name, from_here, task); |
554 } | 555 } |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
646 bool BrowserThread::PostNonNestableDelayedTask( | 647 bool BrowserThread::PostNonNestableDelayedTask( |
647 ID identifier, | 648 ID identifier, |
648 const tracked_objects::Location& from_here, | 649 const tracked_objects::Location& from_here, |
649 const base::Closure& task, | 650 const base::Closure& task, |
650 base::TimeDelta delay) { | 651 base::TimeDelta delay) { |
651 return BrowserThreadImpl::PostTaskHelper( | 652 return BrowserThreadImpl::PostTaskHelper( |
652 identifier, from_here, task, delay, false); | 653 identifier, from_here, task, delay, false); |
653 } | 654 } |
654 | 655 |
655 // static | 656 // static |
656 bool BrowserThread::PostTaskAndReply( | 657 bool BrowserThread::PostTaskAndReply(ID identifier, |
657 ID identifier, | 658 const tracked_objects::Location& from_here, |
658 const tracked_objects::Location& from_here, | 659 base::Closure task, |
659 const base::Closure& task, | 660 base::Closure reply) { |
660 const base::Closure& reply) { | |
661 return GetTaskRunnerForThread(identifier) | 661 return GetTaskRunnerForThread(identifier) |
662 ->PostTaskAndReply(from_here, task, reply); | 662 ->PostTaskAndReply(from_here, std::move(task), std::move(reply)); |
663 } | 663 } |
664 | 664 |
665 // static | 665 // static |
666 bool BrowserThread::GetCurrentThreadIdentifier(ID* identifier) { | 666 bool BrowserThread::GetCurrentThreadIdentifier(ID* identifier) { |
667 if (g_globals == nullptr) | 667 if (g_globals == nullptr) |
668 return false; | 668 return false; |
669 | 669 |
670 BrowserThreadGlobals& globals = g_globals.Get(); | 670 BrowserThreadGlobals& globals = g_globals.Get(); |
671 // Profiler to track potential contention on |globals.lock|. This only does | 671 // Profiler to track potential contention on |globals.lock|. This only does |
672 // real work on canary and local dev builds, so the cost of having this here | 672 // real work on canary and local dev builds, so the cost of having this here |
(...skipping 23 matching lines...) Expand all Loading... |
696 BrowserThreadDelegateAtomicPtr old_delegate = | 696 BrowserThreadDelegateAtomicPtr old_delegate = |
697 base::subtle::NoBarrier_AtomicExchange( | 697 base::subtle::NoBarrier_AtomicExchange( |
698 &globals.io_thread_delegate, | 698 &globals.io_thread_delegate, |
699 reinterpret_cast<BrowserThreadDelegateAtomicPtr>(delegate)); | 699 reinterpret_cast<BrowserThreadDelegateAtomicPtr>(delegate)); |
700 | 700 |
701 // This catches registration when previously registered. | 701 // This catches registration when previously registered. |
702 DCHECK(!delegate || !old_delegate); | 702 DCHECK(!delegate || !old_delegate); |
703 } | 703 } |
704 | 704 |
705 } // namespace content | 705 } // namespace content |
OLD | NEW |