From f20e7de4e77407cf74b7543d120da232347f7cd5 Mon Sep 17 00:00:00 2001 From: suetfei Date: Wed, 13 Oct 2021 15:12:21 -0700 Subject: [PATCH] [Nearby Cleanup] Remove dead code and unused includes. PiperOrigin-RevId: 402933192 --- cpp/core/internal/mediums/webrtc.h | 2 - cpp/core/internal/p2p_cluster_pcp_handler.cc | 93 -------------------- cpp/core/internal/p2p_cluster_pcp_handler.h | 8 -- 3 files changed, 103 deletions(-) diff --git a/cpp/core/internal/mediums/webrtc.h b/cpp/core/internal/mediums/webrtc.h index 3de27ffc..77f14294 100644 --- a/cpp/core/internal/mediums/webrtc.h +++ b/cpp/core/internal/mediums/webrtc.h @@ -41,9 +41,7 @@ #include "platform/public/webrtc.h" #include "proto/connections/offline_wire_formats.pb.h" #include "proto/mediums/web_rtc_signaling_frames.pb.h" -#include "webrtc/api/data_channel_interface.h" #include "webrtc/api/jsep.h" -#include "webrtc/api/scoped_refptr.h" namespace location { namespace nearby { diff --git a/cpp/core/internal/p2p_cluster_pcp_handler.cc b/cpp/core/internal/p2p_cluster_pcp_handler.cc index aa709b0a..bb593957 100644 --- a/cpp/core/internal/p2p_cluster_pcp_handler.cc +++ b/cpp/core/internal/p2p_cluster_pcp_handler.cc @@ -1358,99 +1358,6 @@ BasePcpHandler::ConnectImplResult P2pClusterPcpHandler::WifiLanConnectImpl( }; } -proto::connections::Medium -P2pClusterPcpHandler::StartListeningForWebRtcConnections( - ClientProxy* client, const std::string& service_id, - const std::string& local_endpoint_id, - const ByteArray& local_endpoint_info) { - if (!webrtc_medium_.IsAvailable()) { - return proto::connections::UNKNOWN_MEDIUM; - } - - if (!webrtc_medium_.IsAcceptingConnections(service_id)) { - mediums::PeerId self_id = CreatePeerIdFromAdvertisement( - service_id, local_endpoint_id, local_endpoint_info); - std::string empty_country_code; - if (!webrtc_medium_.StartAcceptingConnections( - service_id, self_id, Utils::BuildLocationHint(empty_country_code), - {[this, client, - local_endpoint_info](mediums::WebRtcSocketWrapper socket) { - if (!socket.IsValid()) { - NEARBY_LOGS(WARNING) - << "Invalid socket in accept callback(" - << absl::BytesToHexString(local_endpoint_info.data()) - << "), client=" << client->GetClientId(); - return; - } - - RunOnPcpHandlerThread( - "p2p-rtc-on-incoming-connection", - [this, client, socket = std::move(socket)]() - RUN_ON_PCP_HANDLER_THREAD() { - std::string remote_device_name = "WebRtcSocket"; - auto channel = absl::make_unique( - remote_device_name, socket); - ByteArray remote_device_info{remote_device_name}; - - OnIncomingConnection(client, remote_device_info, - std::move(channel), - proto::connections::WEB_RTC); - }); - }})) { - NEARBY_LOGS(WARNING) << "In StartListeningForWebRtcConnections(" - << absl::BytesToHexString(local_endpoint_info.data()) - << "), client=" << client->GetClientId() - << " failed to start listening for incoming WebRTC " - "connections to service_id=" - << service_id; - return proto::connections::UNKNOWN_MEDIUM; - } - NEARBY_LOGS(VERBOSE) - << "In StartListeningForWebRtcConnections(" - << absl::BytesToHexString(local_endpoint_info.data()) - << "), client=" << client->GetClientId() - << " started listening for incoming WebRtc connections to service_id=" - << service_id; - } - - return proto::connections::WEB_RTC; -} - -BasePcpHandler::ConnectImplResult P2pClusterPcpHandler::WebRtcConnectImpl( - ClientProxy* client, WebRtcEndpoint* webrtc_endpoint) { - std::string empty_country_code; - mediums::WebRtcSocketWrapper socket_wrapper = webrtc_medium_.Connect( - webrtc_endpoint->service_id, webrtc_endpoint->peer_id, - Utils::BuildLocationHint(empty_country_code), - client->GetCancellationFlag(webrtc_endpoint->endpoint_id)); - if (!socket_wrapper.IsValid()) { - NEARBY_LOGS(ERROR) - << "In WebRtcConnectImpl(), failed to connect to WebRTC device for " - "endpoint(id=" - << webrtc_endpoint->endpoint_id << ")."; - return BasePcpHandler::ConnectImplResult{.status = {Status::kError}}; - } - - auto channel = absl::make_unique( - webrtc_endpoint->endpoint_id, socket_wrapper); - - if (!channel) { - NEARBY_LOGS(ERROR) << "In WebRtcConnectImpl(), failed to create WebRTC " - "endpoint channel for endpoint(id=" - << webrtc_endpoint->endpoint_id << ")."; - socket_wrapper.Close(); - return BasePcpHandler::ConnectImplResult{.status = {Status::kError}}; - } - - NEARBY_LOGS(VERBOSE) - << "Client created WebRTC endpoint channel to endpoint(id=" - << webrtc_endpoint->endpoint_id << ")."; - return BasePcpHandler::ConnectImplResult{ - .medium = proto::connections::Medium::WEB_RTC, - .status = {Status::kSuccess}, - .endpoint_channel = std::move(channel)}; -} - } // namespace connections } // namespace nearby } // namespace location diff --git a/cpp/core/internal/p2p_cluster_pcp_handler.h b/cpp/core/internal/p2p_cluster_pcp_handler.h index fda43215..efbb13ae 100644 --- a/cpp/core/internal/p2p_cluster_pcp_handler.h +++ b/cpp/core/internal/p2p_cluster_pcp_handler.h @@ -188,14 +188,6 @@ class P2pClusterPcpHandler : public BasePcpHandler { BasePcpHandler::ConnectImplResult WifiLanConnectImpl( ClientProxy* client, WifiLanEndpoint* endpoint); - // WebRtc - proto::connections::Medium StartListeningForWebRtcConnections( - ClientProxy* client, const std::string& service_id, - const std::string& local_endpoint_id, - const ByteArray& local_endpoint_info); - BasePcpHandler::ConnectImplResult WebRtcConnectImpl( - ClientProxy* client, WebRtcEndpoint* webrtc_endpoint); - BluetoothRadio& bluetooth_radio_; BluetoothClassic& bluetooth_medium_; Ble& ble_medium_;