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() { ...@@ -403,7 +403,7 @@ MockRTCPeerConnectionHandlerPlatform::NativePeerConnection() {
} }
void MockRTCPeerConnectionHandlerPlatform:: void MockRTCPeerConnectionHandlerPlatform::
RunSynchronousOnceClosureOnSignalingThread(base::OnceClosure closure, RunSynchronousOnceClosureOnSignalingThread(CrossThreadOnceClosure closure,
const char* trace_event_name) {} const char* trace_event_name) {}
void MockRTCPeerConnectionHandlerPlatform:: void MockRTCPeerConnectionHandlerPlatform::
......
...@@ -76,7 +76,7 @@ class MockRTCPeerConnectionHandlerPlatform ...@@ -76,7 +76,7 @@ class MockRTCPeerConnectionHandlerPlatform
void Stop() override; void Stop() override;
webrtc::PeerConnectionInterface* NativePeerConnection() override; webrtc::PeerConnectionInterface* NativePeerConnection() override;
void RunSynchronousOnceClosureOnSignalingThread( void RunSynchronousOnceClosureOnSignalingThread(
base::OnceClosure closure, CrossThreadOnceClosure closure,
const char* trace_event_name) override; const char* trace_event_name) override;
void RunSynchronousRepeatingClosureOnSignalingThread( void RunSynchronousRepeatingClosureOnSignalingThread(
const base::RepeatingClosure& closure, const base::RepeatingClosure& closure,
......
...@@ -234,7 +234,7 @@ RTCDataChannel::RTCDataChannel( ...@@ -234,7 +234,7 @@ RTCDataChannel::RTCDataChannel(
// thread. Done in a single synchronous call to the signaling thread to ensure // thread. Done in a single synchronous call to the signaling thread to ensure
// channel state consistency. // channel state consistency.
peer_connection_handler->RunSynchronousOnceClosureOnSignalingThread( peer_connection_handler->RunSynchronousOnceClosureOnSignalingThread(
ConvertToBaseOnceCallback(CrossThreadBindOnce( CrossThreadBindOnce(
[](scoped_refptr<RTCDataChannel::Observer> observer, [](scoped_refptr<RTCDataChannel::Observer> observer,
webrtc::DataChannelInterface::DataState current_state) { webrtc::DataChannelInterface::DataState current_state) {
scoped_refptr<webrtc::DataChannelInterface> channel = scoped_refptr<webrtc::DataChannelInterface> channel =
...@@ -244,7 +244,7 @@ RTCDataChannel::RTCDataChannel( ...@@ -244,7 +244,7 @@ RTCDataChannel::RTCDataChannel(
observer->OnStateChange(); observer->OnStateChange();
} }
}, },
observer_, state_)), observer_, state_),
"RegisterObserverAndGetStateUpdate"); "RegisterObserverAndGetStateUpdate");
IncrementCounters(*channel.get()); IncrementCounters(*channel.get());
......
...@@ -52,7 +52,7 @@ class MockPeerConnectionHandler : public MockRTCPeerConnectionHandlerPlatform { ...@@ -52,7 +52,7 @@ class MockPeerConnectionHandler : public MockRTCPeerConnectionHandlerPlatform {
: signaling_thread_(signaling_thread) {} : signaling_thread_(signaling_thread) {}
void RunSynchronousOnceClosureOnSignalingThread( void RunSynchronousOnceClosureOnSignalingThread(
base::OnceClosure closure, CrossThreadOnceClosure closure,
const char* trace_event_name) override { const char* trace_event_name) override {
closure_ = std::move(closure); closure_ = std::move(closure);
RunSynchronous( RunSynchronous(
...@@ -68,7 +68,7 @@ class MockPeerConnectionHandler : public MockRTCPeerConnectionHandlerPlatform { ...@@ -68,7 +68,7 @@ class MockPeerConnectionHandler : public MockRTCPeerConnectionHandlerPlatform {
} }
scoped_refptr<base::TestSimpleTaskRunner> signaling_thread_; scoped_refptr<base::TestSimpleTaskRunner> signaling_thread_;
base::OnceClosure closure_; CrossThreadOnceClosure closure_;
DISALLOW_COPY_AND_ASSIGN(MockPeerConnectionHandler); DISALLOW_COPY_AND_ASSIGN(MockPeerConnectionHandler);
}; };
......
...@@ -50,7 +50,6 @@ ...@@ -50,7 +50,6 @@
#include "third_party/blink/renderer/platform/peerconnection/rtc_stats.h" #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/peerconnection/rtc_void_request.h"
#include "third_party/blink/renderer/platform/scheduler/public/post_cross_thread_task.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/text/string_builder.h"
#include "third_party/blink/renderer/platform/wtf/thread_safe_ref_counted.h" #include "third_party/blink/renderer/platform/wtf/thread_safe_ref_counted.h"
#include "third_party/webrtc/api/data_channel_interface.h" #include "third_party/webrtc/api/data_channel_interface.h"
...@@ -74,6 +73,13 @@ struct CrossThreadCopier<scoped_refptr<DataChannelInterface>> ...@@ -74,6 +73,13 @@ struct CrossThreadCopier<scoped_refptr<DataChannelInterface>>
STATIC_ONLY(CrossThreadCopier); STATIC_ONLY(CrossThreadCopier);
}; };
template <>
struct CrossThreadCopier<scoped_refptr<PeerConnectionInterface>>
: public CrossThreadCopierPassThrough<
scoped_refptr<PeerConnectionInterface>> {
STATIC_ONLY(CrossThreadCopier);
};
template <typename T> template <typename T>
struct CrossThreadCopier<rtc::scoped_refptr<T>> { struct CrossThreadCopier<rtc::scoped_refptr<T>> {
STATIC_ONLY(CrossThreadCopier); STATIC_ONLY(CrossThreadCopier);
...@@ -124,7 +130,7 @@ void RunClosureWithTrace(base::OnceClosure closure, ...@@ -124,7 +130,7 @@ void RunClosureWithTrace(base::OnceClosure closure,
std::move(closure).Run(); std::move(closure).Run();
} }
void RunSynchronousOnceClosure(base::OnceClosure closure, void RunSynchronousOnceClosure(CrossThreadOnceClosure closure,
const char* trace_event_name, const char* trace_event_name,
base::WaitableEvent* event) { base::WaitableEvent* event) {
{ {
...@@ -147,7 +153,7 @@ void RunSynchronousRepeatingClosure(const base::RepeatingClosure& closure, ...@@ -147,7 +153,7 @@ void RunSynchronousRepeatingClosure(const base::RepeatingClosure& closure,
// Initializes |description| if |description_callback| returns non-null, // Initializes |description| if |description_callback| returns non-null,
// otherwise does nothing. // otherwise does nothing.
void GetRTCSessionDescriptionPlatformFromSessionDescriptionCallback( void GetRTCSessionDescriptionPlatformFromSessionDescriptionCallback(
base::OnceCallback<const webrtc::SessionDescriptionInterface*()> CrossThreadOnceFunction<const webrtc::SessionDescriptionInterface*()>
description_callback, description_callback,
std::string* out_type, std::string* out_type,
std::string* out_sdp, std::string* out_sdp,
...@@ -1464,9 +1470,9 @@ RTCSessionDescriptionPlatform* RTCPeerConnectionHandler::LocalDescription() { ...@@ -1464,9 +1470,9 @@ RTCSessionDescriptionPlatform* RTCPeerConnectionHandler::LocalDescription() {
DCHECK(task_runner_->RunsTasksInCurrentSequence()); DCHECK(task_runner_->RunsTasksInCurrentSequence());
TRACE_EVENT0("webrtc", "RTCPeerConnectionHandler::localDescription"); TRACE_EVENT0("webrtc", "RTCPeerConnectionHandler::localDescription");
base::OnceCallback<const webrtc::SessionDescriptionInterface*()> CrossThreadOnceFunction<const webrtc::SessionDescriptionInterface*()>
description_cb = description_cb = CrossThreadBindOnce(
base::BindOnce(&webrtc::PeerConnectionInterface::local_description, &webrtc::PeerConnectionInterface::local_description,
native_peer_connection_); native_peer_connection_);
return GetRTCSessionDescriptionPlatformOnSignalingThread( return GetRTCSessionDescriptionPlatformOnSignalingThread(
std::move(description_cb), "localDescription"); std::move(description_cb), "localDescription");
...@@ -1475,9 +1481,10 @@ RTCSessionDescriptionPlatform* RTCPeerConnectionHandler::LocalDescription() { ...@@ -1475,9 +1481,10 @@ RTCSessionDescriptionPlatform* RTCPeerConnectionHandler::LocalDescription() {
RTCSessionDescriptionPlatform* RTCPeerConnectionHandler::RemoteDescription() { RTCSessionDescriptionPlatform* RTCPeerConnectionHandler::RemoteDescription() {
DCHECK(task_runner_->RunsTasksInCurrentSequence()); DCHECK(task_runner_->RunsTasksInCurrentSequence());
TRACE_EVENT0("webrtc", "RTCPeerConnectionHandler::remoteDescription"); TRACE_EVENT0("webrtc", "RTCPeerConnectionHandler::remoteDescription");
base::OnceCallback<const webrtc::SessionDescriptionInterface*()>
description_cb = CrossThreadOnceFunction<const webrtc::SessionDescriptionInterface*()>
base::BindOnce(&webrtc::PeerConnectionInterface::remote_description, description_cb = CrossThreadBindOnce(
&webrtc::PeerConnectionInterface::remote_description,
native_peer_connection_); native_peer_connection_);
return GetRTCSessionDescriptionPlatformOnSignalingThread( return GetRTCSessionDescriptionPlatformOnSignalingThread(
std::move(description_cb), "remoteDescription"); std::move(description_cb), "remoteDescription");
...@@ -1488,8 +1495,8 @@ RTCPeerConnectionHandler::CurrentLocalDescription() { ...@@ -1488,8 +1495,8 @@ RTCPeerConnectionHandler::CurrentLocalDescription() {
DCHECK(task_runner_->RunsTasksInCurrentSequence()); DCHECK(task_runner_->RunsTasksInCurrentSequence());
TRACE_EVENT0("webrtc", "RTCPeerConnectionHandler::currentLocalDescription"); TRACE_EVENT0("webrtc", "RTCPeerConnectionHandler::currentLocalDescription");
base::OnceCallback<const webrtc::SessionDescriptionInterface*()> CrossThreadOnceFunction<const webrtc::SessionDescriptionInterface*()>
description_cb = base::BindOnce( description_cb = CrossThreadBindOnce(
&webrtc::PeerConnectionInterface::current_local_description, &webrtc::PeerConnectionInterface::current_local_description,
native_peer_connection_); native_peer_connection_);
return GetRTCSessionDescriptionPlatformOnSignalingThread( return GetRTCSessionDescriptionPlatformOnSignalingThread(
...@@ -1500,8 +1507,9 @@ RTCSessionDescriptionPlatform* ...@@ -1500,8 +1507,9 @@ RTCSessionDescriptionPlatform*
RTCPeerConnectionHandler::CurrentRemoteDescription() { RTCPeerConnectionHandler::CurrentRemoteDescription() {
DCHECK(task_runner_->RunsTasksInCurrentSequence()); DCHECK(task_runner_->RunsTasksInCurrentSequence());
TRACE_EVENT0("webrtc", "RTCPeerConnectionHandler::currentRemoteDescription"); 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, &webrtc::PeerConnectionInterface::current_remote_description,
native_peer_connection_); native_peer_connection_);
return GetRTCSessionDescriptionPlatformOnSignalingThread( return GetRTCSessionDescriptionPlatformOnSignalingThread(
...@@ -1512,8 +1520,9 @@ RTCSessionDescriptionPlatform* ...@@ -1512,8 +1520,9 @@ RTCSessionDescriptionPlatform*
RTCPeerConnectionHandler::PendingLocalDescription() { RTCPeerConnectionHandler::PendingLocalDescription() {
DCHECK(task_runner_->RunsTasksInCurrentSequence()); DCHECK(task_runner_->RunsTasksInCurrentSequence());
TRACE_EVENT0("webrtc", "RTCPeerConnectionHandler::pendingLocalDescription"); 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, &webrtc::PeerConnectionInterface::pending_local_description,
native_peer_connection_); native_peer_connection_);
return GetRTCSessionDescriptionPlatformOnSignalingThread( return GetRTCSessionDescriptionPlatformOnSignalingThread(
...@@ -1524,8 +1533,8 @@ RTCSessionDescriptionPlatform* ...@@ -1524,8 +1533,8 @@ RTCSessionDescriptionPlatform*
RTCPeerConnectionHandler::PendingRemoteDescription() { RTCPeerConnectionHandler::PendingRemoteDescription() {
DCHECK(task_runner_->RunsTasksInCurrentSequence()); DCHECK(task_runner_->RunsTasksInCurrentSequence());
TRACE_EVENT0("webrtc", "RTCPeerConnectionHandler::pendingRemoteDescription"); TRACE_EVENT0("webrtc", "RTCPeerConnectionHandler::pendingRemoteDescription");
base::OnceCallback<const webrtc::SessionDescriptionInterface*()> CrossThreadOnceFunction<const webrtc::SessionDescriptionInterface*()>
description_cb = base::BindOnce( description_cb = CrossThreadBindOnce(
&webrtc::PeerConnectionInterface::pending_remote_description, &webrtc::PeerConnectionInterface::pending_remote_description,
native_peer_connection_); native_peer_connection_);
return GetRTCSessionDescriptionPlatformOnSignalingThread( return GetRTCSessionDescriptionPlatformOnSignalingThread(
...@@ -2102,7 +2111,7 @@ RTCPeerConnectionHandler::NativePeerConnection() { ...@@ -2102,7 +2111,7 @@ RTCPeerConnectionHandler::NativePeerConnection() {
} }
void RTCPeerConnectionHandler::RunSynchronousOnceClosureOnSignalingThread( void RTCPeerConnectionHandler::RunSynchronousOnceClosureOnSignalingThread(
base::OnceClosure closure, CrossThreadOnceClosure closure,
const char* trace_event_name) { const char* trace_event_name) {
DCHECK(task_runner_->RunsTasksInCurrentSequence()); DCHECK(task_runner_->RunsTasksInCurrentSequence());
scoped_refptr<base::SingleThreadTaskRunner> thread(signaling_thread()); scoped_refptr<base::SingleThreadTaskRunner> thread(signaling_thread());
...@@ -2112,11 +2121,11 @@ void RTCPeerConnectionHandler::RunSynchronousOnceClosureOnSignalingThread( ...@@ -2112,11 +2121,11 @@ void RTCPeerConnectionHandler::RunSynchronousOnceClosureOnSignalingThread(
} else { } else {
base::WaitableEvent event(base::WaitableEvent::ResetPolicy::AUTOMATIC, base::WaitableEvent event(base::WaitableEvent::ResetPolicy::AUTOMATIC,
base::WaitableEvent::InitialState::NOT_SIGNALED); base::WaitableEvent::InitialState::NOT_SIGNALED);
thread->PostTask( PostCrossThreadTask(
FROM_HERE, *thread.get(), FROM_HERE,
base::BindOnce(&RunSynchronousOnceClosure, std::move(closure), CrossThreadBindOnce(&RunSynchronousOnceClosure, std::move(closure),
base::Unretained(trace_event_name), CrossThreadUnretained(trace_event_name),
base::Unretained(&event))); CrossThreadUnretained(&event)));
event.Wait(); event.Wait();
} }
} }
...@@ -2611,7 +2620,7 @@ RTCPeerConnectionHandler::signaling_thread() const { ...@@ -2611,7 +2620,7 @@ RTCPeerConnectionHandler::signaling_thread() const {
RTCSessionDescriptionPlatform* RTCSessionDescriptionPlatform*
RTCPeerConnectionHandler::GetRTCSessionDescriptionPlatformOnSignalingThread( RTCPeerConnectionHandler::GetRTCSessionDescriptionPlatformOnSignalingThread(
base::OnceCallback<const webrtc::SessionDescriptionInterface*()> CrossThreadOnceFunction<const webrtc::SessionDescriptionInterface*()>
description_cb, description_cb,
const char* log_text) { const char* log_text) {
// Since the webrtc::PeerConnectionInterface::*_description() functions // Since the webrtc::PeerConnectionInterface::*_description() functions
...@@ -2625,10 +2634,10 @@ RTCPeerConnectionHandler::GetRTCSessionDescriptionPlatformOnSignalingThread( ...@@ -2625,10 +2634,10 @@ RTCPeerConnectionHandler::GetRTCSessionDescriptionPlatformOnSignalingThread(
std::string type, sdp; std::string type, sdp;
bool success = false; bool success = false;
RunSynchronousOnceClosureOnSignalingThread( RunSynchronousOnceClosureOnSignalingThread(
base::BindOnce( CrossThreadBindOnce(
&GetRTCSessionDescriptionPlatformFromSessionDescriptionCallback, &GetRTCSessionDescriptionPlatformFromSessionDescriptionCallback,
std::move(description_cb), base::Unretained(&type), std::move(description_cb), CrossThreadUnretained(&type),
base::Unretained(&sdp), base::Unretained(&success)), CrossThreadUnretained(&sdp), CrossThreadUnretained(&success)),
log_text); log_text);
if (!success) if (!success)
......
...@@ -164,7 +164,7 @@ class MODULES_EXPORT RTCPeerConnectionHandler ...@@ -164,7 +164,7 @@ class MODULES_EXPORT RTCPeerConnectionHandler
void Stop() override; void Stop() override;
webrtc::PeerConnectionInterface* NativePeerConnection() override; webrtc::PeerConnectionInterface* NativePeerConnection() override;
void RunSynchronousOnceClosureOnSignalingThread( void RunSynchronousOnceClosureOnSignalingThread(
base::OnceClosure closure, CrossThreadOnceClosure closure,
const char* trace_event_name) override; const char* trace_event_name) override;
void RunSynchronousRepeatingClosureOnSignalingThread( void RunSynchronousRepeatingClosureOnSignalingThread(
const base::RepeatingClosure& closure, const base::RepeatingClosure& closure,
...@@ -265,7 +265,7 @@ class MODULES_EXPORT RTCPeerConnectionHandler ...@@ -265,7 +265,7 @@ class MODULES_EXPORT RTCPeerConnectionHandler
RTCSessionDescriptionPlatform* RTCSessionDescriptionPlatform*
GetRTCSessionDescriptionPlatformOnSignalingThread( GetRTCSessionDescriptionPlatformOnSignalingThread(
base::OnceCallback<const webrtc::SessionDescriptionInterface*()> CrossThreadOnceFunction<const webrtc::SessionDescriptionInterface*()>
description_cb, description_cb,
const char* log_text); const char* log_text);
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include "third_party/blink/renderer/platform/peerconnection/rtc_stats.h" #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/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/text/wtf_string.h"
#include "third_party/blink/renderer/platform/wtf/vector.h" #include "third_party/blink/renderer/platform/wtf/vector.h"
#include "third_party/webrtc/api/peer_connection_interface.h" #include "third_party/webrtc/api/peer_connection_interface.h"
...@@ -150,7 +151,7 @@ class PLATFORM_EXPORT RTCPeerConnectionHandlerPlatform { ...@@ -150,7 +151,7 @@ class PLATFORM_EXPORT RTCPeerConnectionHandlerPlatform {
virtual webrtc::PeerConnectionInterface* NativePeerConnection() = 0; virtual webrtc::PeerConnectionInterface* NativePeerConnection() = 0;
virtual void RunSynchronousOnceClosureOnSignalingThread( virtual void RunSynchronousOnceClosureOnSignalingThread(
base::OnceClosure closure, CrossThreadOnceClosure closure,
const char* trace_event_name) = 0; const char* trace_event_name) = 0;
virtual void RunSynchronousRepeatingClosureOnSignalingThread( virtual void RunSynchronousRepeatingClosureOnSignalingThread(
const base::RepeatingClosure& closure, 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