Commit 14962608 authored by Antonio Gomes's avatar Antonio Gomes Committed by Commit Bot

Switch RTCPeerConnectionHandler away from base::Bind (2/n)

Instead, code now uses the WTF counterpart helpers.

BUG=787254
R=haraken@chromium.org

Change-Id: Icc0b0f55abd216925fb19341c25a57a1b89102c7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1988667
Commit-Queue: Antonio Gomes <tonikitoo@igalia.com>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#728800}
parent f5778595
......@@ -403,7 +403,7 @@ MockRTCPeerConnectionHandlerPlatform::NativePeerConnection() {
}
void MockRTCPeerConnectionHandlerPlatform::
RunSynchronousOnceClosureOnSignalingThread(base::OnceClosure closure,
RunSynchronousOnceClosureOnSignalingThread(CrossThreadOnceClosure closure,
const char* trace_event_name) {}
void MockRTCPeerConnectionHandlerPlatform::
......
......@@ -76,7 +76,7 @@ class MockRTCPeerConnectionHandlerPlatform
void Stop() override;
webrtc::PeerConnectionInterface* NativePeerConnection() override;
void RunSynchronousOnceClosureOnSignalingThread(
base::OnceClosure closure,
CrossThreadOnceClosure closure,
const char* trace_event_name) override;
void RunSynchronousRepeatingClosureOnSignalingThread(
const base::RepeatingClosure& closure,
......
......@@ -234,7 +234,7 @@ RTCDataChannel::RTCDataChannel(
// thread. Done in a single synchronous call to the signaling thread to ensure
// channel state consistency.
peer_connection_handler->RunSynchronousOnceClosureOnSignalingThread(
ConvertToBaseOnceCallback(CrossThreadBindOnce(
CrossThreadBindOnce(
[](scoped_refptr<RTCDataChannel::Observer> observer,
webrtc::DataChannelInterface::DataState current_state) {
scoped_refptr<webrtc::DataChannelInterface> channel =
......@@ -244,7 +244,7 @@ RTCDataChannel::RTCDataChannel(
observer->OnStateChange();
}
},
observer_, state_)),
observer_, state_),
"RegisterObserverAndGetStateUpdate");
IncrementCounters(*channel.get());
......
......@@ -52,7 +52,7 @@ class MockPeerConnectionHandler : public MockRTCPeerConnectionHandlerPlatform {
: signaling_thread_(signaling_thread) {}
void RunSynchronousOnceClosureOnSignalingThread(
base::OnceClosure closure,
CrossThreadOnceClosure closure,
const char* trace_event_name) override {
closure_ = std::move(closure);
RunSynchronous(
......@@ -68,7 +68,7 @@ class MockPeerConnectionHandler : public MockRTCPeerConnectionHandlerPlatform {
}
scoped_refptr<base::TestSimpleTaskRunner> signaling_thread_;
base::OnceClosure closure_;
CrossThreadOnceClosure closure_;
DISALLOW_COPY_AND_ASSIGN(MockPeerConnectionHandler);
};
......
......@@ -50,7 +50,6 @@
#include "third_party/blink/renderer/platform/peerconnection/rtc_stats.h"
#include "third_party/blink/renderer/platform/peerconnection/rtc_void_request.h"
#include "third_party/blink/renderer/platform/scheduler/public/post_cross_thread_task.h"
#include "third_party/blink/renderer/platform/wtf/cross_thread_functional.h"
#include "third_party/blink/renderer/platform/wtf/text/string_builder.h"
#include "third_party/blink/renderer/platform/wtf/thread_safe_ref_counted.h"
#include "third_party/webrtc/api/data_channel_interface.h"
......@@ -74,6 +73,13 @@ struct CrossThreadCopier<scoped_refptr<DataChannelInterface>>
STATIC_ONLY(CrossThreadCopier);
};
template <>
struct CrossThreadCopier<scoped_refptr<PeerConnectionInterface>>
: public CrossThreadCopierPassThrough<
scoped_refptr<PeerConnectionInterface>> {
STATIC_ONLY(CrossThreadCopier);
};
template <typename T>
struct CrossThreadCopier<rtc::scoped_refptr<T>> {
STATIC_ONLY(CrossThreadCopier);
......@@ -124,7 +130,7 @@ void RunClosureWithTrace(base::OnceClosure closure,
std::move(closure).Run();
}
void RunSynchronousOnceClosure(base::OnceClosure closure,
void RunSynchronousOnceClosure(CrossThreadOnceClosure closure,
const char* trace_event_name,
base::WaitableEvent* event) {
{
......@@ -147,7 +153,7 @@ void RunSynchronousRepeatingClosure(const base::RepeatingClosure& closure,
// Initializes |description| if |description_callback| returns non-null,
// otherwise does nothing.
void GetRTCSessionDescriptionPlatformFromSessionDescriptionCallback(
base::OnceCallback<const webrtc::SessionDescriptionInterface*()>
CrossThreadOnceFunction<const webrtc::SessionDescriptionInterface*()>
description_callback,
std::string* out_type,
std::string* out_sdp,
......@@ -1464,10 +1470,10 @@ RTCSessionDescriptionPlatform* RTCPeerConnectionHandler::LocalDescription() {
DCHECK(task_runner_->RunsTasksInCurrentSequence());
TRACE_EVENT0("webrtc", "RTCPeerConnectionHandler::localDescription");
base::OnceCallback<const webrtc::SessionDescriptionInterface*()>
description_cb =
base::BindOnce(&webrtc::PeerConnectionInterface::local_description,
native_peer_connection_);
CrossThreadOnceFunction<const webrtc::SessionDescriptionInterface*()>
description_cb = CrossThreadBindOnce(
&webrtc::PeerConnectionInterface::local_description,
native_peer_connection_);
return GetRTCSessionDescriptionPlatformOnSignalingThread(
std::move(description_cb), "localDescription");
}
......@@ -1475,10 +1481,11 @@ RTCSessionDescriptionPlatform* RTCPeerConnectionHandler::LocalDescription() {
RTCSessionDescriptionPlatform* RTCPeerConnectionHandler::RemoteDescription() {
DCHECK(task_runner_->RunsTasksInCurrentSequence());
TRACE_EVENT0("webrtc", "RTCPeerConnectionHandler::remoteDescription");
base::OnceCallback<const webrtc::SessionDescriptionInterface*()>
description_cb =
base::BindOnce(&webrtc::PeerConnectionInterface::remote_description,
native_peer_connection_);
CrossThreadOnceFunction<const webrtc::SessionDescriptionInterface*()>
description_cb = CrossThreadBindOnce(
&webrtc::PeerConnectionInterface::remote_description,
native_peer_connection_);
return GetRTCSessionDescriptionPlatformOnSignalingThread(
std::move(description_cb), "remoteDescription");
}
......@@ -1488,8 +1495,8 @@ RTCPeerConnectionHandler::CurrentLocalDescription() {
DCHECK(task_runner_->RunsTasksInCurrentSequence());
TRACE_EVENT0("webrtc", "RTCPeerConnectionHandler::currentLocalDescription");
base::OnceCallback<const webrtc::SessionDescriptionInterface*()>
description_cb = base::BindOnce(
CrossThreadOnceFunction<const webrtc::SessionDescriptionInterface*()>
description_cb = CrossThreadBindOnce(
&webrtc::PeerConnectionInterface::current_local_description,
native_peer_connection_);
return GetRTCSessionDescriptionPlatformOnSignalingThread(
......@@ -1500,8 +1507,9 @@ RTCSessionDescriptionPlatform*
RTCPeerConnectionHandler::CurrentRemoteDescription() {
DCHECK(task_runner_->RunsTasksInCurrentSequence());
TRACE_EVENT0("webrtc", "RTCPeerConnectionHandler::currentRemoteDescription");
base::OnceCallback<const webrtc::SessionDescriptionInterface*()>
description_cb = base::BindOnce(
CrossThreadOnceFunction<const webrtc::SessionDescriptionInterface*()>
description_cb = CrossThreadBindOnce(
&webrtc::PeerConnectionInterface::current_remote_description,
native_peer_connection_);
return GetRTCSessionDescriptionPlatformOnSignalingThread(
......@@ -1512,8 +1520,9 @@ RTCSessionDescriptionPlatform*
RTCPeerConnectionHandler::PendingLocalDescription() {
DCHECK(task_runner_->RunsTasksInCurrentSequence());
TRACE_EVENT0("webrtc", "RTCPeerConnectionHandler::pendingLocalDescription");
base::OnceCallback<const webrtc::SessionDescriptionInterface*()>
description_cb = base::BindOnce(
CrossThreadOnceFunction<const webrtc::SessionDescriptionInterface*()>
description_cb = CrossThreadBindOnce(
&webrtc::PeerConnectionInterface::pending_local_description,
native_peer_connection_);
return GetRTCSessionDescriptionPlatformOnSignalingThread(
......@@ -1524,8 +1533,8 @@ RTCSessionDescriptionPlatform*
RTCPeerConnectionHandler::PendingRemoteDescription() {
DCHECK(task_runner_->RunsTasksInCurrentSequence());
TRACE_EVENT0("webrtc", "RTCPeerConnectionHandler::pendingRemoteDescription");
base::OnceCallback<const webrtc::SessionDescriptionInterface*()>
description_cb = base::BindOnce(
CrossThreadOnceFunction<const webrtc::SessionDescriptionInterface*()>
description_cb = CrossThreadBindOnce(
&webrtc::PeerConnectionInterface::pending_remote_description,
native_peer_connection_);
return GetRTCSessionDescriptionPlatformOnSignalingThread(
......@@ -2102,7 +2111,7 @@ RTCPeerConnectionHandler::NativePeerConnection() {
}
void RTCPeerConnectionHandler::RunSynchronousOnceClosureOnSignalingThread(
base::OnceClosure closure,
CrossThreadOnceClosure closure,
const char* trace_event_name) {
DCHECK(task_runner_->RunsTasksInCurrentSequence());
scoped_refptr<base::SingleThreadTaskRunner> thread(signaling_thread());
......@@ -2112,11 +2121,11 @@ void RTCPeerConnectionHandler::RunSynchronousOnceClosureOnSignalingThread(
} else {
base::WaitableEvent event(base::WaitableEvent::ResetPolicy::AUTOMATIC,
base::WaitableEvent::InitialState::NOT_SIGNALED);
thread->PostTask(
FROM_HERE,
base::BindOnce(&RunSynchronousOnceClosure, std::move(closure),
base::Unretained(trace_event_name),
base::Unretained(&event)));
PostCrossThreadTask(
*thread.get(), FROM_HERE,
CrossThreadBindOnce(&RunSynchronousOnceClosure, std::move(closure),
CrossThreadUnretained(trace_event_name),
CrossThreadUnretained(&event)));
event.Wait();
}
}
......@@ -2611,7 +2620,7 @@ RTCPeerConnectionHandler::signaling_thread() const {
RTCSessionDescriptionPlatform*
RTCPeerConnectionHandler::GetRTCSessionDescriptionPlatformOnSignalingThread(
base::OnceCallback<const webrtc::SessionDescriptionInterface*()>
CrossThreadOnceFunction<const webrtc::SessionDescriptionInterface*()>
description_cb,
const char* log_text) {
// Since the webrtc::PeerConnectionInterface::*_description() functions
......@@ -2625,10 +2634,10 @@ RTCPeerConnectionHandler::GetRTCSessionDescriptionPlatformOnSignalingThread(
std::string type, sdp;
bool success = false;
RunSynchronousOnceClosureOnSignalingThread(
base::BindOnce(
CrossThreadBindOnce(
&GetRTCSessionDescriptionPlatformFromSessionDescriptionCallback,
std::move(description_cb), base::Unretained(&type),
base::Unretained(&sdp), base::Unretained(&success)),
std::move(description_cb), CrossThreadUnretained(&type),
CrossThreadUnretained(&sdp), CrossThreadUnretained(&success)),
log_text);
if (!success)
......
......@@ -164,7 +164,7 @@ class MODULES_EXPORT RTCPeerConnectionHandler
void Stop() override;
webrtc::PeerConnectionInterface* NativePeerConnection() override;
void RunSynchronousOnceClosureOnSignalingThread(
base::OnceClosure closure,
CrossThreadOnceClosure closure,
const char* trace_event_name) override;
void RunSynchronousRepeatingClosureOnSignalingThread(
const base::RepeatingClosure& closure,
......@@ -265,7 +265,7 @@ class MODULES_EXPORT RTCPeerConnectionHandler
RTCSessionDescriptionPlatform*
GetRTCSessionDescriptionPlatformOnSignalingThread(
base::OnceCallback<const webrtc::SessionDescriptionInterface*()>
CrossThreadOnceFunction<const webrtc::SessionDescriptionInterface*()>
description_cb,
const char* log_text);
......
......@@ -36,6 +36,7 @@
#include "third_party/blink/renderer/platform/peerconnection/rtc_stats.h"
#include "third_party/blink/renderer/platform/platform_export.h"
#include "third_party/blink/renderer/platform/wtf/cross_thread_functional.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
#include "third_party/blink/renderer/platform/wtf/vector.h"
#include "third_party/webrtc/api/peer_connection_interface.h"
......@@ -150,7 +151,7 @@ class PLATFORM_EXPORT RTCPeerConnectionHandlerPlatform {
virtual webrtc::PeerConnectionInterface* NativePeerConnection() = 0;
virtual void RunSynchronousOnceClosureOnSignalingThread(
base::OnceClosure closure,
CrossThreadOnceClosure closure,
const char* trace_event_name) = 0;
virtual void RunSynchronousRepeatingClosureOnSignalingThread(
const base::RepeatingClosure& closure,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment