[nearby] Migrate to new rtc::Thread::PostTask() API.

In WebRTC, rtc::Thread contains multiple PostTask signatures.
The one that takes "RTC_FROM_HERE" is being deprecated. This CL
upgrades to the newer version to unblock the old signature's
removal. See https://crbug.com/webrtc/13582.

PiperOrigin-RevId: 423317626
This commit is contained in:
hai007
2022-01-21 07:26:06 -08:00
committed by Copybara-Service
parent 56eb46db06
commit e429d2d373
3 changed files with 7 additions and 7 deletions
@@ -298,8 +298,8 @@ bool ConnectionFlow::OnRemoteIceCandidatesReceived(
return false;
}
pc->signaling_thread()->PostTask(
RTC_FROM_HERE, [this, can_run_tasks = std::weak_ptr<void>(can_run_tasks_),
candidates = std::move(ice_candidates)]() mutable {
[this, can_run_tasks = std::weak_ptr<void>(can_run_tasks_),
candidates = std::move(ice_candidates)]() mutable {
// don't run the task if the weak_ptr is no longer valid.
if (!can_run_tasks.lock()) {
return;
@@ -515,8 +515,8 @@ bool ConnectionFlow::RunOnSignalingThread(Runnable&& runnable) {
// We are off signaling thread, so we can't use peer connection's methods
// but we can access the signaling thread handle.
pc->signaling_thread()->PostTask(
RTC_FROM_HERE, [can_run_tasks = std::weak_ptr<void>(can_run_tasks_),
task = std::move(runnable)] {
[can_run_tasks = std::weak_ptr<void>(can_run_tasks_),
task = std::move(runnable)] {
// don't run the task if the weak_ptr is no longer valid.
// shared_ptr |can_run_tasks_| is destroyed on the same thread
// (signaling thread). This guarantees that if the weak_ptr is valid
@@ -306,7 +306,7 @@ TEST_F(ConnectionFlowTest, TerminateAnswerer) {
CountDownLatch latch(1);
auto pc = answerer->GetPeerConnection();
pc->signaling_thread()->PostTask(RTC_FROM_HERE, [pc, latch]() mutable {
pc->signaling_thread()->PostTask([pc, latch]() mutable {
pc->Close();
latch.CountDown();
});
@@ -387,7 +387,7 @@ TEST_F(ConnectionFlowTest, TerminateOfferer) {
CountDownLatch latch(1);
auto pc = offerer->GetPeerConnection();
pc->signaling_thread()->PostTask(RTC_FROM_HERE, [pc, latch]() mutable {
pc->signaling_thread()->PostTask([pc, latch]() mutable {
pc->Close();
latch.CountDown();
});