mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-14 22:56:12 -04:00
Refactor WebRTC code to avoid use of select for stubs
PiperOrigin-RevId: 518491132
This commit is contained in:
committed by
Copybara-Service
parent
b2da1efbbf
commit
ec025502dc
@@ -66,6 +66,8 @@ cc_library(
|
||||
"payload_manager.cc",
|
||||
"pcp_manager.cc",
|
||||
"service_controller_router.cc",
|
||||
"webrtc_bwu_handler.cc",
|
||||
"webrtc_bwu_handler_stub.cc",
|
||||
"webrtc_endpoint_channel.cc",
|
||||
"wifi_direct_bwu_handler.cc",
|
||||
"wifi_direct_endpoint_channel.cc",
|
||||
@@ -74,14 +76,7 @@ cc_library(
|
||||
"wifi_lan_bwu_handler.cc",
|
||||
"wifi_lan_endpoint_channel.cc",
|
||||
"wifi_lan_service_info.cc",
|
||||
] + select({
|
||||
"@platforms//cpu:arm": [
|
||||
"webrtc_bwu_handler_stub.cc",
|
||||
],
|
||||
"//conditions:default": [
|
||||
"webrtc_bwu_handler_stub.cc",
|
||||
],
|
||||
}),
|
||||
],
|
||||
hdrs = [
|
||||
"base_bwu_handler.h",
|
||||
"base_endpoint_channel.h",
|
||||
@@ -115,6 +110,8 @@ cc_library(
|
||||
"service_controller.h",
|
||||
"service_controller_router.h",
|
||||
"service_id_constants.h",
|
||||
"webrtc_bwu_handler.h",
|
||||
"webrtc_bwu_handler_stub.h",
|
||||
"webrtc_endpoint_channel.h",
|
||||
"wifi_direct_bwu_handler.h",
|
||||
"wifi_direct_endpoint_channel.h",
|
||||
@@ -123,14 +120,7 @@ cc_library(
|
||||
"wifi_lan_bwu_handler.h",
|
||||
"wifi_lan_endpoint_channel.h",
|
||||
"wifi_lan_service_info.h",
|
||||
] + select({
|
||||
"@platforms//cpu:arm": [
|
||||
"webrtc_bwu_handler_stub.h",
|
||||
],
|
||||
"//conditions:default": [
|
||||
"webrtc_bwu_handler_stub.h",
|
||||
],
|
||||
}),
|
||||
],
|
||||
copts = ["-DCORE_ADAPTER_DLL"] + select({
|
||||
"@platforms//cpu:arm": [
|
||||
"-DNO_WEBRTC",
|
||||
|
||||
@@ -21,35 +21,25 @@ cc_library(
|
||||
"bluetooth_classic.cc",
|
||||
"bluetooth_radio.cc",
|
||||
"mediums.cc",
|
||||
"webrtc.cc",
|
||||
"webrtc_stub.cc",
|
||||
"wifi_direct.cc",
|
||||
"wifi_hotspot.cc",
|
||||
"wifi_lan.cc",
|
||||
] + select({
|
||||
"@platforms//cpu:arm": [
|
||||
"webrtc_stub.cc",
|
||||
],
|
||||
"//conditions:default": [
|
||||
"webrtc_stub.cc",
|
||||
],
|
||||
}),
|
||||
],
|
||||
hdrs = [
|
||||
"ble.h",
|
||||
"ble_v2.h",
|
||||
"bluetooth_classic.h",
|
||||
"bluetooth_radio.h",
|
||||
"mediums.h",
|
||||
"webrtc.h",
|
||||
"webrtc_stub.h",
|
||||
"wifi.h",
|
||||
"wifi_direct.h",
|
||||
"wifi_hotspot.h",
|
||||
"wifi_lan.h",
|
||||
] + select({
|
||||
"@platforms//cpu:arm": [
|
||||
"webrtc_stub.h",
|
||||
],
|
||||
"//conditions:default": [
|
||||
"webrtc_stub.h",
|
||||
],
|
||||
}),
|
||||
],
|
||||
copts = select({
|
||||
"@platforms//cpu:arm": [
|
||||
"-DNO_WEBRTC",
|
||||
@@ -91,27 +81,17 @@ cc_library(
|
||||
name = "utils",
|
||||
srcs = [
|
||||
"utils.cc",
|
||||
] + select({
|
||||
"@platforms//cpu:arm": [
|
||||
"webrtc_peer_id_stub.cc",
|
||||
],
|
||||
"//conditions:default": [
|
||||
"webrtc_peer_id_stub.cc",
|
||||
],
|
||||
}),
|
||||
"webrtc_peer_id.cc",
|
||||
"webrtc_peer_id_stub.cc",
|
||||
],
|
||||
hdrs = [
|
||||
"lost_entity_tracker.h",
|
||||
"utils.h",
|
||||
] + select({
|
||||
"@platforms//cpu:arm": [
|
||||
"webrtc_peer_id_stub.h",
|
||||
"webrtc_socket_stub.h",
|
||||
],
|
||||
"//conditions:default": [
|
||||
"webrtc_peer_id_stub.h",
|
||||
"webrtc_socket_stub.h",
|
||||
],
|
||||
}),
|
||||
"webrtc_peer_id.h",
|
||||
"webrtc_peer_id_stub.h",
|
||||
"webrtc_socket.h",
|
||||
"webrtc_socket_stub.h",
|
||||
],
|
||||
copts = select({
|
||||
"@platforms//cpu:arm": [
|
||||
"-DNO_WEBRTC",
|
||||
@@ -164,3 +144,28 @@ cc_test(
|
||||
"@com_google_googletest//:gtest_main",
|
||||
],
|
||||
)
|
||||
|
||||
cc_test(
|
||||
name = "core_internal_mediums_webrtc_test",
|
||||
size = "small",
|
||||
srcs = [
|
||||
"webrtc_peer_id_test.cc",
|
||||
"webrtc_test.cc",
|
||||
],
|
||||
defines = ["NO_WEBRTC"],
|
||||
shard_count = 16,
|
||||
tags = [
|
||||
"notsan", # NOTE(b/139734036): known data race in usrsctplib.
|
||||
"requires-net:external",
|
||||
],
|
||||
deps = [
|
||||
":mediums",
|
||||
":utils",
|
||||
"//internal/platform:base",
|
||||
"//internal/platform:test_util",
|
||||
"//internal/platform:types",
|
||||
"//internal/platform/implementation/g3", # build_cleaner: keep
|
||||
"@com_github_protobuf_matchers//protobuf-matchers",
|
||||
"@com_google_googletest//:gtest_main",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef NO_WEBRTC
|
||||
|
||||
#include "connections/implementation/mediums/webrtc.h"
|
||||
|
||||
#include <functional>
|
||||
@@ -741,3 +743,5 @@ void WebRtc::OffloadFromThread(const std::string& name, Runnable runnable) {
|
||||
} // namespace mediums
|
||||
} // namespace connections
|
||||
} // namespace nearby
|
||||
|
||||
#endif
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
#ifndef CORE_INTERNAL_MEDIUMS_WEBRTC_H_
|
||||
#define CORE_INTERNAL_MEDIUMS_WEBRTC_H_
|
||||
|
||||
#ifndef NO_WEBRTC
|
||||
|
||||
#include <cstddef>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
@@ -249,4 +251,6 @@ class WebRtc {
|
||||
} // namespace connections
|
||||
} // namespace nearby
|
||||
|
||||
#endif
|
||||
|
||||
#endif // CORE_INTERNAL_MEDIUMS_WEBRTC_H_
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef NO_WEBRTC
|
||||
|
||||
#include "connections/implementation/mediums/webrtc_peer_id.h"
|
||||
|
||||
#include <sstream>
|
||||
@@ -50,3 +52,5 @@ bool WebrtcPeerId::IsValid() const { return !id_.empty(); }
|
||||
} // namespace mediums
|
||||
} // namespace connections
|
||||
} // namespace nearby
|
||||
|
||||
#endif
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
#ifndef CORE_INTERNAL_MEDIUMS_WEBRTC_PEER_ID_H_
|
||||
#define CORE_INTERNAL_MEDIUMS_WEBRTC_PEER_ID_H_
|
||||
|
||||
#ifndef NO_WEBRTC
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
@@ -47,4 +49,6 @@ class WebrtcPeerId {
|
||||
} // namespace connections
|
||||
} // namespace nearby
|
||||
|
||||
#endif
|
||||
|
||||
#endif // CORE_INTERNAL_MEDIUMS_WEBRTC_PEER_ID_H_
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifdef NO_WEBRTC
|
||||
|
||||
#include "connections/implementation/mediums/webrtc_peer_id_stub.h"
|
||||
|
||||
#include <sstream>
|
||||
@@ -33,3 +35,5 @@ bool WebrtcPeerId::IsValid() const { return false; }
|
||||
} // namespace mediums
|
||||
} // namespace connections
|
||||
} // namespace nearby
|
||||
|
||||
#endif
|
||||
|
||||
@@ -12,8 +12,10 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef CORE_INTERNAL_MEDIUMS_WEBRTC_PEER_ID_H_
|
||||
#define CORE_INTERNAL_MEDIUMS_WEBRTC_PEER_ID_H_
|
||||
#ifndef CORE_INTERNAL_MEDIUMS_WEBRTC_PEER_ID_STUB_H_
|
||||
#define CORE_INTERNAL_MEDIUMS_WEBRTC_PEER_ID_STUB_H_
|
||||
|
||||
#ifdef NO_WEBRTC
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
@@ -47,4 +49,6 @@ class WebrtcPeerId {
|
||||
} // namespace connections
|
||||
} // namespace nearby
|
||||
|
||||
#endif // CORE_INTERNAL_MEDIUMS_WEBRTC_PEER_ID_H_
|
||||
#endif
|
||||
|
||||
#endif // CORE_INTERNAL_MEDIUMS_WEBRTC_PEER_ID_STUB_H_
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
#ifndef CORE_INTERNAL_MEDIUMS_WEBRTC_SOCKET_H_
|
||||
#define CORE_INTERNAL_MEDIUMS_WEBRTC_SOCKET_H_
|
||||
|
||||
#ifndef NO_WEBRTC
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "connections/implementation/mediums/webrtc/webrtc_socket_impl.h"
|
||||
@@ -50,4 +52,6 @@ class WebRtcSocketWrapper final {
|
||||
} // namespace connections
|
||||
} // namespace nearby
|
||||
|
||||
#endif
|
||||
|
||||
#endif // CORE_INTERNAL_MEDIUMS_WEBRTC_WEBRTC_SOCKET_H_
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
#ifndef CORE_INTERNAL_MEDIUMS_WEBRTC_SOCKET_STUB_H_
|
||||
#define CORE_INTERNAL_MEDIUMS_WEBRTC_SOCKET_STUB_H_
|
||||
|
||||
#ifdef NO_WEBRTC
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "internal/platform/input_stream.h"
|
||||
@@ -64,4 +66,6 @@ class WebRtcSocketWrapper final {
|
||||
} // namespace connections
|
||||
} // namespace nearby
|
||||
|
||||
#endif
|
||||
|
||||
#endif // CORE_INTERNAL_MEDIUMS_WEBRTC_SOCKET_STUB_H_
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifdef NO_WEBRTC
|
||||
|
||||
#include "connections/implementation/mediums/webrtc_stub.h"
|
||||
|
||||
#include <functional>
|
||||
@@ -58,3 +60,5 @@ WebRtcSocketWrapper WebRtc::Connect(const std::string& service_id,
|
||||
} // namespace mediums
|
||||
} // namespace connections
|
||||
} // namespace nearby
|
||||
|
||||
#endif
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
#ifndef CORE_INTERNAL_MEDIUMS_WEBRTC_STUB_H_
|
||||
#define CORE_INTERNAL_MEDIUMS_WEBRTC_STUB_H_
|
||||
|
||||
#ifdef NO_WEBRTC
|
||||
|
||||
#include <cstddef>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
@@ -77,4 +79,6 @@ class WebRtc {
|
||||
} // namespace connections
|
||||
} // namespace nearby
|
||||
|
||||
#endif
|
||||
|
||||
#endif // CORE_INTERNAL_MEDIUMS_WEBRTC_STUB_H_
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef NO_WEBRTC
|
||||
|
||||
#include "connections/implementation/webrtc_bwu_handler.h"
|
||||
|
||||
#include <string>
|
||||
@@ -152,3 +154,5 @@ void WebrtcBwuHandler::OnIncomingWebrtcConnection(
|
||||
|
||||
} // namespace connections
|
||||
} // namespace nearby
|
||||
|
||||
#endif
|
||||
|
||||
@@ -15,17 +15,15 @@
|
||||
#ifndef CORE_INTERNAL_WEBRTC_BWU_HANDLER_H_
|
||||
#define CORE_INTERNAL_WEBRTC_BWU_HANDLER_H_
|
||||
|
||||
#ifndef NO_WEBRTC
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "connections/implementation/base_bwu_handler.h"
|
||||
#include "connections/implementation/client_proxy.h"
|
||||
#include "connections/implementation/endpoint_channel_manager.h"
|
||||
#include "connections/implementation/mediums/mediums.h"
|
||||
#ifdef NO_WEBRTC
|
||||
#include "connections/implementation/mediums/webrtc_socket_stub.h"
|
||||
#else
|
||||
#include "connections/implementation/mediums/webrtc_socket.h"
|
||||
#endif
|
||||
|
||||
namespace nearby {
|
||||
namespace connections {
|
||||
@@ -77,4 +75,6 @@ class WebrtcBwuHandler : public BaseBwuHandler {
|
||||
} // namespace connections
|
||||
} // namespace nearby
|
||||
|
||||
#endif
|
||||
|
||||
#endif // CORE_INTERNAL_WEBRTC_BWU_HANDLER_H_
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifdef NO_WEBRTC
|
||||
|
||||
#include "connections/implementation/webrtc_bwu_handler_stub.h"
|
||||
|
||||
#include <string>
|
||||
@@ -70,3 +72,5 @@ void WebrtcBwuHandler::OnIncomingWebrtcConnection(
|
||||
|
||||
} // namespace connections
|
||||
} // namespace nearby
|
||||
|
||||
#endif
|
||||
|
||||
@@ -12,8 +12,10 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef CORE_INTERNAL_WEBRTC_BWU_HANDLER_H_
|
||||
#define CORE_INTERNAL_WEBRTC_BWU_HANDLER_H_
|
||||
#ifndef CORE_INTERNAL_WEBRTC_BWU_HANDLER_STUB_H_
|
||||
#define CORE_INTERNAL_WEBRTC_BWU_HANDLER_STUB_H_
|
||||
|
||||
#ifdef NO_WEBRTC
|
||||
|
||||
#include <string>
|
||||
|
||||
@@ -77,4 +79,6 @@ class WebrtcBwuHandler : public BaseBwuHandler {
|
||||
} // namespace connections
|
||||
} // namespace nearby
|
||||
|
||||
#endif // CORE_INTERNAL_WEBRTC_BWU_HANDLER_H_
|
||||
#endif
|
||||
|
||||
#endif // CORE_INTERNAL_WEBRTC_BWU_HANDLER_STUB_H_
|
||||
|
||||
@@ -397,6 +397,7 @@ cc_library(
|
||||
"bluetooth_adapter.h",
|
||||
"bluetooth_classic.h",
|
||||
"credential_storage_impl.h",
|
||||
"webrtc.h",
|
||||
"wifi.h",
|
||||
"wifi_direct.h",
|
||||
"wifi_hotspot.h",
|
||||
|
||||
@@ -66,6 +66,7 @@ cc_library(
|
||||
"credential_storage.h",
|
||||
"http_loader.h",
|
||||
"server_sync.h",
|
||||
"webrtc.h",
|
||||
"wifi.h",
|
||||
"wifi_direct.h",
|
||||
"wifi_hotspot.h",
|
||||
|
||||
@@ -62,6 +62,7 @@ cc_library(
|
||||
"bluetooth_adapter.cc",
|
||||
"bluetooth_classic.cc",
|
||||
"credential_storage_impl.cc",
|
||||
"webrtc.cc",
|
||||
"wifi_direct.cc",
|
||||
"wifi_hotspot.cc",
|
||||
"wifi_lan.cc",
|
||||
@@ -72,6 +73,7 @@ cc_library(
|
||||
"bluetooth_adapter.h",
|
||||
"bluetooth_classic.h",
|
||||
"credential_storage_impl.h",
|
||||
"webrtc.h",
|
||||
"wifi.h",
|
||||
"wifi_direct.h",
|
||||
"wifi_hotspot.h",
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
#ifndef PLATFORM_API_WEBRTC_H_
|
||||
#define PLATFORM_API_WEBRTC_H_
|
||||
|
||||
#ifndef NO_WEBRTC
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
@@ -67,4 +69,6 @@ class WebRtcMedium {
|
||||
} // namespace api
|
||||
} // namespace nearby
|
||||
|
||||
#endif
|
||||
|
||||
#endif // PLATFORM_API_WEBRTC_H_
|
||||
|
||||
Reference in New Issue
Block a user