From 084f7ebd8847cfb68191f787dda192644377e6ad Mon Sep 17 00:00:00 2001 From: Suet-Fei Li Date: Thu, 5 Jan 2023 15:27:50 -0800 Subject: [PATCH] Remove location namespace in third_party/nearby. PiperOrigin-RevId: 500023196 --- connections/advertising_options.cc | 2 - connections/advertising_options.h | 2 - .../clients/ios/Internal/GNCAdvertiser.mm | 29 +- connections/clients/ios/Internal/GNCCore.h | 5 +- connections/clients/ios/Internal/GNCCore.mm | 4 +- .../clients/ios/Internal/GNCCoreConnection.mm | 22 +- .../clients/ios/Internal/GNCDiscoverer.mm | 17 +- .../clients/ios/Internal/GNCPayload.mm | 4 +- .../clients/ios/Internal/GNCPayloadListener.h | 2 - .../ios/Internal/GNCPayloadListener.mm | 2 - connections/clients/ios/Internal/GNCUtils.h | 2 - connections/clients/ios/Internal/GNCUtils.mm | 2 - .../Sources/CPPInputStreamBinding.h | 6 +- .../Sources/CPPInputStreamBinding.mm | 8 +- .../GNCAdvertisingOptions+CppConversions.h | 6 +- .../GNCAdvertisingOptions+CppConversions.mm | 4 +- .../GNCConnectionOptions+CppConversions.h | 6 +- .../GNCConnectionOptions+CppConversions.mm | 2 +- .../Sources/GNCCoreAdapter.mm | 30 +- .../GNCDiscoveryOptions+CppConversions.h | 6 +- .../GNCDiscoveryOptions+CppConversions.mm | 4 +- .../Sources/GNCError+Internal.h | 4 +- .../NearbyCoreAdapter/Sources/GNCError.mm | 2 - .../Sources/GNCException+Internal.h | 4 +- .../NearbyCoreAdapter/Sources/GNCException.mm | 2 - .../Sources/GNCInputStream.h | 6 +- .../Sources/GNCInputStream.mm | 8 +- .../Sources/GNCPayload+CppConversions.h | 8 +- .../Sources/GNCPayload+CppConversions.mm | 16 +- .../NearbyCoreAdapter/Sources/GNCPayload.mm | 2 +- .../Sources/GNCStrategy+Internal.h | 4 +- .../NearbyCoreAdapter/Sources/GNCStrategy.mm | 2 - .../clients/windows/advertising_options_w.cc | 4 +- .../clients/windows/advertising_options_w.h | 4 +- .../bluetooth_classic_server_socket_test.cc | 1224 ++++++++--------- .../clients/windows/connection_options_w.cc | 4 +- .../clients/windows/connection_options_w.h | 4 +- connections/clients/windows/core_adapter.cc | 4 +- connections/clients/windows/core_adapter.h | 8 +- .../clients/windows/dart/core_adapter_dart.cc | 8 +- .../clients/windows/dart/core_adapter_dart.h | 4 +- .../clients/windows/discovery_options_w.cc | 4 +- .../clients/windows/discovery_options_w.h | 4 +- connections/clients/windows/dll_config.h | 4 +- connections/clients/windows/file_w.cc | 134 +- connections/clients/windows/file_w.h | 26 +- connections/clients/windows/input_stream_w.cc | 6 +- connections/clients/windows/input_stream_w.h | 98 +- connections/clients/windows/listeners_w.cc | 540 ++++---- connections/clients/windows/listeners_w.h | 6 +- .../clients/windows/medium_selector_w.h | 4 +- connections/clients/windows/options_base_w.h | 68 +- .../out_of_band_connection_metadata_w.h | 116 +- connections/clients/windows/params_w.h | 84 +- connections/clients/windows/payload_w.cc | 4 +- connections/clients/windows/payload_w.h | 8 +- connections/clients/windows/strategy_w.cc | 4 +- connections/clients/windows/strategy_w.h | 4 +- connections/connection_options.cc | 2 - connections/connection_options.h | 4 +- connections/core.cc | 2 - connections/core.h | 2 - connections/core_test.cc | 2 - connections/device_provider.h | 4 +- connections/discovery_options.cc | 2 - connections/discovery_options.h | 2 - .../analytics/analytics_recorder.cc | 24 +- .../analytics/analytics_recorder.h | 60 +- .../analytics/analytics_recorder_test.cc | 4 +- .../connection_attempt_metadata_params.h | 2 - .../analytics/packet_meta_data.h | 2 - .../analytics/throughput_recorder.cc | 7 +- .../analytics/throughput_recorder.h | 6 +- .../analytics/throughput_recorder_test.cc | 40 +- .../implementation/base_bwu_handler.cc | 2 - connections/implementation/base_bwu_handler.h | 2 - .../implementation/base_bwu_handler_test.cc | 2 - .../implementation/base_endpoint_channel.cc | 39 +- .../implementation/base_endpoint_channel.h | 26 +- .../base_endpoint_channel_test.cc | 2 - .../implementation/base_pcp_handler.cc | 119 +- connections/implementation/base_pcp_handler.h | 38 +- .../implementation/base_pcp_handler_test.cc | 49 +- .../implementation/ble_advertisement.cc | 2 - .../implementation/ble_advertisement.h | 2 - .../implementation/ble_advertisement_test.cc | 2 - .../implementation/ble_endpoint_channel.cc | 7 +- .../implementation/ble_endpoint_channel.h | 4 +- .../implementation/ble_v2_endpoint_channel.cc | 7 +- .../implementation/ble_v2_endpoint_channel.h | 4 +- .../implementation/bluetooth_bwu_handler.cc | 2 - .../implementation/bluetooth_bwu_handler.h | 2 - .../implementation/bluetooth_device_name.cc | 2 - .../implementation/bluetooth_device_name.h | 2 - .../bluetooth_device_name_test.cc | 2 - .../bluetooth_endpoint_channel.cc | 7 +- .../bluetooth_endpoint_channel.h | 4 +- connections/implementation/bwu_handler.h | 5 +- connections/implementation/bwu_manager.cc | 181 +-- connections/implementation/bwu_manager.h | 12 +- .../implementation/bwu_manager_test.cc | 18 +- connections/implementation/client_proxy.cc | 22 +- connections/implementation/client_proxy.h | 10 +- .../implementation/client_proxy_test.cc | 9 +- .../implementation/encryption_runner.cc | 2 - .../implementation/encryption_runner.h | 2 - .../implementation/encryption_runner_test.cc | 16 +- connections/implementation/endpoint_channel.h | 13 +- .../endpoint_channel_manager.cc | 8 +- .../implementation/endpoint_channel_manager.h | 12 +- .../endpoint_channel_manager_test.cc | 2 - .../implementation/endpoint_manager.cc | 17 +- connections/implementation/endpoint_manager.h | 35 +- .../implementation/endpoint_manager_test.cc | 11 +- connections/implementation/fake_bwu_handler.h | 31 +- .../implementation/fake_endpoint_channel.h | 22 +- .../fuzzers/offline_frames_fuzzer.cc | 4 +- .../injected_bluetooth_device_store.cc | 2 - .../injected_bluetooth_device_store.h | 2 - .../injected_bluetooth_device_store_test.cc | 2 - .../implementation/internal_payload.cc | 2 - connections/implementation/internal_payload.h | 6 +- .../internal_payload_factory.cc | 41 +- .../implementation/internal_payload_factory.h | 5 +- .../internal_payload_factory_test.cc | 3 +- connections/implementation/mediums/ble.cc | 2 - connections/implementation/mediums/ble.h | 2 - .../implementation/mediums/ble_test.cc | 2 - connections/implementation/mediums/ble_v2.cc | 8 +- connections/implementation/mediums/ble_v2.h | 2 - .../ble_v2/advertisement_read_result.cc | 2 - .../ble_v2/advertisement_read_result.h | 2 - .../ble_v2/advertisement_read_result_test.cc | 2 - .../mediums/ble_v2/ble_advertisement.cc | 2 - .../mediums/ble_v2/ble_advertisement.h | 2 - .../ble_v2/ble_advertisement_header.cc | 2 - .../mediums/ble_v2/ble_advertisement_header.h | 2 - .../ble_v2/ble_advertisement_header_test.cc | 2 - .../mediums/ble_v2/ble_advertisement_test.cc | 2 - .../mediums/ble_v2/ble_packet.cc | 2 - .../mediums/ble_v2/ble_packet.h | 2 - .../mediums/ble_v2/ble_packet_test.cc | 2 - .../mediums/ble_v2/ble_utils.cc | 2 - .../implementation/mediums/ble_v2/ble_utils.h | 2 - .../mediums/ble_v2/ble_utils_test.cc | 2 - .../mediums/ble_v2/bloom_filter.cc | 2 - .../mediums/ble_v2/bloom_filter.h | 2 - .../mediums/ble_v2/bloom_filter_test.cc | 2 - .../ble_v2/discovered_peripheral_callback.h | 2 - .../ble_v2/discovered_peripheral_tracker.cc | 31 +- .../ble_v2/discovered_peripheral_tracker.h | 2 - .../discovered_peripheral_tracker_test.cc | 2 - .../implementation/mediums/ble_v2_test.cc | 2 - .../mediums/bluetooth_classic.cc | 2 - .../mediums/bluetooth_classic.h | 2 - .../mediums/bluetooth_classic_test.cc | 2 - .../implementation/mediums/bluetooth_radio.cc | 2 - .../implementation/mediums/bluetooth_radio.h | 2 - .../mediums/bluetooth_radio_test.cc | 2 - .../mediums/lost_entity_tracker.h | 2 - .../mediums/lost_entity_tracker_test.cc | 2 - connections/implementation/mediums/mediums.cc | 2 - connections/implementation/mediums/mediums.h | 2 - connections/implementation/mediums/utils.cc | 4 +- connections/implementation/mediums/utils.h | 5 +- connections/implementation/mediums/webrtc.cc | 7 +- connections/implementation/mediums/webrtc.h | 31 +- .../mediums/webrtc/connection_flow.cc | 2 - .../mediums/webrtc/connection_flow.h | 2 - .../mediums/webrtc/connection_flow_test.cc | 2 - .../mediums/webrtc/data_channel_listener.h | 2 - .../webrtc/local_ice_candidate_listener.h | 6 +- .../mediums/webrtc/signaling_frames.cc | 4 +- .../mediums/webrtc/signaling_frames.h | 2 - .../mediums/webrtc/signaling_frames_test.cc | 20 +- .../mediums/webrtc/webrtc_socket_impl.cc | 2 - .../mediums/webrtc/webrtc_socket_impl.h | 4 +- .../mediums/webrtc/webrtc_socket_impl_test.cc | 2 - .../implementation/mediums/webrtc_peer_id.cc | 2 - .../implementation/mediums/webrtc_peer_id.h | 2 - .../mediums/webrtc_peer_id_stub.cc | 2 - .../mediums/webrtc_peer_id_stub.h | 2 - .../mediums/webrtc_peer_id_test.cc | 2 - .../implementation/mediums/webrtc_socket.h | 2 - .../mediums/webrtc_socket_stub.h | 2 - .../implementation/mediums/webrtc_stub.cc | 3 +- .../implementation/mediums/webrtc_stub.h | 18 +- .../implementation/mediums/webrtc_test.cc | 3 +- connections/implementation/mediums/wifi.h | 2 - .../implementation/mediums/wifi_direct.cc | 2 - .../implementation/mediums/wifi_direct.h | 2 - .../mediums/wifi_direct_test.cc | 2 - .../implementation/mediums/wifi_hotspot.cc | 2 - .../implementation/mediums/wifi_hotspot.h | 2 - .../mediums/wifi_hotspot_test.cc | 2 - .../implementation/mediums/wifi_lan.cc | 2 - connections/implementation/mediums/wifi_lan.h | 2 - .../implementation/mediums/wifi_lan_test.cc | 2 - .../implementation/mediums/wifi_test.cc | 2 - .../implementation/mock_service_controller.h | 2 - .../mock_service_controller_router.h | 2 - connections/implementation/offline_frames.cc | 12 +- connections/implementation/offline_frames.h | 37 +- .../implementation/offline_frames_test.cc | 7 +- .../offline_frames_validator.cc | 26 +- .../implementation/offline_frames_validator.h | 5 +- .../offline_frames_validator_test.cc | 5 +- .../offline_service_controller.cc | 2 - .../offline_service_controller.h | 2 - .../offline_service_controller_test.cc | 2 - .../implementation/offline_simulation_user.cc | 2 - .../implementation/offline_simulation_user.h | 3 +- .../implementation/p2p_cluster_pcp_handler.cc | 453 +++--- .../implementation/p2p_cluster_pcp_handler.h | 23 +- .../p2p_cluster_pcp_handler_test.cc | 2 - .../p2p_point_to_point_pcp_handler.cc | 18 +- .../p2p_point_to_point_pcp_handler.h | 6 +- .../p2p_point_to_point_pcp_handler_test.cc | 2 - .../implementation/p2p_star_pcp_handler.cc | 23 +- .../implementation/p2p_star_pcp_handler.h | 7 +- connections/implementation/payload_manager.cc | 121 +- connections/implementation/payload_manager.h | 37 +- .../implementation/payload_manager_test.cc | 2 - connections/implementation/pcp.h | 2 - connections/implementation/pcp_handler.h | 2 - connections/implementation/pcp_manager.cc | 2 - connections/implementation/pcp_manager.h | 4 +- .../implementation/pcp_manager_test.cc | 2 - .../implementation/service_controller.h | 4 +- .../service_controller_router.cc | 2 - .../service_controller_router.h | 6 +- .../service_controller_router_test.cc | 6 +- .../implementation/service_id_constants.h | 2 - connections/implementation/simulation_user.cc | 2 - connections/implementation/simulation_user.h | 3 +- .../implementation/webrtc_bwu_handler.cc | 4 +- .../implementation/webrtc_bwu_handler.h | 2 - .../implementation/webrtc_bwu_handler_stub.cc | 2 - .../implementation/webrtc_bwu_handler_stub.h | 2 - .../implementation/webrtc_endpoint_channel.cc | 7 +- .../implementation/webrtc_endpoint_channel.h | 4 +- .../implementation/wifi_direct_bwu_handler.cc | 2 - .../implementation/wifi_direct_bwu_handler.h | 2 - .../implementation/wifi_direct_bwu_test.cc | 5 +- .../wifi_direct_endpoint_channel.cc | 7 +- .../wifi_direct_endpoint_channel.h | 4 +- .../wifi_hotspot_bwu_handler.cc | 2 - .../implementation/wifi_hotspot_bwu_handler.h | 2 - .../wifi_hotspot_endpoint_channel.cc | 7 +- .../wifi_hotspot_endpoint_channel.h | 4 +- .../implementation/wifi_hotspot_test.cc | 5 +- .../implementation/wifi_lan_bwu_handler.cc | 2 - .../implementation/wifi_lan_bwu_handler.h | 2 - .../wifi_lan_endpoint_channel.cc | 8 +- .../wifi_lan_endpoint_channel.h | 4 +- .../implementation/wifi_lan_service_info.cc | 2 - .../implementation/wifi_lan_service_info.h | 2 - .../wifi_lan_service_info_test.cc | 2 - connections/listeners.h | 2 - connections/listeners_test.cc | 2 - connections/medium_selector.h | 2 - connections/options_base.h | 2 - connections/out_of_band_connection_metadata.h | 2 - connections/params.h | 2 - connections/payload.cc | 2 - connections/payload.h | 2 - connections/payload_test.cc | 2 - connections/payload_type.h | 2 - connections/power_level.h | 2 - connections/status.cc | 2 - connections/status.h | 2 - connections/status_test.cc | 2 - connections/strategy.cc | 2 - connections/strategy.h | 3 +- connections/strategy_test.cc | 2 - .../windows/fast_pair_controller_adapter.cc | 2 - .../windows/fast_pair_controller_adapter.h | 2 - .../fast_pair_controller_adapter_dart.cc | 2 - .../fast_pair_controller_adapter_dart.h | 2 - fastpair/common/constant.h | 2 - fastpair/common/fast_pair_device.cc | 2 - fastpair/common/fast_pair_device.h | 2 - fastpair/common/fast_pair_device_test.cc | 2 - fastpair/common/fast_pair_http_result.cc | 2 - fastpair/common/fast_pair_http_result.h | 2 - fastpair/common/protocol.cc | 2 - fastpair/common/protocol.h | 2 - fastpair/fast_pair_controller.h | 2 - fastpair/internal/api/device_info.h | 2 - fastpair/internal/api/fast_pair_platform.h | 2 - fastpair/internal/api/timer.h | 2 - fastpair/internal/base/bluetooth_address.cc | 2 - fastpair/internal/base/bluetooth_address.h | 2 - .../internal/base/bluetooth_address_test.cc | 2 - fastpair/internal/base/observer_list.h | 2 - fastpair/internal/ble/ble.cc | 2 - fastpair/internal/ble/ble.h | 2 - fastpair/internal/ble/ble_test.cc | 2 - fastpair/internal/impl/g3/device_info.h | 2 - fastpair/internal/impl/g3/device_info_test.cc | 2 - .../internal/impl/g3/fast_pair_platform.cc | 2 - fastpair/internal/impl/g3/timer.h | 2 - .../internal/impl/windows/ble_gatt_client.cc | 2 - .../internal/impl/windows/ble_gatt_client.h | 2 - fastpair/internal/impl/windows/device_info.cc | 2 - fastpair/internal/impl/windows/device_info.h | 3 +- .../internal/impl/windows/device_info_test.cc | 2 - .../impl/windows/fast_pair_platform.cc | 2 - fastpair/internal/impl/windows/timer.cc | 2 - fastpair/internal/impl/windows/timer.h | 2 - fastpair/internal/impl/windows/timer_test.cc | 2 - fastpair/internal/impl/windows/utils.cc | 6 +- fastpair/internal/impl/windows/utils.h | 2 - fastpair/internal/public/device_info.h | 2 - fastpair/internal/public/device_info_impl.cc | 2 - fastpair/internal/public/device_info_impl.h | 2 - fastpair/internal/public/task_runner.h | 2 - fastpair/internal/public/task_runner_impl.cc | 5 +- fastpair/internal/public/task_runner_impl.h | 4 +- .../internal/public/task_runner_impl_test.cc | 2 - fastpair/internal/public/timer.h | 2 - fastpair/internal/public/timer_impl.cc | 2 - fastpair/internal/public/timer_impl.h | 2 - fastpair/internal/public/timer_impl_test.cc | 2 - .../test/fast_pair_fake_http_client.h | 2 - .../test/fast_pair_fake_http_client_test.cc | 2 - .../repository/fast_pair_metadata_fetcher.h | 2 - .../fast_pair_metadata_fetcher_impl.cc | 2 - .../fast_pair_metadata_fetcher_impl.h | 2 - .../fast_pair_metadata_fetcher_impl_test.cc | 8 +- .../fastpair/fast_pair_scanner_impl.cc | 2 - .../fastpair/fast_pair_scanner_impl.h | 2 - internal/device.h | 2 - internal/network/debug.h | 2 - internal/network/http_body.h | 2 - internal/network/http_client.h | 2 - internal/network/http_client_factory.h | 2 - internal/network/http_client_factory_impl.h | 2 - internal/network/http_client_impl.cc | 2 - internal/network/http_client_impl.h | 2 - internal/network/http_client_impl_test.cc | 2 - internal/network/http_request.cc | 2 - internal/network/http_request.h | 2 - internal/network/http_request_test.cc | 2 - internal/network/http_response.cc | 2 - internal/network/http_response.h | 2 - internal/network/http_response_test.cc | 2 - internal/network/http_status_code.cc | 2 - internal/network/http_status_code.h | 2 - internal/network/http_status_code_test.cc | 2 - internal/network/url.cc | 2 - internal/network/url.h | 2 - internal/network/url_test.cc | 2 - internal/network/utils.cc | 2 - internal/network/utils.h | 2 - internal/network/utils_test.cc | 2 - internal/platform/atomic_boolean.h | 2 - internal/platform/atomic_boolean_test.cc | 2 - internal/platform/atomic_reference.h | 2 - internal/platform/atomic_reference_test.cc | 2 - internal/platform/base64_utils.cc | 2 - internal/platform/base64_utils.h | 2 - internal/platform/base_input_stream.cc | 2 - internal/platform/base_input_stream.h | 2 - internal/platform/base_mutex_lock.h | 2 - internal/platform/base_pipe.cc | 2 - internal/platform/base_pipe.h | 2 - internal/platform/ble.cc | 2 - internal/platform/ble.h | 2 - internal/platform/ble_connection_info.cc | 2 - internal/platform/ble_connection_info.h | 2 - internal/platform/ble_connection_info_test.cc | 2 - internal/platform/ble_test.cc | 2 - internal/platform/ble_v2.cc | 8 +- internal/platform/ble_v2.h | 18 +- internal/platform/ble_v2_test.cc | 8 +- internal/platform/bluetooth_adapter.h | 2 - internal/platform/bluetooth_adapter_test.cc | 2 - internal/platform/bluetooth_classic.cc | 2 - internal/platform/bluetooth_classic.h | 2 - internal/platform/bluetooth_classic_test.cc | 2 - .../platform/bluetooth_connection_info.cc | 2 - internal/platform/bluetooth_connection_info.h | 2 - .../bluetooth_connection_info_test.cc | 2 - internal/platform/bluetooth_utils.cc | 2 - internal/platform/bluetooth_utils.h | 2 - internal/platform/bluetooth_utils_test.cc | 2 - internal/platform/borrowable.h | 2 - internal/platform/borrowable_test.cc | 2 - internal/platform/byte_array.h | 2 - internal/platform/byte_array_test.cc | 2 +- internal/platform/byte_utils.cc | 2 - internal/platform/byte_utils.h | 2 - internal/platform/byte_utils_test.cc | 2 - internal/platform/callable.h | 2 - internal/platform/cancelable.h | 2 - internal/platform/cancelable_alarm.h | 2 - internal/platform/cancelable_alarm_test.cc | 2 - internal/platform/cancellable_task.h | 2 - internal/platform/cancellation_flag.cc | 2 - internal/platform/cancellation_flag.h | 2 - .../platform/cancellation_flag_listener.h | 2 - internal/platform/cancellation_flag_test.cc | 16 +- internal/platform/condition_variable.h | 2 - internal/platform/condition_variable_test.cc | 2 - internal/platform/connection_info.h | 2 - internal/platform/count_down_latch.h | 2 - internal/platform/count_down_latch_test.cc | 2 - internal/platform/credential_storage_impl.cc | 2 - internal/platform/credential_storage_impl.h | 2 - .../platform/credential_storage_impl_test.cc | 2 - internal/platform/crypto_test.cc | 2 - internal/platform/direct_executor.h | 2 - internal/platform/direct_executor_test.cc | 2 - internal/platform/error_code_params.h | 2 - internal/platform/error_code_recorder.cc | 8 +- internal/platform/error_code_recorder.h | 2 - internal/platform/error_code_recorder_test.cc | 70 +- internal/platform/exception.h | 2 - internal/platform/exception_test.cc | 4 +- internal/platform/feature_flags.h | 2 - internal/platform/feature_flags_test.cc | 2 - internal/platform/file.cc | 2 - internal/platform/file.h | 2 - internal/platform/future.h | 2 - internal/platform/future_test.cc | 2 - .../implementation/apple/Tests/GNCBleTest.mm | 18 +- .../apple/Tests/GNCBluetoothAdapterTest.mm | 8 +- .../apple/Tests/GNCCryptoTest.mm | 4 +- .../apple/Tests/GNCMultiThreadExecutorTest.mm | 6 +- .../apple/Tests/GNCScheduledExecutorTest.mm | 6 +- .../Tests/GNCSingleThreadExecutorTest.mm | 6 +- .../apple/Tests/GNCUtilsTest.mm | 8 +- .../implementation/apple/atomic_boolean.h | 2 - .../apple/atomic_boolean_test.cc | 2 - .../implementation/apple/atomic_uint32.h | 2 - .../apple/atomic_uint32_test.cc | 2 - internal/platform/implementation/apple/ble.h | 4 +- internal/platform/implementation/apple/ble.mm | 15 +- .../implementation/apple/bluetooth_adapter.h | 2 - .../implementation/apple/bluetooth_adapter.mm | 2 - .../apple/condition_variable.cc | 2 - .../implementation/apple/condition_variable.h | 2 - .../apple/condition_variable_test.cc | 2 - .../implementation/apple/count_down_latch.cc | 2 - .../implementation/apple/count_down_latch.h | 2 - .../apple/count_down_latch_test.cc | 2 - .../platform/implementation/apple/crypto.mm | 2 - .../implementation/apple/log_message.h | 2 - .../implementation/apple/log_message.mm | 2 - .../apple/multi_thread_executor.h | 2 - .../apple/multi_thread_executor.mm | 2 - .../platform/implementation/apple/mutex.h | 2 - .../implementation/apple/mutex_test.cc | 2 - .../platform/implementation/apple/platform.mm | 2 - .../implementation/apple/scheduled_executor.h | 2 - .../apple/scheduled_executor.mm | 10 +- .../apple/single_thread_executor.h | 2 - .../implementation/apple/system_clock.cc | 2 - .../platform/implementation/apple/utils.h | 2 - .../platform/implementation/apple/utils.mm | 2 - .../platform/implementation/apple/wifi_lan.h | 2 - .../platform/implementation/apple/wifi_lan.mm | 2 - .../platform/implementation/atomic_boolean.h | 2 - .../implementation/atomic_reference.h | 2 - internal/platform/implementation/ble.h | 2 - internal/platform/implementation/ble_v2.h | 9 +- .../implementation/bluetooth_adapter.h | 2 - .../implementation/bluetooth_classic.h | 2 - internal/platform/implementation/cancelable.h | 2 - .../implementation/condition_variable.h | 2 - .../implementation/count_down_latch.h | 2 - .../implementation/credential_storage.h | 2 - internal/platform/implementation/crypto.h | 2 - internal/platform/implementation/executor.h | 2 - internal/platform/implementation/future.h | 2 - .../implementation/g3/atomic_boolean.h | 2 - .../implementation/g3/atomic_reference.h | 2 - internal/platform/implementation/g3/ble.cc | 2 - internal/platform/implementation/g3/ble.h | 2 - internal/platform/implementation/g3/ble_v2.cc | 8 +- internal/platform/implementation/g3/ble_v2.h | 5 +- .../implementation/g3/bluetooth_adapter.cc | 2 - .../implementation/g3/bluetooth_adapter.h | 2 - .../implementation/g3/bluetooth_classic.cc | 2 - .../implementation/g3/bluetooth_classic.h | 2 - .../implementation/g3/condition_variable.h | 2 - .../g3/credential_storage_impl.cc | 2 - .../g3/credential_storage_impl.h | 2 - internal/platform/implementation/g3/crypto.cc | 2 - .../platform/implementation/g3/log_message.cc | 2 - .../platform/implementation/g3/log_message.h | 2 - .../implementation/g3/multi_thread_executor.h | 2 - internal/platform/implementation/g3/mutex.h | 2 - internal/platform/implementation/g3/pipe.h | 2 - .../platform/implementation/g3/platform.cc | 2 - .../implementation/g3/scheduled_executor.cc | 2 - .../implementation/g3/scheduled_executor.h | 2 - .../g3/single_thread_executor.h | 2 - .../implementation/g3/system_clock.cc | 2 - internal/platform/implementation/g3/webrtc.cc | 9 +- internal/platform/implementation/g3/webrtc.h | 9 +- internal/platform/implementation/g3/wifi.h | 2 - .../platform/implementation/g3/wifi_direct.cc | 2 - .../platform/implementation/g3/wifi_direct.h | 2 - .../implementation/g3/wifi_hotspot.cc | 2 - .../platform/implementation/g3/wifi_hotspot.h | 2 - .../platform/implementation/g3/wifi_lan.cc | 2 - .../platform/implementation/g3/wifi_lan.h | 2 - .../platform/implementation/http_loader.h | 2 - internal/platform/implementation/input_file.h | 2 - .../implementation/listenable_future.h | 2 - .../platform/implementation/log_message.h | 2 - internal/platform/implementation/mutex.h | 2 - .../platform/implementation/output_file.h | 2 - internal/platform/implementation/platform.h | 2 - .../implementation/scheduled_executor.h | 2 - .../platform/implementation/server_sync.h | 2 - .../platform/implementation/settable_future.h | 2 - .../implementation/shared/count_down_latch.cc | 2 - .../implementation/shared/count_down_latch.h | 2 - .../platform/implementation/shared/file.cc | 2 - .../platform/implementation/shared/file.h | 2 - .../implementation/shared/file_test.cc | 2 - .../shared/posix_condition_variable.cc | 2 - .../shared/posix_condition_variable.h | 2 - .../implementation/shared/posix_mutex.cc | 2 - .../implementation/shared/posix_mutex.h | 2 - .../implementation/submittable_executor.h | 2 - .../platform/implementation/system_clock.h | 2 - internal/platform/implementation/webrtc.h | 4 +- internal/platform/implementation/wifi.h | 2 - .../platform/implementation/wifi_direct.h | 2 - .../platform/implementation/wifi_hotspot.h | 2 - internal/platform/implementation/wifi_lan.h | 2 - .../implementation/windows/atomic_boolean.h | 2 - .../windows/atomic_boolean_test.cc | 2 +- .../implementation/windows/atomic_reference.h | 2 - .../windows/atomic_reference_test.cc | 8 +- .../implementation/windows/ble_medium.cc | 2 - .../implementation/windows/ble_medium.h | 2 - .../implementation/windows/ble_medium_test.cc | 2 - .../implementation/windows/ble_peripheral.h | 2 - .../implementation/windows/ble_socket.cc | 2 - .../implementation/windows/ble_socket.h | 2 - .../platform/implementation/windows/ble_v2.cc | 16 +- .../platform/implementation/windows/ble_v2.h | 2 - .../implementation/windows/ble_v2_test.cc | 2 - .../windows/bluetooth_adapter.cc | 14 +- .../windows/bluetooth_adapter.h | 2 - .../windows/bluetooth_adapter_test.cc | 2 - .../windows/bluetooth_classic_device.cc | 2 - .../windows/bluetooth_classic_device.h | 2 - .../windows/bluetooth_classic_medium.cc | 4 +- .../windows/bluetooth_classic_medium.h | 2 - .../windows/bluetooth_classic_medium_test.cc | 76 +- .../bluetooth_classic_server_socket.cc | 2 - .../windows/bluetooth_classic_server_socket.h | 3 +- .../windows/bluetooth_classic_socket.cc | 2 - .../windows/bluetooth_classic_socket.h | 2 - .../windows/bluetooth_pairing.cc | 2 - .../windows/bluetooth_pairing.h | 2 - .../windows/condition_variable.h | 3 +- .../windows/condition_variable_test.cc | 15 +- .../windows/count_down_latch_test.cc | 30 +- .../platform/implementation/windows/crypto.cc | 3 +- .../implementation/windows/crypto_test.cc | 2 - .../implementation/windows/executor.cc | 2 - .../implementation/windows/executor.h | 2 - .../implementation/windows/executor_test.cc | 2 - .../platform/implementation/windows/file.cc | 2 - .../platform/implementation/windows/file.h | 2 - .../implementation/windows/file_path.cc | 2 - .../implementation/windows/file_path.h | 2 - .../implementation/windows/file_path_test.cc | 2 - .../platform/implementation/windows/future.h | 2 - .../implementation/windows/http_loader.cc | 4 +- .../implementation/windows/http_loader.h | 10 +- .../windows/http_loader_test.cc | 4 +- .../implementation/windows/input_file.h | 2 - .../implementation/windows/input_file_test.cc | 46 +- .../windows/listenable_future.h | 2 - .../implementation/windows/log_message.cc | 2 - .../implementation/windows/log_message.h | 2 - .../implementation/windows/mediums_api.h | 2 - .../windows/mediums_manager/mediums_api.cc | 2 - .../windows/mediums_manager/mediums_manager.h | 2 - .../mediums_manager/mediums_manager_impl.cc | 2 - .../mediums_manager/mediums_manager_impl.h | 2 - .../platform/implementation/windows/mutex.h | 4 +- .../implementation/windows/mutex_test.cc | 21 +- .../implementation/windows/output_file.h | 2 - .../windows/output_file_test.cc | 27 +- .../implementation/windows/platform.cc | 2 - .../windows/scheduled_executor.cc | 2 - .../windows/scheduled_executor.h | 2 - .../windows/scheduled_executor_test.cc | 2 - .../implementation/windows/server_sync.h | 2 - .../implementation/windows/settable_future.h | 2 - .../windows/submittable_executor.cc | 2 - .../windows/submittable_executor.h | 2 - .../windows/submittable_executor_test.cc | 2 - .../implementation/windows/system_clock.cc | 2 - .../implementation/windows/test_utils.cc | 2 +- .../implementation/windows/test_utils.h | 2 +- .../implementation/windows/thread_pool.cc | 2 - .../implementation/windows/thread_pool.h | 2 - .../windows/thread_pool_test.cc | 2 - .../platform/implementation/windows/utils.cc | 4 +- .../platform/implementation/windows/utils.h | 2 - .../implementation/windows/utils_test.cc | 5 +- .../platform/implementation/windows/webrtc.h | 5 +- .../platform/implementation/windows/wifi.h | 2 - .../implementation/windows/wifi_direct.h | 4 +- .../windows/wifi_direct_medium.cc | 4 +- .../windows/wifi_direct_server_socket.cc | 2 - .../windows/wifi_direct_socket.cc | 4 +- .../implementation/windows/wifi_hotspot.h | 4 +- .../windows/wifi_hotspot_medium.cc | 4 +- .../windows/wifi_hotspot_server_socket.cc | 2 - .../windows/wifi_hotspot_socket.cc | 2 - .../implementation/windows/wifi_lan.h | 4 +- .../implementation/windows/wifi_lan_medium.cc | 4 +- .../windows/wifi_lan_server_socket.cc | 2 - .../implementation/windows/wifi_lan_socket.cc | 2 - .../implementation/windows/wifi_medium.cc | 2 - internal/platform/input_stream.cc | 2 - internal/platform/input_stream.h | 2 - internal/platform/listeners.h | 2 - internal/platform/lockable.h | 2 - internal/platform/logging.h | 40 +- internal/platform/medium_environment.cc | 2 - internal/platform/medium_environment.h | 8 +- internal/platform/monitored_runnable.cc | 2 - internal/platform/monitored_runnable.h | 2 - internal/platform/multi_thread_executor.h | 2 - .../platform/multi_thread_executor_test.cc | 2 - internal/platform/mutex.h | 2 - internal/platform/mutex_lock.h | 2 - internal/platform/mutex_test.cc | 2 - internal/platform/nsd_service_info.cc | 2 - internal/platform/nsd_service_info.h | 2 - internal/platform/os_name.h | 2 - internal/platform/output_stream.h | 2 - internal/platform/payload_id.h | 2 - internal/platform/pending_job_registry.cc | 2 - internal/platform/pending_job_registry.h | 2 - internal/platform/pipe.cc | 2 - internal/platform/pipe.h | 2 - internal/platform/pipe_test.cc | 2 - internal/platform/prng.cc | 2 - internal/platform/prng.h | 2 - internal/platform/prng_test.cc | 2 - internal/platform/runnable.h | 2 - internal/platform/scheduled_executor.h | 2 - internal/platform/scheduled_executor_test.cc | 2 - internal/platform/settable_future.h | 2 - internal/platform/single_thread_executor.h | 2 - .../platform/single_thread_executor_test.cc | 2 - internal/platform/socket.h | 2 - internal/platform/submittable_executor.h | 2 - internal/platform/thread_check_callable.h | 2 - internal/platform/thread_check_nocompile.cc | 3 +- internal/platform/thread_check_runnable.h | 2 - internal/platform/types.h | 2 - internal/platform/uuid.cc | 2 - internal/platform/uuid.h | 2 - internal/platform/uuid_test.cc | 2 - internal/platform/webrtc.h | 4 +- internal/platform/wifi.h | 4 - internal/platform/wifi_direct.cc | 2 - internal/platform/wifi_direct.h | 2 - internal/platform/wifi_direct_test.cc | 2 - internal/platform/wifi_hotspot.cc | 2 - internal/platform/wifi_hotspot.h | 2 - internal/platform/wifi_hotspot_credential.h | 24 +- internal/platform/wifi_hotspot_test.cc | 2 - internal/platform/wifi_lan.cc | 2 - internal/platform/wifi_lan.h | 2 - internal/platform/wifi_lan_connection_info.cc | 2 - internal/platform/wifi_lan_connection_info.h | 2 - .../platform/wifi_lan_connection_info_test.cc | 2 - internal/platform/wifi_lan_test.cc | 2 - internal/platform/wifi_test.cc | 2 - internal/platform/wifi_utils.cc | 2 - internal/platform/wifi_utils.h | 4 +- internal/platform/wifi_utils_test.cc | 3 - .../proto/analytics/connections_log_test.cc | 2 - presence/credential_test.cc | 2 +- .../advertisement_decoder_test.cc | 2 +- .../advertisement_factory_test.cc | 2 +- presence/implementation/broadcast_manager.cc | 5 +- presence/implementation/broadcast_manager.h | 6 +- .../implementation/broadcast_manager_test.cc | 10 +- .../implementation/credential_manager_impl.cc | 10 +- .../implementation/credential_manager_impl.h | 15 +- .../credential_manager_impl_test.cc | 6 +- presence/implementation/ldt_test.cc | 2 +- presence/implementation/mediums/ble.h | 30 +- presence/implementation/mediums/ble_test.cc | 41 +- presence/implementation/mediums/mediums.h | 2 +- presence/implementation/scan_manager.cc | 19 +- presence/implementation/scan_manager.h | 14 +- presence/implementation/scan_manager_test.cc | 22 +- .../implementation/service_controller_impl.h | 2 +- presence/listeners.h | 2 +- presence/presence_client.cc | 8 +- presence/presence_client.h | 3 +- presence/presence_client_test.cc | 5 +- presence/presence_device.cc | 11 +- presence/presence_device.h | 4 +- presence/presence_device_test.cc | 10 +- presence/presence_service.h | 2 +- presence/presence_service_test.cc | 3 +- 714 files changed, 2714 insertions(+), 3742 deletions(-) diff --git a/connections/advertising_options.cc b/connections/advertising_options.cc index c630e5fad7..1874badb64 100644 --- a/connections/advertising_options.cc +++ b/connections/advertising_options.cc @@ -16,7 +16,6 @@ #include -namespace location { namespace nearby { namespace connections { @@ -49,4 +48,3 @@ AdvertisingOptions AdvertisingOptions::CompatibleOptions() const { } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/advertising_options.h b/connections/advertising_options.h index 497da0156b..d0fbf7f30f 100644 --- a/connections/advertising_options.h +++ b/connections/advertising_options.h @@ -22,7 +22,6 @@ #include "internal/platform/byte_array.h" #include "proto/connections_enums.pb.h" -namespace location { namespace nearby { namespace connections { @@ -54,6 +53,5 @@ struct AdvertisingOptions : public OptionsBase { } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_ADVERTISING_OPTIONS_H_ diff --git a/connections/clients/ios/Internal/GNCAdvertiser.mm b/connections/clients/ios/Internal/GNCAdvertiser.mm index f5ae21b368..b5a40adeb2 100644 --- a/connections/clients/ios/Internal/GNCAdvertiser.mm +++ b/connections/clients/ios/Internal/GNCAdvertiser.mm @@ -33,17 +33,17 @@ NS_ASSUME_NONNULL_BEGIN -using ::location::nearby::ByteArrayFromNSData; -using ::location::nearby::CppStringFromObjCString; -using ::location::nearby::ObjCStringFromCppString; -using ::location::nearby::connections::ConnectionListener; -using ::location::nearby::connections::AdvertisingOptions; -using ::location::nearby::connections::ConnectionRequestInfo; -using ::location::nearby::connections::ConnectionResponseInfo; -using ::location::nearby::connections::GNCStrategyToStrategy; -using ::location::nearby::connections::Medium; -using ResultListener = ::location::nearby::connections::ResultCallback; -using ::location::nearby::connections::Status; +using ::nearby::ByteArrayFromNSData; +using ::nearby::CppStringFromObjCString; +using ::nearby::ObjCStringFromCppString; +using ::nearby::connections::AdvertisingOptions; +using ::nearby::connections::ConnectionListener; +using ::nearby::connections::ConnectionRequestInfo; +using ::nearby::connections::ConnectionResponseInfo; +using ::nearby::connections::GNCStrategyToStrategy; +using ::nearby::connections::Medium; +using ResultListener = ::nearby::connections::ResultCallback; +using ::nearby::connections::Status; /** This is a GNCAdvertiserConnectionInfo that provides storage for its properties. */ @interface GNCAdvertiserConnectionInfo : NSObject @@ -108,7 +108,7 @@ @interface GNCAdvertiser () @end /** C++ classes passed to the core library by GNCAdvertiser. */ -namespace location { + namespace nearby { namespace connections { @@ -268,9 +268,8 @@ void OnBandwidthChanged(const std::string &endpoint_id, Medium medium) { } // namespace connections } // namespace nearby -} // namespace location -using ::location::nearby::connections::GNCAdvertiserConnectionListener; +using ::nearby::connections::GNCAdvertiserConnectionListener; @interface GNCAdvertiser () { std::unique_ptr advertiserListener; @@ -304,7 +303,7 @@ + (instancetype)advertiserWithEndpointInfo:(NSData *)endpointInfo AdvertisingOptions advertising_options; advertising_options.strategy = GNCStrategyToStrategy(strategy); - advertising_options.allowed = location::nearby::connections::BooleanMediumSelector(); + advertising_options.allowed = nearby::connections::BooleanMediumSelector(); advertising_options.auto_upgrade_bandwidth = true; advertising_options.enforce_topology_constraints = true; diff --git a/connections/clients/ios/Internal/GNCCore.h b/connections/clients/ios/Internal/GNCCore.h index 9d528df13f..007cfad6f8 100644 --- a/connections/clients/ios/Internal/GNCCore.h +++ b/connections/clients/ios/Internal/GNCCore.h @@ -26,9 +26,8 @@ NS_ASSUME_NONNULL_BEGIN /** This class contains the C++ Core object. */ @interface GNCCore : NSObject { @public - std::unique_ptr<::location::nearby::connections::Core> _core; - std::unique_ptr<::location::nearby::connections::ServiceControllerRouter> - _service_controller_router; + std::unique_ptr<::nearby::connections::Core> _core; + std::unique_ptr<::nearby::connections::ServiceControllerRouter> _service_controller_router; } @end diff --git a/connections/clients/ios/Internal/GNCCore.mm b/connections/clients/ios/Internal/GNCCore.mm index 5494da91f1..0891a93d13 100644 --- a/connections/clients/ios/Internal/GNCCore.mm +++ b/connections/clients/ios/Internal/GNCCore.mm @@ -21,8 +21,8 @@ #include "connections/implementation/service_controller_router.h" #import "GoogleToolboxForMac/GTMLogger.h" -using ::location::nearby::connections::Core; -using ::location::nearby::connections::ServiceControllerRouter; +using ::nearby::connections::Core; +using ::nearby::connections::ServiceControllerRouter; @implementation GNCCore { } diff --git a/connections/clients/ios/Internal/GNCCoreConnection.mm b/connections/clients/ios/Internal/GNCCoreConnection.mm index d9f14cb4df..35ad77e128 100644 --- a/connections/clients/ios/Internal/GNCCoreConnection.mm +++ b/connections/clients/ios/Internal/GNCCoreConnection.mm @@ -28,15 +28,14 @@ #import "connections/clients/ios/Public/NearbyConnections/GNCPayload.h" #import "internal/platform/implementation/apple/utils.h" -using ::location::nearby::ByteArrayFromNSData; -using ::location::nearby::CppStringFromObjCString; -using ::location::nearby::InputFile; -using ::location::nearby::InputStream; -using ::location::nearby::connections::Payload; -using ::location::nearby::PayloadId; -using ResultListener = ::location::nearby::connections::ResultCallback; - -namespace location { +using ::nearby::ByteArrayFromNSData; +using ::nearby::CppStringFromObjCString; +using ::nearby::InputFile; +using ::nearby::InputStream; +using ::nearby::PayloadId; +using ::nearby::connections::Payload; +using ResultListener = ::nearby::connections::ResultCallback; + namespace nearby { namespace connections { @@ -83,7 +82,6 @@ Exception Close() override { } // namespace connections } // namespace nearby -} // namespace location @implementation GNCPayloadInfo @@ -142,8 +140,8 @@ - (NSProgress *)sendStreamPayload:(GNCStreamPayload *)payload PayloadId payloadId = payload.identifier; Payload corePayload(payloadId, [payload]() -> InputStream & { - location::nearby::connections::GNCInputStreamFromNSStream *stream = - new location::nearby::connections::GNCInputStreamFromNSStream(payload.stream); + nearby::connections::GNCInputStreamFromNSStream *stream = + new nearby::connections::GNCInputStreamFromNSStream(payload.stream); return *stream; }); return [self sendPayload:std::move(corePayload) size:-1 progress:progress completion:completion]; diff --git a/connections/clients/ios/Internal/GNCDiscoverer.mm b/connections/clients/ios/Internal/GNCDiscoverer.mm index 560de78382..8f8c48eba9 100644 --- a/connections/clients/ios/Internal/GNCDiscoverer.mm +++ b/connections/clients/ios/Internal/GNCDiscoverer.mm @@ -34,12 +34,12 @@ NS_ASSUME_NONNULL_BEGIN -using ::location::nearby::CppStringFromObjCString; -using ::location::nearby::connections::DiscoveryOptions; -using ::location::nearby::connections::DiscoveryListener; -using ::location::nearby::connections::GNCStrategyToStrategy; -using ResultListener = ::location::nearby::connections::ResultCallback; -using ::location::nearby::connections::Status; +using ::nearby::CppStringFromObjCString; +using ::nearby::connections::DiscoveryListener; +using ::nearby::connections::DiscoveryOptions; +using ::nearby::connections::GNCStrategyToStrategy; +using ResultListener = ::nearby::connections::ResultCallback; +using ::nearby::connections::Status; /** This is a GNCDiscovererConnectionInfo that provides storage for its properties. */ @interface GNCDiscovererConnectionInfo : NSObject @@ -123,7 +123,7 @@ @interface GNCDiscoverer () @end /** C++ classes passed to the core library by GNCDiscoverer. */ -namespace location { + namespace nearby { namespace connections { @@ -349,9 +349,8 @@ void OnEndpointDistanceChanged_cb(const std::string &endpoint_id, DistanceInfo i } // namespace connections } // namespace nearby -} // namespace location -using ::location::nearby::connections::GNCDiscoveryListener; +using ::nearby::connections::GNCDiscoveryListener; @interface GNCDiscoverer () { std::unique_ptr discoveryListener; diff --git a/connections/clients/ios/Internal/GNCPayload.mm b/connections/clients/ios/Internal/GNCPayload.mm index 3dd795283a..0e1cadfa25 100644 --- a/connections/clients/ios/Internal/GNCPayload.mm +++ b/connections/clients/ios/Internal/GNCPayload.mm @@ -19,8 +19,8 @@ #include -using ::location::nearby::connections::Payload; -using ::location::nearby::PayloadId; +using ::nearby::PayloadId; +using ::nearby::connections::Payload; NS_ASSUME_NONNULL_BEGIN diff --git a/connections/clients/ios/Internal/GNCPayloadListener.h b/connections/clients/ios/Internal/GNCPayloadListener.h index 9a334710a7..45d55f2737 100644 --- a/connections/clients/ios/Internal/GNCPayloadListener.h +++ b/connections/clients/ios/Internal/GNCPayloadListener.h @@ -25,7 +25,6 @@ NS_ASSUME_NONNULL_BEGIN @class GNCPayloadInfo; -namespace location { namespace nearby { namespace connections { @@ -53,7 +52,6 @@ class GNCPayloadListener : public PayloadListener { } // namespace connections } // namespace nearby -} // namespace location NS_ASSUME_NONNULL_END diff --git a/connections/clients/ios/Internal/GNCPayloadListener.mm b/connections/clients/ios/Internal/GNCPayloadListener.mm index 63583a4b02..5776f2e4e5 100644 --- a/connections/clients/ios/Internal/GNCPayloadListener.mm +++ b/connections/clients/ios/Internal/GNCPayloadListener.mm @@ -32,7 +32,6 @@ NS_ASSUME_NONNULL_BEGIN -namespace location { namespace nearby { namespace connections { @@ -213,6 +212,5 @@ } // namespace connections } // namespace nearby -} // namespace location NS_ASSUME_NONNULL_END diff --git a/connections/clients/ios/Internal/GNCUtils.h b/connections/clients/ios/Internal/GNCUtils.h index a7f77de4f0..1082b579d5 100644 --- a/connections/clients/ios/Internal/GNCUtils.h +++ b/connections/clients/ios/Internal/GNCUtils.h @@ -24,7 +24,6 @@ NS_ASSUME_NONNULL_BEGIN -namespace location { namespace nearby { namespace connections { @@ -33,7 +32,6 @@ const Strategy& GNCStrategyToStrategy(GNCStrategy strategy); } // namespace connections } // namespace nearby -} // namespace location /** Internal-only properties of the connection result handlers class. */ @interface GNCConnectionResultHandlers () diff --git a/connections/clients/ios/Internal/GNCUtils.mm b/connections/clients/ios/Internal/GNCUtils.mm index 15f39724d1..eea51eadb0 100644 --- a/connections/clients/ios/Internal/GNCUtils.mm +++ b/connections/clients/ios/Internal/GNCUtils.mm @@ -20,7 +20,6 @@ NS_ASSUME_NONNULL_BEGIN -namespace location { namespace nearby { namespace connections { @@ -37,7 +36,6 @@ } // namespace connections } // namespace nearby -} // namespace location @implementation GNCConnectionHandlers diff --git a/connections/clients/swift/NearbyCoreAdapter/Sources/CPPInputStreamBinding.h b/connections/clients/swift/NearbyCoreAdapter/Sources/CPPInputStreamBinding.h index 92554d6719..06aac0d9ea 100644 --- a/connections/clients/swift/NearbyCoreAdapter/Sources/CPPInputStreamBinding.h +++ b/connections/clients/swift/NearbyCoreAdapter/Sources/CPPInputStreamBinding.h @@ -15,11 +15,11 @@ #import #ifdef __cplusplus -namespace location { + namespace nearby { class InputStream; } -} // namespace location + #endif @interface CPPInputStreamBinding : NSObject @@ -44,7 +44,7 @@ class InputStream; * * @param stream The stream that has a c++ pointer associated with it. */ -+ (location::nearby::InputStream &)getRefFromStream:(NSInputStream *)stream; ++ (nearby::InputStream &)getRefFromStream:(NSInputStream *)stream; #endif @end diff --git a/connections/clients/swift/NearbyCoreAdapter/Sources/CPPInputStreamBinding.mm b/connections/clients/swift/NearbyCoreAdapter/Sources/CPPInputStreamBinding.mm index d62cb47697..1469442c72 100644 --- a/connections/clients/swift/NearbyCoreAdapter/Sources/CPPInputStreamBinding.mm +++ b/connections/clients/swift/NearbyCoreAdapter/Sources/CPPInputStreamBinding.mm @@ -23,10 +23,10 @@ // TODO(b/239758418): Change this to the non-internal version when available. #include "internal/platform/input_stream.h" -using ::location::nearby::ByteArray; -using ::location::nearby::Exception; -using ::location::nearby::ExceptionOr; -using ::location::nearby::InputStream; +using ::nearby::ByteArray; +using ::nearby::Exception; +using ::nearby::ExceptionOr; +using ::nearby::InputStream; class CPPInputStream : public InputStream { public: diff --git a/connections/clients/swift/NearbyCoreAdapter/Sources/GNCAdvertisingOptions+CppConversions.h b/connections/clients/swift/NearbyCoreAdapter/Sources/GNCAdvertisingOptions+CppConversions.h index 00f61348ee..f97c840507 100644 --- a/connections/clients/swift/NearbyCoreAdapter/Sources/GNCAdvertisingOptions+CppConversions.h +++ b/connections/clients/swift/NearbyCoreAdapter/Sources/GNCAdvertisingOptions+CppConversions.h @@ -17,19 +17,19 @@ #import "connections/clients/swift/NearbyCoreAdapter/Sources/Public/NearbyCoreAdapter/GNCAdvertisingOptions.h" #ifdef __cplusplus -namespace location { + namespace nearby { namespace connections { class AdvertisingOptions; } } // namespace nearby -} // namespace location + #endif @interface GNCAdvertisingOptions (CppConversions) #ifdef __cplusplus -- (location::nearby::connections::AdvertisingOptions)toCpp; +- (nearby::connections::AdvertisingOptions)toCpp; #endif @end diff --git a/connections/clients/swift/NearbyCoreAdapter/Sources/GNCAdvertisingOptions+CppConversions.mm b/connections/clients/swift/NearbyCoreAdapter/Sources/GNCAdvertisingOptions+CppConversions.mm index bca0529a0f..60182f262d 100644 --- a/connections/clients/swift/NearbyCoreAdapter/Sources/GNCAdvertisingOptions+CppConversions.mm +++ b/connections/clients/swift/NearbyCoreAdapter/Sources/GNCAdvertisingOptions+CppConversions.mm @@ -21,8 +21,8 @@ #import "connections/clients/swift/NearbyCoreAdapter/Sources/GNCAdvertisingOptions+CppConversions.h" #import "connections/clients/swift/NearbyCoreAdapter/Sources/GNCStrategy+Internal.h" -using ::location::nearby::connections::AdvertisingOptions; -using ::location::nearby::connections::CppStrategyFromGNCStrategy; +using ::nearby::connections::AdvertisingOptions; +using ::nearby::connections::CppStrategyFromGNCStrategy; @implementation GNCAdvertisingOptions (CppConversions) diff --git a/connections/clients/swift/NearbyCoreAdapter/Sources/GNCConnectionOptions+CppConversions.h b/connections/clients/swift/NearbyCoreAdapter/Sources/GNCConnectionOptions+CppConversions.h index 4689e531ac..6a471661f4 100644 --- a/connections/clients/swift/NearbyCoreAdapter/Sources/GNCConnectionOptions+CppConversions.h +++ b/connections/clients/swift/NearbyCoreAdapter/Sources/GNCConnectionOptions+CppConversions.h @@ -17,19 +17,19 @@ #import "connections/clients/swift/NearbyCoreAdapter/Sources/Public/NearbyCoreAdapter/GNCConnectionOptions.h" #ifdef __cplusplus -namespace location { + namespace nearby { namespace connections { class ConnectionOptions; } } // namespace nearby -} // namespace location + #endif @interface GNCConnectionOptions (CppConversions) #ifdef __cplusplus -- (location::nearby::connections::ConnectionOptions)toCpp; +- (nearby::connections::ConnectionOptions)toCpp; #endif @end diff --git a/connections/clients/swift/NearbyCoreAdapter/Sources/GNCConnectionOptions+CppConversions.mm b/connections/clients/swift/NearbyCoreAdapter/Sources/GNCConnectionOptions+CppConversions.mm index 3d21d23c54..122c2f39fc 100644 --- a/connections/clients/swift/NearbyCoreAdapter/Sources/GNCConnectionOptions+CppConversions.mm +++ b/connections/clients/swift/NearbyCoreAdapter/Sources/GNCConnectionOptions+CppConversions.mm @@ -20,7 +20,7 @@ #import "connections/clients/swift/NearbyCoreAdapter/Sources/GNCConnectionOptions+CppConversions.h" -using ::location::nearby::connections::ConnectionOptions; +using ::nearby::connections::ConnectionOptions; @implementation GNCConnectionOptions (CppConversions) diff --git a/connections/clients/swift/NearbyCoreAdapter/Sources/GNCCoreAdapter.mm b/connections/clients/swift/NearbyCoreAdapter/Sources/GNCCoreAdapter.mm index bf39c99645..24345ab603 100644 --- a/connections/clients/swift/NearbyCoreAdapter/Sources/GNCCoreAdapter.mm +++ b/connections/clients/swift/NearbyCoreAdapter/Sources/GNCCoreAdapter.mm @@ -37,21 +37,21 @@ #import "connections/clients/swift/NearbyCoreAdapter/Sources/Public/NearbyCoreAdapter/GNCPayload.h" #import "connections/clients/swift/NearbyCoreAdapter/Sources/Public/NearbyCoreAdapter/GNCPayloadDelegate.h" -using ::location::nearby::ByteArray; -using ::location::nearby::connections::AdvertisingOptions; -using ::location::nearby::connections::ConnectionListener; -using ::location::nearby::connections::ConnectionOptions; -using ::location::nearby::connections::ConnectionRequestInfo; -using ::location::nearby::connections::ConnectionResponseInfo; -using ::location::nearby::connections::Core; -using ::location::nearby::connections::DiscoveryListener; -using ::location::nearby::connections::DiscoveryOptions; -using ::location::nearby::connections::Payload; -using ::location::nearby::connections::PayloadListener; -using ::location::nearby::connections::PayloadProgressInfo; -using ResultListener = ::location::nearby::connections::ResultCallback; -using ::location::nearby::connections::ServiceControllerRouter; -using ::location::nearby::connections::Status; +using ::nearby::ByteArray; +using ::nearby::connections::AdvertisingOptions; +using ::nearby::connections::ConnectionListener; +using ::nearby::connections::ConnectionOptions; +using ::nearby::connections::ConnectionRequestInfo; +using ::nearby::connections::ConnectionResponseInfo; +using ::nearby::connections::Core; +using ::nearby::connections::DiscoveryListener; +using ::nearby::connections::DiscoveryOptions; +using ::nearby::connections::Payload; +using ::nearby::connections::PayloadListener; +using ::nearby::connections::PayloadProgressInfo; +using ResultListener = ::nearby::connections::ResultCallback; +using ::nearby::connections::ServiceControllerRouter; +using ::nearby::connections::Status; GNCStatus GNCStatusFromCppStatus(Status status) { switch (status.value) { diff --git a/connections/clients/swift/NearbyCoreAdapter/Sources/GNCDiscoveryOptions+CppConversions.h b/connections/clients/swift/NearbyCoreAdapter/Sources/GNCDiscoveryOptions+CppConversions.h index 185c347f1f..d2631751f5 100644 --- a/connections/clients/swift/NearbyCoreAdapter/Sources/GNCDiscoveryOptions+CppConversions.h +++ b/connections/clients/swift/NearbyCoreAdapter/Sources/GNCDiscoveryOptions+CppConversions.h @@ -17,19 +17,19 @@ #import "connections/clients/swift/NearbyCoreAdapter/Sources/Public/NearbyCoreAdapter/GNCDiscoveryOptions.h" #ifdef __cplusplus -namespace location { + namespace nearby { namespace connections { class DiscoveryOptions; } } // namespace nearby -} // namespace location + #endif @interface GNCDiscoveryOptions (CppConversions) #ifdef __cplusplus -- (location::nearby::connections::DiscoveryOptions)toCpp; +- (nearby::connections::DiscoveryOptions)toCpp; #endif @end diff --git a/connections/clients/swift/NearbyCoreAdapter/Sources/GNCDiscoveryOptions+CppConversions.mm b/connections/clients/swift/NearbyCoreAdapter/Sources/GNCDiscoveryOptions+CppConversions.mm index 4ac7f6b264..d11c971d1f 100644 --- a/connections/clients/swift/NearbyCoreAdapter/Sources/GNCDiscoveryOptions+CppConversions.mm +++ b/connections/clients/swift/NearbyCoreAdapter/Sources/GNCDiscoveryOptions+CppConversions.mm @@ -21,8 +21,8 @@ #import "connections/clients/swift/NearbyCoreAdapter/Sources/GNCDiscoveryOptions+CppConversions.h" #import "connections/clients/swift/NearbyCoreAdapter/Sources/GNCStrategy+Internal.h" -using ::location::nearby::connections::CppStrategyFromGNCStrategy; -using ::location::nearby::connections::DiscoveryOptions; +using ::nearby::connections::CppStrategyFromGNCStrategy; +using ::nearby::connections::DiscoveryOptions; @implementation GNCDiscoveryOptions (CppConversions) diff --git a/connections/clients/swift/NearbyCoreAdapter/Sources/GNCError+Internal.h b/connections/clients/swift/NearbyCoreAdapter/Sources/GNCError+Internal.h index 3e86b216d1..dd2b3a8647 100644 --- a/connections/clients/swift/NearbyCoreAdapter/Sources/GNCError+Internal.h +++ b/connections/clients/swift/NearbyCoreAdapter/Sources/GNCError+Internal.h @@ -15,12 +15,12 @@ #import #ifdef __cplusplus -namespace location { + namespace nearby { namespace connections { class Status; NSError *NSErrorFromCppStatus(Status status); } // namespace connections } // namespace nearby -} // namespace location + #endif diff --git a/connections/clients/swift/NearbyCoreAdapter/Sources/GNCError.mm b/connections/clients/swift/NearbyCoreAdapter/Sources/GNCError.mm index c23cf8295a..f674c194eb 100644 --- a/connections/clients/swift/NearbyCoreAdapter/Sources/GNCError.mm +++ b/connections/clients/swift/NearbyCoreAdapter/Sources/GNCError.mm @@ -22,7 +22,6 @@ extern NSErrorDomain const GNCErrorDomain = @"com.google.nearby.connections.error"; -namespace location { namespace nearby { namespace connections { @@ -69,4 +68,3 @@ } // namespace connections } // namespace nearby -} // namespace location \ No newline at end of file diff --git a/connections/clients/swift/NearbyCoreAdapter/Sources/GNCException+Internal.h b/connections/clients/swift/NearbyCoreAdapter/Sources/GNCException+Internal.h index 8e5b019cea..80f0b8c290 100644 --- a/connections/clients/swift/NearbyCoreAdapter/Sources/GNCException+Internal.h +++ b/connections/clients/swift/NearbyCoreAdapter/Sources/GNCException+Internal.h @@ -15,12 +15,12 @@ #import #ifdef __cplusplus -namespace location { + namespace nearby { class Exception; namespace connections { NSError *NSErrorFromCppException(Exception exception); } // namespace connections } // namespace nearby -} // namespace location + #endif diff --git a/connections/clients/swift/NearbyCoreAdapter/Sources/GNCException.mm b/connections/clients/swift/NearbyCoreAdapter/Sources/GNCException.mm index 77c5647e91..4f730f6832 100644 --- a/connections/clients/swift/NearbyCoreAdapter/Sources/GNCException.mm +++ b/connections/clients/swift/NearbyCoreAdapter/Sources/GNCException.mm @@ -23,7 +23,6 @@ extern NSErrorDomain const GNCExceptionDomain = @"com.google.nearby.connections.exception"; -namespace location { namespace nearby { namespace connections { @@ -54,4 +53,3 @@ } // namespace connections } // namespace nearby -} // namespace location \ No newline at end of file diff --git a/connections/clients/swift/NearbyCoreAdapter/Sources/GNCInputStream.h b/connections/clients/swift/NearbyCoreAdapter/Sources/GNCInputStream.h index e8dbbead5d..bdd698e12f 100644 --- a/connections/clients/swift/NearbyCoreAdapter/Sources/GNCInputStream.h +++ b/connections/clients/swift/NearbyCoreAdapter/Sources/GNCInputStream.h @@ -15,11 +15,11 @@ #import #ifdef __cplusplus -namespace location { + namespace nearby { class InputStream; } -} // namespace location + #endif @interface GNCInputStream : NSInputStream @@ -29,7 +29,7 @@ class InputStream; - (nonnull instancetype)initWithURL:(nonnull NSURL *)url NS_UNAVAILABLE; #ifdef __cplusplus -- (nonnull instancetype)initWithCppInputStream:(nonnull location::nearby::InputStream *)stream +- (nonnull instancetype)initWithCppInputStream:(nonnull nearby::InputStream *)stream NS_DESIGNATED_INITIALIZER; #endif diff --git a/connections/clients/swift/NearbyCoreAdapter/Sources/GNCInputStream.mm b/connections/clients/swift/NearbyCoreAdapter/Sources/GNCInputStream.mm index f4e76cad8c..7713c0f787 100644 --- a/connections/clients/swift/NearbyCoreAdapter/Sources/GNCInputStream.mm +++ b/connections/clients/swift/NearbyCoreAdapter/Sources/GNCInputStream.mm @@ -24,10 +24,10 @@ #import "connections/clients/swift/NearbyCoreAdapter/Sources/GNCException+Internal.h" #import "connections/clients/swift/NearbyCoreAdapter/Sources/Public/NearbyCoreAdapter/GNCException.h" -using ::location::nearby::ByteArray; -using ::location::nearby::ExceptionOr; -using ::location::nearby::InputStream; -using ::location::nearby::connections::NSErrorFromCppException; +using ::nearby::ByteArray; +using ::nearby::ExceptionOr; +using ::nearby::InputStream; +using ::nearby::connections::NSErrorFromCppException; @implementation GNCInputStream { NSStreamStatus _streamStatus; diff --git a/connections/clients/swift/NearbyCoreAdapter/Sources/GNCPayload+CppConversions.h b/connections/clients/swift/NearbyCoreAdapter/Sources/GNCPayload+CppConversions.h index f1dd951f28..aeb0765374 100644 --- a/connections/clients/swift/NearbyCoreAdapter/Sources/GNCPayload+CppConversions.h +++ b/connections/clients/swift/NearbyCoreAdapter/Sources/GNCPayload+CppConversions.h @@ -17,23 +17,23 @@ #import "connections/clients/swift/NearbyCoreAdapter/Sources/Public/NearbyCoreAdapter/GNCPayload.h" #ifdef __cplusplus -namespace location { + namespace nearby { namespace connections { class Payload; } } // namespace nearby -} // namespace location + #endif @interface GNCPayload (CppConversions) #ifdef __cplusplus -+ (nonnull GNCPayload *)fromCpp:(location::nearby::connections::Payload)payload; ++ (nonnull GNCPayload *)fromCpp:(nearby::connections::Payload)payload; #endif #ifdef __cplusplus -- (location::nearby::connections::Payload)toCpp; +- (nearby::connections::Payload)toCpp; #endif @end diff --git a/connections/clients/swift/NearbyCoreAdapter/Sources/GNCPayload+CppConversions.mm b/connections/clients/swift/NearbyCoreAdapter/Sources/GNCPayload+CppConversions.mm index d92dad8d9a..98dbcba8c2 100644 --- a/connections/clients/swift/NearbyCoreAdapter/Sources/GNCPayload+CppConversions.mm +++ b/connections/clients/swift/NearbyCoreAdapter/Sources/GNCPayload+CppConversions.mm @@ -24,22 +24,22 @@ #import "connections/clients/swift/NearbyCoreAdapter/Sources/GNCInputStream.h" #import "connections/clients/swift/NearbyCoreAdapter/Sources/GNCPayload+CppConversions.h" -using ::location::nearby::ByteArray; -using ::location::nearby::InputFile; -using ::location::nearby::InputStream; -using ::location::nearby::connections::Payload; +using ::nearby::ByteArray; +using ::nearby::InputFile; +using ::nearby::InputStream; +using ::nearby::connections::Payload; @implementation GNCPayload (CppConversions) + (GNCPayload *)fromCpp:(Payload)payload { int64_t payloadId = payload.GetId(); switch (payload.GetType()) { - case location::nearby::connections::PayloadType::kBytes: { + case nearby::connections::PayloadType::kBytes: { ByteArray bytes = payload.AsBytes(); NSData *payloadData = [NSData dataWithBytes:bytes.data() length:bytes.size()]; return [[GNCBytesPayload alloc] initWithData:payloadData identifier:payloadId]; } - case location::nearby::connections::PayloadType::kFile: { + case nearby::connections::PayloadType::kFile: { InputFile *inputFile = payload.AsFile(); NSString *filePath = @(inputFile->GetFilePath().c_str()); NSString *parentFolder = @(payload.GetParentFolder().c_str()); @@ -50,11 +50,11 @@ + (GNCPayload *)fromCpp:(Payload)payload { fileName:fileName identifier:payloadId]; } - case location::nearby::connections::PayloadType::kStream: { + case nearby::connections::PayloadType::kStream: { GNCInputStream *stream = [[GNCInputStream alloc] initWithCppInputStream:payload.AsStream()]; return [[GNCStreamPayload alloc] initWithStream:stream identifier:payloadId]; } - case location::nearby::connections::PayloadType::kUnknown: + case nearby::connections::PayloadType::kUnknown: return nil; } } diff --git a/connections/clients/swift/NearbyCoreAdapter/Sources/GNCPayload.mm b/connections/clients/swift/NearbyCoreAdapter/Sources/GNCPayload.mm index 1f894783fe..6bb12ab224 100644 --- a/connections/clients/swift/NearbyCoreAdapter/Sources/GNCPayload.mm +++ b/connections/clients/swift/NearbyCoreAdapter/Sources/GNCPayload.mm @@ -22,7 +22,7 @@ #import "connections/clients/swift/NearbyCoreAdapter/Sources/CPPInputStreamBinding.h" -using ::location::nearby::connections::Payload; +using ::nearby::connections::Payload; @implementation GNCPayload diff --git a/connections/clients/swift/NearbyCoreAdapter/Sources/GNCStrategy+Internal.h b/connections/clients/swift/NearbyCoreAdapter/Sources/GNCStrategy+Internal.h index e2b33d9649..57d9a556bd 100644 --- a/connections/clients/swift/NearbyCoreAdapter/Sources/GNCStrategy+Internal.h +++ b/connections/clients/swift/NearbyCoreAdapter/Sources/GNCStrategy+Internal.h @@ -17,12 +17,12 @@ typedef NS_ENUM(NSInteger, GNCStrategy); #ifdef __cplusplus -namespace location { + namespace nearby { namespace connections { class Strategy; Strategy CppStrategyFromGNCStrategy(GNCStrategy strategy); } // namespace connections } // namespace nearby -} // namespace location + #endif diff --git a/connections/clients/swift/NearbyCoreAdapter/Sources/GNCStrategy.mm b/connections/clients/swift/NearbyCoreAdapter/Sources/GNCStrategy.mm index 29e02404bc..8caa0cc773 100644 --- a/connections/clients/swift/NearbyCoreAdapter/Sources/GNCStrategy.mm +++ b/connections/clients/swift/NearbyCoreAdapter/Sources/GNCStrategy.mm @@ -20,7 +20,6 @@ #import "connections/clients/swift/NearbyCoreAdapter/Sources/GNCStrategy+Internal.h" -namespace location { namespace nearby { namespace connections { @@ -37,4 +36,3 @@ Strategy CppStrategyFromGNCStrategy(GNCStrategy strategy) { } // namespace connections } // namespace nearby -} // namespace location \ No newline at end of file diff --git a/connections/clients/windows/advertising_options_w.cc b/connections/clients/windows/advertising_options_w.cc index 0d0e68d99e..ecbdb78c1d 100644 --- a/connections/clients/windows/advertising_options_w.cc +++ b/connections/clients/windows/advertising_options_w.cc @@ -16,7 +16,7 @@ #include -namespace location::nearby::windows { +namespace nearby::windows { // Returns a copy and normalizes allowed mediums: // (1) If is_out_of_band_connection is true, verifies that there is only one @@ -45,4 +45,4 @@ AdvertisingOptionsW AdvertisingOptionsW::CompatibleOptions() const { return result; } -} // namespace location::nearby::windows +} // namespace nearby::windows diff --git a/connections/clients/windows/advertising_options_w.h b/connections/clients/windows/advertising_options_w.h index 446656c4e5..feff812d36 100644 --- a/connections/clients/windows/advertising_options_w.h +++ b/connections/clients/windows/advertising_options_w.h @@ -16,7 +16,7 @@ #include "connections/clients/windows/options_base_w.h" -namespace location::nearby::windows { +namespace nearby::windows { extern "C" { @@ -44,6 +44,6 @@ struct DLL_API AdvertisingOptionsW : public OptionsBaseW { }; } // extern "C" -} // namespace location::nearby::windows +} // namespace nearby::windows #endif // THIRD_PARTY_NEARBY_CONNECTIONS_CLIENTS_WINDOWS_ADVERTISING_OPTIONS_W_H_ diff --git a/connections/clients/windows/bluetooth_classic_server_socket_test.cc b/connections/clients/windows/bluetooth_classic_server_socket_test.cc index 7e7b358039..10cb1051f8 100644 --- a/connections/clients/windows/bluetooth_classic_server_socket_test.cc +++ b/connections/clients/windows/bluetooth_classic_server_socket_test.cc @@ -1,612 +1,612 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include - -#include -#include - -#include "gtest/gtest.h" -#include "absl/synchronization/notification.h" -#include "connections/advertising_options.h" -#include "connections/core.h" -#include "connections/implementation/service_controller_router.h" -#include "connections/listeners.h" -#include "connections/status.h" -#include "connections/strategy.h" -#include "internal/platform/byte_array.h" -#include "internal/platform/count_down_latch.h" - -namespace location::nearby::windows { - -using ::location::nearby::ByteArray; -using ::location::nearby::connections::AdvertisingOptions; -using ::location::nearby::connections::ConnectionListener; -using ::location::nearby::connections::ConnectionRequestInfo; -using ::location::nearby::connections::Core; -using ::location::nearby::connections::ServiceControllerRouter; -using ::location::nearby::connections::Status; -using ::location::nearby::connections::Strategy; - -constexpr absl::string_view SERVICE_ID = - "com.google.location.nearby.apps.helloconnections"; - -constexpr int TimeoutSeconds = 3; -constexpr int LoopCount = 10; -constexpr absl::string_view device_name = "12345678901"; - -AdvertisingOptions AdvertiseOptions{ - { - // Strategy - { - Strategy::kP2pPointToPoint, - }, - // Allowed: - { - true, // bluetooth - true, // ble - true, // webrtc - true, // wifi_lan - true, // wifi_hotspot - }, - }, - true, // auto_upgrade_bandwidth - true, // enforce_topology_constraints - false, // low_power - false, // enable_bluetooth_listening - false, // enable_webrtc_listening - false, // is_out_of_band_connection - "", // fast_advertisement_service_uuid -}; - -class PerformanceTimer { - public: - static void start() { - QueryPerformanceFrequency(&frequency_); - QueryPerformanceCounter(&starting_time_); - } - static void stop() { - QueryPerformanceCounter(&ending_time_); - elapsed_microseconds_.QuadPart = - ending_time_.QuadPart - starting_time_.QuadPart; - elapsed_milliseconds_ = elapsed_microseconds_.QuadPart / 100; - } - - static uint64_t ElapsedMilliseconds() { return elapsed_milliseconds_; } - - private: - static uint64_t elapsed_milliseconds_; - static LARGE_INTEGER starting_time_; - static LARGE_INTEGER ending_time_; - static LARGE_INTEGER elapsed_microseconds_; - static LARGE_INTEGER frequency_; -}; - -uint64_t PerformanceTimer::elapsed_milliseconds_; -LARGE_INTEGER PerformanceTimer::starting_time_; -LARGE_INTEGER PerformanceTimer::ending_time_; -LARGE_INTEGER PerformanceTimer::elapsed_microseconds_; -LARGE_INTEGER PerformanceTimer::frequency_; - -TEST(BluetoothClassicServerSocketTest, - DISABLED_SingleRunWithTimeoutReproStuck) { - ServiceControllerRouter router; - Core core(&router); - - ConnectionListener listener; - - ConnectionRequestInfo request_info; - - request_info.endpoint_info = ByteArray(std::string(device_name)); - request_info.listener = listener; - - Status request_result; - absl::Notification notification; - - PerformanceTimer::start(); - - core.StartAdvertising(SERVICE_ID, AdvertiseOptions, request_info, - {.result_cb = [&](Status status) { - request_result = status; - notification.Notify(); - }}); - - if (notification.WaitForNotificationWithTimeout( - absl::Seconds(TimeoutSeconds))) { - PerformanceTimer::stop(); - - NEARBY_LOGS(INFO) << "SingleRunWithTimeoutReproStuck Line: " << __LINE__ - << " Started advertising elapsed time: " - << std::to_string( - PerformanceTimer::ElapsedMilliseconds()); - -#ifdef TEST_OUTPUT - EXPECT_TRUE(false) << "Started advertising elapsed time: " - << std::to_string(ElapsedMilliseconds); -#endif - - std::cout << "StartAdvertising started once:" << request_result.ToString() - << std::endl; - NEARBY_LOGS(INFO) << "StartAdvertising started once:" - << request_result.ToString(); - } else { - PerformanceTimer::stop(); - - NEARBY_LOGS(INFO) << "SingleRunWithTimeoutReproStuck Line: " << __LINE__ - << " Timeout on starting advertising elapsed time: " - << std::to_string( - PerformanceTimer::ElapsedMilliseconds()); - - EXPECT_TRUE(false) << "Timeout on starting advertising elapsed time: " - << std::to_string( - PerformanceTimer::ElapsedMilliseconds()); - - std::cout << "StartAdvertising failed to start once:" - << request_result.ToString() << std::endl; - NEARBY_LOGS(INFO) << "StartAdvertising failed to start once:" - << request_result.ToString(); - } - - absl::Notification notification2; - - PerformanceTimer::start(); - - core.StartAdvertising(SERVICE_ID, AdvertiseOptions, request_info, - {.result_cb = [&](Status status) { - request_result = status; - notification2.Notify(); - }}); - - if (notification2.WaitForNotificationWithTimeout( - absl::Seconds(TimeoutSeconds))) { - PerformanceTimer::stop(); - - NEARBY_LOGS(INFO) << "SingleRunWithTimeoutReproStuck Line: " << __LINE__ - << " Started advertising second time elapsed time: " - << std::to_string( - PerformanceTimer::ElapsedMilliseconds()); - -#ifdef TEST_OUTPUT - EXPECT_TRUE(false) << "Started advertising elapsed time: " - << std::to_string(ElapsedMilliseconds); -#endif - - std::cout << "StartAdvertising started twice:" << request_result.ToString() - << std::endl; - NEARBY_LOGS(INFO) << "StartAdvertising started twice:" - << request_result.ToString(); - } else { - PerformanceTimer::stop(); - - NEARBY_LOGS(INFO) - << "SingleRunWithTimeoutReproStuck Line: " << __LINE__ - << " Timeout on starting advertising the second time elapsed time: " - << std::to_string(PerformanceTimer::ElapsedMilliseconds()); - - EXPECT_TRUE(false) << "SingleRunWithTimeoutReproStuck Line: " << __LINE__ - << " Timeout for started advertising elapsed time: " - << std::to_string( - PerformanceTimer::ElapsedMilliseconds()); - - std::cout << "StartAdvertising failed to start twice:" - << request_result.ToString() << std::endl; - NEARBY_LOGS(INFO) << "StartAdvertising failed to start twice:" - << request_result.ToString(); - } - - absl::Notification notification3; - - PerformanceTimer::start(); - - core.StopAdvertising({.result_cb = [&](Status status) { - request_result = status; - notification3.Notify(); - }}); - - if (notification3.WaitForNotificationWithTimeout( - absl::Seconds(TimeoutSeconds))) { - PerformanceTimer::stop(); - - NEARBY_LOGS(INFO) << "SingleRunWithTimeoutReproStuck Line: " << __LINE__ - << " Stopped advertising first time elapsed time: " - << std::to_string( - PerformanceTimer::ElapsedMilliseconds()); - -#ifdef TEST_OUTPUT - EXPECT_TRUE(false) << "Started advertising elapsed time: " - << std::to_string(elapsed_microseconds); -#endif - - std::cout << "StopAdvertising called once:" << request_result.ToString() - << std::endl; - NEARBY_LOGS(INFO) << "StopAdvertising called once:" - << request_result.ToString(); - } else { - PerformanceTimer::stop(); - - NEARBY_LOGS(INFO) - << "SingleRunWithTimeoutReproStuck Line: " << __LINE__ - << " Timeout on stopping advertising the first time elapsed time: " - << std::to_string(PerformanceTimer::ElapsedMilliseconds()); - - EXPECT_TRUE(false) << "SingleRunWithTimeoutReproStuck Line: " << __LINE__ - << " Timeout on stop advertising elapsed time: " - << std::to_string( - PerformanceTimer::ElapsedMilliseconds()); - - std::cout << "StopAdvertising failed to stop once:" - << request_result.ToString() << std::endl; - NEARBY_LOGS(INFO) << "StopAdvertising failed to stop once:" - << request_result.ToString(); - } - - std::cout << "Test completed." << std::endl; - NEARBY_LOGS(INFO) << "Test completed."; -} - -TEST(BluetoothClassicServerSocketTest, DISABLED_MultiRunWithTimeoutReproStuck) { - ServiceControllerRouter router; - Core core(&router); - - ConnectionListener listener; - - ConnectionRequestInfo request_info; - - request_info.endpoint_info = ByteArray(std::string(device_name)); - request_info.listener = listener; - - for (int loop_count = 0; loop_count < LoopCount; ++loop_count) { - Status request_result; - absl::Notification notification; - - PerformanceTimer::start(); - - core.StartAdvertising(SERVICE_ID, AdvertiseOptions, request_info, - {.result_cb = [&](Status status) { - request_result = status; - notification.Notify(); - }}); - - if (notification.WaitForNotificationWithTimeout( - absl::Seconds(TimeoutSeconds))) { - PerformanceTimer::stop(); - - NEARBY_LOGS(INFO) << "SingleRunWithTimeoutReproStuck Line: " << __LINE__ - << " Started advertising elapsed time: " - << std::to_string( - PerformanceTimer::ElapsedMilliseconds()); - -#ifdef TEST_OUTPUT - EXPECT_TRUE(false) << "Started advertising elapsed time : " - << std::to_string(ElapsedMilliseconds); -#endif - - std::cout << "StartAdvertising started once:" << request_result.ToString() - << std::endl; - NEARBY_LOGS(INFO) << "StartAdvertising started once:" - << request_result.ToString(); - } else { - PerformanceTimer::stop(); - - NEARBY_LOGS(INFO) << "SingleRunWithTimeoutReproStuck Line: " << __LINE__ - << " Timeout on starting advertising elapsed time: " - << std::to_string( - PerformanceTimer::ElapsedMilliseconds()); - - EXPECT_TRUE(false) << "Timeout on starting advertising elapsed time: " - << std::to_string( - PerformanceTimer::ElapsedMilliseconds()); - - std::cout << "StartAdvertising failed to start once:" - << request_result.ToString() << std::endl; - NEARBY_LOGS(INFO) << "StartAdvertising failed to start once:" - << request_result.ToString(); - } - - absl::Notification notification2; - - PerformanceTimer::start(); - - core.StartAdvertising(SERVICE_ID, AdvertiseOptions, request_info, - {.result_cb = [&](Status status) { - request_result = status; - notification2.Notify(); - }}); - - if (notification2.WaitForNotificationWithTimeout( - absl::Seconds(TimeoutSeconds))) { - PerformanceTimer::stop(); - - NEARBY_LOGS(INFO) << "SingleRunWithTimeoutReproStuck Line: " << __LINE__ - << " Started advertising second time elapsed time: " - << std::to_string( - PerformanceTimer::ElapsedMilliseconds()); - // EXPECT_TRUE(false) - // << "Started advertising elapsed time: " - // << std::to_string(ElapsedMilliseconds); - std::cout << "StartAdvertising started twice:" - << request_result.ToString() << std::endl; - NEARBY_LOGS(INFO) << "StartAdvertising started twice:" - << request_result.ToString(); - } else { - PerformanceTimer::stop(); - - NEARBY_LOGS(INFO) - << "SingleRunWithTimeoutReproStuck Line: " << __LINE__ - << " Timeout on starting advertising the second time elapsed time: " - << std::to_string(PerformanceTimer::ElapsedMilliseconds()); - - EXPECT_TRUE(false) - << "Timeout on starting advertising the second time elapsed time: " - << std::to_string(PerformanceTimer::ElapsedMilliseconds()); - - std::cout << "StartAdvertising failed to start twice:" - << request_result.ToString() << std::endl; - NEARBY_LOGS(INFO) << "StartAdvertising failed to start twice:" - << request_result.ToString(); - } - - absl::Notification notification3; - - PerformanceTimer::start(); - - core.StopAdvertising({.result_cb = [&](Status status) { - request_result = status; - notification3.Notify(); - }}); - - if (notification3.WaitForNotificationWithTimeout( - absl::Seconds(TimeoutSeconds))) { - PerformanceTimer::stop(); - - NEARBY_LOGS(INFO) << "SingleRunWithTimeoutReproStuck Line: " << __LINE__ - << " Stopped advertising first time elapsed time: " - << std::to_string( - PerformanceTimer::ElapsedMilliseconds()); - -#ifdef TEST_OUTPUT - EXPECT_TRUE(false) << "Started advertising elapsed time: " - << std::to_string(ElapsedMilliseconds); -#endif - - std::cout << "StopAdvertising called once:" << request_result.ToString() - << std::endl; - NEARBY_LOGS(INFO) << "StopAdvertising called once:" - << request_result.ToString(); - } else { - PerformanceTimer::stop(); - - NEARBY_LOGS(INFO) - << "SingleRunWithTimeoutReproStuck Line: " << __LINE__ - << " Timeout on stopping advertising the first time elapsed time: " - << std::to_string(PerformanceTimer::ElapsedMilliseconds()); - - EXPECT_TRUE(false) << "Timeout on started advertising elapsed time: " - << std::to_string( - PerformanceTimer::ElapsedMilliseconds()); - - std::cout << "StopAdvertising failed to stop once:" - << request_result.ToString() << std::endl; - NEARBY_LOGS(INFO) << "StopAdvertising failed to stop once:" - << request_result.ToString(); - } - } - - std::cout << "Test completed." << std::endl; - NEARBY_LOGS(INFO) << "Test completed."; -} - -TEST(BluetoothClassicServerSocketTest, DISABLED_SingleRunNoTimeoutReproStuck) { - ServiceControllerRouter router; - Core core(&router); - - ConnectionListener listener; - - ConnectionRequestInfo request_info; - - request_info.endpoint_info = ByteArray(std::string(device_name)); - request_info.listener = listener; - - Status request_result; - absl::Notification notification; - - PerformanceTimer::start(); - - core.StartAdvertising(SERVICE_ID, AdvertiseOptions, request_info, - {.result_cb = [&](Status status) { - request_result = status; - notification.Notify(); - }}); - - notification.WaitForNotification(); - PerformanceTimer::stop(); - - NEARBY_LOGS(INFO) << "SingleRunNoTimeoutReproStuck Line: " << __LINE__ - << " Started advertising first time elapsed time: " - << std::to_string(PerformanceTimer::ElapsedMilliseconds()); - -#ifdef TEST_OUTPUT - EXPECT_TRUE(false) << "Started advertising first time elapsed time: " - << std::to_string(ElapsedMilliseconds); -#endif - - std::cout << "StartAdvertising started once:" << request_result.ToString() - << std::endl; - NEARBY_LOGS(INFO) << "StartAdvertising started once:" - << request_result.ToString(); - - absl::Notification notification2; - - PerformanceTimer::start(); - - core.StartAdvertising(SERVICE_ID, AdvertiseOptions, request_info, - {.result_cb = [&](Status status) { - request_result = status; - notification2.Notify(); - }}); - - notification2.WaitForNotification(); - PerformanceTimer::stop(); - - NEARBY_LOGS(INFO) << "SingleRunNoTimeoutReproStuck Line: " << __LINE__ - << " Started advertising first time elapsed time: " - << std::to_string(PerformanceTimer::ElapsedMilliseconds()); - -#ifdef TEST_OUTPUT - EXPECT_TRUE(false) << "Started advertising first time elapsed time: " - << std::to_string(ElapsedMilliseconds); -#endif - - std::cout << "StartAdvertising started twice:" << request_result.ToString() - << std::endl; - NEARBY_LOGS(INFO) << "StartAdvertising started twice:" - << request_result.ToString(); - - absl::Notification notification3; - - PerformanceTimer::start(); - - core.StopAdvertising({.result_cb = [&](Status status) { - request_result = status; - notification3.Notify(); - }}); - - notification3.WaitForNotification(); - PerformanceTimer::stop(); - - NEARBY_LOGS(INFO) << "SingleRunNoTimeoutReproStuck " << __LINE__ - << "Stopped advertising elapsed time: " - << std::to_string(PerformanceTimer::ElapsedMilliseconds()); - -#ifdef TEST_OUTPUT - EXPECT_TRUE(false) << "Stopped advertising elapsed time: " - << std::to_string(ElapsedMilliseconds); -#endif - - std::cout << "StopAdvertising called once:" << request_result.ToString() - << std::endl; - NEARBY_LOGS(INFO) << "StopAdvertising called once:" - << request_result.ToString(); - - std::cout << "Test completed." << std::endl; - NEARBY_LOGS(INFO) << "Test completed."; -} - -TEST(BluetoothClassicServerSocketTest, DISABLED_MultiRunNoTimeoutReproStuck) { - ServiceControllerRouter router; - Core core(&router); - - ConnectionListener listener; - - ConnectionRequestInfo request_info; - - request_info.endpoint_info = ByteArray(std::string(device_name)); - request_info.listener = listener; - - for (int loop_count = 0; loop_count < LoopCount; ++loop_count) { - Status request_result; - absl::Notification notification; - - PerformanceTimer::start(); - - core.StartAdvertising(SERVICE_ID, AdvertiseOptions, request_info, - {.result_cb = [&](Status status) { - request_result = status; - notification.Notify(); - }}); - - notification.WaitForNotification(); - - PerformanceTimer::stop(); - - NEARBY_LOGS(INFO) << "MultiRunNoTimeoutReproStuck " << __LINE__ - << "Started advertising elapsed time: " - << std::to_string( - PerformanceTimer::ElapsedMilliseconds()); - -#ifdef TEST_OUTPUT - EXPECT_TRUE(false) << "Started advertising elapsed time: " - << std::to_string(ElapsedMilliseconds); -#endif - - std::cout << "MultiRunNoTimeoutReproStuck " << __LINE__ - << " : StartAdvertising started once: " - << request_result.ToString() << std::endl; - NEARBY_LOGS(INFO) << "StartAdvertising started once:" - << request_result.ToString(); - - absl::Notification notification2; - - PerformanceTimer::start(); - - core.StartAdvertising(SERVICE_ID, AdvertiseOptions, request_info, - {.result_cb = [&](Status status) { - request_result = status; - notification2.Notify(); - }}); - - notification2.WaitForNotification(); - PerformanceTimer::stop(); - - NEARBY_LOGS(INFO) << "MultiRunNoTimeoutReproStuck " << __LINE__ - << "Started advertising elapsed time: " - << std::to_string( - PerformanceTimer::ElapsedMilliseconds()); - -#ifdef TEST_OUTPUT - EXPECT_TRUE(false) << "Started advertising elapsed time: " - << std::to_string(ElapsedMilliseconds); -#endif - - std::cout << "MultiRunNoTimeoutReproStuck " << __LINE__ - << "StartAdvertising started twice:" << request_result.ToString() - << std::endl; - NEARBY_LOGS(INFO) << "MultiRunNoTimeoutReproStuck " << __LINE__ - << "StartAdvertising started twice:" - << request_result.ToString(); - - absl::Notification notification3; - - PerformanceTimer::start(); - - core.StopAdvertising({.result_cb = [&](Status status) { - request_result = status; - notification3.Notify(); - }}); - - notification3.WaitForNotification(); - PerformanceTimer::stop(); - - NEARBY_LOGS(INFO) << "MultiRunNoTimeoutReproStuck " << __LINE__ - << "Stopped advertising elapsed time: " - << std::to_string( - PerformanceTimer::ElapsedMilliseconds()); - -#ifdef TEST_OUTPUT - EXPECT_TRUE(false) << "Stop advertising elapsed time: " - << std::to_string(ElapsedMilliseconds); -#endif - - std::cout << "StopAdvertising called once:" << request_result.ToString() - << std::endl; - NEARBY_LOGS(INFO) << "MultiRunNoTimeoutReproStuck " << __LINE__ - << "StopAdvertising called once:" - << request_result.ToString(); - } - - std::cout << "Test completed." << std::endl; - NEARBY_LOGS(INFO) << "Test completed."; -} - -} // namespace location::nearby::windows +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include + +#include +#include + +#include "gtest/gtest.h" +#include "absl/synchronization/notification.h" +#include "connections/advertising_options.h" +#include "connections/core.h" +#include "connections/implementation/service_controller_router.h" +#include "connections/listeners.h" +#include "connections/status.h" +#include "connections/strategy.h" +#include "internal/platform/byte_array.h" +#include "internal/platform/count_down_latch.h" + +namespace nearby::windows { + +using ::nearby::ByteArray; +using ::nearby::connections::AdvertisingOptions; +using ::nearby::connections::ConnectionListener; +using ::nearby::connections::ConnectionRequestInfo; +using ::nearby::connections::Core; +using ::nearby::connections::ServiceControllerRouter; +using ::nearby::connections::Status; +using ::nearby::connections::Strategy; + +constexpr absl::string_view SERVICE_ID = + "com.google.location.nearby.apps.helloconnections"; + +constexpr int TimeoutSeconds = 3; +constexpr int LoopCount = 10; +constexpr absl::string_view device_name = "12345678901"; + +AdvertisingOptions AdvertiseOptions{ + { + // Strategy + { + Strategy::kP2pPointToPoint, + }, + // Allowed: + { + true, // bluetooth + true, // ble + true, // webrtc + true, // wifi_lan + true, // wifi_hotspot + }, + }, + true, // auto_upgrade_bandwidth + true, // enforce_topology_constraints + false, // low_power + false, // enable_bluetooth_listening + false, // enable_webrtc_listening + false, // is_out_of_band_connection + "", // fast_advertisement_service_uuid +}; + +class PerformanceTimer { + public: + static void start() { + QueryPerformanceFrequency(&frequency_); + QueryPerformanceCounter(&starting_time_); + } + static void stop() { + QueryPerformanceCounter(&ending_time_); + elapsed_microseconds_.QuadPart = + ending_time_.QuadPart - starting_time_.QuadPart; + elapsed_milliseconds_ = elapsed_microseconds_.QuadPart / 100; + } + + static uint64_t ElapsedMilliseconds() { return elapsed_milliseconds_; } + + private: + static uint64_t elapsed_milliseconds_; + static LARGE_INTEGER starting_time_; + static LARGE_INTEGER ending_time_; + static LARGE_INTEGER elapsed_microseconds_; + static LARGE_INTEGER frequency_; +}; + +uint64_t PerformanceTimer::elapsed_milliseconds_; +LARGE_INTEGER PerformanceTimer::starting_time_; +LARGE_INTEGER PerformanceTimer::ending_time_; +LARGE_INTEGER PerformanceTimer::elapsed_microseconds_; +LARGE_INTEGER PerformanceTimer::frequency_; + +TEST(BluetoothClassicServerSocketTest, + DISABLED_SingleRunWithTimeoutReproStuck) { + ServiceControllerRouter router; + Core core(&router); + + ConnectionListener listener; + + ConnectionRequestInfo request_info; + + request_info.endpoint_info = ByteArray(std::string(device_name)); + request_info.listener = listener; + + Status request_result; + absl::Notification notification; + + PerformanceTimer::start(); + + core.StartAdvertising(SERVICE_ID, AdvertiseOptions, request_info, + {.result_cb = [&](Status status) { + request_result = status; + notification.Notify(); + }}); + + if (notification.WaitForNotificationWithTimeout( + absl::Seconds(TimeoutSeconds))) { + PerformanceTimer::stop(); + + NEARBY_LOGS(INFO) << "SingleRunWithTimeoutReproStuck Line: " << __LINE__ + << " Started advertising elapsed time: " + << std::to_string( + PerformanceTimer::ElapsedMilliseconds()); + +#ifdef TEST_OUTPUT + EXPECT_TRUE(false) << "Started advertising elapsed time: " + << std::to_string(ElapsedMilliseconds); +#endif + + std::cout << "StartAdvertising started once:" << request_result.ToString() + << std::endl; + NEARBY_LOGS(INFO) << "StartAdvertising started once:" + << request_result.ToString(); + } else { + PerformanceTimer::stop(); + + NEARBY_LOGS(INFO) << "SingleRunWithTimeoutReproStuck Line: " << __LINE__ + << " Timeout on starting advertising elapsed time: " + << std::to_string( + PerformanceTimer::ElapsedMilliseconds()); + + EXPECT_TRUE(false) << "Timeout on starting advertising elapsed time: " + << std::to_string( + PerformanceTimer::ElapsedMilliseconds()); + + std::cout << "StartAdvertising failed to start once:" + << request_result.ToString() << std::endl; + NEARBY_LOGS(INFO) << "StartAdvertising failed to start once:" + << request_result.ToString(); + } + + absl::Notification notification2; + + PerformanceTimer::start(); + + core.StartAdvertising(SERVICE_ID, AdvertiseOptions, request_info, + {.result_cb = [&](Status status) { + request_result = status; + notification2.Notify(); + }}); + + if (notification2.WaitForNotificationWithTimeout( + absl::Seconds(TimeoutSeconds))) { + PerformanceTimer::stop(); + + NEARBY_LOGS(INFO) << "SingleRunWithTimeoutReproStuck Line: " << __LINE__ + << " Started advertising second time elapsed time: " + << std::to_string( + PerformanceTimer::ElapsedMilliseconds()); + +#ifdef TEST_OUTPUT + EXPECT_TRUE(false) << "Started advertising elapsed time: " + << std::to_string(ElapsedMilliseconds); +#endif + + std::cout << "StartAdvertising started twice:" << request_result.ToString() + << std::endl; + NEARBY_LOGS(INFO) << "StartAdvertising started twice:" + << request_result.ToString(); + } else { + PerformanceTimer::stop(); + + NEARBY_LOGS(INFO) + << "SingleRunWithTimeoutReproStuck Line: " << __LINE__ + << " Timeout on starting advertising the second time elapsed time: " + << std::to_string(PerformanceTimer::ElapsedMilliseconds()); + + EXPECT_TRUE(false) << "SingleRunWithTimeoutReproStuck Line: " << __LINE__ + << " Timeout for started advertising elapsed time: " + << std::to_string( + PerformanceTimer::ElapsedMilliseconds()); + + std::cout << "StartAdvertising failed to start twice:" + << request_result.ToString() << std::endl; + NEARBY_LOGS(INFO) << "StartAdvertising failed to start twice:" + << request_result.ToString(); + } + + absl::Notification notification3; + + PerformanceTimer::start(); + + core.StopAdvertising({.result_cb = [&](Status status) { + request_result = status; + notification3.Notify(); + }}); + + if (notification3.WaitForNotificationWithTimeout( + absl::Seconds(TimeoutSeconds))) { + PerformanceTimer::stop(); + + NEARBY_LOGS(INFO) << "SingleRunWithTimeoutReproStuck Line: " << __LINE__ + << " Stopped advertising first time elapsed time: " + << std::to_string( + PerformanceTimer::ElapsedMilliseconds()); + +#ifdef TEST_OUTPUT + EXPECT_TRUE(false) << "Started advertising elapsed time: " + << std::to_string(elapsed_microseconds); +#endif + + std::cout << "StopAdvertising called once:" << request_result.ToString() + << std::endl; + NEARBY_LOGS(INFO) << "StopAdvertising called once:" + << request_result.ToString(); + } else { + PerformanceTimer::stop(); + + NEARBY_LOGS(INFO) + << "SingleRunWithTimeoutReproStuck Line: " << __LINE__ + << " Timeout on stopping advertising the first time elapsed time: " + << std::to_string(PerformanceTimer::ElapsedMilliseconds()); + + EXPECT_TRUE(false) << "SingleRunWithTimeoutReproStuck Line: " << __LINE__ + << " Timeout on stop advertising elapsed time: " + << std::to_string( + PerformanceTimer::ElapsedMilliseconds()); + + std::cout << "StopAdvertising failed to stop once:" + << request_result.ToString() << std::endl; + NEARBY_LOGS(INFO) << "StopAdvertising failed to stop once:" + << request_result.ToString(); + } + + std::cout << "Test completed." << std::endl; + NEARBY_LOGS(INFO) << "Test completed."; +} + +TEST(BluetoothClassicServerSocketTest, DISABLED_MultiRunWithTimeoutReproStuck) { + ServiceControllerRouter router; + Core core(&router); + + ConnectionListener listener; + + ConnectionRequestInfo request_info; + + request_info.endpoint_info = ByteArray(std::string(device_name)); + request_info.listener = listener; + + for (int loop_count = 0; loop_count < LoopCount; ++loop_count) { + Status request_result; + absl::Notification notification; + + PerformanceTimer::start(); + + core.StartAdvertising(SERVICE_ID, AdvertiseOptions, request_info, + {.result_cb = [&](Status status) { + request_result = status; + notification.Notify(); + }}); + + if (notification.WaitForNotificationWithTimeout( + absl::Seconds(TimeoutSeconds))) { + PerformanceTimer::stop(); + + NEARBY_LOGS(INFO) << "SingleRunWithTimeoutReproStuck Line: " << __LINE__ + << " Started advertising elapsed time: " + << std::to_string( + PerformanceTimer::ElapsedMilliseconds()); + +#ifdef TEST_OUTPUT + EXPECT_TRUE(false) << "Started advertising elapsed time : " + << std::to_string(ElapsedMilliseconds); +#endif + + std::cout << "StartAdvertising started once:" << request_result.ToString() + << std::endl; + NEARBY_LOGS(INFO) << "StartAdvertising started once:" + << request_result.ToString(); + } else { + PerformanceTimer::stop(); + + NEARBY_LOGS(INFO) << "SingleRunWithTimeoutReproStuck Line: " << __LINE__ + << " Timeout on starting advertising elapsed time: " + << std::to_string( + PerformanceTimer::ElapsedMilliseconds()); + + EXPECT_TRUE(false) << "Timeout on starting advertising elapsed time: " + << std::to_string( + PerformanceTimer::ElapsedMilliseconds()); + + std::cout << "StartAdvertising failed to start once:" + << request_result.ToString() << std::endl; + NEARBY_LOGS(INFO) << "StartAdvertising failed to start once:" + << request_result.ToString(); + } + + absl::Notification notification2; + + PerformanceTimer::start(); + + core.StartAdvertising(SERVICE_ID, AdvertiseOptions, request_info, + {.result_cb = [&](Status status) { + request_result = status; + notification2.Notify(); + }}); + + if (notification2.WaitForNotificationWithTimeout( + absl::Seconds(TimeoutSeconds))) { + PerformanceTimer::stop(); + + NEARBY_LOGS(INFO) << "SingleRunWithTimeoutReproStuck Line: " << __LINE__ + << " Started advertising second time elapsed time: " + << std::to_string( + PerformanceTimer::ElapsedMilliseconds()); + // EXPECT_TRUE(false) + // << "Started advertising elapsed time: " + // << std::to_string(ElapsedMilliseconds); + std::cout << "StartAdvertising started twice:" + << request_result.ToString() << std::endl; + NEARBY_LOGS(INFO) << "StartAdvertising started twice:" + << request_result.ToString(); + } else { + PerformanceTimer::stop(); + + NEARBY_LOGS(INFO) + << "SingleRunWithTimeoutReproStuck Line: " << __LINE__ + << " Timeout on starting advertising the second time elapsed time: " + << std::to_string(PerformanceTimer::ElapsedMilliseconds()); + + EXPECT_TRUE(false) + << "Timeout on starting advertising the second time elapsed time: " + << std::to_string(PerformanceTimer::ElapsedMilliseconds()); + + std::cout << "StartAdvertising failed to start twice:" + << request_result.ToString() << std::endl; + NEARBY_LOGS(INFO) << "StartAdvertising failed to start twice:" + << request_result.ToString(); + } + + absl::Notification notification3; + + PerformanceTimer::start(); + + core.StopAdvertising({.result_cb = [&](Status status) { + request_result = status; + notification3.Notify(); + }}); + + if (notification3.WaitForNotificationWithTimeout( + absl::Seconds(TimeoutSeconds))) { + PerformanceTimer::stop(); + + NEARBY_LOGS(INFO) << "SingleRunWithTimeoutReproStuck Line: " << __LINE__ + << " Stopped advertising first time elapsed time: " + << std::to_string( + PerformanceTimer::ElapsedMilliseconds()); + +#ifdef TEST_OUTPUT + EXPECT_TRUE(false) << "Started advertising elapsed time: " + << std::to_string(ElapsedMilliseconds); +#endif + + std::cout << "StopAdvertising called once:" << request_result.ToString() + << std::endl; + NEARBY_LOGS(INFO) << "StopAdvertising called once:" + << request_result.ToString(); + } else { + PerformanceTimer::stop(); + + NEARBY_LOGS(INFO) + << "SingleRunWithTimeoutReproStuck Line: " << __LINE__ + << " Timeout on stopping advertising the first time elapsed time: " + << std::to_string(PerformanceTimer::ElapsedMilliseconds()); + + EXPECT_TRUE(false) << "Timeout on started advertising elapsed time: " + << std::to_string( + PerformanceTimer::ElapsedMilliseconds()); + + std::cout << "StopAdvertising failed to stop once:" + << request_result.ToString() << std::endl; + NEARBY_LOGS(INFO) << "StopAdvertising failed to stop once:" + << request_result.ToString(); + } + } + + std::cout << "Test completed." << std::endl; + NEARBY_LOGS(INFO) << "Test completed."; +} + +TEST(BluetoothClassicServerSocketTest, DISABLED_SingleRunNoTimeoutReproStuck) { + ServiceControllerRouter router; + Core core(&router); + + ConnectionListener listener; + + ConnectionRequestInfo request_info; + + request_info.endpoint_info = ByteArray(std::string(device_name)); + request_info.listener = listener; + + Status request_result; + absl::Notification notification; + + PerformanceTimer::start(); + + core.StartAdvertising(SERVICE_ID, AdvertiseOptions, request_info, + {.result_cb = [&](Status status) { + request_result = status; + notification.Notify(); + }}); + + notification.WaitForNotification(); + PerformanceTimer::stop(); + + NEARBY_LOGS(INFO) << "SingleRunNoTimeoutReproStuck Line: " << __LINE__ + << " Started advertising first time elapsed time: " + << std::to_string(PerformanceTimer::ElapsedMilliseconds()); + +#ifdef TEST_OUTPUT + EXPECT_TRUE(false) << "Started advertising first time elapsed time: " + << std::to_string(ElapsedMilliseconds); +#endif + + std::cout << "StartAdvertising started once:" << request_result.ToString() + << std::endl; + NEARBY_LOGS(INFO) << "StartAdvertising started once:" + << request_result.ToString(); + + absl::Notification notification2; + + PerformanceTimer::start(); + + core.StartAdvertising(SERVICE_ID, AdvertiseOptions, request_info, + {.result_cb = [&](Status status) { + request_result = status; + notification2.Notify(); + }}); + + notification2.WaitForNotification(); + PerformanceTimer::stop(); + + NEARBY_LOGS(INFO) << "SingleRunNoTimeoutReproStuck Line: " << __LINE__ + << " Started advertising first time elapsed time: " + << std::to_string(PerformanceTimer::ElapsedMilliseconds()); + +#ifdef TEST_OUTPUT + EXPECT_TRUE(false) << "Started advertising first time elapsed time: " + << std::to_string(ElapsedMilliseconds); +#endif + + std::cout << "StartAdvertising started twice:" << request_result.ToString() + << std::endl; + NEARBY_LOGS(INFO) << "StartAdvertising started twice:" + << request_result.ToString(); + + absl::Notification notification3; + + PerformanceTimer::start(); + + core.StopAdvertising({.result_cb = [&](Status status) { + request_result = status; + notification3.Notify(); + }}); + + notification3.WaitForNotification(); + PerformanceTimer::stop(); + + NEARBY_LOGS(INFO) << "SingleRunNoTimeoutReproStuck " << __LINE__ + << "Stopped advertising elapsed time: " + << std::to_string(PerformanceTimer::ElapsedMilliseconds()); + +#ifdef TEST_OUTPUT + EXPECT_TRUE(false) << "Stopped advertising elapsed time: " + << std::to_string(ElapsedMilliseconds); +#endif + + std::cout << "StopAdvertising called once:" << request_result.ToString() + << std::endl; + NEARBY_LOGS(INFO) << "StopAdvertising called once:" + << request_result.ToString(); + + std::cout << "Test completed." << std::endl; + NEARBY_LOGS(INFO) << "Test completed."; +} + +TEST(BluetoothClassicServerSocketTest, DISABLED_MultiRunNoTimeoutReproStuck) { + ServiceControllerRouter router; + Core core(&router); + + ConnectionListener listener; + + ConnectionRequestInfo request_info; + + request_info.endpoint_info = ByteArray(std::string(device_name)); + request_info.listener = listener; + + for (int loop_count = 0; loop_count < LoopCount; ++loop_count) { + Status request_result; + absl::Notification notification; + + PerformanceTimer::start(); + + core.StartAdvertising(SERVICE_ID, AdvertiseOptions, request_info, + {.result_cb = [&](Status status) { + request_result = status; + notification.Notify(); + }}); + + notification.WaitForNotification(); + + PerformanceTimer::stop(); + + NEARBY_LOGS(INFO) << "MultiRunNoTimeoutReproStuck " << __LINE__ + << "Started advertising elapsed time: " + << std::to_string( + PerformanceTimer::ElapsedMilliseconds()); + +#ifdef TEST_OUTPUT + EXPECT_TRUE(false) << "Started advertising elapsed time: " + << std::to_string(ElapsedMilliseconds); +#endif + + std::cout << "MultiRunNoTimeoutReproStuck " << __LINE__ + << " : StartAdvertising started once: " + << request_result.ToString() << std::endl; + NEARBY_LOGS(INFO) << "StartAdvertising started once:" + << request_result.ToString(); + + absl::Notification notification2; + + PerformanceTimer::start(); + + core.StartAdvertising(SERVICE_ID, AdvertiseOptions, request_info, + {.result_cb = [&](Status status) { + request_result = status; + notification2.Notify(); + }}); + + notification2.WaitForNotification(); + PerformanceTimer::stop(); + + NEARBY_LOGS(INFO) << "MultiRunNoTimeoutReproStuck " << __LINE__ + << "Started advertising elapsed time: " + << std::to_string( + PerformanceTimer::ElapsedMilliseconds()); + +#ifdef TEST_OUTPUT + EXPECT_TRUE(false) << "Started advertising elapsed time: " + << std::to_string(ElapsedMilliseconds); +#endif + + std::cout << "MultiRunNoTimeoutReproStuck " << __LINE__ + << "StartAdvertising started twice:" << request_result.ToString() + << std::endl; + NEARBY_LOGS(INFO) << "MultiRunNoTimeoutReproStuck " << __LINE__ + << "StartAdvertising started twice:" + << request_result.ToString(); + + absl::Notification notification3; + + PerformanceTimer::start(); + + core.StopAdvertising({.result_cb = [&](Status status) { + request_result = status; + notification3.Notify(); + }}); + + notification3.WaitForNotification(); + PerformanceTimer::stop(); + + NEARBY_LOGS(INFO) << "MultiRunNoTimeoutReproStuck " << __LINE__ + << "Stopped advertising elapsed time: " + << std::to_string( + PerformanceTimer::ElapsedMilliseconds()); + +#ifdef TEST_OUTPUT + EXPECT_TRUE(false) << "Stop advertising elapsed time: " + << std::to_string(ElapsedMilliseconds); +#endif + + std::cout << "StopAdvertising called once:" << request_result.ToString() + << std::endl; + NEARBY_LOGS(INFO) << "MultiRunNoTimeoutReproStuck " << __LINE__ + << "StopAdvertising called once:" + << request_result.ToString(); + } + + std::cout << "Test completed." << std::endl; + NEARBY_LOGS(INFO) << "Test completed."; +} + +} // namespace nearby::windows diff --git a/connections/clients/windows/connection_options_w.cc b/connections/clients/windows/connection_options_w.cc index d9d71490f8..a0e94f0dc2 100644 --- a/connections/clients/windows/connection_options_w.cc +++ b/connections/clients/windows/connection_options_w.cc @@ -16,7 +16,7 @@ #include -namespace location::nearby::windows { +namespace nearby::windows { void ConnectionOptionsW::GetMediums(const MediumW* mediums, size_t mediums_size) const { @@ -32,4 +32,4 @@ void ConnectionOptionsW::GetMediums(const MediumW* mediums, return; } -} // namespace location::nearby::windows +} // namespace nearby::windows diff --git a/connections/clients/windows/connection_options_w.h b/connections/clients/windows/connection_options_w.h index 11a4bcc32a..d2c71832e3 100644 --- a/connections/clients/windows/connection_options_w.h +++ b/connections/clients/windows/connection_options_w.h @@ -18,7 +18,7 @@ #include "connections/clients/windows/medium_selector_w.h" #include "connections/clients/windows/options_base_w.h" -namespace location::nearby::windows { +namespace nearby::windows { extern "C" { @@ -49,6 +49,6 @@ struct DLL_API ConnectionOptionsW : public OptionsBaseW { }; } // extern "C" -} // namespace location::nearby::windows +} // namespace nearby::windows #endif // THIRD_PARTY_NEARBY_CONNECTIONS_CLIENTS_WINDOWS_CONNECTION_OPTIONS_W_H_ diff --git a/connections/clients/windows/core_adapter.cc b/connections/clients/windows/core_adapter.cc index 75f1c39bc0..00bdc16c23 100644 --- a/connections/clients/windows/core_adapter.cc +++ b/connections/clients/windows/core_adapter.cc @@ -19,7 +19,7 @@ #include "internal/platform/bluetooth_utils.h" #include "internal/platform/logging.h" -namespace location::nearby::windows { +namespace nearby::windows { Core *InitCore(connections::ServiceControllerRouter *router) { #if defined(LOG_SEVERITY_VERBOSE) @@ -293,4 +293,4 @@ void CloseServiceControllerRouter( } } -} // namespace location::nearby::windows +} // namespace nearby::windows diff --git a/connections/clients/windows/core_adapter.h b/connections/clients/windows/core_adapter.h index ad9385dfc7..95c605fc08 100644 --- a/connections/clients/windows/core_adapter.h +++ b/connections/clients/windows/core_adapter.h @@ -24,13 +24,13 @@ #include "connections/clients/windows/params_w.h" #include "connections/clients/windows/payload_w.h" -namespace location::nearby::connections { +namespace nearby::connections { class Core; class ServiceController; class ServiceControllerRouter; class OfflineServiceController; -} // namespace location::nearby::connections -namespace location::nearby::windows { +} // namespace nearby::connections +namespace nearby::windows { extern "C" { @@ -255,6 +255,6 @@ DLL_API ServiceControllerRouter* __stdcall InitServiceControllerRouter(); DLL_API void __stdcall CloseServiceControllerRouter(ServiceControllerRouter*); } // extern "C" -} // namespace location::nearby::windows +} // namespace nearby::windows #endif // THIRD_PARTY_NEARBY_CONNECTIONS_CLIENTS_WINDOWS_CORE_ADAPTER_H_ diff --git a/connections/clients/windows/dart/core_adapter_dart.cc b/connections/clients/windows/dart/core_adapter_dart.cc index 5534a37dc9..4ef563f08b 100644 --- a/connections/clients/windows/dart/core_adapter_dart.cc +++ b/connections/clients/windows/dart/core_adapter_dart.cc @@ -24,7 +24,7 @@ #include "internal/platform/count_down_latch.h" #include "internal/platform/logging.h" -namespace location::nearby::windows { +namespace nearby::windows { static CountDownLatch *adapter_finished; @@ -229,7 +229,7 @@ void ListenerPayloadCB(const char *endpoint_id, PayloadW &payload) { Dart_CObject dart_object_payload_data; dart_object_offset.type = Dart_CObject_kString; switch (payload.GetType()) { - case location::nearby::connections::PayloadType::kBytes: { + case nearby::connections::PayloadType::kBytes: { char *bytes = nullptr; size_t bytes_size; @@ -238,7 +238,7 @@ void ListenerPayloadCB(const char *endpoint_id, PayloadW &payload) { } dart_object_offset.value.as_string = bytes; } break; - case location::nearby::connections::PayloadType::kFile: { + case nearby::connections::PayloadType::kFile: { std::string payload_data(payload.AsFile()->GetFilePath().data()); dart_object_offset.value.as_string = const_cast(payload_data.c_str()); @@ -654,4 +654,4 @@ void SendPayloadDart(Core *pCore, const char *endpoint_id, } } -} // namespace location::nearby::windows +} // namespace nearby::windows diff --git a/connections/clients/windows/dart/core_adapter_dart.h b/connections/clients/windows/dart/core_adapter_dart.h index 6dc9d862f7..f7ecce1a48 100644 --- a/connections/clients/windows/dart/core_adapter_dart.h +++ b/connections/clients/windows/dart/core_adapter_dart.h @@ -19,7 +19,7 @@ #include "third_party/dart_lang/v2/runtime/include/dart_native_api.h" #include "connections/clients/windows/core_adapter.h" -namespace location::nearby::windows { +namespace nearby::windows { enum class StrategyDart { P2P_CLUSTER = 0, @@ -302,6 +302,6 @@ DLL_API void __stdcall SendPayloadDart(Core *pCore, const char *endpoint_id, PayloadDart payload_dart, Dart_Port result_cb); } // extern "C" -} // namespace location::nearby::windows +} // namespace nearby::windows #endif // LOCATION_NEARBY_CONNECTIONS_WINDOWS_CORE_ADAPTER_DART_H_ diff --git a/connections/clients/windows/discovery_options_w.cc b/connections/clients/windows/discovery_options_w.cc index 800eb36bd0..a11d23ce25 100644 --- a/connections/clients/windows/discovery_options_w.cc +++ b/connections/clients/windows/discovery_options_w.cc @@ -16,7 +16,7 @@ #include -namespace location::nearby::windows { +namespace nearby::windows { // Returns a copy and normalizes allowed mediums: // (1) If is_out_of_band_connection is true, verifies that there is only one @@ -45,4 +45,4 @@ DiscoveryOptionsW DiscoveryOptionsW::CompatibleOptions() const { return result; } -} // namespace location::nearby::windows +} // namespace nearby::windows diff --git a/connections/clients/windows/discovery_options_w.h b/connections/clients/windows/discovery_options_w.h index a52459f482..f616cb06a5 100644 --- a/connections/clients/windows/discovery_options_w.h +++ b/connections/clients/windows/discovery_options_w.h @@ -17,7 +17,7 @@ #include "connections/clients/windows/options_base_w.h" -namespace location::nearby::windows { +namespace nearby::windows { extern "C" { @@ -41,6 +41,6 @@ struct DLL_API DiscoveryOptionsW : public OptionsBaseW { }; } // extern "C" -} // namespace location::nearby::windows +} // namespace nearby::windows #endif // THIRD_PARTY_NEARBY_CONNECTIONS_CLIENTS_WINDOWS_DISCOVERY_OPTIONS_W_H_ diff --git a/connections/clients/windows/dll_config.h b/connections/clients/windows/dll_config.h index 72bde25e68..1fcf75222e 100644 --- a/connections/clients/windows/dll_config.h +++ b/connections/clients/windows/dll_config.h @@ -14,7 +14,7 @@ #ifndef THIRD_PARTY_NEARBY_CONNECTIONS_CLIENTS_WINDOWS_CONFIG_H_ #define THIRD_PARTY_NEARBY_CONNECTIONS_CLIENTS_WINDOWS_CONFIG_H_ -namespace location::nearby::windows { +namespace nearby::windows { #ifdef _WIN32 // These storage class specifiers only matter to win32 dll // builds. @@ -29,6 +29,6 @@ namespace location::nearby::windows { #define DLL_API // We're not building a win32 dll, leave the source unchanged. #endif // _WIN32 -} // namespace location::nearby::windows +} // namespace nearby::windows #endif // THIRD_PARTY_NEARBY_CONNECTIONS_CLIENTS_WINDOWS_CONFIG_H_ diff --git a/connections/clients/windows/file_w.cc b/connections/clients/windows/file_w.cc index fc611995b2..3c59b76f1c 100644 --- a/connections/clients/windows/file_w.cc +++ b/connections/clients/windows/file_w.cc @@ -1,67 +1,67 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -#include "connections/clients/windows/file_w.h" - -#include - -#include "internal/platform/file.h" - -namespace location::nearby { -void InputFileDeleter::operator()(nearby::InputFile* p) { delete p; } -void OutputFileDeleter::operator()(nearby::OutputFile* p) { delete p; } - -namespace windows { -InputFileW::InputFileW(InputFile* input_file) - : impl_(std::unique_ptr( - new nearby::InputFile(std::move(*input_file)))) {} -InputFileW::InputFileW(PayloadId payload_id, size_t size) - : impl_(std::unique_ptr( - new nearby::InputFile(payload_id, size))) {} -InputFileW::InputFileW(const char* file_path, size_t size) - : impl_(std::unique_ptr( - new nearby::InputFile(file_path, size))) {} -InputFileW::InputFileW(InputFileW&& other) noexcept - : impl_(std::move(other.impl_)) {} - -// Returns a string that uniquely identifies this file. -// Caller allocates buffer[MAX_PATH] and is responsible -// for freeing. -void InputFileW::GetFilePath(char* file_path) const { - std::string fp = impl_->GetFilePath(); - strncpy(file_path, fp.c_str(), fp.length()); -} - -// Returns total size of this file in bytes. -size_t InputFileW::GetTotalSize() const { return impl_->GetTotalSize(); } - -std::unique_ptr -InputFileW::GetImpl() { - return std::move(impl_); -} - -OutputFileW::OutputFileW(PayloadId payload_id) {} -OutputFileW::OutputFileW(const char* file_path) {} -OutputFileW::OutputFileW(OutputFileW&&) noexcept {} -OutputFileW& OutputFileW::operator=(OutputFileW&& other) noexcept { - impl_ = std::move(other.impl_); - return *this; -} - -std::unique_ptr -OutputFileW::GetImpl() { - return std::move(impl_); -} - -} // namespace windows -} // namespace location::nearby +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +#include "connections/clients/windows/file_w.h" + +#include + +#include "internal/platform/file.h" + +namespace nearby { +void InputFileDeleter::operator()(nearby::InputFile* p) { delete p; } +void OutputFileDeleter::operator()(nearby::OutputFile* p) { delete p; } + +namespace windows { +InputFileW::InputFileW(InputFile* input_file) + : impl_(std::unique_ptr( + new nearby::InputFile(std::move(*input_file)))) {} +InputFileW::InputFileW(PayloadId payload_id, size_t size) + : impl_(std::unique_ptr( + new nearby::InputFile(payload_id, size))) {} +InputFileW::InputFileW(const char* file_path, size_t size) + : impl_(std::unique_ptr( + new nearby::InputFile(file_path, size))) {} +InputFileW::InputFileW(InputFileW&& other) noexcept + : impl_(std::move(other.impl_)) {} + +// Returns a string that uniquely identifies this file. +// Caller allocates buffer[MAX_PATH] and is responsible +// for freeing. +void InputFileW::GetFilePath(char* file_path) const { + std::string fp = impl_->GetFilePath(); + strncpy(file_path, fp.c_str(), fp.length()); +} + +// Returns total size of this file in bytes. +size_t InputFileW::GetTotalSize() const { return impl_->GetTotalSize(); } + +std::unique_ptr +InputFileW::GetImpl() { + return std::move(impl_); +} + +OutputFileW::OutputFileW(PayloadId payload_id) {} +OutputFileW::OutputFileW(const char* file_path) {} +OutputFileW::OutputFileW(OutputFileW&&) noexcept {} +OutputFileW& OutputFileW::operator=(OutputFileW&& other) noexcept { + impl_ = std::move(other.impl_); + return *this; +} + +std::unique_ptr +OutputFileW::GetImpl() { + return std::move(impl_); +} + +} // namespace windows +} // namespace nearby diff --git a/connections/clients/windows/file_w.h b/connections/clients/windows/file_w.h index 032cb57e23..3bb8719baa 100644 --- a/connections/clients/windows/file_w.h +++ b/connections/clients/windows/file_w.h @@ -20,7 +20,6 @@ #include "connections/clients/windows/dll_config.h" #include "internal/platform/payload_id.h" -namespace location { namespace nearby { class InputFile; struct DLL_API InputFileDeleter { @@ -33,16 +32,14 @@ struct DLL_API OutputFileDeleter { }; } // namespace nearby -} // namespace location -namespace location { namespace nearby { namespace windows { class DLL_API InputFileW { public: - explicit InputFileW(location::nearby::InputFile* input_file); - InputFileW(location::nearby::PayloadId payload_id, size_t size); + explicit InputFileW(nearby::InputFile* input_file); + InputFileW(nearby::PayloadId payload_id, size_t size); InputFileW(const char* file_path, size_t size); InputFileW(InputFileW&&) noexcept; @@ -52,35 +49,26 @@ class DLL_API InputFileW { // Returns total size of this file in bytes. size_t GetTotalSize() const; - std::unique_ptr - GetImpl(); + std::unique_ptr GetImpl(); private: - std::unique_ptr - impl_; + std::unique_ptr impl_; }; class DLL_API OutputFileW { public: - explicit OutputFileW(location::nearby::PayloadId payload_id); + explicit OutputFileW(nearby::PayloadId payload_id); explicit OutputFileW(const char* file_path); OutputFileW(OutputFileW&&) noexcept; OutputFileW& operator=(OutputFileW&&) noexcept; - std::unique_ptr - GetImpl(); + std::unique_ptr GetImpl(); private: - std::unique_ptr - impl_; + std::unique_ptr impl_; }; } // namespace windows } // namespace nearby -} // namespace location #endif // THIRD_PARTY_NEARBY_CONNECTIONS_CLIENTS_WINDOWS_FILE_W_H_ diff --git a/connections/clients/windows/input_stream_w.cc b/connections/clients/windows/input_stream_w.cc index bf3b3e03fe..307d4cb5a8 100644 --- a/connections/clients/windows/input_stream_w.cc +++ b/connections/clients/windows/input_stream_w.cc @@ -15,11 +15,10 @@ #include "internal/platform/input_stream.h" -namespace location::nearby { +namespace nearby { void InputStreamDeleter::operator()(nearby::InputStream* p) { delete p; } -} // namespace location::nearby +} // namespace nearby -namespace location { namespace nearby { namespace windows { @@ -49,4 +48,3 @@ int64_t InputStreamW::Close() { } // namespace windows } // namespace nearby -} // namespace location diff --git a/connections/clients/windows/input_stream_w.h b/connections/clients/windows/input_stream_w.h index fbce8305d9..f3a76c0e5b 100644 --- a/connections/clients/windows/input_stream_w.h +++ b/connections/clients/windows/input_stream_w.h @@ -1,51 +1,47 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -#ifndef THIRD_PARTY_NEARBY_CONNECTIONS_CLIENTS_WINDOWS_INPUT_STREAM_W_H_ -#define THIRD_PARTY_NEARBY_CONNECTIONS_CLIENTS_WINDOWS_INPUT_STREAM_W_H_ - -#include - -namespace location { -namespace nearby { - -class InputStream; -struct InputStreamDeleter { - void operator()(InputStream* p); -}; -} // namespace nearby -} // namespace location - -namespace location { -namespace nearby { -namespace windows { - -class InputStreamW { - public: - char* Read(size_t size); - - // throws Exception::kIo - int64_t Skip(size_t offset); - - // throws Exception::kIo - int64_t Close(); - - private: - std::unique_ptr impl_; -}; - -} // namespace windows -} // namespace nearby -} // namespace location - -#endif // THIRD_PARTY_NEARBY_CONNECTIONS_CLIENTS_WINDOWS_INPUT_STREAM_W_H_ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +#ifndef THIRD_PARTY_NEARBY_CONNECTIONS_CLIENTS_WINDOWS_INPUT_STREAM_W_H_ +#define THIRD_PARTY_NEARBY_CONNECTIONS_CLIENTS_WINDOWS_INPUT_STREAM_W_H_ + +#include + +namespace nearby { + +class InputStream; +struct InputStreamDeleter { + void operator()(InputStream* p); +}; +} // namespace nearby + +namespace nearby { +namespace windows { + +class InputStreamW { + public: + char* Read(size_t size); + + // throws Exception::kIo + int64_t Skip(size_t offset); + + // throws Exception::kIo + int64_t Close(); + + private: + std::unique_ptr impl_; +}; + +} // namespace windows +} // namespace nearby + +#endif // THIRD_PARTY_NEARBY_CONNECTIONS_CLIENTS_WINDOWS_INPUT_STREAM_W_H_ diff --git a/connections/clients/windows/listeners_w.cc b/connections/clients/windows/listeners_w.cc index 40584f4ef3..9e95971d23 100644 --- a/connections/clients/windows/listeners_w.cc +++ b/connections/clients/windows/listeners_w.cc @@ -1,270 +1,270 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "connections/clients/windows/listeners_w.h" - -#include "connections/listeners.h" - -namespace location::nearby { -// Must implement Deleters, since the connections classes weren't -// fully defined in the header -namespace connections { -void ResultCallbackDeleter::operator()(connections::ResultCallback *p) { - delete p; -} -void ConnectionListenerDeleter::operator()(connections::ConnectionListener *p) { - delete p; -} -void DiscoveryListenerDeleter::operator()(connections::DiscoveryListener *p) { - delete p; -} -void PayloadListenerDeleter::operator()(connections::PayloadListener *p) { - delete p; -} -} // namespace connections - -namespace windows { - -static ResultCallbackW *ResultCallbackImpl; - -void ResultCB(Status status) { ResultCallbackImpl->result_cb(status); } - -ResultCallbackW::ResultCallbackW() - : impl_(std::unique_ptr( - new connections::ResultCallback())) { - ResultCallbackImpl = this; - impl_->result_cb = ResultCB; -} - -ResultCallbackW::~ResultCallbackW() {} - -ResultCallbackW::ResultCallbackW(ResultCallbackW &other) { - impl_ = std::move(other.impl_); -} - -ResultCallbackW::ResultCallbackW(ResultCallbackW &&other) noexcept { - impl_ = std::move(other.impl_); -} - -ConnectionListenerW::ConnectionListenerW(InitiatedCB initiatedCB, - AcceptedCB acceptedCB, - RejectedCB rejectedCB, - DisconnectedCB disconnectedCB, - BandwidthChangedCB bandwidthChangedCB) - : initiated_cb(initiatedCB), - accepted_cb(acceptedCB), - rejected_cb(rejectedCB), - disconnected_cb(disconnectedCB), - bandwidth_changed_cb(bandwidthChangedCB), - impl_(std::unique_ptr( - new connections::ConnectionListener())) { - CHECK(initiated_cb != nullptr); - auto i = initiated_cb; - impl_->initiated_cb = - [i](const std::string &endpoint_id, - const connections::ConnectionResponseInfo connection_response_info) { - ConnectionResponseInfoW connection_response_info_w{ - connection_response_info.remote_endpoint_info.data(), - connection_response_info.remote_endpoint_info.size(), - connection_response_info.authentication_token.c_str(), - connection_response_info.raw_authentication_token.data(), - connection_response_info.raw_authentication_token.size(), - connection_response_info.is_incoming_connection, - connection_response_info.is_connection_verified}; - i(endpoint_id.c_str(), connection_response_info_w); - }; - - CHECK(accepted_cb != nullptr); - auto a = accepted_cb; - impl_->accepted_cb = [a](const std::string &endpoint_id) { - a(endpoint_id.c_str()); - }; - - CHECK(rejected_cb != nullptr); - auto r = rejected_cb; - impl_->rejected_cb = [r](const std::string &endpoint_id, Status status) { - r(endpoint_id.c_str(), status); - }; - - CHECK(disconnected_cb != nullptr); - auto d = disconnected_cb; - impl_->disconnected_cb = [d](const std::string &endpoint_id) { - d(endpoint_id.c_str()); - }; - - CHECK(bandwidth_changed_cb != nullptr); - auto bwc = bandwidth_changed_cb; - impl_->bandwidth_changed_cb = [bwc](const std::string &endpoint_id, - connections::Medium medium) { - bwc(endpoint_id.c_str(), medium); - }; -} - -ConnectionListenerW::ConnectionListenerW(ConnectionListenerW &other) { - impl_ = std::move(other.impl_); - accepted_cb = other.accepted_cb; - bandwidth_changed_cb = other.bandwidth_changed_cb; - disconnected_cb = other.disconnected_cb; - initiated_cb = other.initiated_cb; - rejected_cb = other.rejected_cb; -} - -ConnectionListenerW::ConnectionListenerW(ConnectionListenerW &&other) noexcept = - default; - -DiscoveryListenerW::DiscoveryListenerW( - EndpointFoundCB endpointFoundCB, EndpointLostCB endpointLostCB, - EndpointDistanceChangedCB endpointDistanceChangedCB) - : endpoint_found_cb(endpointFoundCB), - endpoint_lost_cb(endpointLostCB), - endpoint_distance_changed_cb(endpointDistanceChangedCB), - impl_(new connections::DiscoveryListener()) { - CHECK(endpoint_distance_changed_cb != nullptr); - auto epdc = endpoint_distance_changed_cb; - impl_->endpoint_distance_changed_cb = - [epdc](const std::string &endpoint_id, - connections::DistanceInfo distance_info) { - DistanceInfoW distanceInfoW = DistanceInfoW::kUnknown; - switch (distance_info) { - case connections::DistanceInfo::kFar: - distanceInfoW = DistanceInfoW::kFar; - break; - case connections::DistanceInfo::kClose: - distanceInfoW = DistanceInfoW::kFar; - break; - case connections::DistanceInfo::kVeryClose: - distanceInfoW = DistanceInfoW::kVeryClose; - break; - case connections::DistanceInfo::kUnknown: - break; - } - epdc(endpoint_id.c_str(), distanceInfoW); - }; - - CHECK(endpoint_found_cb != nullptr); - auto epf = endpoint_found_cb; - impl_->endpoint_found_cb = [epf](const std::string &endpoint_id, - ByteArray endpoint_info, - const std::string &service_id) { - epf(endpoint_id.c_str(), endpoint_info.data(), endpoint_info.size(), - service_id.c_str()); - }; - - CHECK(endpoint_lost_cb != nullptr); - auto epl = endpoint_lost_cb; - impl_->endpoint_lost_cb = [epl](const std::string &endpoint_id) { - epl(endpoint_id.c_str()); - }; -} - -DiscoveryListenerW::DiscoveryListenerW(DiscoveryListenerW &other) { - endpoint_distance_changed_cb = other.endpoint_distance_changed_cb; - endpoint_found_cb = other.endpoint_found_cb; - endpoint_lost_cb = other.endpoint_lost_cb; - impl_ = std::move(other.impl_); -} - -DiscoveryListenerW::DiscoveryListenerW(DiscoveryListenerW &&other) noexcept { - endpoint_distance_changed_cb = other.endpoint_distance_changed_cb; - endpoint_found_cb = other.endpoint_found_cb; - endpoint_lost_cb = other.endpoint_lost_cb; - impl_ = std::move(other.impl_); -} - -PayloadListenerW::PayloadListenerW(PayloadCB payloadCB, - PayloadProgressCB payloadProgressCB) - : payload_cb(payloadCB), - payload_progress_cb(payloadProgressCB), - impl_(std::unique_ptr( - new connections::PayloadListener())) { - CHECK(payload_cb != nullptr); - auto pcb = payload_cb; - impl_->payload_cb = [pcb](const std::string &endpoint_id, - connections::Payload payload) { - PayloadW payloadW; - - switch (payload.GetType()) { - case connections::PayloadType::kBytes: { - payloadW = PayloadW(payload.GetId(), payload.AsBytes().data(), - payload.AsBytes().size()); - break; - } - case connections::PayloadType::kFile: { - InputFileW file(std::move(payload.AsFile())); - payloadW = PayloadW(payload.GetId(), std::move(file)); - } break; - - // TODO(jfcarroll): Figure out how to capture type kStream. - // case connections::PayloadType::kStream: { - // payloadW = PayloadW(payload.AsStream()); - //} - case connections::PayloadType::kStream: { - InputFileW file(std::move(payload.AsFile())); - payloadW = PayloadW(payload.GetId(), std::move(file)); - } break; - case connections::PayloadType::kUnknown: { - // Throw exception here? - break; - } - } - pcb(endpoint_id.c_str(), payloadW); - }; - - CHECK(payload_progress_cb != nullptr); - auto ppcb = payload_progress_cb; - impl_->payload_progress_cb = - [ppcb](const std::string &endpoint_id, - connections::PayloadProgressInfo payload_progress_info) { - PayloadProgressInfoW payload_progress_info_w; - payload_progress_info_w.payload_id = payload_progress_info.payload_id; - payload_progress_info_w.total_bytes = payload_progress_info.total_bytes; - payload_progress_info_w.bytes_transferred = - payload_progress_info.bytes_transferred; - - switch (payload_progress_info.status) { - case connections::PayloadProgressInfo::Status::kCanceled: - payload_progress_info_w.status = - PayloadProgressInfoW::Status::kCanceled; - break; - case connections::PayloadProgressInfo::Status::kFailure: - payload_progress_info_w.status = - PayloadProgressInfoW::Status::kFailure; - break; - case connections::PayloadProgressInfo::Status::kInProgress: - payload_progress_info_w.status = - PayloadProgressInfoW::Status::kInProgress; - break; - case connections::PayloadProgressInfo::Status::kSuccess: - payload_progress_info_w.status = - PayloadProgressInfoW::Status::kSuccess; - break; - } - - ppcb(endpoint_id.c_str(), payload_progress_info_w); - }; -} - -PayloadListenerW::PayloadListenerW(PayloadListenerW &other) { - impl_ = std::move(other.impl_); -} - -PayloadListenerW::PayloadListenerW(PayloadListenerW &&other) noexcept { - impl_ = std::move(other.impl_); -} - -} // namespace windows -} // namespace location::nearby +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "connections/clients/windows/listeners_w.h" + +#include "connections/listeners.h" + +namespace nearby { +// Must implement Deleters, since the connections classes weren't +// fully defined in the header +namespace connections { +void ResultCallbackDeleter::operator()(connections::ResultCallback *p) { + delete p; +} +void ConnectionListenerDeleter::operator()(connections::ConnectionListener *p) { + delete p; +} +void DiscoveryListenerDeleter::operator()(connections::DiscoveryListener *p) { + delete p; +} +void PayloadListenerDeleter::operator()(connections::PayloadListener *p) { + delete p; +} +} // namespace connections + +namespace windows { + +static ResultCallbackW *ResultCallbackImpl; + +void ResultCB(Status status) { ResultCallbackImpl->result_cb(status); } + +ResultCallbackW::ResultCallbackW() + : impl_(std::unique_ptr( + new connections::ResultCallback())) { + ResultCallbackImpl = this; + impl_->result_cb = ResultCB; +} + +ResultCallbackW::~ResultCallbackW() {} + +ResultCallbackW::ResultCallbackW(ResultCallbackW &other) { + impl_ = std::move(other.impl_); +} + +ResultCallbackW::ResultCallbackW(ResultCallbackW &&other) noexcept { + impl_ = std::move(other.impl_); +} + +ConnectionListenerW::ConnectionListenerW(InitiatedCB initiatedCB, + AcceptedCB acceptedCB, + RejectedCB rejectedCB, + DisconnectedCB disconnectedCB, + BandwidthChangedCB bandwidthChangedCB) + : initiated_cb(initiatedCB), + accepted_cb(acceptedCB), + rejected_cb(rejectedCB), + disconnected_cb(disconnectedCB), + bandwidth_changed_cb(bandwidthChangedCB), + impl_(std::unique_ptr( + new connections::ConnectionListener())) { + CHECK(initiated_cb != nullptr); + auto i = initiated_cb; + impl_->initiated_cb = + [i](const std::string &endpoint_id, + const connections::ConnectionResponseInfo connection_response_info) { + ConnectionResponseInfoW connection_response_info_w{ + connection_response_info.remote_endpoint_info.data(), + connection_response_info.remote_endpoint_info.size(), + connection_response_info.authentication_token.c_str(), + connection_response_info.raw_authentication_token.data(), + connection_response_info.raw_authentication_token.size(), + connection_response_info.is_incoming_connection, + connection_response_info.is_connection_verified}; + i(endpoint_id.c_str(), connection_response_info_w); + }; + + CHECK(accepted_cb != nullptr); + auto a = accepted_cb; + impl_->accepted_cb = [a](const std::string &endpoint_id) { + a(endpoint_id.c_str()); + }; + + CHECK(rejected_cb != nullptr); + auto r = rejected_cb; + impl_->rejected_cb = [r](const std::string &endpoint_id, Status status) { + r(endpoint_id.c_str(), status); + }; + + CHECK(disconnected_cb != nullptr); + auto d = disconnected_cb; + impl_->disconnected_cb = [d](const std::string &endpoint_id) { + d(endpoint_id.c_str()); + }; + + CHECK(bandwidth_changed_cb != nullptr); + auto bwc = bandwidth_changed_cb; + impl_->bandwidth_changed_cb = [bwc](const std::string &endpoint_id, + connections::Medium medium) { + bwc(endpoint_id.c_str(), medium); + }; +} + +ConnectionListenerW::ConnectionListenerW(ConnectionListenerW &other) { + impl_ = std::move(other.impl_); + accepted_cb = other.accepted_cb; + bandwidth_changed_cb = other.bandwidth_changed_cb; + disconnected_cb = other.disconnected_cb; + initiated_cb = other.initiated_cb; + rejected_cb = other.rejected_cb; +} + +ConnectionListenerW::ConnectionListenerW(ConnectionListenerW &&other) noexcept = + default; + +DiscoveryListenerW::DiscoveryListenerW( + EndpointFoundCB endpointFoundCB, EndpointLostCB endpointLostCB, + EndpointDistanceChangedCB endpointDistanceChangedCB) + : endpoint_found_cb(endpointFoundCB), + endpoint_lost_cb(endpointLostCB), + endpoint_distance_changed_cb(endpointDistanceChangedCB), + impl_(new connections::DiscoveryListener()) { + CHECK(endpoint_distance_changed_cb != nullptr); + auto epdc = endpoint_distance_changed_cb; + impl_->endpoint_distance_changed_cb = + [epdc](const std::string &endpoint_id, + connections::DistanceInfo distance_info) { + DistanceInfoW distanceInfoW = DistanceInfoW::kUnknown; + switch (distance_info) { + case connections::DistanceInfo::kFar: + distanceInfoW = DistanceInfoW::kFar; + break; + case connections::DistanceInfo::kClose: + distanceInfoW = DistanceInfoW::kFar; + break; + case connections::DistanceInfo::kVeryClose: + distanceInfoW = DistanceInfoW::kVeryClose; + break; + case connections::DistanceInfo::kUnknown: + break; + } + epdc(endpoint_id.c_str(), distanceInfoW); + }; + + CHECK(endpoint_found_cb != nullptr); + auto epf = endpoint_found_cb; + impl_->endpoint_found_cb = [epf](const std::string &endpoint_id, + ByteArray endpoint_info, + const std::string &service_id) { + epf(endpoint_id.c_str(), endpoint_info.data(), endpoint_info.size(), + service_id.c_str()); + }; + + CHECK(endpoint_lost_cb != nullptr); + auto epl = endpoint_lost_cb; + impl_->endpoint_lost_cb = [epl](const std::string &endpoint_id) { + epl(endpoint_id.c_str()); + }; +} + +DiscoveryListenerW::DiscoveryListenerW(DiscoveryListenerW &other) { + endpoint_distance_changed_cb = other.endpoint_distance_changed_cb; + endpoint_found_cb = other.endpoint_found_cb; + endpoint_lost_cb = other.endpoint_lost_cb; + impl_ = std::move(other.impl_); +} + +DiscoveryListenerW::DiscoveryListenerW(DiscoveryListenerW &&other) noexcept { + endpoint_distance_changed_cb = other.endpoint_distance_changed_cb; + endpoint_found_cb = other.endpoint_found_cb; + endpoint_lost_cb = other.endpoint_lost_cb; + impl_ = std::move(other.impl_); +} + +PayloadListenerW::PayloadListenerW(PayloadCB payloadCB, + PayloadProgressCB payloadProgressCB) + : payload_cb(payloadCB), + payload_progress_cb(payloadProgressCB), + impl_(std::unique_ptr( + new connections::PayloadListener())) { + CHECK(payload_cb != nullptr); + auto pcb = payload_cb; + impl_->payload_cb = [pcb](const std::string &endpoint_id, + connections::Payload payload) { + PayloadW payloadW; + + switch (payload.GetType()) { + case connections::PayloadType::kBytes: { + payloadW = PayloadW(payload.GetId(), payload.AsBytes().data(), + payload.AsBytes().size()); + break; + } + case connections::PayloadType::kFile: { + InputFileW file(std::move(payload.AsFile())); + payloadW = PayloadW(payload.GetId(), std::move(file)); + } break; + + // TODO(jfcarroll): Figure out how to capture type kStream. + // case connections::PayloadType::kStream: { + // payloadW = PayloadW(payload.AsStream()); + //} + case connections::PayloadType::kStream: { + InputFileW file(std::move(payload.AsFile())); + payloadW = PayloadW(payload.GetId(), std::move(file)); + } break; + case connections::PayloadType::kUnknown: { + // Throw exception here? + break; + } + } + pcb(endpoint_id.c_str(), payloadW); + }; + + CHECK(payload_progress_cb != nullptr); + auto ppcb = payload_progress_cb; + impl_->payload_progress_cb = + [ppcb](const std::string &endpoint_id, + connections::PayloadProgressInfo payload_progress_info) { + PayloadProgressInfoW payload_progress_info_w; + payload_progress_info_w.payload_id = payload_progress_info.payload_id; + payload_progress_info_w.total_bytes = payload_progress_info.total_bytes; + payload_progress_info_w.bytes_transferred = + payload_progress_info.bytes_transferred; + + switch (payload_progress_info.status) { + case connections::PayloadProgressInfo::Status::kCanceled: + payload_progress_info_w.status = + PayloadProgressInfoW::Status::kCanceled; + break; + case connections::PayloadProgressInfo::Status::kFailure: + payload_progress_info_w.status = + PayloadProgressInfoW::Status::kFailure; + break; + case connections::PayloadProgressInfo::Status::kInProgress: + payload_progress_info_w.status = + PayloadProgressInfoW::Status::kInProgress; + break; + case connections::PayloadProgressInfo::Status::kSuccess: + payload_progress_info_w.status = + PayloadProgressInfoW::Status::kSuccess; + break; + } + + ppcb(endpoint_id.c_str(), payload_progress_info_w); + }; +} + +PayloadListenerW::PayloadListenerW(PayloadListenerW &other) { + impl_ = std::move(other.impl_); +} + +PayloadListenerW::PayloadListenerW(PayloadListenerW &&other) noexcept { + impl_ = std::move(other.impl_); +} + +} // namespace windows +} // namespace nearby diff --git a/connections/clients/windows/listeners_w.h b/connections/clients/windows/listeners_w.h index 64fb04bd62..e0eb95552e 100644 --- a/connections/clients/windows/listeners_w.h +++ b/connections/clients/windows/listeners_w.h @@ -32,7 +32,7 @@ #include "connections/status.h" #include "internal/platform/payload_id.h" -namespace location::nearby { +namespace nearby { // Forward declarations namespace connections { struct ConnectionListener; @@ -61,7 +61,7 @@ struct PayloadProgressInfo; namespace windows { -using ::location::nearby::connections::Status; +using ::nearby::connections::Status; template T DefaultConstructor() { @@ -295,6 +295,6 @@ struct DLL_API PayloadListenerW { } // extern "C" } // namespace windows -} // namespace location::nearby +} // namespace nearby #endif // THIRD_PARTY_NEARBY_CONNECTIONS_CLIENTS_WINDOWS_LISTENERS_W_H_ diff --git a/connections/clients/windows/medium_selector_w.h b/connections/clients/windows/medium_selector_w.h index 8ae801ddff..e50c5946cb 100644 --- a/connections/clients/windows/medium_selector_w.h +++ b/connections/clients/windows/medium_selector_w.h @@ -16,7 +16,7 @@ #include "proto/connections_enums.pb.h" -namespace location::nearby::windows { +namespace nearby::windows { using MediumW = ::location::nearby::proto::connections::Medium; @@ -80,6 +80,6 @@ struct MediumSelectorW { // Feature On/Off switch for mediums. using BooleanMediumSelectorW = MediumSelectorW; -} // namespace location::nearby::windows +} // namespace nearby::windows #endif // THIRD_PARTY_NEARBY_CONNECTIONS_CLIENTS_WINDOWS_MEDIUM_SELECTOR_W_H_ diff --git a/connections/clients/windows/options_base_w.h b/connections/clients/windows/options_base_w.h index c3f31da5bf..28f8e5f392 100644 --- a/connections/clients/windows/options_base_w.h +++ b/connections/clients/windows/options_base_w.h @@ -1,34 +1,34 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -#ifndef THIRD_PARTY_NEARBY_CONNECTIONS_CLIENTS_WINDOWS_OPTIONS_BASE_W_H_ -#define THIRD_PARTY_NEARBY_CONNECTIONS_CLIENTS_WINDOWS_OPTIONS_BASE_W_H_ - -#include "connections/clients/windows/medium_selector_w.h" -#include "connections/clients/windows/strategy_w.h" - -namespace location::nearby::windows { - -extern "C" { - -// Connection Options: used for both Advertising and Discovery. -// All fields are mutable, to make the type copy-assignable. -struct OptionsBaseW { - location::nearby::windows::StrategyW strategy; - BooleanMediumSelectorW allowed{BooleanMediumSelectorW().SetAll(true)}; -}; - -} // extern "C" -} // namespace location::nearby::windows - -#endif // THIRD_PARTY_NEARBY_CONNECTIONS_CLIENTS_WINDOWS_OPTIONS_BASE_W_H_ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +#ifndef THIRD_PARTY_NEARBY_CONNECTIONS_CLIENTS_WINDOWS_OPTIONS_BASE_W_H_ +#define THIRD_PARTY_NEARBY_CONNECTIONS_CLIENTS_WINDOWS_OPTIONS_BASE_W_H_ + +#include "connections/clients/windows/medium_selector_w.h" +#include "connections/clients/windows/strategy_w.h" + +namespace nearby::windows { + +extern "C" { + +// Connection Options: used for both Advertising and Discovery. +// All fields are mutable, to make the type copy-assignable. +struct OptionsBaseW { + nearby::windows::StrategyW strategy; + BooleanMediumSelectorW allowed{BooleanMediumSelectorW().SetAll(true)}; +}; + +} // extern "C" +} // namespace nearby::windows + +#endif // THIRD_PARTY_NEARBY_CONNECTIONS_CLIENTS_WINDOWS_OPTIONS_BASE_W_H_ diff --git a/connections/clients/windows/out_of_band_connection_metadata_w.h b/connections/clients/windows/out_of_band_connection_metadata_w.h index d4e9c5588b..1cd4760109 100644 --- a/connections/clients/windows/out_of_band_connection_metadata_w.h +++ b/connections/clients/windows/out_of_band_connection_metadata_w.h @@ -1,58 +1,58 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -#ifndef THIRD_PARTY_NEARBY_CONNECTIONS_CLIENTS_WINDOWS_OUT_OF_BAND_CONNECTION_METADATA_H_ -#define THIRD_PARTY_NEARBY_CONNECTIONS_CLIENTS_WINDOWS_OUT_OF_BAND_CONNECTION_METADATA_H_ - -#include - -#include "connections/clients/windows/medium_selector_w.h" -#include "connections/clients/windows/strategy_w.h" -#include "internal/platform/byte_array.h" -#include "proto/connections_enums.pb.h" - -namespace location::nearby::windows { - -extern "C" { - -// Metadata injected to facilitate out-of-band connections. The medium field is -// required, and the other fields are only specified for a specific medium. -// Currently, Bluetooth is the only supported medium for out-of-band -// connections. -struct DLL_API OutOfBandConnectionMetadataW { - // Medium to use for the out-of-band connection. - MediumW medium; - - // Endpoint ID to use for the injected connection; will be included in the - // endpoint_found_cb callback. Must be exactly 4 bytes and should be randomly- - // generated such that no two IDs are identical. - const char* endpoint_id; - - // Endpoint info to use for the injected connection; will be included in the - // endpoint_found_cb callback. Should uniquely identify the InjectEndpoint() - // call so that the client which made the call can verify the endpoint - // that was found is the one that was injected. - // - // Cannot be empty, and must be <131 bytes. - const char* endpoint_info; - size_t endpoint_info_size; - - // Used for Bluetooth connections. - const char* remote_bluetooth_mac_address; - size_t remote_bluetooth_mac_address_size; -}; - -} // extern "C" -} // namespace location::nearby::windows - -#endif // THIRD_PARTY_NEARBY_CONNECTIONS_CLIENTS_WINDOWS_OUT_OF_BAND_CONNECTION_METADATA_H_ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +#ifndef THIRD_PARTY_NEARBY_CONNECTIONS_CLIENTS_WINDOWS_OUT_OF_BAND_CONNECTION_METADATA_H_ +#define THIRD_PARTY_NEARBY_CONNECTIONS_CLIENTS_WINDOWS_OUT_OF_BAND_CONNECTION_METADATA_H_ + +#include + +#include "connections/clients/windows/medium_selector_w.h" +#include "connections/clients/windows/strategy_w.h" +#include "internal/platform/byte_array.h" +#include "proto/connections_enums.pb.h" + +namespace nearby::windows { + +extern "C" { + +// Metadata injected to facilitate out-of-band connections. The medium field is +// required, and the other fields are only specified for a specific medium. +// Currently, Bluetooth is the only supported medium for out-of-band +// connections. +struct DLL_API OutOfBandConnectionMetadataW { + // Medium to use for the out-of-band connection. + MediumW medium; + + // Endpoint ID to use for the injected connection; will be included in the + // endpoint_found_cb callback. Must be exactly 4 bytes and should be randomly- + // generated such that no two IDs are identical. + const char* endpoint_id; + + // Endpoint info to use for the injected connection; will be included in the + // endpoint_found_cb callback. Should uniquely identify the InjectEndpoint() + // call so that the client which made the call can verify the endpoint + // that was found is the one that was injected. + // + // Cannot be empty, and must be <131 bytes. + const char* endpoint_info; + size_t endpoint_info_size; + + // Used for Bluetooth connections. + const char* remote_bluetooth_mac_address; + size_t remote_bluetooth_mac_address_size; +}; + +} // extern "C" +} // namespace nearby::windows + +#endif // THIRD_PARTY_NEARBY_CONNECTIONS_CLIENTS_WINDOWS_OUT_OF_BAND_CONNECTION_METADATA_H_ diff --git a/connections/clients/windows/params_w.h b/connections/clients/windows/params_w.h index 824a730dc7..eadfecb9f3 100644 --- a/connections/clients/windows/params_w.h +++ b/connections/clients/windows/params_w.h @@ -1,42 +1,42 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef THIRD_PARTY_NEARBY_CONNECTIONS_CLIENTS_WINDOWS_PARAMS_W_H_ -#define THIRD_PARTY_NEARBY_CONNECTIONS_CLIENTS_WINDOWS_PARAMS_W_H_ - -#include - -#include "connections/clients/windows/listeners_w.h" - -namespace location::nearby::windows { - -extern "C" { - -// Used by Discovery in Core::RequestConnection(). -// Used by Advertising in Core::StartAdvertising(). -struct DLL_API ConnectionRequestInfoW { - // endpoint_info - Identifying information about this endpoint (eg. name, - // device type). - // listener - A set of callbacks notified when remote endpoints request a - // connection to this endpoint. - // ByteArray endpoint_info; - const char* endpoint_info; - size_t endpoint_info_size; - ConnectionListenerW& listener; -}; - -} // extern "C" -} // namespace location::nearby::windows - -#endif // THIRD_PARTY_NEARBY_CONNECTIONS_CLIENTS_WINDOWS_PARAMS_W_H_ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef THIRD_PARTY_NEARBY_CONNECTIONS_CLIENTS_WINDOWS_PARAMS_W_H_ +#define THIRD_PARTY_NEARBY_CONNECTIONS_CLIENTS_WINDOWS_PARAMS_W_H_ + +#include + +#include "connections/clients/windows/listeners_w.h" + +namespace nearby::windows { + +extern "C" { + +// Used by Discovery in Core::RequestConnection(). +// Used by Advertising in Core::StartAdvertising(). +struct DLL_API ConnectionRequestInfoW { + // endpoint_info - Identifying information about this endpoint (eg. name, + // device type). + // listener - A set of callbacks notified when remote endpoints request a + // connection to this endpoint. + // ByteArray endpoint_info; + const char* endpoint_info; + size_t endpoint_info_size; + ConnectionListenerW& listener; +}; + +} // extern "C" +} // namespace nearby::windows + +#endif // THIRD_PARTY_NEARBY_CONNECTIONS_CLIENTS_WINDOWS_PARAMS_W_H_ diff --git a/connections/clients/windows/payload_w.cc b/connections/clients/windows/payload_w.cc index 7d3f801b8f..d99484e549 100644 --- a/connections/clients/windows/payload_w.cc +++ b/connections/clients/windows/payload_w.cc @@ -18,7 +18,7 @@ #include "internal/platform/byte_array.h" #include "internal/platform/payload_id.h" -namespace location::nearby { +namespace nearby { // Must implement Deleter since Payload wasn't fully defined in // the header namespace connections { @@ -129,4 +129,4 @@ PayloadW::GetImpl() { } } // namespace windows -} // namespace location::nearby +} // namespace nearby diff --git a/connections/clients/windows/payload_w.h b/connections/clients/windows/payload_w.h index 5b1a5cb200..95f2ecec0f 100644 --- a/connections/clients/windows/payload_w.h +++ b/connections/clients/windows/payload_w.h @@ -25,7 +25,6 @@ #include "connections/payload_type.h" #include "internal/platform/payload_id.h" -namespace location { namespace nearby { namespace connections { @@ -35,18 +34,14 @@ struct PayloadDeleter { }; } // namespace connections } // namespace nearby -} // namespace location -namespace location { namespace nearby { class InputFile; class InputStream; } // namespace nearby -} // namespace location -namespace location { namespace nearby { namespace windows { @@ -91,7 +86,7 @@ class DLL_API PayloadW { int64_t GetId() const; // Returns Payload type. - const location::nearby::connections::PayloadType GetType() const; + const nearby::connections::PayloadType GetType() const; // Sets the payload offset in bytes void SetOffset(size_t offset); @@ -114,6 +109,5 @@ class DLL_API PayloadW { } // namespace windows } // namespace nearby -} // namespace location #endif // THIRD_PARTY_NEARBY_CONNECTIONS_CLIENTS_WINDOWS_PAYLOAD_W_H_ diff --git a/connections/clients/windows/strategy_w.cc b/connections/clients/windows/strategy_w.cc index 6d27f89fc3..c61af8b03a 100644 --- a/connections/clients/windows/strategy_w.cc +++ b/connections/clients/windows/strategy_w.cc @@ -16,7 +16,7 @@ #include -namespace location::nearby::windows { +namespace nearby::windows { const StrategyW StrategyW::kNone = {StrategyW::ConnectionType::kNone, StrategyW::TopologyType::kUnknown}; @@ -76,4 +76,4 @@ bool operator!=(const StrategyW& lhs, const StrategyW& rhs) { return !(lhs == rhs); } -} // namespace location::nearby::windows +} // namespace nearby::windows diff --git a/connections/clients/windows/strategy_w.h b/connections/clients/windows/strategy_w.h index cb3c1eb23c..f6af57c24c 100644 --- a/connections/clients/windows/strategy_w.h +++ b/connections/clients/windows/strategy_w.h @@ -18,7 +18,7 @@ #include "connections/clients/windows/dll_config.h" -namespace location::nearby::windows { +namespace nearby::windows { // Defines a copyable, comparable connection strategy type. // It is one of: kP2pCluster, kP2pStar, kP2pPointToPoint. @@ -71,6 +71,6 @@ class DLL_API StrategyW { TopologyType topology_type_; }; -} // namespace location::nearby::windows +} // namespace nearby::windows #endif // THIRD_PARTY_NEARBY_CONNECTIONS_CLIENTS_WINDOWS_STRATEGY_W_H_ diff --git a/connections/connection_options.cc b/connections/connection_options.cc index 573bd50486..78af3479ee 100644 --- a/connections/connection_options.cc +++ b/connections/connection_options.cc @@ -16,7 +16,6 @@ #include -namespace location { namespace nearby { namespace connections { @@ -26,4 +25,3 @@ std::vector ConnectionOptions::GetMediums() const { } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/connection_options.h b/connections/connection_options.h index 2bdfd8925a..e2b382a0b3 100644 --- a/connections/connection_options.h +++ b/connections/connection_options.h @@ -20,7 +20,6 @@ #include "internal/platform/byte_array.h" #include "proto/connections_enums.pb.h" -namespace location { namespace nearby { namespace connections { @@ -32,7 +31,7 @@ struct ConnectionInfo { std::string bssid; std::int32_t ap_frequency = -1; std::string ip_address; - std::vector supported_mediums; + std::vector supported_mediums; std::int32_t keep_alive_interval_millis; std::int32_t keep_alive_timeout_millis; }; @@ -59,6 +58,5 @@ struct ConnectionOptions : public OptionsBase { } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_CONNECTION_OPTIONS_H_ diff --git a/connections/core.cc b/connections/core.cc index 80c1a7d4d5..253fa22a3c 100644 --- a/connections/core.cc +++ b/connections/core.cc @@ -25,7 +25,6 @@ #include "internal/platform/feature_flags.h" #include "internal/platform/logging.h" -namespace location { namespace nearby { namespace connections { @@ -177,4 +176,3 @@ std::string Core::Dump() { return client_.Dump(); } } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/core.h b/connections/core.h index a4ca60b20f..a444f65395 100644 --- a/connections/core.h +++ b/connections/core.h @@ -29,7 +29,6 @@ #include "internal/analytics/event_logger.h" #include "internal/device.h" -namespace location { namespace nearby { namespace connections { @@ -282,6 +281,5 @@ class Core { } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_CORE_H_ diff --git a/connections/core_test.cc b/connections/core_test.cc index 14ef007290..c3f2cc6696 100644 --- a/connections/core_test.cc +++ b/connections/core_test.cc @@ -21,7 +21,6 @@ #include "connections/implementation/mock_service_controller_router.h" #include "internal/platform/logging.h" -namespace location { namespace nearby { namespace connections { namespace { @@ -50,4 +49,3 @@ TEST(CoreTest, DestructorReportsFatalFailure) { } // namespace } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/device_provider.h b/connections/device_provider.h index 8d333b37bd..f46915ede7 100644 --- a/connections/device_provider.h +++ b/connections/device_provider.h @@ -19,11 +19,10 @@ #include "internal/device.h" -namespace location { namespace nearby { namespace connections { -using ::location::nearby::NearbyDevice; +using ::nearby::NearbyDevice; class NearbyDeviceProvider { virtual ~NearbyDeviceProvider() = default; @@ -33,6 +32,5 @@ class NearbyDeviceProvider { } // namespace connections } // namespace nearby -} // namespace location #endif // THIRD_PARTY_NEARBY_CONNECTIONS_DEVICE_PROVIDER_H_ diff --git a/connections/discovery_options.cc b/connections/discovery_options.cc index d2321afbf9..090f7b2df2 100644 --- a/connections/discovery_options.cc +++ b/connections/discovery_options.cc @@ -16,7 +16,6 @@ #include -namespace location { namespace nearby { namespace connections { @@ -49,4 +48,3 @@ DiscoveryOptions DiscoveryOptions::CompatibleOptions() const { } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/discovery_options.h b/connections/discovery_options.h index 18e8402d96..afda126c7e 100644 --- a/connections/discovery_options.h +++ b/connections/discovery_options.h @@ -22,7 +22,6 @@ #include "internal/platform/byte_array.h" #include "proto/connections_enums.pb.h" -namespace location { namespace nearby { namespace connections { @@ -52,6 +51,5 @@ struct DiscoveryOptions : OptionsBase { } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_DISCOVERY_OPTIONS_H_ diff --git a/connections/implementation/analytics/analytics_recorder.cc b/connections/implementation/analytics/analytics_recorder.cc index e96abd6efa..78956d4606 100644 --- a/connections/implementation/analytics/analytics_recorder.cc +++ b/connections/implementation/analytics/analytics_recorder.cc @@ -30,7 +30,6 @@ #include "internal/proto/analytics/connections_log.pb.h" #include "proto/connections_enums.pb.h" -namespace location { namespace nearby { namespace analytics { @@ -627,33 +626,35 @@ void AnalyticsRecorder::OnErrorCode(const ErrorCodeParams ¶ms) { error_code->set_common_error(params.common_error); } else { switch (params.event) { - case errorcode::proto::START_ADVERTISING: + case location::nearby::errorcode::proto::START_ADVERTISING: error_code->set_start_advertising_error(params.start_advertising_error); break; - case errorcode::proto::STOP_ADVERTISING: + case location::nearby::errorcode::proto::STOP_ADVERTISING: error_code->set_stop_advertising_error(params.stop_advertising_error); break; - case errorcode::proto::START_LISTENING_INCOMING_CONNECTION: + case location::nearby::errorcode::proto:: + START_LISTENING_INCOMING_CONNECTION: error_code->set_start_listening_incoming_connection_error( params.start_listening_incoming_connection_error); break; - case errorcode::proto::STOP_LISTENING_INCOMING_CONNECTION: + case location::nearby::errorcode::proto:: + STOP_LISTENING_INCOMING_CONNECTION: error_code->set_stop_listening_incoming_connection_error( params.stop_listening_incoming_connection_error); break; - case errorcode::proto::START_DISCOVERING: + case location::nearby::errorcode::proto::START_DISCOVERING: error_code->set_start_discovering_error(params.start_discovering_error); break; - case errorcode::proto::STOP_DISCOVERING: + case location::nearby::errorcode::proto::STOP_DISCOVERING: error_code->set_stop_discovering_error(params.stop_discovering_error); break; - case errorcode::proto::CONNECT: + case location::nearby::errorcode::proto::CONNECT: error_code->set_connect_error(params.connect_error); break; - case errorcode::proto::DISCONNECT: + case location::nearby::errorcode::proto::DISCONNECT: error_code->set_disconnect_error(params.disconnect_error); break; - case errorcode::proto::UNKNOWN_EVENT: + case location::nearby::errorcode::proto::UNKNOWN_EVENT: default: error_code->set_common_error(params.common_error); break; @@ -687,7 +688,7 @@ void AnalyticsRecorder::LogStartSession() { session_was_logged_ = false; if (CanRecordAnalyticsLocked(kOnStartClientSession)) { - client_session_ = std::make_unique(); + client_session_ = std::make_unique(); started_client_session_time_ = SystemClock::ElapsedRealtime(); start_client_session_was_logged_ = true; LogEvent(START_CLIENT_SESSION); @@ -1282,4 +1283,3 @@ AnalyticsRecorder::LogicalConnection::ResolvePendingPayloads( } // namespace analytics } // namespace nearby -} // namespace location diff --git a/connections/implementation/analytics/analytics_recorder.h b/connections/implementation/analytics/analytics_recorder.h index 1b4f4bf474..8418964d2f 100644 --- a/connections/implementation/analytics/analytics_recorder.h +++ b/connections/implementation/analytics/analytics_recorder.h @@ -31,7 +31,6 @@ #include "internal/proto/analytics/connections_log.pb.h" #include "proto/connections_enums.pb.h" -namespace location { namespace nearby { namespace analytics { @@ -190,7 +189,7 @@ class AnalyticsRecorder { void AddChunk(std::int64_t chunk_size_bytes); - proto::ConnectionsLog::Payload GetProtoPayload( + location::nearby::analytics::proto::ConnectionsLog::Payload GetProtoPayload( location::nearby::proto::connections::PayloadStatus status); location::nearby::proto::connections::PayloadType type() const { @@ -249,23 +248,26 @@ class AnalyticsRecorder { std::int64_t payload_id, location::nearby::proto::connections::PayloadStatus status); - std::vector + std::vector GetEstablisedConnections(); private: void FinishPhysicalConnection( - proto::ConnectionsLog::EstablishedConnection *established_connection, + location::nearby::analytics::proto::ConnectionsLog:: + EstablishedConnection *established_connection, location::nearby::proto::connections::DisconnectionReason reason); - std::vector ResolvePendingPayloads( + std::vector + ResolvePendingPayloads( absl::btree_map> &pending_payloads, location::nearby::proto::connections::DisconnectionReason reason); location::nearby::proto::connections::Medium current_medium_ = location::nearby::proto::connections::UNKNOWN_MEDIUM; - absl::btree_map< - location::nearby::proto::connections::Medium, - std::unique_ptr> + absl::btree_map> physical_connections_; absl::btree_map> incoming_payloads_; @@ -293,14 +295,14 @@ class AnalyticsRecorder { ABSL_SHARED_LOCKS_REQUIRED(mutex_); void FinishDiscoveryPhaseLocked() ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex_); bool UpdateAdvertiserConnectionRequestLocked( - proto::ConnectionsLog::ConnectionRequest *request) - ABSL_SHARED_LOCKS_REQUIRED(mutex_); + location::nearby::analytics::proto::ConnectionsLog::ConnectionRequest + *request) ABSL_SHARED_LOCKS_REQUIRED(mutex_); bool UpdateDiscovererConnectionRequestLocked( - proto::ConnectionsLog::ConnectionRequest *request) - ABSL_SHARED_LOCKS_REQUIRED(mutex_); + location::nearby::analytics::proto::ConnectionsLog::ConnectionRequest + *request) ABSL_SHARED_LOCKS_REQUIRED(mutex_); bool BothEndpointsRespondedLocked( - proto::ConnectionsLog::ConnectionRequest *request) - ABSL_SHARED_LOCKS_REQUIRED(mutex_); + location::nearby::analytics::proto::ConnectionsLog::ConnectionRequest + *request) ABSL_SHARED_LOCKS_REQUIRED(mutex_); void LocalEndpointRespondedLocked( const std::string &remote_endpoint_id, location::nearby::proto::connections::ConnectionRequestResponse response) @@ -310,8 +312,8 @@ class AnalyticsRecorder { location::nearby::proto::connections::ConnectionRequestResponse response) ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex_); void MarkConnectionRequestIgnoredLocked( - proto::ConnectionsLog::ConnectionRequest *request) - ABSL_SHARED_LOCKS_REQUIRED(mutex_); + location::nearby::analytics::proto::ConnectionsLog::ConnectionRequest + *request) ABSL_SHARED_LOCKS_REQUIRED(mutex_); void FinishUpgradeAttemptLocked( const std::string &endpoint_id, location::nearby::proto::connections::BandwidthUpgradeResult result, @@ -338,7 +340,9 @@ class AnalyticsRecorder { Mutex mutex_; // ClientSession - std::unique_ptr client_session_; + std::unique_ptr< + location::nearby::analytics::proto::ConnectionsLog::ClientSession> + client_session_; absl::Time started_client_session_time_; bool session_was_logged_ ABSL_GUARDED_BY(mutex_) = false; bool start_client_session_was_logged_ ABSL_GUARDED_BY(mutex_) = false; @@ -346,36 +350,40 @@ class AnalyticsRecorder { // Current StrategySession connections::Strategy current_strategy_ ABSL_GUARDED_BY(mutex_) = connections::Strategy::kNone; - std::unique_ptr + std::unique_ptr< + location::nearby::analytics::proto::ConnectionsLog::StrategySession> current_strategy_session_ ABSL_GUARDED_BY(mutex_); absl::Time started_strategy_session_time_ ABSL_GUARDED_BY(mutex_); // Current AdvertisingPhase - std::unique_ptr + std::unique_ptr< + location::nearby::analytics::proto::ConnectionsLog::AdvertisingPhase> current_advertising_phase_; absl::Time started_advertising_phase_time_; // Current DiscoveryPhase - std::unique_ptr + std::unique_ptr< + location::nearby::analytics::proto::ConnectionsLog::DiscoveryPhase> current_discovery_phase_; absl::Time started_discovery_phase_time_; absl::btree_map> + std::unique_ptr> incoming_connection_requests_ ABSL_GUARDED_BY(mutex_); absl::btree_map> + std::unique_ptr> outgoing_connection_requests_ ABSL_GUARDED_BY(mutex_); absl::btree_map> active_connections_ ABSL_GUARDED_BY(mutex_); - absl::btree_map< - std::string, - std::unique_ptr> + absl::btree_map> bandwidth_upgrade_attempts_ ABSL_GUARDED_BY(mutex_); }; } // namespace analytics } // namespace nearby -} // namespace location #endif // ANALYTICS_ANALYTICS_RECORDER_H_ diff --git a/connections/implementation/analytics/analytics_recorder_test.cc b/connections/implementation/analytics/analytics_recorder_test.cc index 6101c9b23b..4c9f0c6560 100644 --- a/connections/implementation/analytics/analytics_recorder_test.cc +++ b/connections/implementation/analytics/analytics_recorder_test.cc @@ -30,7 +30,6 @@ #include "internal/proto/analytics/connections_log.pb.h" #include "proto/connections_enums.pb.h" -namespace location { namespace nearby { namespace analytics { namespace { @@ -85,7 +84,7 @@ class FakeEventLogger : public EventLogger { start_client_session_done_latch_ptr) {} void Log(const ::google::protobuf::MessageLite& message) override { - auto connections_log = dynamic_cast(&message); + auto connections_log = dynamic_cast(&message); if (connections_log == nullptr) { return; } @@ -1742,4 +1741,3 @@ TEST(AnalyticsRecorderTest, } // namespace } // namespace analytics } // namespace nearby -} // namespace location diff --git a/connections/implementation/analytics/connection_attempt_metadata_params.h b/connections/implementation/analytics/connection_attempt_metadata_params.h index d1650da525..e1e0714608 100644 --- a/connections/implementation/analytics/connection_attempt_metadata_params.h +++ b/connections/implementation/analytics/connection_attempt_metadata_params.h @@ -19,7 +19,6 @@ #include "proto/connections_enums.pb.h" -namespace location { namespace nearby { // A struct to construct ConnectionAttemptMetadata for the analytics recorder. @@ -41,6 +40,5 @@ struct ConnectionAttemptMetadataParams { }; } // namespace nearby -} // namespace location #endif // ANALYTICS_CONNECTION_ATTEMPT_METADATA_PARAMS_H_ diff --git a/connections/implementation/analytics/packet_meta_data.h b/connections/implementation/analytics/packet_meta_data.h index a8c183b413..e45021f863 100644 --- a/connections/implementation/analytics/packet_meta_data.h +++ b/connections/implementation/analytics/packet_meta_data.h @@ -21,7 +21,6 @@ #include "absl/time/time.h" #include "internal/platform/system_clock.h" -namespace location { namespace nearby { namespace analytics { @@ -99,6 +98,5 @@ struct PacketMetaData { } // namespace analytics } // namespace nearby -} // namespace location #endif // NEARBY_CONNECTIONS_IMPLEMENTATION_ANALYTICS_PACKET_META_DATA_H_ diff --git a/connections/implementation/analytics/throughput_recorder.cc b/connections/implementation/analytics/throughput_recorder.cc index 3a9cda1a2f..0f8fd2189a 100644 --- a/connections/implementation/analytics/throughput_recorder.cc +++ b/connections/implementation/analytics/throughput_recorder.cc @@ -19,7 +19,7 @@ #include "internal/platform/logging.h" #include "internal/platform/mutex_lock.h" -namespace location { + namespace nearby { namespace analytics { @@ -169,8 +169,8 @@ bool ThroughputRecorder::Throughput::dump() { (payload_direction_ == PayloadDirection::INCOMING_PAYLOAD) ? "Received" : "Sent", ToString(payload_type_), total_byte_size_, - proto::connections::Medium_Name(medium_), total_millis, throughpu_mbps, - throughput_kbps, file_io_time_, + location::nearby::proto::connections::Medium_Name(medium_), total_millis, + throughpu_mbps, throughput_kbps, file_io_time_, (payload_direction_ == PayloadDirection::INCOMING_PAYLOAD) ? "Decryption" : "Encryption", encryption_time_, socket_io_time_, other); @@ -321,4 +321,3 @@ int ThroughputRecorderContainer::GetSize() { } // namespace analytics } // namespace nearby -} // namespace location diff --git a/connections/implementation/analytics/throughput_recorder.h b/connections/implementation/analytics/throughput_recorder.h index ec038dba94..3deaa811b1 100644 --- a/connections/implementation/analytics/throughput_recorder.h +++ b/connections/implementation/analytics/throughput_recorder.h @@ -25,15 +25,14 @@ #include "internal/platform/mutex.h" #include "proto/connections_enums.pb.h" -namespace location { namespace nearby { namespace analytics { // The following aliases are only for users' convenience. using ::location::nearby::proto::connections::Medium; -using ::location::nearby::connections::PayloadType; +using ::nearby::connections::PayloadType; // Enum to represent if a payload is incoming or outgoing. -using ::location::nearby::connections::PayloadDirection; +using ::nearby::connections::PayloadDirection; class ThroughputRecorder { public: @@ -139,6 +138,5 @@ class ThroughputRecorderContainer { } // namespace analytics } // namespace nearby -} // namespace location #endif // NEARBY_CONNECTIONS_IMPLEMENTATION_ANALYTICS_THROUGHPUT_RECORDER_H_ diff --git a/connections/implementation/analytics/throughput_recorder_test.cc b/connections/implementation/analytics/throughput_recorder_test.cc index 1a5da288f8..6416972307 100644 --- a/connections/implementation/analytics/throughput_recorder_test.cc +++ b/connections/implementation/analytics/throughput_recorder_test.cc @@ -21,7 +21,6 @@ #include "internal/platform/logging.h" #include "proto/connections_enums.proto.h" -namespace location { namespace nearby { namespace analytics { namespace { @@ -83,11 +82,15 @@ TEST_F(ThroughputRecorderTest, OnFrameSentSaveTransferredSize) { PacketMetaData packet_meta_data; packet_meta_data.SetPacketSize(kFrameSize); - TPRecorder->OnFrameSent(proto::connections::BLE, packet_meta_data); - TPRecorder->OnFrameSent(proto::connections::BLE, packet_meta_data); - TPRecorder->OnFrameSent(proto::connections::BLE, packet_meta_data); - - auto throughput = TPRecorder->GetThroughput(proto::connections::BLE, 0); + TPRecorder->OnFrameSent(location::nearby::proto::connections::BLE, + packet_meta_data); + TPRecorder->OnFrameSent(location::nearby::proto::connections::BLE, + packet_meta_data); + TPRecorder->OnFrameSent(location::nearby::proto::connections::BLE, + packet_meta_data); + + auto throughput = + TPRecorder->GetThroughput(location::nearby::proto::connections::BLE, 0); EXPECT_EQ(throughput.GetTotalByteSize(), kFrameSize * 3); } @@ -97,11 +100,13 @@ TEST_F(ThroughputRecorderTest, OnIgnoreUnkownPaylaodType) { TPRecorder->Start(PayloadType::kUnknown, PayloadDirection::OUTGOING_PAYLOAD); PacketMetaData packet_meta_data; - TPRecorder->OnFrameSent(proto::connections::BLE, packet_meta_data); + TPRecorder->OnFrameSent(location::nearby::proto::connections::BLE, + packet_meta_data); EXPECT_EQ(TPRecorder->GetThroughputsSize(), 0); TPRecorder->Start(PayloadType::kUnknown, PayloadDirection::INCOMING_PAYLOAD); - TPRecorder->OnFrameReceived(proto::connections::BLE, packet_meta_data); + TPRecorder->OnFrameReceived(location::nearby::proto::connections::BLE, + packet_meta_data); EXPECT_EQ(TPRecorder->GetThroughputsSize(), 0); } @@ -121,7 +126,8 @@ TEST_P(ThroughputRecorderTest, OnFrameSentStopAndDump) { packet_meta_data.StartSocketIo(); absl::SleepFor(absl::Milliseconds(7)); packet_meta_data.StopSocketIo(); - TPRecorder->OnFrameSent(proto::connections::BLE, packet_meta_data); + TPRecorder->OnFrameSent(location::nearby::proto::connections::BLE, + packet_meta_data); EXPECT_EQ(TPRecorder->GetDurationMillis(), packet_meta_data.GetEncryptionTimeInMillis() + packet_meta_data.GetFileIoTimeInMillis() + @@ -137,7 +143,8 @@ TEST_P(ThroughputRecorderTest, OnFrameSentStopAndDump) { packet_meta_data.StartSocketIo(); absl::SleepFor(absl::Milliseconds(17)); packet_meta_data.StopSocketIo(); - TPRecorder->OnFrameSent(proto::connections::BLE, packet_meta_data); + TPRecorder->OnFrameSent(location::nearby::proto::connections::BLE, + packet_meta_data); if (GetParam() == true) { NEARBY_LOGS(INFO) << "MarkAsSuccess"; @@ -163,7 +170,8 @@ TEST_F(ThroughputRecorderTest, OnFrameSentStopAndDumpForMultiMeadium) { packet_meta_data1.StartSocketIo(); absl::SleepFor(absl::Milliseconds(7)); packet_meta_data1.StopSocketIo(); - TPRecorder->OnFrameSent(proto::connections::BLE, packet_meta_data1); + TPRecorder->OnFrameSent(location::nearby::proto::connections::BLE, + packet_meta_data1); PacketMetaData packet_meta_data2; packet_meta_data2.SetPacketSize(kFrameSize); @@ -176,7 +184,8 @@ TEST_F(ThroughputRecorderTest, OnFrameSentStopAndDumpForMultiMeadium) { packet_meta_data2.StartSocketIo(); absl::SleepFor(absl::Milliseconds(17)); packet_meta_data2.StopSocketIo(); - TPRecorder->OnFrameSent(proto::connections::WIFI_LAN, packet_meta_data2); + TPRecorder->OnFrameSent(location::nearby::proto::connections::WIFI_LAN, + packet_meta_data2); TPRecorder->MarkAsSuccess(); EXPECT_TRUE(TPRecorder->Stop()); @@ -199,7 +208,8 @@ TEST_F(ThroughputRecorderTest, OnFrameReceivedCheckDurationMillis) { packet_meta_data.StartSocketIo(); absl::SleepFor(absl::Milliseconds(7)); packet_meta_data.StopSocketIo(); - TPRecorder->OnFrameReceived(proto::connections::BLE, packet_meta_data); + TPRecorder->OnFrameReceived(location::nearby::proto::connections::BLE, + packet_meta_data); EXPECT_EQ(TPRecorder->GetDurationMillis(), packet_meta_data.GetEncryptionTimeInMillis() + packet_meta_data.GetFileIoTimeInMillis() + @@ -209,11 +219,11 @@ TEST_F(ThroughputRecorderTest, OnFrameReceivedCheckDurationMillis) { TEST_F(ThroughputRecorderTest, OnTPRecorderNotStarted) { auto TPRecorder = tp_recorder_container_.GetTPRecorder( kPayloadIdA, PayloadDirection::OUTGOING_PAYLOAD); - auto throughput = TPRecorder->GetThroughput(proto::connections::BLE, 0); + auto throughput = + TPRecorder->GetThroughput(location::nearby::proto::connections::BLE, 0); EXPECT_FALSE(throughput.dump()); } } // namespace } // namespace analytics } // namespace nearby -} // namespace location diff --git a/connections/implementation/base_bwu_handler.cc b/connections/implementation/base_bwu_handler.cc index f1162fa5b8..c652dfbf00 100644 --- a/connections/implementation/base_bwu_handler.cc +++ b/connections/implementation/base_bwu_handler.cc @@ -20,7 +20,6 @@ #include "connections/implementation/service_id_constants.h" #include "internal/platform/logging.h" -namespace location { namespace nearby { namespace connections { @@ -81,4 +80,3 @@ void BaseBwuHandler::RevertResponderState(const std::string& service_id) { } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/base_bwu_handler.h b/connections/implementation/base_bwu_handler.h index 39c710728c..a6d936250c 100644 --- a/connections/implementation/base_bwu_handler.h +++ b/connections/implementation/base_bwu_handler.h @@ -23,7 +23,6 @@ #include "connections/implementation/bwu_handler.h" #include "connections/implementation/endpoint_channel_manager.h" -namespace location { namespace nearby { namespace connections { @@ -68,6 +67,5 @@ class BaseBwuHandler : public BwuHandler { } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_BASE_BWU_HANDLER_H_ diff --git a/connections/implementation/base_bwu_handler_test.cc b/connections/implementation/base_bwu_handler_test.cc index 991bd5245d..d04cff92fd 100644 --- a/connections/implementation/base_bwu_handler_test.cc +++ b/connections/implementation/base_bwu_handler_test.cc @@ -20,7 +20,6 @@ #include "absl/strings/string_view.h" #include "connections/implementation/service_id_constants.h" -namespace location { namespace nearby { namespace connections { namespace { @@ -226,4 +225,3 @@ TEST(BaseBwuHandlerTest, Revert_Failure_CantFindEndpoint) { } // namespace } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/base_endpoint_channel.cc b/connections/implementation/base_endpoint_channel.cc index 1538b925b3..4aaf3589a6 100644 --- a/connections/implementation/base_endpoint_channel.cc +++ b/connections/implementation/base_endpoint_channel.cc @@ -27,7 +27,6 @@ #include "internal/platform/mutex.h" #include "internal/platform/mutex_lock.h" -namespace location { namespace nearby { namespace connections { @@ -103,16 +102,19 @@ BaseEndpointChannel::BaseEndpointChannel(const std::string& service_id, // derived medium sockets should dervied, and implement the supported // values and leave the default values in base #MediumSocket. /*ConnectionTechnology*/ - proto::connections::CONNECTION_TECHNOLOGY_UNKNOWN_TECHNOLOGY, - /*ConnectionBand*/ proto::connections::CONNECTION_BAND_UNKNOWN_BAND, + location::nearby::proto::connections:: + CONNECTION_TECHNOLOGY_UNKNOWN_TECHNOLOGY, + /*ConnectionBand*/ + location::nearby::proto::connections::CONNECTION_BAND_UNKNOWN_BAND, /*frequency*/ -1, /*try_count*/ 0) {} BaseEndpointChannel::BaseEndpointChannel( const std::string& service_id, const std::string& channel_name, InputStream* reader, OutputStream* writer, - proto::connections::ConnectionTechnology technology, - proto::connections::ConnectionBand band, int frequency, int try_count) + location::nearby::proto::connections::ConnectionTechnology technology, + location::nearby::proto::connections::ConnectionBand band, int frequency, + int try_count) : service_id_(service_id), channel_name_(channel_name), reader_(reader), @@ -174,7 +176,8 @@ ExceptionOr BaseEndpointChannel::Read( result = {}; auto parsed = parser::FromBytes(ByteArray(input)); if (parsed.ok()) { - if (parser::GetFrameType(parsed.result()) == V1Frame::KEEP_ALIVE) { + if (parser::GetFrameType(parsed.result()) == + location::nearby::connections::V1Frame::KEEP_ALIVE) { NEARBY_LOGS(INFO) << __func__ << ": Read unencrypted KEEP_ALIVE on encrypted channel."; @@ -323,7 +326,7 @@ void BaseEndpointChannel::SetAnalyticsRecorder( } void BaseEndpointChannel::Close( - proto::connections::DisconnectionReason reason) { + location::nearby::proto::connections::DisconnectionReason reason) { NEARBY_LOGS(INFO) << __func__ << ": Closing endpoint channel, reason: " << reason; Close(); @@ -336,12 +339,14 @@ void BaseEndpointChannel::Close( std::string BaseEndpointChannel::GetType() const { MutexLock crypto_lock(&crypto_mutex_); std::string subtype = IsEncryptionEnabledLocked() ? "ENCRYPTED_" : ""; - std::string medium = proto::connections::Medium_Name( - proto::connections::Medium::UNKNOWN_MEDIUM); - - if (GetMedium() != proto::connections::Medium::UNKNOWN_MEDIUM) { - medium = - absl::StrCat(subtype, proto::connections::Medium_Name(GetMedium())); + std::string medium = location::nearby::proto::connections::Medium_Name( + location::nearby::proto::connections::Medium::UNKNOWN_MEDIUM); + + if (GetMedium() != + location::nearby::proto::connections::Medium::UNKNOWN_MEDIUM) { + medium = absl::StrCat( + subtype, + location::nearby::proto::connections::Medium_Name(GetMedium())); } return medium; } @@ -392,13 +397,14 @@ absl::Time BaseEndpointChannel::GetLastWriteTimestamp() const { return last_write_timestamp_; } -proto::connections::ConnectionTechnology BaseEndpointChannel::GetTechnology() - const { +location::nearby::proto::connections::ConnectionTechnology +BaseEndpointChannel::GetTechnology() const { return technology_; } // Returns the used wifi band of this EndpointChannel. -proto::connections::ConnectionBand BaseEndpointChannel::GetBand() const { +location::nearby::proto::connections::ConnectionBand +BaseEndpointChannel::GetBand() const { return band_; } @@ -434,4 +440,3 @@ void BaseEndpointChannel::UnblockPausedWriter() { } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/base_endpoint_channel.h b/connections/implementation/base_endpoint_channel.h index c9e2c9e92f..18df11e2e0 100644 --- a/connections/implementation/base_endpoint_channel.h +++ b/connections/implementation/base_endpoint_channel.h @@ -28,7 +28,6 @@ #include "internal/platform/mutex.h" #include "internal/platform/output_stream.h" -namespace location { namespace nearby { namespace connections { @@ -39,12 +38,12 @@ class BaseEndpointChannel : public EndpointChannel { BaseEndpointChannel(const std::string& service_id, const std::string& channel_name, InputStream* reader, OutputStream* writer); - BaseEndpointChannel(const std::string& service_id, - const std::string& channel_name, InputStream* reader, - OutputStream* writer, - proto::connections::ConnectionTechnology, - proto::connections::ConnectionBand band, int frequency, - int try_count); + BaseEndpointChannel( + const std::string& service_id, const std::string& channel_name, + InputStream* reader, OutputStream* writer, + location::nearby::proto::connections::ConnectionTechnology, + location::nearby::proto::connections::ConnectionBand band, int frequency, + int try_count); ~BaseEndpointChannel() override = default; // EndpointChannel: @@ -56,12 +55,14 @@ class BaseEndpointChannel : public EndpointChannel { Exception Write(const ByteArray& data, PacketMetaData& packet_meta_data) ABSL_LOCKS_EXCLUDED(writer_mutex_, crypto_mutex_) override; void Close() ABSL_LOCKS_EXCLUDED(is_paused_mutex_) override; - void Close(proto::connections::DisconnectionReason reason) override; + void Close(location::nearby::proto::connections::DisconnectionReason reason) + override; std::string GetType() const override; std::string GetServiceId() const override; std::string GetName() const override; - proto::connections::ConnectionTechnology GetTechnology() const override; - proto::connections::ConnectionBand GetBand() const override; + location::nearby::proto::connections::ConnectionTechnology GetTechnology() + const override; + location::nearby::proto::connections::ConnectionBand GetBand() const override; int GetFrequency() const override; int GetTryCount() const override; int GetMaxTransmitPacketSize() const override; @@ -127,8 +128,8 @@ class BaseEndpointChannel : public EndpointChannel { bool is_paused_ ABSL_GUARDED_BY(is_paused_mutex_) = false; // The medium technology information of this endpoint channel. - proto::connections::ConnectionTechnology technology_; - proto::connections::ConnectionBand band_; + location::nearby::proto::connections::ConnectionTechnology technology_; + location::nearby::proto::connections::ConnectionBand band_; int frequency_; int try_count_; @@ -138,6 +139,5 @@ class BaseEndpointChannel : public EndpointChannel { } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_BASE_ENDPOINT_CHANNEL_H_ diff --git a/connections/implementation/base_endpoint_channel_test.cc b/connections/implementation/base_endpoint_channel_test.cc index dab8706822..da2b05ce2d 100644 --- a/connections/implementation/base_endpoint_channel_test.cc +++ b/connections/implementation/base_endpoint_channel_test.cc @@ -38,7 +38,6 @@ #include "internal/platform/single_thread_executor.h" #include "proto/connections_enums.pb.h" -namespace location { namespace nearby { namespace connections { namespace { @@ -407,4 +406,3 @@ TEST(BaseEndpointChannelTest, ReadUnencryptedFrameOnEncryptedChannel) { } // namespace } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/base_pcp_handler.cc b/connections/implementation/base_pcp_handler.cc index ab789067e5..70d168e636 100644 --- a/connections/implementation/base_pcp_handler.cc +++ b/connections/implementation/base_pcp_handler.cc @@ -39,10 +39,14 @@ #include "internal/platform/bluetooth_utils.h" #include "internal/platform/logging.h" -namespace location { namespace nearby { namespace connections { +using ::location::nearby::connections::ConnectionRequestFrame; +using ::location::nearby::connections::ConnectionResponseFrame; +using ::location::nearby::connections::MediumMetadata; +using ::location::nearby::connections::OfflineFrame; +using ::location::nearby::connections::V1Frame; using ::securegcm::UKey2Handshake; constexpr absl::Duration BasePcpHandler::kConnectionRequestReadTimeout; @@ -165,22 +169,32 @@ void BasePcpHandler::OptionsAllowed(const BooleanMediumSelector& allowed, std::ostringstream& result) const { result << "{ "; if (allowed.bluetooth) { - result << proto::connections::Medium_Name(Medium::BLUETOOTH) << " "; + result << location::nearby::proto::connections::Medium_Name( + Medium::BLUETOOTH) + << " "; } if (allowed.ble) { - result << proto::connections::Medium_Name(Medium::BLE) << " "; + result << location::nearby::proto::connections::Medium_Name(Medium::BLE) + << " "; } if (allowed.web_rtc) { - result << proto::connections::Medium_Name(Medium::WEB_RTC) << " "; + result << location::nearby::proto::connections::Medium_Name(Medium::WEB_RTC) + << " "; } if (allowed.wifi_lan) { - result << proto::connections::Medium_Name(Medium::WIFI_LAN) << " "; + result << location::nearby::proto::connections::Medium_Name( + Medium::WIFI_LAN) + << " "; } if (allowed.wifi_hotspot) { - result << proto::connections::Medium_Name(Medium::WIFI_HOTSPOT) << " "; + result << location::nearby::proto::connections::Medium_Name( + Medium::WIFI_HOTSPOT) + << " "; } if (allowed.wifi_direct) { - result << proto::connections::Medium_Name(Medium::WIFI_DIRECT) << " "; + result << location::nearby::proto::connections::Medium_Name( + Medium::WIFI_DIRECT) + << " "; } result << "}"; } @@ -203,12 +217,14 @@ BooleanMediumSelector BasePcpHandler::ComputeIntersectionOfSupportedMediums( for (auto medium : their_mediums) { NEARBY_LOGS(VERBOSE) << "Their supported medium name: " - << proto::connections::Medium_Name(medium); + << location::nearby::proto::connections::Medium_Name( + medium); } for (Medium my_medium : GetConnectionMediumsByPriority()) { NEARBY_LOGS(VERBOSE) << "Our supported medium name: " - << proto::connections::Medium_Name(my_medium); + << location::nearby::proto::connections::Medium_Name( + my_medium); if (std::find(their_mediums.begin(), their_mediums.end(), my_medium) != their_mediums.end()) { // We use advertising options as a proxy to whether or not the local @@ -355,7 +371,8 @@ EncryptionRunner::ResultListener BasePcpHandler::GetResultListener() { NEARBY_LOGS(ERROR) << "Encryption failed for endpoint_id=" << endpoint_id << " on medium=" - << proto::connections::Medium_Name(channel->GetMedium()); + << location::nearby::proto::connections::Medium_Name( + channel->GetMedium()); OnEncryptionFailureRunnable(endpoint_id, channel); }); }, @@ -633,7 +650,7 @@ Status BasePcpHandler::RequestConnection( } bool BasePcpHandler::MediumSupportedByClientOptions( - const proto::connections::Medium& medium, + const location::nearby::proto::connections::Medium& medium, const ConnectionOptions& connection_options) const { for (auto supported_medium : connection_options.GetMediums()) { if (medium == supported_medium) { @@ -645,10 +662,11 @@ bool BasePcpHandler::MediumSupportedByClientOptions( // Get ordered supported connection medium based on local advertising/discovery // option. -std::vector +std::vector BasePcpHandler::GetSupportedConnectionMediumsByPriority( const ConnectionOptions& local_connection_option) { - std::vector supported_mediums_by_priority; + std::vector + supported_mediums_by_priority; for (auto medium_by_priority : GetConnectionMediumsByPriority()) { if (MediumSupportedByClientOptions(medium_by_priority, local_connection_option)) { @@ -685,7 +703,7 @@ BasePcpHandler::GetDiscoveredEndpoints(const std::string& endpoint_id) { std::vector BasePcpHandler::GetDiscoveredEndpoints( - const proto::connections::Medium medium) { + const location::nearby::proto::connections::Medium medium) { std::vector result; for (const auto& item : discovered_endpoints_) { if (item.second->medium == medium) { @@ -898,11 +916,10 @@ Status BasePcpHandler::RejectConnection(ClientProxy* client, client->GetClientId(), &response); } -void BasePcpHandler::OnIncomingFrame(OfflineFrame& frame, - const std::string& endpoint_id, - ClientProxy* client, - proto::connections::Medium medium, - PacketMetaData& packet_meta_data) { +void BasePcpHandler::OnIncomingFrame( + OfflineFrame& frame, const std::string& endpoint_id, ClientProxy* client, + location::nearby::proto::connections::Medium medium, + PacketMetaData& packet_meta_data) { CountDownLatch latch(1); RunOnPcpHandlerThread( "incoming-frame", @@ -1056,7 +1073,7 @@ void BasePcpHandler::OnEndpointLost( bool BasePcpHandler::IsPreferred( const BasePcpHandler::DiscoveredEndpoint& new_endpoint, const BasePcpHandler::DiscoveredEndpoint& old_endpoint) { - std::vector mediums = + std::vector mediums = GetConnectionMediumsByPriority(); // Make sure the comparator is irreflexive, so we have a strict weak ordering. if (new_endpoint.medium != old_endpoint.medium) { @@ -1089,7 +1106,7 @@ bool BasePcpHandler::IsPreferred( Exception BasePcpHandler::OnIncomingConnection( ClientProxy* client, const ByteArray& remote_endpoint_info, std::unique_ptr channel, - proto::connections::Medium medium) { + location::nearby::proto::connections::Medium medium) { absl::Time start_time = SystemClock::ElapsedRealtime(); // Fixes an NPE in ClientProxy.OnConnectionAccepted. The crash happened when @@ -1097,7 +1114,7 @@ Exception BasePcpHandler::OnIncomingConnection( // incoming connection where we attempted to check that state. if (!client->IsAdvertising()) { NEARBY_LOGS(WARNING) << "Ignoring incoming connection on medium " - << proto::connections::Medium_Name( + << location::nearby::proto::connections::Medium_Name( channel->GetMedium()) << " because client=" << client->GetClientId() << " is no longer advertising."; @@ -1126,13 +1143,15 @@ Exception BasePcpHandler::OnIncomingConnection( const ConnectionRequestFrame& connection_request = frame.v1().connection_request(); NEARBY_LOGS(INFO) << "In onIncomingConnection(" - << proto::connections::Medium_Name(channel->GetMedium()) + << location::nearby::proto::connections::Medium_Name( + channel->GetMedium()) << ") for client=" << client->GetClientId() << ", read ConnectionRequestFrame from endpoint(id=" << connection_request.endpoint_id() << ")"; if (client->IsConnectedToEndpoint(connection_request.endpoint_id())) { NEARBY_LOGS(ERROR) << "Incoming connection on medium " - << proto::connections::Medium_Name(channel->GetMedium()) + << location::nearby::proto::connections::Medium_Name( + channel->GetMedium()) << " was denied because we're " "already connected to endpoint(id=" << connection_request.endpoint_id() << ")."; @@ -1243,7 +1262,8 @@ bool BasePcpHandler::BreakTie(ClientProxy* client, NEARBY_LOGS(INFO) << "In onIncomingConnection(" - << proto::connections::Medium_Name(endpoint_channel->GetMedium()) + << location::nearby::proto::connections::Medium_Name( + endpoint_channel->GetMedium()) << ") for client=" << client->GetClientId() << ", found a collision with endpoint " << endpoint_id << ". We've already sent a connection request to them with nonce " @@ -1257,7 +1277,7 @@ bool BasePcpHandler::BreakTie(ClientProxy* client, endpoint_channel->Close(); NEARBY_LOGS(INFO) << "In onIncomingConnection(" - << proto::connections::Medium_Name( + << location::nearby::proto::connections::Medium_Name( endpoint_channel->GetMedium()) << ") for client=" << client->GetClientId() << ", cleaned up the collision with endpoint " @@ -1269,7 +1289,8 @@ bool BasePcpHandler::BreakTie(ClientProxy* client, ProcessTieBreakLoss(client, endpoint_id, &info); NEARBY_LOGS(INFO) << "In onIncomingConnection(" - << proto::connections::Medium_Name(endpoint_channel->GetMedium()) + << location::nearby::proto::connections::Medium_Name( + endpoint_channel->GetMedium()) << ") for client=" << client->GetClientId() << ", cleaned up the collision with endpoint " << endpoint_id << " by closing our channel and notifying our client of the failure."; @@ -1282,7 +1303,8 @@ bool BasePcpHandler::BreakTie(ClientProxy* client, NEARBY_LOGS(INFO) << "In onIncomingConnection(" - << proto::connections::Medium_Name(endpoint_channel->GetMedium()) + << location::nearby::proto::connections::Medium_Name( + endpoint_channel->GetMedium()) << ") for client=" << client->GetClientId() << ", cleaned up the collision with endpoint " << endpoint_id << " by closing both channels. Our nonces were identical, so we " @@ -1318,7 +1340,8 @@ bool BasePcpHandler::AppendRemoteBluetoothMacAddressEndpoint( } auto endpoint = it.first->second.get(); for (auto item = it.first; item != it.second; item++) { - if (item->second->medium == proto::connections::Medium::BLUETOOTH) { + if (item->second->medium == + location::nearby::proto::connections::Medium::BLUETOOTH) { NEARBY_LOGS(INFO) << "Cannot append remote Bluetooth MAC Address endpoint, because " "the endpoint has already been found over Bluetooth [" @@ -1340,7 +1363,8 @@ bool BasePcpHandler::AppendRemoteBluetoothMacAddressEndpoint( auto bluetooth_endpoint = std::make_shared(BluetoothEndpoint{ {endpoint_id, endpoint->endpoint_info, endpoint->service_id, - proto::connections::Medium::BLUETOOTH, WebRtcState::kUnconnectable}, + location::nearby::proto::connections::Medium::BLUETOOTH, + WebRtcState::kUnconnectable}, remote_bluetooth_device, }); @@ -1369,7 +1393,8 @@ bool BasePcpHandler::AppendWebRTCEndpoint( auto webrtc_endpoint = std::make_shared(WebRtcEndpoint{ {endpoint_id, endpoint->endpoint_info, endpoint->service_id, - proto::connections::Medium::WEB_RTC, WebRtcState::kConnectable}, + location::nearby::proto::connections::Medium::WEB_RTC, + WebRtcState::kConnectable}, CreatePeerIdFromAdvertisement(endpoint->service_id, endpoint->endpoint_id, endpoint->endpoint_info), }); @@ -1470,7 +1495,8 @@ void BasePcpHandler::EvaluateConnectionResult(ClientProxy* client, client->OnBandwidthChanged(endpoint_id, medium); NEARBY_LOGS(INFO) << "Connection accepted on Medium:" - << proto::connections::Medium_Name(medium); + << location::nearby::proto::connections::Medium_Name( + medium); // Kick off the bandwidth upgrade for incoming connections. if (connection_info.is_incoming && @@ -1517,8 +1543,7 @@ ExceptionOr BasePcpHandler::ReadConnectionRequestFrame( std::string BasePcpHandler::GetHashedConnectionToken( const ByteArray& token_bytes) { auto token = std::string(token_bytes); - return location::nearby::Base64Utils::Encode( - Utils::Sha256Hash(token, token.size())) + return nearby::Base64Utils::Encode(Utils::Sha256Hash(token, token.size())) .substr(0, kConnectionTokenLength); } @@ -1526,9 +1551,10 @@ void BasePcpHandler::LogConnectionAttemptFailure( ClientProxy* client, Medium medium, const std::string& endpoint_id, bool is_incoming, absl::Time start_time, EndpointChannel* endpoint_channel) { - proto::connections::ConnectionAttemptResult result = - Cancelled(client, endpoint_id) ? proto::connections::RESULT_CANCELLED - : proto::connections::RESULT_ERROR; + location::nearby::proto::connections::ConnectionAttemptResult result = + Cancelled(client, endpoint_id) + ? location::nearby::proto::connections::RESULT_CANCELLED + : location::nearby::proto::connections::RESULT_ERROR; std::unique_ptr connections_attempt_metadata_params; if (endpoint_channel != nullptr) { @@ -1539,13 +1565,13 @@ void BasePcpHandler::LogConnectionAttemptFailure( } if (is_incoming) { client->GetAnalyticsRecorder().OnIncomingConnectionAttempt( - proto::connections::INITIAL, medium, result, + location::nearby::proto::connections::INITIAL, medium, result, SystemClock::ElapsedRealtime() - start_time, /* connection_token= */ "", connections_attempt_metadata_params.get()); } else { client->GetAnalyticsRecorder().OnOutgoingConnectionAttempt( - endpoint_id, proto::connections::INITIAL, medium, result, - SystemClock::ElapsedRealtime() - start_time, + endpoint_id, location::nearby::proto::connections::INITIAL, medium, + result, SystemClock::ElapsedRealtime() - start_time, /* connection_token= */ "", connections_attempt_metadata_params.get()); } } @@ -1571,16 +1597,17 @@ void BasePcpHandler::LogConnectionAttemptSuccess( } if (connection_info.is_incoming) { connection_info.client->GetAnalyticsRecorder().OnIncomingConnectionAttempt( - proto::connections::INITIAL, connection_info.channel->GetMedium(), - proto::connections::RESULT_SUCCESS, + location::nearby::proto::connections::INITIAL, + connection_info.channel->GetMedium(), + location::nearby::proto::connections::RESULT_SUCCESS, SystemClock::ElapsedRealtime() - connection_info.start_time, connection_info.connection_token, connections_attempt_metadata_params.get()); } else { connection_info.client->GetAnalyticsRecorder().OnOutgoingConnectionAttempt( - endpoint_id, proto::connections::INITIAL, + endpoint_id, location::nearby::proto::connections::INITIAL, connection_info.channel->GetMedium(), - proto::connections::RESULT_SUCCESS, + location::nearby::proto::connections::RESULT_SUCCESS, SystemClock::ElapsedRealtime() - connection_info.start_time, connection_info.connection_token, connections_attempt_metadata_params.get()); @@ -1611,7 +1638,8 @@ BasePcpHandler::PendingConnectionInfo::~PendingConnectionInfo() { } if (channel != nullptr) { - channel->Close(proto::connections::DisconnectionReason::SHUTDOWN); + channel->Close( + location::nearby::proto::connections::DisconnectionReason::SHUTDOWN); } // Destroy crypto context now; for some reason, crypto context destructor @@ -1631,4 +1659,3 @@ void BasePcpHandler::PendingConnectionInfo::LocalEndpointRejectedConnection( } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/base_pcp_handler.h b/connections/implementation/base_pcp_handler.h index 9eb442fd3d..100cacf641 100644 --- a/connections/implementation/base_pcp_handler.h +++ b/connections/implementation/base_pcp_handler.h @@ -48,7 +48,6 @@ #include "internal/platform/scheduled_executor.h" #include "internal/platform/single_thread_executor.h" -namespace location { namespace nearby { namespace connections { @@ -132,9 +131,9 @@ class BasePcpHandler : public PcpHandler, const std::string& endpoint_id) override; // @EndpointManagerReaderThread - void OnIncomingFrame(OfflineFrame& frame, const std::string& endpoint_id, - ClientProxy* client, - proto::connections::Medium medium, + void OnIncomingFrame(location::nearby::connections::OfflineFrame& frame, + const std::string& endpoint_id, ClientProxy* client, + location::nearby::proto::connections::Medium medium, analytics::PacketMetaData& packet_meta_data) override; // Called when an endpoint disconnects while we're waiting for both sides to @@ -154,7 +153,7 @@ class BasePcpHandler : public PcpHandler, Status status; // If success, the mediums on which we are now advertising/discovering, for // analytics. - std::vector mediums; + std::vector mediums; }; // Represents an endpoint that we've discovered. Typically, the implementation @@ -174,7 +173,7 @@ class BasePcpHandler : public PcpHandler, struct DiscoveredEndpoint { DiscoveredEndpoint(std::string endpoint_id, ByteArray endpoint_info, std::string service_id, - proto::connections::Medium medium, + location::nearby::proto::connections::Medium medium, WebRtcState web_rtc_state) : endpoint_id(std::move(endpoint_id)), endpoint_info(std::move(endpoint_info)), @@ -186,7 +185,7 @@ class BasePcpHandler : public PcpHandler, std::string endpoint_id; ByteArray endpoint_info; std::string service_id; - proto::connections::Medium medium; + location::nearby::proto::connections::Medium medium; WebRtcState web_rtc_state; }; @@ -231,8 +230,8 @@ class BasePcpHandler : public PcpHandler, }; struct ConnectImplResult { - proto::connections::Medium medium = - proto::connections::Medium::UNKNOWN_MEDIUM; + location::nearby::proto::connections::Medium medium = + location::nearby::proto::connections::Medium::UNKNOWN_MEDIUM; Status status = {Status::kError}; std::unique_ptr endpoint_channel; }; @@ -252,7 +251,8 @@ class BasePcpHandler : public PcpHandler, Exception OnIncomingConnection( ClientProxy* client, const ByteArray& remote_endpoint_info, std::unique_ptr endpoint_channel, - proto::connections::Medium medium); // throws Exception::IO + location::nearby::proto::connections::Medium + medium); // throws Exception::IO virtual bool HasOutgoingConnections(ClientProxy* client) const; virtual bool HasIncomingConnections(ClientProxy* client) const; @@ -287,9 +287,10 @@ class BasePcpHandler : public PcpHandler, DiscoveredEndpoint* endpoint) RUN_ON_PCP_HANDLER_THREAD() = 0; - virtual std::vector + virtual std::vector GetConnectionMediumsByPriority() = 0; - virtual proto::connections::Medium GetDefaultUpgradeMedium() = 0; + virtual location::nearby::proto::connections::Medium + GetDefaultUpgradeMedium() = 0; // Returns the first discovered endpoint for the given endpoint_id. DiscoveredEndpoint* GetDiscoveredEndpoint(const std::string& endpoint_id); @@ -301,7 +302,7 @@ class BasePcpHandler : public PcpHandler, // Returns a vector of discovered endpoints that share a given Medium. std::vector GetDiscoveredEndpoints( - const proto::connections::Medium medium); + const location::nearby::proto::connections::Medium medium); mediums::WebrtcPeerId CreatePeerIdFromAdvertisement( const string& service_id, const string& endpoint_id, @@ -352,7 +353,7 @@ class BasePcpHandler : public PcpHandler, std::weak_ptr> result; // Only (possibly) vector for incoming connections. - std::vector supported_mediums; + std::vector supported_mediums; // Keep track of a channel before we pass it to EndpointChannelManager. std::unique_ptr channel; @@ -455,8 +456,8 @@ class BasePcpHandler : public PcpHandler, const std::string& endpoint_id, bool can_close_immediately); - ExceptionOr ReadConnectionRequestFrame( - EndpointChannel* channel); + ExceptionOr + ReadConnectionRequestFrame(EndpointChannel* channel); // Returns an 8 characters length hashed string generated via a token byte // array. @@ -480,9 +481,9 @@ class BasePcpHandler : public PcpHandler, Status WaitForResult(const std::string& method_name, std::int64_t client_id, Future* future); bool MediumSupportedByClientOptions( - const proto::connections::Medium& medium, + const location::nearby::proto::connections::Medium& medium, const ConnectionOptions& connection_options) const; - std::vector + std::vector GetSupportedConnectionMediumsByPriority( const ConnectionOptions& local_connection_option); std::string GetStringValueOfSupportedMediums( @@ -540,6 +541,5 @@ class BasePcpHandler : public PcpHandler, } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_BASE_PCP_HANDLER_H_ diff --git a/connections/implementation/base_pcp_handler_test.cc b/connections/implementation/base_pcp_handler_test.cc index 18c5590230..25ccec74b8 100644 --- a/connections/implementation/base_pcp_handler_test.cc +++ b/connections/implementation/base_pcp_handler_test.cc @@ -37,7 +37,6 @@ #include "internal/platform/pipe.h" #include "proto/connections_enums.pb.h" -namespace location { namespace nearby { namespace connections { namespace { @@ -102,7 +101,8 @@ class MockEndpointChannel : public BaseEndpointChannel { MOCK_METHOD(ExceptionOr, Read, (), (override)); MOCK_METHOD(Exception, Write, (const ByteArray& data), (override)); MOCK_METHOD(void, CloseImpl, (), (override)); - MOCK_METHOD(proto::connections::Medium, GetMedium, (), (const override)); + MOCK_METHOD(location::nearby::proto::connections::Medium, GetMedium, (), + (const override)); MOCK_METHOD(std::string, GetType, (), (const override)); MOCK_METHOD(std::string, GetName, (), (const override)); MOCK_METHOD(bool, IsPaused, (), (const override)); @@ -157,14 +157,16 @@ class MockPcpHandler : public BasePcpHandler { (override)); MOCK_METHOD(ConnectImplResult, ConnectImpl, (ClientProxy * client, DiscoveredEndpoint* endpoint), (override)); - MOCK_METHOD(proto::connections::Medium, GetDefaultUpgradeMedium, (), - (override)); - - std::vector GetConnectionMediumsByPriority() - override { - return std::vector{ - proto::connections::WIFI_LAN, proto::connections::WEB_RTC, - proto::connections::BLUETOOTH, proto::connections::BLE}; + MOCK_METHOD(location::nearby::proto::connections::Medium, + GetDefaultUpgradeMedium, (), (override)); + + std::vector + GetConnectionMediumsByPriority() override { + return std::vector{ + location::nearby::proto::connections::WIFI_LAN, + location::nearby::proto::connections::WEB_RTC, + location::nearby::proto::connections::BLUETOOTH, + location::nearby::proto::connections::BLE}; } // Mock adapters for protected non-virtual methods of a base class. @@ -182,14 +184,14 @@ class MockPcpHandler : public BasePcpHandler { return BasePcpHandler::GetDiscoveredEndpoints(endpoint_id); } - std::vector GetDiscoveryMediums( + std::vector GetDiscoveryMediums( ClientProxy* client) { auto allowed = client->GetDiscoveryOptions().CompatibleOptions().allowed; return GetMediumsFromSelector(allowed); } - std::vector GetMediumsFromSelector( - BooleanMediumSelector allowed) { + std::vector + GetMediumsFromSelector(BooleanMediumSelector allowed) { return allowed.GetMediums(true); } }; @@ -302,8 +304,9 @@ class BasePcpHandlerTest std::pair, std::unique_ptr> - SetupConnection(Pipe& pipe_a, Pipe& pipe_b, - proto::connections::Medium medium) { // NOLINT + SetupConnection( + Pipe& pipe_a, Pipe& pipe_b, + location::nearby::proto::connections::Medium medium) { // NOLINT auto channel_a = std::make_unique(&pipe_b, &pipe_a); auto channel_b = std::make_unique(&pipe_a, &pipe_b); // On initiator (A) side, we drop the first write, since this is a @@ -338,13 +341,14 @@ class BasePcpHandlerTest return std::make_pair(std::move(channel_a), std::move(channel_b)); } - void RequestConnection(const std::string& endpoint_id, - std::unique_ptr channel_a, - MockEndpointChannel* channel_b, ClientProxy* client, - MockPcpHandler* pcp_handler, - proto::connections::Medium connect_medium, - std::atomic_int* flag = nullptr, - Status expected_result = {Status::kSuccess}) { + void RequestConnection( + const std::string& endpoint_id, + std::unique_ptr channel_a, + MockEndpointChannel* channel_b, ClientProxy* client, + MockPcpHandler* pcp_handler, + location::nearby::proto::connections::Medium connect_medium, + std::atomic_int* flag = nullptr, + Status expected_result = {Status::kSuccess}) { ConnectionRequestInfo info{ .endpoint_info = ByteArray{"ABCD"}, .listener = connection_listener_, @@ -811,4 +815,3 @@ TEST_F(BasePcpHandlerTest, InjectEndpoint) { } // namespace } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/ble_advertisement.cc b/connections/implementation/ble_advertisement.cc index 794effd069..08861b4d11 100644 --- a/connections/implementation/ble_advertisement.cc +++ b/connections/implementation/ble_advertisement.cc @@ -21,7 +21,6 @@ #include "internal/platform/base_input_stream.h" #include "internal/platform/logging.h" -namespace location { namespace nearby { namespace connections { @@ -275,4 +274,3 @@ BleAdvertisement::operator ByteArray() const { } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/ble_advertisement.h b/connections/implementation/ble_advertisement.h index 579e5af8d4..6ba4cd5b7f 100644 --- a/connections/implementation/ble_advertisement.h +++ b/connections/implementation/ble_advertisement.h @@ -20,7 +20,6 @@ #include "internal/platform/bluetooth_utils.h" #include "internal/platform/byte_array.h" -namespace location { namespace nearby { namespace connections { @@ -121,6 +120,5 @@ class BleAdvertisement { } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_BLE_ADVERTISEMENT_H_ diff --git a/connections/implementation/ble_advertisement_test.cc b/connections/implementation/ble_advertisement_test.cc index d7dcaafb47..d73df08c5d 100644 --- a/connections/implementation/ble_advertisement_test.cc +++ b/connections/implementation/ble_advertisement_test.cc @@ -17,7 +17,6 @@ #include "gtest/gtest.h" #include "connections/implementation/base_pcp_handler.h" -namespace location { namespace nearby { namespace connections { namespace { @@ -433,4 +432,3 @@ TEST(BleAdvertisementTest, } // namespace } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/ble_endpoint_channel.cc b/connections/implementation/ble_endpoint_channel.cc index 7d00301f31..0578bb197e 100644 --- a/connections/implementation/ble_endpoint_channel.cc +++ b/connections/implementation/ble_endpoint_channel.cc @@ -19,7 +19,6 @@ #include "internal/platform/ble.h" #include "internal/platform/logging.h" -namespace location { namespace nearby { namespace connections { @@ -45,8 +44,9 @@ BleEndpointChannel::BleEndpointChannel(const std::string& service_id, GetOutputStreamOrNull(socket)), ble_socket_(std::move(socket)) {} -proto::connections::Medium BleEndpointChannel::GetMedium() const { - return proto::connections::Medium::BLE; +location::nearby::proto::connections::Medium BleEndpointChannel::GetMedium() + const { + return location::nearby::proto::connections::Medium::BLE; } int BleEndpointChannel::GetMaxTransmitPacketSize() const { @@ -64,4 +64,3 @@ void BleEndpointChannel::CloseImpl() { } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/ble_endpoint_channel.h b/connections/implementation/ble_endpoint_channel.h index 6645165a2b..c1d972ab6f 100644 --- a/connections/implementation/ble_endpoint_channel.h +++ b/connections/implementation/ble_endpoint_channel.h @@ -20,7 +20,6 @@ #include "connections/implementation/base_endpoint_channel.h" #include "internal/platform/ble.h" -namespace location { namespace nearby { namespace connections { @@ -30,7 +29,7 @@ class BleEndpointChannel final : public BaseEndpointChannel { BleEndpointChannel(const std::string& service_id, const std::string& channel_name, BleSocket socket); - proto::connections::Medium GetMedium() const override; + location::nearby::proto::connections::Medium GetMedium() const override; int GetMaxTransmitPacketSize() const override; @@ -44,6 +43,5 @@ class BleEndpointChannel final : public BaseEndpointChannel { } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_BLE_ENDPOINT_CHANNEL_H_ diff --git a/connections/implementation/ble_v2_endpoint_channel.cc b/connections/implementation/ble_v2_endpoint_channel.cc index 16215ae486..1145a8afaf 100644 --- a/connections/implementation/ble_v2_endpoint_channel.cc +++ b/connections/implementation/ble_v2_endpoint_channel.cc @@ -20,7 +20,6 @@ #include "internal/platform/ble_v2.h" #include "internal/platform/logging.h" -namespace location { namespace nearby { namespace connections { @@ -50,8 +49,9 @@ BleV2EndpointChannel::BleV2EndpointChannel(const std::string& service_id, GetOutputStreamOrNull(socket)), ble_socket_(std::move(socket)) {} -proto::connections::Medium BleV2EndpointChannel::GetMedium() const { - return proto::connections::Medium::BLE; +location::nearby::proto::connections::Medium BleV2EndpointChannel::GetMedium() + const { + return location::nearby::proto::connections::Medium::BLE; } int BleV2EndpointChannel::GetMaxTransmitPacketSize() const { @@ -69,4 +69,3 @@ void BleV2EndpointChannel::CloseImpl() { } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/ble_v2_endpoint_channel.h b/connections/implementation/ble_v2_endpoint_channel.h index 8d7a05330b..f92cd10d79 100644 --- a/connections/implementation/ble_v2_endpoint_channel.h +++ b/connections/implementation/ble_v2_endpoint_channel.h @@ -20,7 +20,6 @@ #include "connections/implementation/base_endpoint_channel.h" #include "internal/platform/ble_v2.h" -namespace location { namespace nearby { namespace connections { @@ -30,7 +29,7 @@ class BleV2EndpointChannel final : public BaseEndpointChannel { BleV2EndpointChannel(const std::string& service_id, const std::string& channel_name, BleV2Socket socket); - proto::connections::Medium GetMedium() const override; + location::nearby::proto::connections::Medium GetMedium() const override; int GetMaxTransmitPacketSize() const override; @@ -44,6 +43,5 @@ class BleV2EndpointChannel final : public BaseEndpointChannel { } // namespace connections } // namespace nearby -} // namespace location #endif // CONNECTIONS_IMPLEMENTATION_BLE_V2_ENDPOINT_CHANNEL_H_ diff --git a/connections/implementation/bluetooth_bwu_handler.cc b/connections/implementation/bluetooth_bwu_handler.cc index 8886ad50f8..894740d056 100644 --- a/connections/implementation/bluetooth_bwu_handler.cc +++ b/connections/implementation/bluetooth_bwu_handler.cc @@ -25,7 +25,6 @@ // Manages the Bluetooth-specific methods needed to upgrade an {@link // EndpointChannel}. -namespace location { namespace nearby { namespace connections { @@ -159,4 +158,3 @@ void BluetoothBwuHandler::OnIncomingBluetoothConnection( } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/bluetooth_bwu_handler.h b/connections/implementation/bluetooth_bwu_handler.h index 998d37e2e2..2fa4d09b6a 100644 --- a/connections/implementation/bluetooth_bwu_handler.h +++ b/connections/implementation/bluetooth_bwu_handler.h @@ -24,7 +24,6 @@ #include "internal/platform/bluetooth_classic.h" #include "internal/platform/count_down_latch.h" -namespace location { namespace nearby { namespace connections { @@ -77,6 +76,5 @@ class BluetoothBwuHandler : public BaseBwuHandler { } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_BLUETOOTH_BWU_HANDLER_H_ diff --git a/connections/implementation/bluetooth_device_name.cc b/connections/implementation/bluetooth_device_name.cc index e20c05afb5..920fd3fdb4 100644 --- a/connections/implementation/bluetooth_device_name.cc +++ b/connections/implementation/bluetooth_device_name.cc @@ -25,7 +25,6 @@ #include "internal/platform/base_input_stream.h" #include "internal/platform/logging.h" -namespace location { namespace nearby { namespace connections { @@ -209,4 +208,3 @@ BluetoothDeviceName::operator std::string() const { } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/bluetooth_device_name.h b/connections/implementation/bluetooth_device_name.h index fe10956ba4..c55a1031b7 100644 --- a/connections/implementation/bluetooth_device_name.h +++ b/connections/implementation/bluetooth_device_name.h @@ -22,7 +22,6 @@ #include "connections/implementation/pcp.h" #include "internal/platform/byte_array.h" -namespace location { namespace nearby { namespace connections { @@ -88,6 +87,5 @@ class BluetoothDeviceName { } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_BLUETOOTH_DEVICE_NAME_H_ diff --git a/connections/implementation/bluetooth_device_name_test.cc b/connections/implementation/bluetooth_device_name_test.cc index 4419451e3a..f339d170bb 100644 --- a/connections/implementation/bluetooth_device_name_test.cc +++ b/connections/implementation/bluetooth_device_name_test.cc @@ -20,7 +20,6 @@ #include "gtest/gtest.h" #include "internal/platform/base64_utils.h" -namespace location { namespace nearby { namespace connections { namespace { @@ -204,4 +203,3 @@ TEST(BluetoothDeviceNameTest, CanParseGeneratedName) { } // namespace } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/bluetooth_endpoint_channel.cc b/connections/implementation/bluetooth_endpoint_channel.cc index 5b2bfdd47b..04278cf96b 100644 --- a/connections/implementation/bluetooth_endpoint_channel.cc +++ b/connections/implementation/bluetooth_endpoint_channel.cc @@ -19,7 +19,6 @@ #include "internal/platform/bluetooth_classic.h" #include "internal/platform/logging.h" -namespace location { namespace nearby { namespace connections { @@ -45,8 +44,9 @@ BluetoothEndpointChannel::BluetoothEndpointChannel( GetOutputStreamOrNull(socket)), bluetooth_socket_(std::move(socket)) {} -proto::connections::Medium BluetoothEndpointChannel::GetMedium() const { - return proto::connections::Medium::BLUETOOTH; +location::nearby::proto::connections::Medium +BluetoothEndpointChannel::GetMedium() const { + return location::nearby::proto::connections::Medium::BLUETOOTH; } int BluetoothEndpointChannel::GetMaxTransmitPacketSize() const { @@ -64,4 +64,3 @@ void BluetoothEndpointChannel::CloseImpl() { } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/bluetooth_endpoint_channel.h b/connections/implementation/bluetooth_endpoint_channel.h index d78dee2342..3c44d71a85 100644 --- a/connections/implementation/bluetooth_endpoint_channel.h +++ b/connections/implementation/bluetooth_endpoint_channel.h @@ -20,7 +20,6 @@ #include "connections/implementation/base_endpoint_channel.h" #include "internal/platform/bluetooth_classic.h" -namespace location { namespace nearby { namespace connections { @@ -31,7 +30,7 @@ class BluetoothEndpointChannel final : public BaseEndpointChannel { const std::string& channel_name, BluetoothSocket bluetooth_socket); - proto::connections::Medium GetMedium() const override; + location::nearby::proto::connections::Medium GetMedium() const override; int GetMaxTransmitPacketSize() const override; @@ -45,6 +44,5 @@ class BluetoothEndpointChannel final : public BaseEndpointChannel { } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_BLUETOOTH_ENDPOINT_CHANNEL_H_ diff --git a/connections/implementation/bwu_handler.h b/connections/implementation/bwu_handler.h index 201e5d811d..d8ab4750bd 100644 --- a/connections/implementation/bwu_handler.h +++ b/connections/implementation/bwu_handler.h @@ -23,11 +23,11 @@ #include "connections/implementation/offline_frames.h" #include "internal/platform/count_down_latch.h" -namespace location { namespace nearby { namespace connections { -using BwuNegotiationFrame = BandwidthUpgradeNegotiationFrame; +using BwuNegotiationFrame = + location::nearby::connections::BandwidthUpgradeNegotiationFrame; // Defines the set of methods that need to be implemented to handle the // per-Medium-specific operations needed to upgrade an EndpointChannel. @@ -98,6 +98,5 @@ class BwuHandler { } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_BWU_HANDLER_H_ diff --git a/connections/implementation/bwu_manager.cc b/connections/implementation/bwu_manager.cc index d653dda44e..e8a21016db 100644 --- a/connections/implementation/bwu_manager.cc +++ b/connections/implementation/bwu_manager.cc @@ -39,10 +39,12 @@ #include "internal/platform/feature_flags.h" #include "internal/platform/logging.h" -namespace location { namespace nearby { namespace connections { +using ::location::nearby::connections::BandwidthUpgradeNegotiationFrame; +using ::location::nearby::connections::OfflineFrame; +using ::location::nearby::connections::V1Frame; using ::location::nearby::proto::connections::DisconnectionReason; // Required for C++ 14 support in Chrome @@ -187,7 +189,8 @@ void BwuManager::InitiateBwuForEndpoint(ClientProxy* client, proposed_medium]() { NEARBY_LOGS(INFO) << "InitiateBwuForEndpoint for endpoint " << endpoint_id << " with medium " - << proto::connections::Medium_Name(proposed_medium); + << location::nearby::proto::connections::Medium_Name( + proposed_medium); if (channel_manager_->isWifiLanConnected() && (proposed_medium == Medium::WIFI_HOTSPOT)) { @@ -225,15 +228,16 @@ void BwuManager::InitiateBwuForEndpoint(ClientProxy* client, channel ? channel->GetMedium() : Medium::UNKNOWN_MEDIUM; client->GetAnalyticsRecorder().OnBandwidthUpgradeStarted( endpoint_id, channel_medium, proposed_medium, - proto::connections::INCOMING, client->GetConnectionToken(endpoint_id)); + location::nearby::proto::connections::INCOMING, + client->GetConnectionToken(endpoint_id)); if (channel == nullptr) { NEARBY_LOGS(INFO) << "BwuManager couldn't complete the upgrade for endpoint " << endpoint_id << " because it couldn't find an existing EndpointChannel for it."; client->GetAnalyticsRecorder().OnBandwidthUpgradeError( - endpoint_id, proto::connections::CHANNEL_ERROR, - proto::connections::NETWORK_AVAILABLE); + endpoint_id, location::nearby::proto::connections::CHANNEL_ERROR, + location::nearby::proto::connections::NETWORK_AVAILABLE); return; } @@ -249,7 +253,8 @@ void BwuManager::InitiateBwuForEndpoint(ClientProxy* client, NEARBY_LOGS(INFO) << "BwuManager ignoring the upgrade for endpoint " << endpoint_id << " because it is already connected over medium " - << proto::connections::Medium_Name(proposed_medium); + << location::nearby::proto::connections::Medium_Name( + proposed_medium); return; } @@ -263,7 +268,7 @@ void BwuManager::InitiateBwuForEndpoint(ClientProxy* client, NEARBY_LOGS(ERROR) << "BwuManager couldn't complete the upgrade for endpoint " << endpoint_id << " to medium " - << proto::connections::Medium_Name(proposed_medium) + << location::nearby::proto::connections::Medium_Name(proposed_medium) << " because it failed to initialize the " "BWU_NEGOTIATION.UPGRADE_PATH_AVAILABLE OfflineFrame."; UpgradePathInfo info; @@ -271,15 +276,15 @@ void BwuManager::InitiateBwuForEndpoint(ClientProxy* client, ProcessUpgradeFailureEvent(client, endpoint_id, info); client->GetAnalyticsRecorder().OnBandwidthUpgradeError( - endpoint_id, proto::connections::RESULT_IO_ERROR, - proto::connections::NETWORK_AVAILABLE); + endpoint_id, location::nearby::proto::connections::RESULT_IO_ERROR, + location::nearby::proto::connections::NETWORK_AVAILABLE); return; } if (!channel->Write(bytes).Ok()) { NEARBY_LOGS(ERROR) << "BwuManager couldn't complete the upgrade for endpoint " << endpoint_id << " to medium " - << proto::connections::Medium_Name(proposed_medium) + << location::nearby::proto::connections::Medium_Name(proposed_medium) << " because it failed to write the " "BWU_NEGOTIATION.UPGRADE_PATH_AVAILABLE OfflineFrame."; return; @@ -290,7 +295,7 @@ void BwuManager::InitiateBwuForEndpoint(ClientProxy* client, "BWU_NEGOTIATION.UPGRADE_PATH_AVAILABLE OfflineFrame while " "upgrading endpoint " << endpoint_id << " to medium " - << proto::connections::Medium_Name(proposed_medium); + << location::nearby::proto::connections::Medium_Name(proposed_medium); in_progress_upgrades_.emplace(endpoint_id, client); }); } @@ -306,8 +311,9 @@ void BwuManager::OnIncomingFrame(OfflineFrame& frame, NEARBY_LOGS(INFO) << "OnIncomingFrame: bwu_frame=" << BandwidthUpgradeNegotiationFrame::EventType_Name( bwu_frame.event_type()) - << ", endpoint_id=" << endpoint_id - << ", medium=" << proto::connections::Medium_Name(medium); + << ", endpoint_id=" << endpoint_id << ", medium=" + << location::nearby::proto::connections::Medium_Name( + medium); if (FeatureFlags::GetInstance().GetFlags().enable_async_bandwidth_upgrade) { RunOnBwuManagerThread( "bwu-on-incoming-frame", [this, client, endpoint_id, bwu_frame]() { @@ -370,7 +376,8 @@ void BwuManager::RevertBwuMediumForEndpoint(const std::string& service_id, // approach and revert the handler for _all_ endpoints. if (!FeatureFlags::GetInstance().GetFlags().support_multiple_bwu_mediums) { NEARBY_LOGS(INFO) << "Reverting medium " - << proto::connections::Medium_Name(medium) + << location::nearby::proto::connections::Medium_Name( + medium) << " for all endpoints for service " << service_id; medium_ = Medium::UNKNOWN_MEDIUM; BwuHandler* handler = GetHandlerForMedium(medium); @@ -381,7 +388,7 @@ void BwuManager::RevertBwuMediumForEndpoint(const std::string& service_id, } NEARBY_LOGS(INFO) << "Reverting medium " - << proto::connections::Medium_Name(medium) + << location::nearby::proto::connections::Medium_Name(medium) << " for service ID " << service_id << " and endpoint " << endpoint_id; endpoint_id_to_bwu_medium_.erase(endpoint_id); @@ -389,7 +396,8 @@ void BwuManager::RevertBwuMediumForEndpoint(const std::string& service_id, BwuHandler* handler = GetHandlerForMedium(medium); if (!handler) { NEARBY_LOGS(INFO) << "No BWU handler can be found for " - << proto::connections::Medium_Name(medium); + << location::nearby::proto::connections::Medium_Name( + medium); return; } // If |service_id| isn't of the INITIATOR-upgrade format--for example, if this @@ -492,8 +500,8 @@ void BwuManager::OnIncomingConnection( "socket."; connection->socket->Close(); AttemptToRecordBandwidthUpgradeErrorForUnknownEndpoint( - proto::connections::MEDIUM_ERROR, - proto::connections::SOCKET_CREATION); + location::nearby::proto::connections::MEDIUM_ERROR, + location::nearby::proto::connections::SOCKET_CREATION); return; } @@ -553,8 +561,8 @@ void BwuManager::OnIncomingConnection( channel->GetFrequency(), channel->GetTryCount()); } client->GetAnalyticsRecorder().OnIncomingConnectionAttempt( - proto::connections::UPGRADE, channel->GetMedium(), - proto::connections::RESULT_SUCCESS, + location::nearby::proto::connections::UPGRADE, channel->GetMedium(), + location::nearby::proto::connections::RESULT_SUCCESS, SystemClock::ElapsedRealtime() - connection_attempt_start_time, client->GetConnectionToken(endpoint_id), connections_attempt_metadata_params.get()); @@ -582,7 +590,7 @@ void BwuManager::RunUpgradeProtocol( std::unique_ptr new_channel, bool enable_encryption) { NEARBY_LOGS(INFO) << "RunUpgradeProtocol new channel @" << new_channel.get() << " name: " << new_channel->GetName() << ", medium: " - << proto::connections::Medium_Name( + << location::nearby::proto::connections::Medium_Name( new_channel->GetMedium()); // First, register this new EndpointChannel as *the* EndpointChannel to use // for this endpoint here onwards. NOTE: We pause this new EndpointChannel @@ -601,8 +609,8 @@ void BwuManager::RunUpgradeProtocol( << " when registering the new EndpointChannel, short-circuiting the " "upgrade protocol."; client->GetAnalyticsRecorder().OnBandwidthUpgradeError( - endpoint_id, proto::connections::CHANNEL_ERROR, - proto::connections::PRIOR_ENDPOINT_CHANNEL); + endpoint_id, location::nearby::proto::connections::CHANNEL_ERROR, + location::nearby::proto::connections::PRIOR_ENDPOINT_CHANNEL); return; } channel_manager_->ReplaceChannelForEndpoint( @@ -618,8 +626,8 @@ void BwuManager::RunUpgradeProtocol( "endpoint " << endpoint_id << ", short-circuiting the upgrade protocol."; client->GetAnalyticsRecorder().OnBandwidthUpgradeError( - endpoint_id, proto::connections::RESULT_IO_ERROR, - proto::connections::LAST_WRITE_TO_PRIOR_CHANNEL); + endpoint_id, location::nearby::proto::connections::RESULT_IO_ERROR, + location::nearby::proto::connections::LAST_WRITE_TO_PRIOR_CHANNEL); return; } NEARBY_LOGS(VERBOSE) << "BwuManager successfully wrote " @@ -649,7 +657,8 @@ void BwuManager::ProcessBwuPathAvailableEvent( parser::UpgradePathInfoMediumToMedium(upgrade_path_info.medium()); NEARBY_LOGS(INFO) << "ProcessBwuPathAvailableEvent for endpoint " << endpoint_id << " medium " - << proto::connections::Medium_Name(upgrade_medium); + << location::nearby::proto::connections::Medium_Name( + upgrade_medium); if (channel_manager_->isWifiLanConnected() && (upgrade_medium == Medium::WIFI_HOTSPOT)) { @@ -700,22 +709,27 @@ void BwuManager::ProcessBwuPathAvailableEvent( } client->GetAnalyticsRecorder().OnBandwidthUpgradeStarted( - endpoint_id, current_medium, upgrade_medium, proto::connections::OUTGOING, + endpoint_id, current_medium, upgrade_medium, + location::nearby::proto::connections::OUTGOING, client->GetConnectionToken(endpoint_id)); absl::Time connection_attempt_start_time = SystemClock::ElapsedRealtime(); auto channel = ProcessBwuPathAvailableEventInternal(client, endpoint_id, upgrade_path_info); - proto::connections::ConnectionAttemptResult connection_attempt_result; + location::nearby::proto::connections::ConnectionAttemptResult + connection_attempt_result; if (channel != nullptr) { - connection_attempt_result = proto::connections::RESULT_SUCCESS; + connection_attempt_result = + location::nearby::proto::connections::RESULT_SUCCESS; } else if (client->GetCancellationFlag(endpoint_id)->Cancelled()) { - connection_attempt_result = proto::connections::RESULT_CANCELLED; + connection_attempt_result = + location::nearby::proto::connections::RESULT_CANCELLED; client->GetAnalyticsRecorder().OnBandwidthUpgradeError( - endpoint_id, proto::connections::RESULT_REMOTE_ERROR, - proto::connections::UPGRADE_CANCEL); + endpoint_id, location::nearby::proto::connections::RESULT_REMOTE_ERROR, + location::nearby::proto::connections::UPGRADE_CANCEL); } else { - connection_attempt_result = proto::connections::RESULT_ERROR; + connection_attempt_result = + location::nearby::proto::connections::RESULT_ERROR; } std::unique_ptr @@ -727,8 +741,8 @@ void BwuManager::ProcessBwuPathAvailableEvent( channel->GetFrequency(), channel->GetTryCount()); } client->GetAnalyticsRecorder().OnOutgoingConnectionAttempt( - endpoint_id, proto::connections::UPGRADE, upgrade_medium, - connection_attempt_result, + endpoint_id, location::nearby::proto::connections::UPGRADE, + upgrade_medium, connection_attempt_result, SystemClock::ElapsedRealtime() - connection_attempt_start_time, client->GetConnectionToken(endpoint_id), connections_attempt_metadata_params.get()); @@ -753,7 +767,8 @@ BwuManager::ProcessBwuPathAvailableEventInternal( if (medium != GetBwuMediumForEndpoint(endpoint_id)) { NEARBY_LOGS(ERROR) << "ProcessBwuPathAvailableEventInternal failed for endpoint " - << endpoint_id << " medium " << proto::connections::Medium_Name(medium) + << endpoint_id << " medium " + << location::nearby::proto::connections::Medium_Name(medium) << ". Upgrade medium not yet set for endpoint."; return nullptr; } @@ -762,7 +777,8 @@ BwuManager::ProcessBwuPathAvailableEventInternal( if (!handler) { NEARBY_LOGS(ERROR) << "ProcessBwuPathAvailableEventInternal failed for endpoint " - << endpoint_id << " medium " << proto::connections::Medium_Name(medium) + << endpoint_id << " medium " + << location::nearby::proto::connections::Medium_Name(medium) << ". No handler for medium."; return nullptr; } @@ -770,7 +786,8 @@ BwuManager::ProcessBwuPathAvailableEventInternal( NEARBY_LOGS(INFO) << "ProcessBwuPathAvailableEventInternal for " "endpoint " << endpoint_id << " medium " - << proto::connections::Medium_Name(medium); + << location::nearby::proto::connections::Medium_Name( + medium); // Get service ID from the old channel. Don't keep the old channel's shared // pointer in scope longer than necessary. @@ -782,7 +799,7 @@ BwuManager::ProcessBwuPathAvailableEventInternal( NEARBY_LOGS(ERROR) << "ProcessBwuPathAvailableEventInternal failed for endpoint " << endpoint_id << " medium " - << proto::connections::Medium_Name(medium) + << location::nearby::proto::connections::Medium_Name(medium) << ". Old endpoint channel is missing."; return nullptr; } @@ -797,8 +814,8 @@ BwuManager::ProcessBwuPathAvailableEventInternal( "channel to endpoint" << endpoint_id << ", aborting upgrade."; client->GetAnalyticsRecorder().OnBandwidthUpgradeError( - endpoint_id, proto::connections::RESULT_IO_ERROR, - proto::connections::SOCKET_CREATION); + endpoint_id, location::nearby::proto::connections::RESULT_IO_ERROR, + location::nearby::proto::connections::SOCKET_CREATION); return nullptr; } @@ -818,8 +835,8 @@ BwuManager::ProcessBwuPathAvailableEventInternal( "OfflineFrame to newly-created EndpointChannel " << new_channel->GetName() << ", aborting upgrade."; client->GetAnalyticsRecorder().OnBandwidthUpgradeError( - endpoint_id, proto::connections::RESULT_IO_ERROR, - proto::connections::CLIENT_INTRODUCTION); + endpoint_id, location::nearby::proto::connections::RESULT_IO_ERROR, + location::nearby::proto::connections::CLIENT_INTRODUCTION); return {}; } @@ -854,7 +871,7 @@ void BwuManager::RunUpgradeFailedProtocol( const UpgradePathInfo& upgrade_path_info) { NEARBY_LOGS(INFO) << "RunUpgradeFailedProtocol for endpoint " << endpoint_id << " medium " - << proto::connections::Medium_Name( + << location::nearby::proto::connections::Medium_Name( parser::UpgradePathInfoMediumToMedium( upgrade_path_info.medium())); // We attempted to connect to the new medium that the remote device has set up @@ -869,8 +886,8 @@ void BwuManager::RunUpgradeFailedProtocol( << " when sending an upgrade failure frame, short-circuiting the " "upgrade protocol."; client->GetAnalyticsRecorder().OnBandwidthUpgradeError( - endpoint_id, proto::connections::CHANNEL_ERROR, - proto::connections::NETWORK_AVAILABLE); + endpoint_id, location::nearby::proto::connections::CHANNEL_ERROR, + location::nearby::proto::connections::NETWORK_AVAILABLE); return; } @@ -883,8 +900,8 @@ void BwuManager::RunUpgradeFailedProtocol( "OfflineFrame to endpoint " << endpoint_id << ", short-circuiting the upgrade protocol."; client->GetAnalyticsRecorder().OnBandwidthUpgradeError( - endpoint_id, proto::connections::RESULT_IO_ERROR, - proto::connections::NETWORK_AVAILABLE); + endpoint_id, location::nearby::proto::connections::RESULT_IO_ERROR, + location::nearby::proto::connections::NETWORK_AVAILABLE); return; } @@ -901,7 +918,8 @@ bool BwuManager::ReadClientIntroductionFrame(EndpointChannel* channel, ClientIntroduction& introduction) { NEARBY_LOGS(INFO) << "ReadClientIntroductionFrame with channel name: " << channel->GetName() << ", medium: " - << proto::connections::Medium_Name(channel->GetMedium()); + << location::nearby::proto::connections::Medium_Name( + channel->GetMedium()); CancelableAlarm timeout_alarm( "BwuManager::ReadClientIntroductionFrame", [channel]() { @@ -952,7 +970,8 @@ bool BwuManager::ReadClientIntroductionFrame(EndpointChannel* channel, bool BwuManager::ReadClientIntroductionAckFrame(EndpointChannel* channel) { NEARBY_LOGS(INFO) << "ReadClientIntroductionAckFrame with channel name: " << channel->GetName() << ", medium: " - << proto::connections::Medium_Name(channel->GetMedium()); + << location::nearby::proto::connections::Medium_Name( + channel->GetMedium()); CancelableAlarm timeout_alarm( "BwuManager::ReadClientIntroductionAckFrame", [channel]() { @@ -982,7 +1001,8 @@ bool BwuManager::ReadClientIntroductionAckFrame(EndpointChannel* channel) { bool BwuManager::WriteClientIntroductionAckFrame(EndpointChannel* channel) { NEARBY_LOGS(INFO) << "WriteClientIntroductionAckFrame channel name: " << channel->GetName() << ", medium: " - << proto::connections::Medium_Name(channel->GetMedium()); + << location::nearby::proto::connections::Medium_Name( + channel->GetMedium()); return channel->Write(parser::ForBwuIntroductionAck()).Ok(); } @@ -1011,7 +1031,7 @@ void BwuManager::ProcessLastWriteToPriorChannelEvent( NEARBY_LOGS(INFO) << "ProcessLastWriteToPriorChannelEvent: service_id=" << previous_endpoint_channel->GetServiceId() << ", endpoint_id=" << endpoint_id << ", medium=" - << proto::connections::Medium_Name( + << location::nearby::proto::connections::Medium_Name( previous_endpoint_channel->GetMedium()); if (!previous_endpoint_channel->Write(parser::ForBwuSafeToClose()).Ok()) { @@ -1026,8 +1046,8 @@ void BwuManager::ProcessLastWriteToPriorChannelEvent( << endpoint_id << ", short-circuiting the upgrade protocol."; client->GetAnalyticsRecorder().OnBandwidthUpgradeError( - endpoint_id, proto::connections::RESULT_IO_ERROR, - proto::connections::SAFE_TO_CLOSE_PRIOR_CHANNEL); + endpoint_id, location::nearby::proto::connections::RESULT_IO_ERROR, + location::nearby::proto::connections::SAFE_TO_CLOSE_PRIOR_CHANNEL); return; } NEARBY_LOGS(VERBOSE) << "BwuManager successfully wrote " @@ -1124,7 +1144,7 @@ void BwuManager::ProcessUpgradeFailureEvent( const UpgradePathInfo& upgrade_info) { NEARBY_LOGS(INFO) << "ProcessUpgradeFailureEvent for endpoint " << endpoint_id << " from medium: " - << proto::connections::Medium_Name( + << location::nearby::proto::connections::Medium_Name( parser::UpgradePathInfoMediumToMedium( upgrade_info.medium())); // The remote device failed to upgrade to the new medium we set up for them. @@ -1147,8 +1167,8 @@ void BwuManager::ProcessUpgradeFailureEvent( << " because we have other connected endpoints and can't try a new " "upgrade medium."; client->GetAnalyticsRecorder().OnBandwidthUpgradeError( - endpoint_id, proto::connections::CHANNEL_ERROR, - proto::connections::NETWORK_AVAILABLE); + endpoint_id, location::nearby::proto::connections::CHANNEL_ERROR, + location::nearby::proto::connections::NETWORK_AVAILABLE); return; } @@ -1187,7 +1207,8 @@ void BwuManager::TryNextBestUpgradeMediums( Medium next_medium = ChooseBestUpgradeMedium(endpoint_id, upgrade_mediums); NEARBY_LOGS(INFO) << "Try Next Best Medium for endpoint " << endpoint_id << " after ChooseBestUpgradeMedium: " - << proto::connections::Medium_Name(next_medium); + << location::nearby::proto::connections::Medium_Name( + next_medium); // If current medium is not WiFi and we have not succeeded with upgrading yet, // retry upgrade. @@ -1196,7 +1217,8 @@ void BwuManager::TryNextBestUpgradeMediums( Medium current_medium = channel ? channel->GetMedium() : Medium::UNKNOWN_MEDIUM; NEARBY_LOGS(VERBOSE) << "current_medium: " - << proto::connections::Medium_Name(current_medium); + << location::nearby::proto::connections::Medium_Name( + current_medium); if (current_medium != Medium::WIFI_LAN && (next_medium == current_medium || next_medium == Medium::UNKNOWN_MEDIUM || upgrade_mediums.empty())) { @@ -1298,12 +1320,13 @@ Medium BwuManager::ChooseBestUpgradeMedium( // switch. std::string mediums_string; for (const auto& medium : available_mediums) { - absl::StrAppend(&mediums_string, proto::connections::Medium_Name(medium), + absl::StrAppend(&mediums_string, + location::nearby::proto::connections::Medium_Name(medium), "; "); } NEARBY_LOGS(INFO) << "Current upgrade medium " - << proto::connections::Medium_Name(current_medium) + << location::nearby::proto::connections::Medium_Name(current_medium) << " is not supported by the remote endpoint (supported mediums: " << mediums_string << ")"; } @@ -1338,8 +1361,9 @@ void BwuManager::RetryUpgradesAfterDelay(ClientProxy* client, } void BwuManager::AttemptToRecordBandwidthUpgradeErrorForUnknownEndpoint( - proto::connections::BandwidthUpgradeResult result, - proto::connections::BandwidthUpgradeErrorStage error_stage) { + location::nearby::proto::connections::BandwidthUpgradeResult result, + location::nearby::proto::connections::BandwidthUpgradeErrorStage + error_stage) { if (in_progress_upgrades_.size() == 1) { auto it = in_progress_upgrades_.begin(); std::string endpoint_id = it->first; @@ -1351,22 +1375,26 @@ void BwuManager::AttemptToRecordBandwidthUpgradeErrorForUnknownEndpoint( // make for them. client->GetAnalyticsRecorder().OnBandwidthUpgradeError(endpoint_id, result, error_stage); - NEARBY_LOGS(INFO) << "BwuManager got error " - << proto::connections::BandwidthUpgradeResult_Name(result) - << " at stage " - << proto::connections::BandwidthUpgradeErrorStage_Name( - error_stage) - << " when upgrading endpoint " << endpoint_id; + NEARBY_LOGS(INFO) + << "BwuManager got error " + << location::nearby::proto::connections::BandwidthUpgradeResult_Name( + result) + << " at stage " + << location::nearby::proto::connections:: + BandwidthUpgradeErrorStage_Name(error_stage) + << " when upgrading endpoint " << endpoint_id; } // Otherwise, we have no way of knowing which endpoint was trying to connect // to us :( - NEARBY_LOGS(INFO) << "BwuManager got error " - << proto::connections::BandwidthUpgradeResult_Name(result) - << " at stage " - << proto::connections::BandwidthUpgradeErrorStage_Name( - error_stage) - << ", but we don't know which endpoint was trying to " - "connect to us, so skipping analytics for his error."; + NEARBY_LOGS(INFO) + << "BwuManager got error " + << location::nearby::proto::connections::BandwidthUpgradeResult_Name( + result) + << " at stage " + << location::nearby::proto::connections::BandwidthUpgradeErrorStage_Name( + error_stage) + << ", but we don't know which endpoint was trying to " + "connect to us, so skipping analytics for his error."; } absl::Duration BwuManager::CalculateNextRetryDelay( @@ -1409,4 +1437,3 @@ void BwuManager::CancelAllRetryUpgradeAlarms() { } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/bwu_manager.h b/connections/implementation/bwu_manager.h index fc62339cca..85d9929ff8 100644 --- a/connections/implementation/bwu_manager.h +++ b/connections/implementation/bwu_manager.h @@ -30,7 +30,6 @@ #include "connections/implementation/mediums/mediums.h" #include "internal/platform/scheduled_executor.h" -namespace location { namespace nearby { namespace connections { @@ -85,8 +84,9 @@ class BwuManager : public EndpointManager::FrameProcessor { // This is also an entry point for handling messages for both outbound and // inbound BWU protocol. // @EndpointManagerReaderThread - void OnIncomingFrame(OfflineFrame& frame, const std::string& endpoint_id, - ClientProxy* client, Medium medium, + void OnIncomingFrame(location::nearby::connections::OfflineFrame& frame, + const std::string& endpoint_id, ClientProxy* client, + Medium medium, PacketMetaData& packet_meta_data) override; // Cleans up in-progress upgrades after endpoint disconnection. @@ -193,8 +193,9 @@ class BwuManager : public EndpointManager::FrameProcessor { void RetryUpgradesAfterDelay(ClientProxy* client, const std::string& endpoint_id); void AttemptToRecordBandwidthUpgradeErrorForUnknownEndpoint( - proto::connections::BandwidthUpgradeResult result, - proto::connections::BandwidthUpgradeErrorStage error_stage); + location::nearby::proto::connections::BandwidthUpgradeResult result, + location::nearby::proto::connections::BandwidthUpgradeErrorStage + error_stage); bool is_single_threaded_for_testing_ = false; @@ -239,6 +240,5 @@ class BwuManager : public EndpointManager::FrameProcessor { } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_BWU_MANAGER_H_ diff --git a/connections/implementation/bwu_manager_test.cc b/connections/implementation/bwu_manager_test.cc index eec09d277f..a6fe2a0539 100644 --- a/connections/implementation/bwu_manager_test.cc +++ b/connections/implementation/bwu_manager_test.cc @@ -31,10 +31,14 @@ #include "connections/implementation/service_id_constants.h" #include "internal/platform/exception.h" -namespace location { namespace nearby { namespace connections { namespace { +using ::location::nearby::connections::BandwidthUpgradeNegotiationFrame; +using ::location::nearby::connections:: + BandwidthUpgradeNegotiationFrame_UpgradePathInfo; +using ::location::nearby::connections::OfflineFrame; +using ::location::nearby::connections::V1Frame; constexpr absl::string_view kServiceIdA = "ServiceA"; constexpr absl::string_view kServiceIdB = "ServiceB"; @@ -266,7 +270,7 @@ TEST_P(BwuManagerTestParam, InitiateBwu_Success) { dynamic_cast(shared_initial_channel.get()); EXPECT_FALSE(upgraded_channel->IsPaused()); EXPECT_TRUE(old_channel->is_closed()); - EXPECT_EQ(proto::connections::DisconnectionReason::UPGRADED, + EXPECT_EQ(location::nearby::proto::connections::DisconnectionReason::UPGRADED, old_channel->disconnection_reason()); } @@ -765,12 +769,11 @@ TEST_F(BwuManagerTest, InitiateBwu_Revert_OnDisconnect_WifiDirect) { /*gateway=*/"123.234.23.1"); frame.ParseFromString(std::string(bytes)); - ::location::nearby::connections::V1Frame* v1_frame = frame.mutable_v1(); - ::location::nearby::connections::BandwidthUpgradeNegotiationFrame* sub_frame = + ::nearby::connections::V1Frame* v1_frame = frame.mutable_v1(); + ::nearby::connections::BandwidthUpgradeNegotiationFrame* sub_frame = v1_frame->mutable_bandwidth_upgrade_negotiation(); - ::location::nearby::connections:: - BandwidthUpgradeNegotiationFrame_UpgradePathInfo* upgrade_path_info = - sub_frame->mutable_upgrade_path_info(); + ::nearby::connections::BandwidthUpgradeNegotiationFrame_UpgradePathInfo* + upgrade_path_info = sub_frame->mutable_upgrade_path_info(); upgrade_path_info->set_supports_client_introduction_ack(false); bwu_manager_->OnIncomingFrame(frame, std::string(kEndpointId1), &client_, Medium::BLUETOOTH, packet_meta_data_); @@ -853,4 +856,3 @@ INSTANTIATE_TEST_SUITE_P(BwuManagerTestParam, BwuManagerTestParam, } // namespace } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/client_proxy.cc b/connections/implementation/client_proxy.cc index 4f4c753f78..bcd2126ac8 100644 --- a/connections/implementation/client_proxy.cc +++ b/connections/implementation/client_proxy.cc @@ -35,7 +35,6 @@ #include "internal/platform/prng.h" #include "proto/connections_enums.pb.h" -namespace location { namespace nearby { namespace connections { @@ -112,7 +111,7 @@ void ClientProxy::Reset() { void ClientProxy::StartedAdvertising( const std::string& service_id, Strategy strategy, const ConnectionListener& listener, - absl::Span mediums, + absl::Span mediums, const AdvertisingOptions& advertising_options) { MutexLock lock(&mutex_); NEARBY_LOGS(INFO) << "ClientProxy [StartedAdvertising]: client=" @@ -130,8 +129,8 @@ void ClientProxy::StartedAdvertising( advertising_info_ = {service_id, listener}; advertising_options_ = advertising_options; - const std::vector medium_vector(mediums.begin(), - mediums.end()); + const std::vector medium_vector( + mediums.begin(), mediums.end()); analytics_recorder_->OnStartAdvertising(strategy, medium_vector, false, 0); } @@ -164,14 +163,14 @@ std::string ClientProxy::GetAdvertisingServiceId() const { void ClientProxy::StartedDiscovery( const std::string& service_id, Strategy strategy, const DiscoveryListener& listener, - absl::Span mediums, + absl::Span mediums, const DiscoveryOptions& discovery_options) { MutexLock lock(&mutex_); discovery_info_ = DiscoveryInfo{service_id, listener}; discovery_options_ = discovery_options; - const std::vector medium_vector(mediums.begin(), - mediums.end()); + const std::vector medium_vector( + mediums.begin(), mediums.end()); analytics_recorder_->OnStartDiscovery(strategy, medium_vector, false, 0); } @@ -205,10 +204,10 @@ std::string ClientProxy::GetDiscoveryServiceId() const { return discovery_info_.service_id; } -void ClientProxy::OnEndpointFound(const std::string& service_id, - const std::string& endpoint_id, - const ByteArray& endpoint_info, - proto::connections::Medium medium) { +void ClientProxy::OnEndpointFound( + const std::string& service_id, const std::string& endpoint_id, + const ByteArray& endpoint_info, + location::nearby::proto::connections::Medium medium) { MutexLock lock(&mutex_); NEARBY_LOGS(INFO) << "ClientProxy [Endpoint Found]: [enter] id=" @@ -840,4 +839,3 @@ std::string ClientProxy::Dump() { } } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/client_proxy.h b/connections/implementation/client_proxy.h index f8e1a4c525..a1ad4cc28d 100644 --- a/connections/implementation/client_proxy.h +++ b/connections/implementation/client_proxy.h @@ -40,7 +40,6 @@ #include "absl/container/flat_hash_set.h" #include "absl/types/span.h" -namespace location { namespace nearby { namespace connections { @@ -75,7 +74,7 @@ class ClientProxy final { void StartedAdvertising( const std::string& service_id, Strategy strategy, const ConnectionListener& connection_lifecycle_listener, - absl::Span mediums, + absl::Span mediums, const AdvertisingOptions& advertising_options = AdvertisingOptions{}); // Marks this client as not advertising. void StoppedAdvertising(); @@ -86,7 +85,7 @@ class ClientProxy final { void StartedDiscovery( const std::string& service_id, Strategy strategy, const DiscoveryListener& discovery_listener, - absl::Span mediums, + absl::Span mediums, const DiscoveryOptions& discovery_options = DiscoveryOptions{}); // Marks this client as not discovering at all. void StoppedDiscovery(); @@ -98,7 +97,7 @@ class ClientProxy final { void OnEndpointFound(const std::string& service_id, const std::string& endpoint_id, const ByteArray& endpoint_info, - proto::connections::Medium medium); + location::nearby::proto::connections::Medium medium); // Proxies to the client's DiscoveryListener::OnEndpointLost() callback. void OnEndpointLost(const std::string& service_id, const std::string& endpoint_id); @@ -202,7 +201,7 @@ class ClientProxy final { //********************************** V2 ********************************** void OnDeviceFound(const absl::string_view service_id, const NearbyDevice& device, - proto::connections::Medium medium); + location::nearby::proto::connections::Medium medium); // Proxies to the client's DiscoveryListener::OnEndpointLost() callback. void OnEndpointLost(absl::string_view service_id, const NearbyDevice& device); @@ -377,6 +376,5 @@ class ClientProxy final { } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_CLIENT_PROXY_H_ diff --git a/connections/implementation/client_proxy_test.cc b/connections/implementation/client_proxy_test.cc index 8107e12e94..9362958a13 100644 --- a/connections/implementation/client_proxy_test.cc +++ b/connections/implementation/client_proxy_test.cc @@ -32,7 +32,6 @@ #include "internal/platform/feature_flags.h" #include "internal/platform/medium_environment.h" -namespace location { namespace nearby { namespace connections { namespace { @@ -249,9 +248,10 @@ class ClientProxyTest : public ::testing::TestWithParam { MockConnectionListener mock_discovery_connection_; MockPayloadListener mock_discovery_payload_; - proto::connections::Medium medium_{proto::connections::Medium::BLUETOOTH}; - std::vector mediums_{ - proto::connections::Medium::BLUETOOTH, + location::nearby::proto::connections::Medium medium_{ + location::nearby::proto::connections::Medium::BLUETOOTH}; + std::vector mediums_{ + location::nearby::proto::connections::Medium::BLUETOOTH, }; Strategy strategy_{Strategy::kP2pPointToPoint}; const std::string service_id_{"service"}; @@ -900,4 +900,3 @@ TEST_F(ClientProxyTest, LogSessionForResetClientProxy) { } // namespace } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/encryption_runner.cc b/connections/implementation/encryption_runner.cc index 68e306f79e..b424b5ab5b 100644 --- a/connections/implementation/encryption_runner.cc +++ b/connections/implementation/encryption_runner.cc @@ -28,7 +28,6 @@ #include "internal/platform/cancelable_alarm.h" #include "internal/platform/logging.h" -namespace location { namespace nearby { namespace connections { namespace { @@ -386,4 +385,3 @@ void EncryptionRunner::StartClient( } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/encryption_runner.h b/connections/implementation/encryption_runner.h index 4262f7ff77..ff8da9c94b 100644 --- a/connections/implementation/encryption_runner.h +++ b/connections/implementation/encryption_runner.h @@ -25,7 +25,6 @@ #include "internal/platform/scheduled_executor.h" #include "internal/platform/single_thread_executor.h" -namespace location { namespace nearby { namespace connections { @@ -81,6 +80,5 @@ class EncryptionRunner { } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_ENCRYPTION_RUNNER_H_ diff --git a/connections/implementation/encryption_runner_test.cc b/connections/implementation/encryption_runner_test.cc index 7fafb7f062..270b82733d 100644 --- a/connections/implementation/encryption_runner_test.cc +++ b/connections/implementation/encryption_runner_test.cc @@ -26,7 +26,6 @@ #include "internal/platform/system_clock.h" #include "proto/connections_enums.pb.h" -namespace location { namespace nearby { namespace connections { namespace { @@ -60,15 +59,19 @@ class FakeEndpointChannel : public EndpointChannel { if (in_) in_->Close(); if (out_) out_->Close(); } - void Close(proto::connections::DisconnectionReason reason) override { + void Close(location::nearby::proto::connections::DisconnectionReason reason) + override { Close(); } - proto::connections::ConnectionTechnology GetTechnology() const override { - return proto::connections::ConnectionTechnology:: + location::nearby::proto::connections::ConnectionTechnology GetTechnology() + const override { + return location::nearby::proto::connections::ConnectionTechnology:: CONNECTION_TECHNOLOGY_BLE_GATT; } - proto::connections::ConnectionBand GetBand() const override { - return proto::connections::ConnectionBand::CONNECTION_BAND_CELLULAR_BAND_2G; + location::nearby::proto::connections::ConnectionBand GetBand() + const override { + return location::nearby::proto::connections::ConnectionBand:: + CONNECTION_BAND_CELLULAR_BAND_2G; } int GetFrequency() const override { return 0; } int GetTryCount() const override { return 0; } @@ -168,4 +171,3 @@ TEST(EncryptionRunnerTest, ReadWrite) { } // namespace } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/endpoint_channel.h b/connections/implementation/endpoint_channel.h index b15e759676..05b093bb82 100644 --- a/connections/implementation/endpoint_channel.h +++ b/connections/implementation/endpoint_channel.h @@ -25,7 +25,6 @@ #include "internal/platform/exception.h" #include "internal/platform/mutex.h" -namespace location { namespace nearby { namespace connections { @@ -52,7 +51,8 @@ class EndpointChannel { virtual void Close() = 0; // Closes this EndpointChannel and records the closure with the given reason. - virtual void Close(proto::connections::DisconnectionReason reason) = 0; + virtual void Close( + location::nearby::proto::connections::DisconnectionReason reason) = 0; // Returns a one-word type descriptor for the concrete EndpointChannel // implementation that can be used in log messages; eg: BLUETOOTH, BLE, WIFI. @@ -65,13 +65,15 @@ class EndpointChannel { virtual std::string GetName() const = 0; // Returns the analytics enum representing the medium of this EndpointChannel. - virtual proto::connections::Medium GetMedium() const = 0; + virtual location::nearby::proto::connections::Medium GetMedium() const = 0; // Returns the used BLE or WiFi technology of this EndpointChannel. - virtual proto::connections::ConnectionTechnology GetTechnology() const = 0; + virtual location::nearby::proto::connections::ConnectionTechnology + GetTechnology() const = 0; // Returns the used wifi band of this EndpointChannel. - virtual proto::connections::ConnectionBand GetBand() const = 0; + virtual location::nearby::proto::connections::ConnectionBand GetBand() + const = 0; // Returns the used wifi frequency of this EndpointChannel. virtual int GetFrequency() const = 0; @@ -124,6 +126,5 @@ inline bool operator!=(const EndpointChannel& lhs, const EndpointChannel& rhs) { } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_ENDPOINT_CHANNEL_H_ diff --git a/connections/implementation/endpoint_channel_manager.cc b/connections/implementation/endpoint_channel_manager.cc index d531566cce..f8c66e21fd 100644 --- a/connections/implementation/endpoint_channel_manager.cc +++ b/connections/implementation/endpoint_channel_manager.cc @@ -24,7 +24,6 @@ #include "internal/platform/mutex.h" #include "internal/platform/mutex_lock.h" -namespace location { namespace nearby { namespace connections { @@ -149,7 +148,7 @@ void EndpointChannelManager::ChannelState::UpdateEncryptionContextForEndpoint( bool EndpointChannelManager::ChannelState::RemoveEndpoint( const std::string& endpoint_id, - proto::connections::DisconnectionReason reason) { + location::nearby::proto::connections::DisconnectionReason reason) { auto item = endpoints_.find(endpoint_id); if (item == endpoints_.end()) return false; item->second.disconnect_reason = reason; @@ -189,8 +188,8 @@ bool EndpointChannelManager::UnregisterChannelForEndpoint( MutexLock lock(&mutex_); if (!channel_state_.RemoveEndpoint( - endpoint_id, - proto::connections::DisconnectionReason::LOCAL_DISCONNECTION)) { + endpoint_id, location::nearby::proto::connections:: + DisconnectionReason::LOCAL_DISCONNECTION)) { return false; } @@ -203,4 +202,3 @@ bool EndpointChannelManager::UnregisterChannelForEndpoint( } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/endpoint_channel_manager.h b/connections/implementation/endpoint_channel_manager.h index 11c16c4a44..980c53a736 100644 --- a/connections/implementation/endpoint_channel_manager.h +++ b/connections/implementation/endpoint_channel_manager.h @@ -24,7 +24,6 @@ #include "connections/implementation/endpoint_channel.h" #include "internal/platform/mutex.h" -namespace location { namespace nearby { namespace connections { @@ -120,8 +119,9 @@ class EndpointChannelManager final { std::shared_ptr channel; std::shared_ptr context; - proto::connections::DisconnectionReason disconnect_reason = - proto::connections::DisconnectionReason::UNKNOWN_DISCONNECTION_REASON; + location::nearby::proto::connections::DisconnectionReason + disconnect_reason = location::nearby::proto::connections:: + DisconnectionReason::UNKNOWN_DISCONNECTION_REASON; }; ChannelState() = default; @@ -147,8 +147,9 @@ class EndpointChannelManager final { // Removes all knowledge of this endpoint, cleaning up as necessary. // Returns false if the endpoint was not found. - bool RemoveEndpoint(const std::string& endpoint_id, - proto::connections::DisconnectionReason reason); + bool RemoveEndpoint( + const std::string& endpoint_id, + location::nearby::proto::connections::DisconnectionReason reason); bool EncryptChannel(EndpointData* endpoint); int GetConnectedEndpointsCount() const { return endpoints_.size(); } @@ -172,6 +173,5 @@ class EndpointChannelManager final { } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_ENDPOINT_CHANNEL_MANAGER_H_ diff --git a/connections/implementation/endpoint_channel_manager_test.cc b/connections/implementation/endpoint_channel_manager_test.cc index 85f60b3e47..fe34336b37 100644 --- a/connections/implementation/endpoint_channel_manager_test.cc +++ b/connections/implementation/endpoint_channel_manager_test.cc @@ -37,7 +37,6 @@ #include "internal/platform/pipe.h" #include "proto/connections_enums.pb.h" -namespace location { namespace nearby { namespace connections { namespace { @@ -295,4 +294,3 @@ TEST(BaseEndpointChannelManagerTest, ReplaceChannelNoEncrypted) { } // namespace } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/endpoint_manager.cc b/connections/implementation/endpoint_manager.cc index 70e25ba7ec..6dcaada9bf 100644 --- a/connections/implementation/endpoint_manager.cc +++ b/connections/implementation/endpoint_manager.cc @@ -32,12 +32,13 @@ #include "internal/platform/logging.h" #include "internal/platform/mutex_lock.h" -namespace location { namespace nearby { namespace connections { -using ::location::nearby::analytics::PacketMetaData; -using ::location::nearby::connections::PayloadDirection; +using ::location::nearby::connections::OfflineFrame; +using ::location::nearby::connections::V1Frame; +using ::nearby::analytics::PacketMetaData; +using ::nearby::connections::PayloadDirection; constexpr absl::Duration EndpointManager::kProcessEndpointDisconnectionTimeout; constexpr absl::Time EndpointManager::kInvalidTimestamp; @@ -132,14 +133,16 @@ void EndpointManager::EndpointChannelLoopRunnable( NEARBY_LOGS(INFO) << "Received invalid protobuf message, re-fetching endpoint " "channel; last_failed_medium=" - << proto::connections::Medium_Name(last_failed_medium); + << location::nearby::proto::connections::Medium_Name( + last_failed_medium); continue; } if (exception.Raised(Exception::kIo)) { last_failed_medium = channel->GetMedium(); NEARBY_LOGS(INFO) << "Endpoint channel IO exception; last_failed_medium=" - << proto::connections::Medium_Name(last_failed_medium); + << location::nearby::proto::connections::Medium_Name( + last_failed_medium); continue; } if (exception.Raised(Exception::kInterrupted)) { @@ -149,7 +152,8 @@ void EndpointManager::EndpointChannelLoopRunnable( if (!keep_using_channel.result()) { NEARBY_LOGS(INFO) << "Dropping current channel: last medium=" - << proto::connections::Medium_Name(last_failed_medium); + << location::nearby::proto::connections::Medium_Name( + last_failed_medium); break; } } @@ -700,4 +704,3 @@ void EndpointManager::RunOnEndpointManagerThread(const std::string& name, } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/endpoint_manager.h b/connections/implementation/endpoint_manager.h index a4931476fd..74ab756679 100644 --- a/connections/implementation/endpoint_manager.h +++ b/connections/implementation/endpoint_manager.h @@ -38,7 +38,6 @@ #include "internal/platform/runnable.h" #include "internal/platform/single_thread_executor.h" -namespace location { namespace nearby { namespace connections { @@ -75,8 +74,9 @@ class EndpointManager { // or rvalue reference. Rvalue references are discouraged by go/cstyle, // and that leaves us with mutable lvalue reference. virtual void OnIncomingFrame( - OfflineFrame& offline_frame, const std::string& from_endpoint_id, - ClientProxy* to_client, proto::connections::Medium current_medium, + location::nearby::connections::OfflineFrame& offline_frame, + const std::string& from_endpoint_id, ClientProxy* to_client, + location::nearby::proto::connections::Medium current_medium, analytics::PacketMetaData& packet_meta_data) = 0; // Implementations must call barrier.CountDown() once @@ -97,10 +97,12 @@ class EndpointManager { // up the OfflineServiceController implementation. // FrameProcessor* instances are of dynamic duration and survive all sessions. // Blocks until registration is complete. - void RegisterFrameProcessor(V1Frame::FrameType frame_type, - FrameProcessor* processor); - void UnregisterFrameProcessor(V1Frame::FrameType frame_type, - const FrameProcessor* processor); + void RegisterFrameProcessor( + location::nearby::connections::V1Frame::FrameType frame_type, + FrameProcessor* processor); + void UnregisterFrameProcessor( + location::nearby::connections::V1Frame::FrameType frame_type, + const FrameProcessor* processor); // Invoked from the different PcpHandler implementations (of which there can // be only one at a time). @@ -123,13 +125,17 @@ class EndpointManager { // // Invoked from the PayloadManager's sendPayload() method. std::vector SendPayloadChunk( - const PayloadTransferFrame::PayloadHeader& payload_header, - const PayloadTransferFrame::PayloadChunk& payload_chunk, + const location::nearby::connections::PayloadTransferFrame::PayloadHeader& + payload_header, + const location::nearby::connections::PayloadTransferFrame::PayloadChunk& + payload_chunk, const std::vector& endpoint_ids, analytics::PacketMetaData& packet_meta_data); std::vector SendControlMessage( - const PayloadTransferFrame::PayloadHeader& payload_header, - const PayloadTransferFrame::ControlMessage& control_message, + const location::nearby::connections::PayloadTransferFrame::PayloadHeader& + payload_header, + const location::nearby::connections::PayloadTransferFrame::ControlMessage& + control_message, const std::vector& endpoint_ids); // Called when we internally want to get rid of the endpoint, without the @@ -209,7 +215,8 @@ class EndpointManager { friend class LockedFrameProcessor; }; - LockedFrameProcessor GetFrameProcessor(V1Frame::FrameType frame_type); + LockedFrameProcessor GetFrameProcessor( + location::nearby::connections::V1Frame::FrameType frame_type); ExceptionOr HandleData(const std::string& endpoint_id, ClientProxy* client_proxy, @@ -274,7 +281,8 @@ class EndpointManager { EndpointChannelManager* channel_manager_; RecursiveMutex frame_processors_lock_; - absl::flat_hash_map + absl::flat_hash_map frame_processors_ ABSL_GUARDED_BY(frame_processors_lock_); // We keep track of all registered channel endpoints here. @@ -291,6 +299,5 @@ bool operator<(const EndpointManager::FrameProcessor& lhs, } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_ENDPOINT_MANAGER_H_ diff --git a/connections/implementation/endpoint_manager_test.cc b/connections/implementation/endpoint_manager_test.cc index bb861d18b9..c024250eca 100644 --- a/connections/implementation/endpoint_manager_test.cc +++ b/connections/implementation/endpoint_manager_test.cc @@ -37,11 +37,13 @@ #include "internal/platform/pipe.h" #include "proto/connections_enums.pb.h" -namespace location { namespace nearby { namespace connections { namespace { +using ::location::nearby::connections::OfflineFrame; +using ::location::nearby::connections::PayloadTransferFrame; +using ::location::nearby::connections::V1Frame; using ::location::nearby::proto::connections::DisconnectionReason; using ::location::nearby::proto::connections::Medium; using ::testing::_; @@ -60,9 +62,9 @@ class MockEndpointChannel : public EndpointChannel { (override)); MOCK_METHOD(void, Close, (), (override)); MOCK_METHOD(void, Close, (DisconnectionReason reason), (override)); - MOCK_METHOD(proto::connections::ConnectionTechnology, GetTechnology, (), - (const override)); - MOCK_METHOD(proto::connections::ConnectionBand, GetBand, (), + MOCK_METHOD(location::nearby::proto::connections::ConnectionTechnology, + GetTechnology, (), (const override)); + MOCK_METHOD(location::nearby::proto::connections::ConnectionBand, GetBand, (), (const override)); MOCK_METHOD(int, GetFrequency, (), (const override)); MOCK_METHOD(int, GetTryCount, (), (const override)); @@ -303,4 +305,3 @@ TEST_F(EndpointManagerTest, SingleReadOnInvalidPayload) { } // namespace } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/fake_bwu_handler.h b/connections/implementation/fake_bwu_handler.h index 9f577c7891..b735dc9e5c 100644 --- a/connections/implementation/fake_bwu_handler.h +++ b/connections/implementation/fake_bwu_handler.h @@ -26,7 +26,6 @@ #include "connections/implementation/client_proxy.h" #include "connections/implementation/fake_endpoint_channel.h" -namespace location { namespace nearby { namespace connections { @@ -130,32 +129,33 @@ class FakeBwuHandler : public BaseBwuHandler { .service_id = upgrade_service_id, .endpoint_id = endpoint_id}); switch (medium_) { - case proto::connections::BLUETOOTH: + case location::nearby::proto::connections::BLUETOOTH: return parser::ForBwuBluetoothPathAvailable( upgrade_service_id, /*mac_address=*/"mac-address"); - case proto::connections::WIFI_LAN: + case location::nearby::proto::connections::WIFI_LAN: return parser::ForBwuWifiLanPathAvailable(/*ip_address=*/"ABCD", /*port=*/1234); - case proto::connections::WEB_RTC: - return parser::ForBwuWebrtcPathAvailable(/*peer_id=*/"peer-id", - LocationHint{}); - case proto::connections::WIFI_HOTSPOT: + case location::nearby::proto::connections::WEB_RTC: + return parser::ForBwuWebrtcPathAvailable( + /*peer_id=*/"peer-id", + location::nearby::connections::LocationHint{}); + case location::nearby::proto::connections::WIFI_HOTSPOT: return parser::ForBwuWifiHotspotPathAvailable( /*ssid=*/"Direct-357a2d8c", /*password=*/"b592f7d3", /*port=*/1234, /*gateway=*/"123.234.23.1", false); - case proto::connections::WIFI_DIRECT: + case location::nearby::proto::connections::WIFI_DIRECT: return parser::ForBwuWifiDirectPathAvailable( /*ssid=*/"Direct-12345678", /*password=*/"87654321", /*port=*/2143, /*frequency=*/2412, /*supports_disabling_encryption=*/false, /*gateway=*/"123.234.23.1"); - case proto::connections::UNKNOWN_MEDIUM: - case proto::connections::MDNS: - case proto::connections::BLE: - case proto::connections::WIFI_AWARE: - case proto::connections::NFC: - case proto::connections::BLE_L2CAP: - case proto::connections::USB: + case location::nearby::proto::connections::UNKNOWN_MEDIUM: + case location::nearby::proto::connections::MDNS: + case location::nearby::proto::connections::BLE: + case location::nearby::proto::connections::WIFI_AWARE: + case location::nearby::proto::connections::NFC: + case location::nearby::proto::connections::BLE_L2CAP: + case location::nearby::proto::connections::USB: return ByteArray{}; } } @@ -174,6 +174,5 @@ class FakeBwuHandler : public BaseBwuHandler { } // namespace connections } // namespace nearby -} // namespace location #endif // NEARBY_CONNECTIONS_IMPLEMENTATION_FAKE_BWU_HANDLER_H_ diff --git a/connections/implementation/fake_endpoint_channel.h b/connections/implementation/fake_endpoint_channel.h index 4c68b0d2f8..db12c2c1cf 100644 --- a/connections/implementation/fake_endpoint_channel.h +++ b/connections/implementation/fake_endpoint_channel.h @@ -20,7 +20,6 @@ #include "connections/implementation/endpoint_channel.h" #include "internal/platform/byte_array.h" -namespace location { namespace nearby { namespace connections { @@ -54,16 +53,20 @@ class FakeEndpointChannel : public EndpointChannel { return write_output_; } void Close() override { is_closed_ = true; } - void Close(proto::connections::DisconnectionReason reason) override { + void Close(location::nearby::proto::connections::DisconnectionReason reason) + override { is_closed_ = true; disconnection_reason_ = reason; } - proto::connections::ConnectionTechnology GetTechnology() const override { - return proto::connections::ConnectionTechnology:: + location::nearby::proto::connections::ConnectionTechnology GetTechnology() + const override { + return location::nearby::proto::connections::ConnectionTechnology:: CONNECTION_TECHNOLOGY_BLE_GATT; } - proto::connections::ConnectionBand GetBand() const override { - return proto::connections::ConnectionBand::CONNECTION_BAND_CELLULAR_BAND_2G; + location::nearby::proto::connections::ConnectionBand GetBand() + const override { + return location::nearby::proto::connections::ConnectionBand:: + CONNECTION_BAND_CELLULAR_BAND_2G; } int GetFrequency() const override { return 0; } int GetTryCount() const override { return 0; } @@ -85,7 +88,8 @@ class FakeEndpointChannel : public EndpointChannel { void set_read_output(ExceptionOr output) { read_output_ = output; } void set_write_output(Exception output) { write_output_ = output; } bool is_closed() const { return is_closed_; } - proto::connections::DisconnectionReason disconnection_reason() const { + location::nearby::proto::connections::DisconnectionReason + disconnection_reason() const { return disconnection_reason_; } @@ -98,11 +102,11 @@ class FakeEndpointChannel : public EndpointChannel { absl::Time write_timestamp_ = absl::InfinitePast(); bool is_closed_ = false; bool is_paused_ = false; - proto::connections::DisconnectionReason disconnection_reason_; + location::nearby::proto::connections::DisconnectionReason + disconnection_reason_; }; } // namespace connections } // namespace nearby -} // namespace location #endif // NEARBY_CONNECTIONS_IMPLEMENTATION_FAKE_ENDPOINT_CHANNEL_H_ diff --git a/connections/implementation/fuzzers/offline_frames_fuzzer.cc b/connections/implementation/fuzzers/offline_frames_fuzzer.cc index 9034a9b34c..256f112cdf 100644 --- a/connections/implementation/fuzzers/offline_frames_fuzzer.cc +++ b/connections/implementation/fuzzers/offline_frames_fuzzer.cc @@ -16,10 +16,10 @@ #include "internal/platform/byte_array.h" extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { - location::nearby::ByteArray byte_array; + nearby::ByteArray byte_array; byte_array.SetData(reinterpret_cast(data), size); - location::nearby::connections::parser::FromBytes(byte_array); + nearby::connections::parser::FromBytes(byte_array); return 0; } diff --git a/connections/implementation/injected_bluetooth_device_store.cc b/connections/implementation/injected_bluetooth_device_store.cc index c71e3e55e3..9162a3d483 100644 --- a/connections/implementation/injected_bluetooth_device_store.cc +++ b/connections/implementation/injected_bluetooth_device_store.cc @@ -20,7 +20,6 @@ #include "internal/platform/implementation/bluetooth_classic.h" #include "internal/platform/bluetooth_utils.h" -namespace location { namespace nearby { namespace connections { namespace { @@ -87,4 +86,3 @@ BluetoothDevice InjectedBluetoothDeviceStore::CreateInjectedBluetoothDevice( } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/injected_bluetooth_device_store.h b/connections/implementation/injected_bluetooth_device_store.h index 0d9a3eaff0..cb7ae9a6b1 100644 --- a/connections/implementation/injected_bluetooth_device_store.h +++ b/connections/implementation/injected_bluetooth_device_store.h @@ -22,7 +22,6 @@ #include "internal/platform/byte_array.h" #include "internal/platform/bluetooth_adapter.h" -namespace location { namespace nearby { namespace connections { @@ -64,6 +63,5 @@ class InjectedBluetoothDeviceStore { } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_INJECTED_BLUETOOTH_DEVICE_STORE_H_ diff --git a/connections/implementation/injected_bluetooth_device_store_test.cc b/connections/implementation/injected_bluetooth_device_store_test.cc index 9e8264e9c1..1018c4570b 100644 --- a/connections/implementation/injected_bluetooth_device_store_test.cc +++ b/connections/implementation/injected_bluetooth_device_store_test.cc @@ -22,7 +22,6 @@ #include "internal/platform/byte_array.h" #include "internal/platform/bluetooth_adapter.h" -namespace location { namespace nearby { namespace connections { namespace { @@ -120,4 +119,3 @@ TEST_F(InjectedBluetoothDeviceStoreTest, Fail_InvalidServiceIdHash) { } // namespace } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/internal_payload.cc b/connections/implementation/internal_payload.cc index 5403f9bb8c..bb9482b10b 100644 --- a/connections/implementation/internal_payload.cc +++ b/connections/implementation/internal_payload.cc @@ -14,7 +14,6 @@ #include "connections/implementation/internal_payload.h" -namespace location { namespace nearby { namespace connections { @@ -30,4 +29,3 @@ Payload::Id InternalPayload::GetId() const { return payload_id_; } } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/internal_payload.h b/connections/implementation/internal_payload.h index 9d0de2214b..2a841e8996 100644 --- a/connections/implementation/internal_payload.h +++ b/connections/implementation/internal_payload.h @@ -22,7 +22,6 @@ #include "internal/platform/byte_array.h" #include "internal/platform/exception.h" -namespace location { namespace nearby { namespace connections { @@ -52,7 +51,9 @@ class InternalPayload { // Payload::getType(). // // @return The PayloadType. - virtual PayloadTransferFrame::PayloadHeader::PayloadType GetType() const = 0; + virtual location::nearby::connections::PayloadTransferFrame::PayloadHeader:: + PayloadType + GetType() const = 0; // Deduces the total size of the Payload to which this object is bound. // @@ -105,6 +106,5 @@ class InternalPayload { } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_INTERNAL_PAYLOAD_H_ diff --git a/connections/implementation/internal_payload_factory.cc b/connections/implementation/internal_payload_factory.cc index f9d72a7d2c..aa86cbe023 100644 --- a/connections/implementation/internal_payload_factory.cc +++ b/connections/implementation/internal_payload_factory.cc @@ -34,11 +34,11 @@ #include "internal/platform/os_name.h" #include "internal/platform/pipe.h" -namespace location { namespace nearby { namespace connections { namespace { +using ::location::nearby::connections::PayloadTransferFrame; class BytesInternalPayload : public InternalPayload { public: @@ -47,8 +47,11 @@ class BytesInternalPayload : public InternalPayload { total_size_(payload_.AsBytes().size()), detached_only_chunk_(false) {} - PayloadTransferFrame::PayloadHeader::PayloadType GetType() const override { - return PayloadTransferFrame::PayloadHeader::BYTES; + location::nearby::connections::PayloadTransferFrame::PayloadHeader:: + PayloadType + GetType() const override { + return location::nearby::connections::PayloadTransferFrame::PayloadHeader:: + BYTES; } std::int64_t GetTotalSize() const override { return total_size_; } @@ -87,8 +90,11 @@ class OutgoingStreamInternalPayload : public InternalPayload { explicit OutgoingStreamInternalPayload(Payload payload) : InternalPayload(std::move(payload)) {} - PayloadTransferFrame::PayloadHeader::PayloadType GetType() const override { - return PayloadTransferFrame::PayloadHeader::STREAM; + location::nearby::connections::PayloadTransferFrame::PayloadHeader:: + PayloadType + GetType() const override { + return location::nearby::connections::PayloadTransferFrame::PayloadHeader:: + STREAM; } std::int64_t GetTotalSize() const override { return -1; } @@ -189,8 +195,11 @@ class OutgoingFileInternalPayload : public InternalPayload { : InternalPayload(std::move(payload)), total_size_{payload_.AsFile()->GetTotalSize()} {} - PayloadTransferFrame::PayloadHeader::PayloadType GetType() const override { - return PayloadTransferFrame::PayloadHeader::FILE; + location::nearby::connections::PayloadTransferFrame::PayloadHeader:: + PayloadType + GetType() const override { + return location::nearby::connections::PayloadTransferFrame::PayloadHeader:: + FILE; } std::int64_t GetTotalSize() const override { return total_size_; } @@ -259,8 +268,11 @@ class IncomingFileInternalPayload : public InternalPayload { output_file_(std::move(output_file)), total_size_(total_size) {} - PayloadTransferFrame::PayloadHeader::PayloadType GetType() const override { - return PayloadTransferFrame::PayloadHeader::FILE; + location::nearby::connections::PayloadTransferFrame::PayloadHeader:: + PayloadType + GetType() const override { + return location::nearby::connections::PayloadTransferFrame::PayloadHeader:: + FILE; } std::int64_t GetTotalSize() const override { return total_size_; } @@ -292,8 +304,8 @@ class IncomingFileInternalPayload : public InternalPayload { } // namespace -using ::location::nearby::api::ImplementationPlatform; -using ::location::nearby::api::OSName; +using ::nearby::api::ImplementationPlatform; +using ::nearby::api::OSName; std::unique_ptr CreateOutgoingInternalPayload( Payload payload) { @@ -337,8 +349,10 @@ std::string make_path(const std::string& custom_save_path, } std::unique_ptr CreateIncomingInternalPayload( - const PayloadTransferFrame& frame, const std::string& custom_save_path) { - if (frame.packet_type() != PayloadTransferFrame::DATA) { + const location::nearby::connections::PayloadTransferFrame& frame, + const std::string& custom_save_path) { + if (frame.packet_type() != + location::nearby::connections::PayloadTransferFrame::DATA) { return {}; } @@ -415,4 +429,3 @@ std::unique_ptr CreateIncomingInternalPayload( } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/internal_payload_factory.h b/connections/implementation/internal_payload_factory.h index dc2896b210..6e510ade96 100644 --- a/connections/implementation/internal_payload_factory.h +++ b/connections/implementation/internal_payload_factory.h @@ -22,7 +22,6 @@ #include "connections/implementation/internal_payload.h" #include "connections/payload.h" -namespace location { namespace nearby { namespace connections { @@ -32,10 +31,10 @@ std::unique_ptr CreateOutgoingInternalPayload(Payload payload); // Creates an InternalPayload representing an incoming Payload from a remote // endpoint. std::unique_ptr CreateIncomingInternalPayload( - const PayloadTransferFrame& frame, const std::string& custom_save_path); + const location::nearby::connections::PayloadTransferFrame& frame, + const std::string& custom_save_path); } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_INTERNAL_PAYLOAD_FACTORY_H_ diff --git a/connections/implementation/internal_payload_factory_test.cc b/connections/implementation/internal_payload_factory_test.cc index 797541c4d0..edbd0c0f60 100644 --- a/connections/implementation/internal_payload_factory_test.cc +++ b/connections/implementation/internal_payload_factory_test.cc @@ -25,11 +25,11 @@ #include "internal/platform/byte_array.h" #include "internal/platform/pipe.h" -namespace location { namespace nearby { namespace connections { namespace { +using ::location::nearby::connections::PayloadTransferFrame; constexpr char kText[] = "data chunk"; TEST(InternalPayloadFactoryTest, CanCreateInternalPayloadFromBytePayload) { @@ -227,4 +227,3 @@ TEST(InternalPayloadFactoryTest, } // namespace } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/mediums/ble.cc b/connections/implementation/mediums/ble.cc index 38e384913d..6b1c972d5a 100644 --- a/connections/implementation/mediums/ble.cc +++ b/connections/implementation/mediums/ble.cc @@ -25,7 +25,6 @@ #include "internal/platform/logging.h" #include "internal/platform/mutex_lock.h" -namespace location { namespace nearby { namespace connections { @@ -360,4 +359,3 @@ ByteArray Ble::UnwrapAdvertisementBytes( } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/mediums/ble.h b/connections/implementation/mediums/ble.h index 83f0f0f7a8..a855b8b353 100644 --- a/connections/implementation/mediums/ble.h +++ b/connections/implementation/mediums/ble.h @@ -28,7 +28,6 @@ #include "internal/platform/multi_thread_executor.h" #include "internal/platform/mutex.h" -namespace location { namespace nearby { namespace connections { @@ -183,6 +182,5 @@ class Ble { } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_MEDIUMS_BLE_H_ diff --git a/connections/implementation/mediums/ble_test.cc b/connections/implementation/mediums/ble_test.cc index 1116d5db86..8669d39539 100644 --- a/connections/implementation/mediums/ble_test.cc +++ b/connections/implementation/mediums/ble_test.cc @@ -25,7 +25,6 @@ #include "internal/platform/logging.h" #include "internal/platform/medium_environment.h" -namespace location { namespace nearby { namespace connections { namespace { @@ -259,4 +258,3 @@ TEST_F(BleTest, CanStartDiscovery) { } // namespace } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/mediums/ble_v2.cc b/connections/implementation/mediums/ble_v2.cc index 884a015006..40a8809a6b 100644 --- a/connections/implementation/mediums/ble_v2.cc +++ b/connections/implementation/mediums/ble_v2.cc @@ -33,15 +33,14 @@ #include "internal/platform/logging.h" #include "internal/platform/mutex_lock.h" -namespace location { namespace nearby { namespace connections { namespace { -using ::location::nearby::api::ble_v2::BleAdvertisementData; -using ::location::nearby::api::ble_v2::GattCharacteristic; -using ::location::nearby::api::ble_v2::TxPowerLevel; +using ::nearby::api::ble_v2::BleAdvertisementData; +using ::nearby::api::ble_v2::GattCharacteristic; +using ::nearby::api::ble_v2::TxPowerLevel; constexpr int kMaxAdvertisementLength = 512; constexpr int kDummyServiceIdLength = 128; @@ -903,4 +902,3 @@ void BleV2::RunOnBleThread(Runnable runnable) { } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/mediums/ble_v2.h b/connections/implementation/mediums/ble_v2.h index 65699db7ae..4a010da9dd 100644 --- a/connections/implementation/mediums/ble_v2.h +++ b/connections/implementation/mediums/ble_v2.h @@ -40,7 +40,6 @@ #include "internal/platform/scheduled_executor.h" #include "internal/platform/single_thread_executor.h" -namespace location { namespace nearby { namespace connections { @@ -232,6 +231,5 @@ class BleV2 final { } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_MEDIUMS_BLE_V2_H_ diff --git a/connections/implementation/mediums/ble_v2/advertisement_read_result.cc b/connections/implementation/mediums/ble_v2/advertisement_read_result.cc index e1036391f6..594b98b297 100644 --- a/connections/implementation/mediums/ble_v2/advertisement_read_result.cc +++ b/connections/implementation/mediums/ble_v2/advertisement_read_result.cc @@ -21,7 +21,6 @@ #include "absl/time/clock.h" #include "internal/platform/mutex_lock.h" -namespace location { namespace nearby { namespace connections { namespace mediums { @@ -123,4 +122,3 @@ absl::Duration AdvertisementReadResult::GetDurationSinceReadLocked() const { } // namespace mediums } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/mediums/ble_v2/advertisement_read_result.h b/connections/implementation/mediums/ble_v2/advertisement_read_result.h index d1b01bd162..6875af349f 100644 --- a/connections/implementation/mediums/ble_v2/advertisement_read_result.h +++ b/connections/implementation/mediums/ble_v2/advertisement_read_result.h @@ -25,7 +25,6 @@ #include "internal/platform/mutex.h" #include "internal/platform/system_clock.h" -namespace location { namespace nearby { namespace connections { namespace mediums { @@ -119,6 +118,5 @@ class AdvertisementReadResult { } // namespace mediums } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_MEDIUMS_BLE_V2_ADVERTISEMENT_READ_RESULT_H_ diff --git a/connections/implementation/mediums/ble_v2/advertisement_read_result_test.cc b/connections/implementation/mediums/ble_v2/advertisement_read_result_test.cc index de76380e7a..5510256025 100644 --- a/connections/implementation/mediums/ble_v2/advertisement_read_result_test.cc +++ b/connections/implementation/mediums/ble_v2/advertisement_read_result_test.cc @@ -17,7 +17,6 @@ #include "gtest/gtest.h" #include "absl/time/clock.h" -namespace location { namespace nearby { namespace connections { namespace mediums { @@ -140,4 +139,3 @@ TEST(AdvertisementReadResultTest, GetDurationSinceRead) { } // namespace mediums } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/mediums/ble_v2/ble_advertisement.cc b/connections/implementation/mediums/ble_v2/ble_advertisement.cc index 821ccf2ad1..3abb8a790e 100644 --- a/connections/implementation/mediums/ble_v2/ble_advertisement.cc +++ b/connections/implementation/mediums/ble_v2/ble_advertisement.cc @@ -25,7 +25,6 @@ #include "internal/platform/base_input_stream.h" #include "internal/platform/logging.h" -namespace location { namespace nearby { namespace connections { namespace mediums { @@ -312,4 +311,3 @@ BleAdvertisement::BleExtraFields::operator ByteArray() const { } // namespace mediums } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/mediums/ble_v2/ble_advertisement.h b/connections/implementation/mediums/ble_v2/ble_advertisement.h index 82e7ba6710..94a20aa6ee 100644 --- a/connections/implementation/mediums/ble_v2/ble_advertisement.h +++ b/connections/implementation/mediums/ble_v2/ble_advertisement.h @@ -20,7 +20,6 @@ #include "connections/implementation/mediums/ble_v2/ble_advertisement_header.h" #include "internal/platform/byte_array.h" -namespace location { namespace nearby { namespace connections { namespace mediums { @@ -176,6 +175,5 @@ class BleAdvertisement { } // namespace mediums } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_MEDIUMS_BLE_V2_BLE_ADVERTISEMENT_H_ diff --git a/connections/implementation/mediums/ble_v2/ble_advertisement_header.cc b/connections/implementation/mediums/ble_v2/ble_advertisement_header.cc index 57ab9c117b..d4f4a5e9c4 100644 --- a/connections/implementation/mediums/ble_v2/ble_advertisement_header.cc +++ b/connections/implementation/mediums/ble_v2/ble_advertisement_header.cc @@ -24,7 +24,6 @@ #include "internal/platform/base_input_stream.h" #include "internal/platform/logging.h" -namespace location { namespace nearby { namespace connections { namespace mediums { @@ -157,4 +156,3 @@ bool BleAdvertisementHeader::operator==( } // namespace mediums } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/mediums/ble_v2/ble_advertisement_header.h b/connections/implementation/mediums/ble_v2/ble_advertisement_header.h index ba4763f57c..440586c324 100644 --- a/connections/implementation/mediums/ble_v2/ble_advertisement_header.h +++ b/connections/implementation/mediums/ble_v2/ble_advertisement_header.h @@ -19,7 +19,6 @@ #include "internal/platform/byte_array.h" -namespace location { namespace nearby { namespace connections { namespace mediums { @@ -112,6 +111,5 @@ class BleAdvertisementHeader { } // namespace mediums } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_MEDIUMS_BLE_V2_BLE_ADVERTISEMENT_HEADER_H_ diff --git a/connections/implementation/mediums/ble_v2/ble_advertisement_header_test.cc b/connections/implementation/mediums/ble_v2/ble_advertisement_header_test.cc index f408f983a5..216cd1e046 100644 --- a/connections/implementation/mediums/ble_v2/ble_advertisement_header_test.cc +++ b/connections/implementation/mediums/ble_v2/ble_advertisement_header_test.cc @@ -20,7 +20,6 @@ #include "absl/hash/hash_testing.h" #include "internal/platform/base64_utils.h" -namespace location { namespace nearby { namespace connections { namespace mediums { @@ -205,4 +204,3 @@ TEST(BleAdvertisementHeaderTest, Hash) { } // namespace mediums } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/mediums/ble_v2/ble_advertisement_test.cc b/connections/implementation/mediums/ble_v2/ble_advertisement_test.cc index 8286bc878a..99131eb65a 100644 --- a/connections/implementation/mediums/ble_v2/ble_advertisement_test.cc +++ b/connections/implementation/mediums/ble_v2/ble_advertisement_test.cc @@ -20,7 +20,6 @@ #include "gtest/gtest.h" #include "absl/hash/hash_testing.h" -namespace location { namespace nearby { namespace connections { namespace mediums { @@ -540,4 +539,3 @@ TEST(BleAdvertisementTest, Hash) { } // namespace mediums } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/mediums/ble_v2/ble_packet.cc b/connections/implementation/mediums/ble_v2/ble_packet.cc index ddeeadf6de..73216acc98 100644 --- a/connections/implementation/mediums/ble_v2/ble_packet.cc +++ b/connections/implementation/mediums/ble_v2/ble_packet.cc @@ -18,7 +18,6 @@ #include "internal/platform/base_input_stream.h" #include "internal/platform/logging.h" -namespace location { namespace nearby { namespace connections { namespace mediums { @@ -70,4 +69,3 @@ BlePacket::operator ByteArray() const { } // namespace mediums } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/mediums/ble_v2/ble_packet.h b/connections/implementation/mediums/ble_v2/ble_packet.h index f83af7c7c7..5444dac70a 100644 --- a/connections/implementation/mediums/ble_v2/ble_packet.h +++ b/connections/implementation/mediums/ble_v2/ble_packet.h @@ -19,7 +19,6 @@ #include "internal/platform/byte_array.h" -namespace location { namespace nearby { namespace connections { namespace mediums { @@ -59,6 +58,5 @@ class BlePacket { } // namespace mediums } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_MEDIUMS_BLE_V2_BLE_PACKET_H_ diff --git a/connections/implementation/mediums/ble_v2/ble_packet_test.cc b/connections/implementation/mediums/ble_v2/ble_packet_test.cc index 4c6f393ba6..30bdfe98d7 100644 --- a/connections/implementation/mediums/ble_v2/ble_packet_test.cc +++ b/connections/implementation/mediums/ble_v2/ble_packet_test.cc @@ -16,7 +16,6 @@ #include "gtest/gtest.h" -namespace location { namespace nearby { namespace connections { namespace mediums { @@ -108,4 +107,3 @@ TEST(BlePacketTest, ConstructionFromShortLengthDataFails) { } // namespace mediums } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/mediums/ble_v2/ble_utils.cc b/connections/implementation/mediums/ble_v2/ble_utils.cc index 7c5b517cf2..e7606227c9 100644 --- a/connections/implementation/mediums/ble_v2/ble_utils.cc +++ b/connections/implementation/mediums/ble_v2/ble_utils.cc @@ -18,7 +18,6 @@ #include "absl/types/optional.h" -namespace location { namespace nearby { namespace connections { namespace mediums { @@ -104,4 +103,3 @@ absl::optional GenerateAdvertisementUuid(int slot) { } // namespace mediums } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/mediums/ble_v2/ble_utils.h b/connections/implementation/mediums/ble_v2/ble_utils.h index eb900003e9..acb80a6fe8 100644 --- a/connections/implementation/mediums/ble_v2/ble_utils.h +++ b/connections/implementation/mediums/ble_v2/ble_utils.h @@ -26,7 +26,6 @@ #include "internal/platform/prng.h" #include "internal/platform/uuid.h" -namespace location { namespace nearby { namespace connections { namespace mediums { @@ -69,6 +68,5 @@ absl::optional GenerateAdvertisementUuid(int slot); } // namespace mediums } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_MEDIUMS_BLE_V2_UTILS_H_ diff --git a/connections/implementation/mediums/ble_v2/ble_utils_test.cc b/connections/implementation/mediums/ble_v2/ble_utils_test.cc index 60650d89dc..6e726a4d38 100644 --- a/connections/implementation/mediums/ble_v2/ble_utils_test.cc +++ b/connections/implementation/mediums/ble_v2/ble_utils_test.cc @@ -20,7 +20,6 @@ #include "protobuf-matchers/protocol-buffer-matchers.h" #include "gtest/gtest.h" -namespace location { namespace nearby { namespace connections { namespace mediums { @@ -102,4 +101,3 @@ TEST(BleUtilsTest, CanGenerateAdvertisementUuid) { } // namespace mediums } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/mediums/ble_v2/bloom_filter.cc b/connections/implementation/mediums/ble_v2/bloom_filter.cc index 23a13ccf81..b82b151d99 100644 --- a/connections/implementation/mediums/ble_v2/bloom_filter.cc +++ b/connections/implementation/mediums/ble_v2/bloom_filter.cc @@ -19,7 +19,6 @@ #include "internal/platform/logging.h" #include "src/MurmurHash3.h" -namespace location { namespace nearby { namespace connections { namespace mediums { @@ -113,4 +112,3 @@ std::vector BloomFilter::GetHashes(const std::string& s) { } // namespace mediums } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/mediums/ble_v2/bloom_filter.h b/connections/implementation/mediums/ble_v2/bloom_filter.h index 151c51eb96..606a510699 100644 --- a/connections/implementation/mediums/ble_v2/bloom_filter.h +++ b/connections/implementation/mediums/ble_v2/bloom_filter.h @@ -20,7 +20,6 @@ #include "internal/platform/byte_array.h" -namespace location { namespace nearby { namespace connections { namespace mediums { @@ -96,6 +95,5 @@ class BitSetImpl final : public BitSet { } // namespace mediums } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_MEDIUMS_BLE_V2_BLOOM_FILTER_H_ diff --git a/connections/implementation/mediums/ble_v2/bloom_filter_test.cc b/connections/implementation/mediums/ble_v2/bloom_filter_test.cc index 123cae9781..971a3b6326 100644 --- a/connections/implementation/mediums/ble_v2/bloom_filter_test.cc +++ b/connections/implementation/mediums/ble_v2/bloom_filter_test.cc @@ -18,7 +18,6 @@ #include "gtest/gtest.h" -namespace location { namespace nearby { namespace connections { namespace mediums { @@ -217,4 +216,3 @@ TEST(BloomFilterTest, ConstructLongByteArrayFails) { } // namespace mediums } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/mediums/ble_v2/discovered_peripheral_callback.h b/connections/implementation/mediums/ble_v2/discovered_peripheral_callback.h index 6b9085053a..b52a194540 100644 --- a/connections/implementation/mediums/ble_v2/discovered_peripheral_callback.h +++ b/connections/implementation/mediums/ble_v2/discovered_peripheral_callback.h @@ -22,7 +22,6 @@ #include "internal/platform/bluetooth_adapter.h" #include "internal/platform/byte_array.h" -namespace location { namespace nearby { namespace connections { namespace mediums { @@ -45,6 +44,5 @@ struct DiscoveredPeripheralCallback { } // namespace mediums } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_MEDIUMS_BLE_V2_DISCOVERED_PERIPHERAL_CALLBACK_H_ diff --git a/connections/implementation/mediums/ble_v2/discovered_peripheral_tracker.cc b/connections/implementation/mediums/ble_v2/discovered_peripheral_tracker.cc index 88812013df..6340640f58 100644 --- a/connections/implementation/mediums/ble_v2/discovered_peripheral_tracker.cc +++ b/connections/implementation/mediums/ble_v2/discovered_peripheral_tracker.cc @@ -29,7 +29,6 @@ #include "internal/platform/bluetooth_adapter.h" #include "internal/platform/mutex_lock.h" -namespace location { namespace nearby { namespace connections { namespace mediums { @@ -68,7 +67,7 @@ void DiscoveredPeripheralTracker::StopTracking(const std::string& service_id) { void DiscoveredPeripheralTracker::ProcessFoundBleAdvertisement( BleV2Peripheral peripheral, - ::location::nearby::api::ble_v2::BleAdvertisementData advertisement_data, + ::nearby::api::ble_v2::BleAdvertisementData advertisement_data, AdvertisementFetcher advertisement_fetcher) { MutexLock lock(&mutex_); @@ -187,8 +186,7 @@ void DiscoveredPeripheralTracker::ClearGattAdvertisement( void DiscoveredPeripheralTracker::HandleAdvertisement( BleV2Peripheral peripheral, - const location::nearby::api::ble_v2::BleAdvertisementData& - advertisement_data) { + const nearby::api::ble_v2::BleAdvertisementData& advertisement_data) { ByteArray advertisement_bytes = ExtractInterestingAdvertisementBytes(advertisement_data); if (advertisement_bytes.Empty()) { @@ -202,15 +200,14 @@ void DiscoveredPeripheralTracker::HandleAdvertisement( // First filter out kCopresenceServiceUuid and see if any Caller UUID // existed; if not then just take the kCopresenceServiceUuid as // |service_uuid|. - absl::flat_hash_map extracted_uuids; + absl::flat_hash_map extracted_uuids; // Filter out kCoprsence service uuid. - std::remove_copy_if( - advertisement_data.service_data.begin(), - advertisement_data.service_data.end(), - std::inserter(extracted_uuids, extracted_uuids.end()), - [](const std::pair& pair) { - return pair.first == bleutils::kCopresenceServiceUuid; - }); + std::remove_copy_if(advertisement_data.service_data.begin(), + advertisement_data.service_data.end(), + std::inserter(extracted_uuids, extracted_uuids.end()), + [](const std::pair& pair) { + return pair.first == bleutils::kCopresenceServiceUuid; + }); Uuid service_uuid; if (!extracted_uuids.empty()) { service_uuid = extracted_uuids.begin()->first; @@ -234,8 +231,7 @@ void DiscoveredPeripheralTracker::HandleAdvertisement( } ByteArray DiscoveredPeripheralTracker::ExtractInterestingAdvertisementBytes( - const location::nearby::api::ble_v2::BleAdvertisementData& - advertisement_data) { + const nearby::api::ble_v2::BleAdvertisementData& advertisement_data) { // Iterate through all tracked service IDs to see if any of their fast // advertisements are contained within this BLE advertisement. for (const auto& item : service_id_infos_) { @@ -465,8 +461,7 @@ bool DiscoveredPeripheralTracker::IsDummyAdvertisementHeader( void DiscoveredPeripheralTracker::HandleAdvertisementHeader( BleV2Peripheral peripheral, - const location::nearby::api::ble_v2::BleAdvertisementData& - advertisement_data, + const nearby::api::ble_v2::BleAdvertisementData& advertisement_data, AdvertisementFetcher advertisement_fetcher) { // Attempt to parse the advertisement header. BleAdvertisementHeader advertisement_header( @@ -507,8 +502,7 @@ void DiscoveredPeripheralTracker::HandleAdvertisementHeader( } ByteArray DiscoveredPeripheralTracker::ExtractAdvertisementHeaderBytes( - const location::nearby::api::ble_v2::BleAdvertisementData& - advertisement_data) { + const nearby::api::ble_v2::BleAdvertisementData& advertisement_data) { const auto it = advertisement_data.service_data.find(bleutils::kCopresenceServiceUuid); if (it != advertisement_data.service_data.end()) { @@ -647,4 +641,3 @@ void DiscoveredPeripheralTracker::UpdateCommonStateForFoundBleAdvertisement( } // namespace mediums } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/mediums/ble_v2/discovered_peripheral_tracker.h b/connections/implementation/mediums/ble_v2/discovered_peripheral_tracker.h index 13e60d4f78..07fd1bf5bb 100644 --- a/connections/implementation/mediums/ble_v2/discovered_peripheral_tracker.h +++ b/connections/implementation/mediums/ble_v2/discovered_peripheral_tracker.h @@ -29,7 +29,6 @@ #include "internal/platform/byte_array.h" #include "internal/platform/mutex.h" -namespace location { namespace nearby { namespace connections { namespace mediums { @@ -294,6 +293,5 @@ class DiscoveredPeripheralTracker { } // namespace mediums } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_MEDIUMS_BLE_V2_DISCOVERED_PERIPHERAL_TRACKER_H_ diff --git a/connections/implementation/mediums/ble_v2/discovered_peripheral_tracker_test.cc b/connections/implementation/mediums/ble_v2/discovered_peripheral_tracker_test.cc index 35e28e350c..f5acd2bbee 100644 --- a/connections/implementation/mediums/ble_v2/discovered_peripheral_tracker_test.cc +++ b/connections/implementation/mediums/ble_v2/discovered_peripheral_tracker_test.cc @@ -25,7 +25,6 @@ #include "internal/platform/mutex.h" #include "internal/platform/mutex_lock.h" -namespace location { namespace nearby { namespace connections { namespace mediums { @@ -967,4 +966,3 @@ TEST_F(DiscoveredPeripheralTrackerTest, } // namespace mediums } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/mediums/ble_v2_test.cc b/connections/implementation/mediums/ble_v2_test.cc index f9d8195a6b..10554c7d62 100644 --- a/connections/implementation/mediums/ble_v2_test.cc +++ b/connections/implementation/mediums/ble_v2_test.cc @@ -22,7 +22,6 @@ #include "internal/platform/count_down_latch.h" #include "internal/platform/medium_environment.h" -namespace location { namespace nearby { namespace connections { namespace { @@ -580,4 +579,3 @@ TEST_F(BleV2Test, StartScanningDiscoverButNoPeripheralLostAfterStopScanning) { } // namespace } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/mediums/bluetooth_classic.cc b/connections/implementation/mediums/bluetooth_classic.cc index de1dae9d58..3d9b18e043 100644 --- a/connections/implementation/mediums/bluetooth_classic.cc +++ b/connections/implementation/mediums/bluetooth_classic.cc @@ -22,7 +22,6 @@ #include "internal/platform/mutex_lock.h" #include "internal/platform/uuid.h" -namespace location { namespace nearby { namespace connections { @@ -432,4 +431,3 @@ std::string BluetoothClassic::GenerateUuidFromString(const std::string& data) { } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/mediums/bluetooth_classic.h b/connections/implementation/mediums/bluetooth_classic.h index c845f27040..7065209a23 100644 --- a/connections/implementation/mediums/bluetooth_classic.h +++ b/connections/implementation/mediums/bluetooth_classic.h @@ -29,7 +29,6 @@ #include "internal/platform/multi_thread_executor.h" #include "internal/platform/mutex.h" -namespace location { namespace nearby { namespace connections { @@ -206,6 +205,5 @@ class BluetoothClassic { } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_MEDIUMS_BLUETOOTH_CLASSIC_H_ diff --git a/connections/implementation/mediums/bluetooth_classic_test.cc b/connections/implementation/mediums/bluetooth_classic_test.cc index e898cf39cd..fa1632e2fb 100644 --- a/connections/implementation/mediums/bluetooth_classic_test.cc +++ b/connections/implementation/mediums/bluetooth_classic_test.cc @@ -27,7 +27,6 @@ #include "internal/platform/medium_environment.h" #include "internal/platform/system_clock.h" -namespace location { namespace nearby { namespace connections { namespace { @@ -288,4 +287,3 @@ TEST_F(BluetoothClassicTest, CanStartAcceptingConnections) { } // namespace } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/mediums/bluetooth_radio.cc b/connections/implementation/mediums/bluetooth_radio.cc index b7914321f9..92ed161dd2 100644 --- a/connections/implementation/mediums/bluetooth_radio.cc +++ b/connections/implementation/mediums/bluetooth_radio.cc @@ -18,7 +18,6 @@ #include "internal/platform/logging.h" #include "internal/platform/system_clock.h" -namespace location { namespace nearby { namespace connections { @@ -111,4 +110,3 @@ bool BluetoothRadio::SaveOriginalState() { } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/mediums/bluetooth_radio.h b/connections/implementation/mediums/bluetooth_radio.h index 386b412e5c..efef647b85 100644 --- a/connections/implementation/mediums/bluetooth_radio.h +++ b/connections/implementation/mediums/bluetooth_radio.h @@ -21,7 +21,6 @@ #include "internal/platform/atomic_boolean.h" #include "internal/platform/bluetooth_adapter.h" -namespace location { namespace nearby { namespace connections { @@ -85,6 +84,5 @@ class BluetoothRadio { } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_MEDIUMS_BLUETOOTH_RADIO_H_ diff --git a/connections/implementation/mediums/bluetooth_radio_test.cc b/connections/implementation/mediums/bluetooth_radio_test.cc index cb939e1c5b..4db50b1d9e 100644 --- a/connections/implementation/mediums/bluetooth_radio_test.cc +++ b/connections/implementation/mediums/bluetooth_radio_test.cc @@ -18,7 +18,6 @@ #include "protobuf-matchers/protocol-buffer-matchers.h" #include "gtest/gtest.h" -namespace location { namespace nearby { namespace connections { namespace { @@ -57,4 +56,3 @@ TEST(BluetoothRadioTest, CanToggle) { } // namespace } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/mediums/lost_entity_tracker.h b/connections/implementation/mediums/lost_entity_tracker.h index b0795c408a..a3e4d50620 100644 --- a/connections/implementation/mediums/lost_entity_tracker.h +++ b/connections/implementation/mediums/lost_entity_tracker.h @@ -19,7 +19,6 @@ #include "internal/platform/mutex.h" #include "internal/platform/mutex_lock.h" -namespace location { namespace nearby { namespace connections { namespace mediums { @@ -89,6 +88,5 @@ LostEntityTracker::ComputeLostEntities() { } // namespace mediums } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_MEDIUMS_LOST_ENTITY_TRACKER_H_ diff --git a/connections/implementation/mediums/lost_entity_tracker_test.cc b/connections/implementation/mediums/lost_entity_tracker_test.cc index b2211ae082..b53fa4cbbf 100644 --- a/connections/implementation/mediums/lost_entity_tracker_test.cc +++ b/connections/implementation/mediums/lost_entity_tracker_test.cc @@ -16,7 +16,6 @@ #include "gtest/gtest.h" -namespace location { namespace nearby { namespace connections { namespace mediums { @@ -134,4 +133,3 @@ TEST(LostEntityTrackerTest, SameEntityMultipleCopies) { } // namespace mediums } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/mediums/mediums.cc b/connections/implementation/mediums/mediums.cc index 30f52dc6c6..52cded28d9 100644 --- a/connections/implementation/mediums/mediums.cc +++ b/connections/implementation/mediums/mediums.cc @@ -14,7 +14,6 @@ #include "connections/implementation/mediums/mediums.h" -namespace location { namespace nearby { namespace connections { @@ -38,4 +37,3 @@ mediums::WebRtc& Mediums::GetWebRtc() { return webrtc_; } } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/mediums/mediums.h b/connections/implementation/mediums/mediums.h index a7c3aecc83..9eb1608c87 100644 --- a/connections/implementation/mediums/mediums.h +++ b/connections/implementation/mediums/mediums.h @@ -29,7 +29,6 @@ #include "connections/implementation/mediums/wifi_direct.h" #include "connections/implementation/mediums/wifi_lan.h" -namespace location { namespace nearby { namespace connections { @@ -88,6 +87,5 @@ class Mediums { } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_MEDIUMS_MEDIUMS_H_ diff --git a/connections/implementation/mediums/utils.cc b/connections/implementation/mediums/utils.cc index b8d7eeb055..a605914528 100644 --- a/connections/implementation/mediums/utils.cc +++ b/connections/implementation/mediums/utils.cc @@ -20,9 +20,10 @@ #include "internal/platform/prng.h" #include "internal/platform/crypto.h" -namespace location { namespace nearby { namespace connections { +using ::location::nearby::connections::LocationHint; +using ::location::nearby::connections::LocationStandard; ByteArray Utils::GenerateRandomBytes(size_t length) { Prng prng; @@ -71,4 +72,3 @@ LocationHint Utils::BuildLocationHint(const std::string& location) { } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/mediums/utils.h b/connections/implementation/mediums/utils.h index 351a4b2a9b..578cf300e2 100644 --- a/connections/implementation/mediums/utils.h +++ b/connections/implementation/mediums/utils.h @@ -21,7 +21,6 @@ #include "connections/implementation/proto/offline_wire_formats.pb.h" #include "internal/platform/byte_array.h" -namespace location { namespace nearby { namespace connections { @@ -30,11 +29,11 @@ class Utils { static ByteArray GenerateRandomBytes(size_t length); static ByteArray Sha256Hash(const ByteArray& source, size_t length); static ByteArray Sha256Hash(const std::string& source, size_t length); - static LocationHint BuildLocationHint(const std::string& location); + static location::nearby::connections::LocationHint BuildLocationHint( + const std::string& location); }; } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_MEDIUMS_UTILS_H_ diff --git a/connections/implementation/mediums/webrtc.cc b/connections/implementation/mediums/webrtc.cc index d549c8560e..6033cd9303 100644 --- a/connections/implementation/mediums/webrtc.cc +++ b/connections/implementation/mediums/webrtc.cc @@ -30,12 +30,12 @@ #include "internal/platform/mutex_lock.h" #include "webrtc/api/jsep.h" -namespace location { namespace nearby { namespace connections { namespace mediums { namespace { +using ::location::nearby::connections::LocationHint; // The maximum amount of time to wait to connect to a data channel via WebRTC. constexpr absl::Duration kDataChannelTimeout = absl::Seconds(10); @@ -325,7 +325,7 @@ WebRtcSocketWrapper WebRtc::AttemptToConnect( void WebRtc::ProcessLocalIceCandidate( const std::string& service_id, const WebrtcPeerId& remote_peer_id, - const ::location::nearby::mediums::IceCandidate ice_candidate) { + const location::nearby::mediums::IceCandidate ice_candidate) { MutexLock lock(&mutex_); // Check first if we have an outgoing request w/ this peer. As this request is @@ -691,7 +691,7 @@ std::unique_ptr WebRtc::CreateConnectionFlow( // Note: We need to encode the ice candidate here, before we jump // off the thread. Otherwise, it gets destroyed and we can't read // it later. - ::location::nearby::mediums::IceCandidate encoded_ice_candidate = + location::nearby::mediums::IceCandidate encoded_ice_candidate = webrtc_frames::EncodeIceCandidate(*ice_candidate); OffloadFromThread( "rtc-ice-candidates", @@ -741,4 +741,3 @@ void WebRtc::OffloadFromThread(const std::string& name, Runnable runnable) { } // namespace mediums } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/mediums/webrtc.h b/connections/implementation/mediums/webrtc.h index 7f2eb9a7c4..1dafec120e 100644 --- a/connections/implementation/mediums/webrtc.h +++ b/connections/implementation/mediums/webrtc.h @@ -36,7 +36,6 @@ #include "proto/mediums/web_rtc_signaling_frames.pb.h" #include "webrtc/api/jsep.h" -namespace location { namespace nearby { namespace connections { namespace mediums { @@ -69,11 +68,10 @@ class WebRtc { // Prepares the device to accept incoming WebRtc connections. Returns a // boolean value indicating if the device has started accepting connections. // Runs on @MainThread. - bool StartAcceptingConnections(const std::string& service_id, - const WebrtcPeerId& self_peer_id, - const LocationHint& location_hint, - AcceptedConnectionCallback callback) - ABSL_LOCKS_EXCLUDED(mutex_); + bool StartAcceptingConnections( + const std::string& service_id, const WebrtcPeerId& self_peer_id, + const location::nearby::connections::LocationHint& location_hint, + AcceptedConnectionCallback callback) ABSL_LOCKS_EXCLUDED(mutex_); // Try to stop (accepting) the specific connection with provided service id. // Runs on @MainThread @@ -83,11 +81,10 @@ class WebRtc { // Initiates a WebRtc connection with peer device identified by |peer_id| // with internal retry for maximum attempts of kConnectAttemptsLimit. // Runs on @MainThread. - WebRtcSocketWrapper Connect(const std::string& service_id, - const WebrtcPeerId& peer_id, - const LocationHint& location_hint, - CancellationFlag* cancellation_flag) - ABSL_LOCKS_EXCLUDED(mutex_); + WebRtcSocketWrapper Connect( + const std::string& service_id, const WebrtcPeerId& peer_id, + const location::nearby::connections::LocationHint& location_hint, + CancellationFlag* cancellation_flag) ABSL_LOCKS_EXCLUDED(mutex_); private: static constexpr int kConnectAttemptsLimit = 3; @@ -139,11 +136,10 @@ class WebRtc { // Attempt to initiates a WebRtc connection with peer device identified by // |peer_id|. // Runs on @MainThread. - WebRtcSocketWrapper AttemptToConnect(const std::string& service_id, - const WebrtcPeerId& peer_id, - const LocationHint& location_hint, - CancellationFlag* cancellation_flag) - ABSL_LOCKS_EXCLUDED(mutex_); + WebRtcSocketWrapper AttemptToConnect( + const std::string& service_id, const WebrtcPeerId& peer_id, + const location::nearby::connections::LocationHint& location_hint, + CancellationFlag* cancellation_flag) ABSL_LOCKS_EXCLUDED(mutex_); // Returns if the device is accepting connection with specific service id. // Runs on @MainThread. @@ -213,7 +209,7 @@ class WebRtc { // Runs on |single_thread_executor_|. void ProcessLocalIceCandidate( const std::string& service_id, const WebrtcPeerId& remote_peer_id, - const ::location::nearby::mediums::IceCandidate ice_candidate) + const location::nearby::mediums::IceCandidate ice_candidate) ABSL_LOCKS_EXCLUDED(mutex_); // Runs on |single_thread_executor_|. @@ -253,6 +249,5 @@ class WebRtc { } // namespace mediums } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_MEDIUMS_WEBRTC_H_ diff --git a/connections/implementation/mediums/webrtc/connection_flow.cc b/connections/implementation/mediums/webrtc/connection_flow.cc index 863f16fa9a..736433135b 100644 --- a/connections/implementation/mediums/webrtc/connection_flow.cc +++ b/connections/implementation/mediums/webrtc/connection_flow.cc @@ -28,7 +28,6 @@ #include "webrtc/api/data_channel_interface.h" #include "webrtc/api/jsep.h" -namespace location { namespace nearby { namespace connections { namespace mediums { @@ -558,4 +557,3 @@ ConnectionFlow::GetAndResetPeerConnection() { } // namespace mediums } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/mediums/webrtc/connection_flow.h b/connections/implementation/mediums/webrtc/connection_flow.h index d042d10233..51086f66f6 100644 --- a/connections/implementation/mediums/webrtc/connection_flow.h +++ b/connections/implementation/mediums/webrtc/connection_flow.h @@ -28,7 +28,6 @@ #include "webrtc/api/data_channel_interface.h" #include "webrtc/api/peer_connection_interface.h" -namespace location { namespace nearby { namespace connections { namespace mediums { @@ -228,6 +227,5 @@ class ConnectionFlow : public webrtc::PeerConnectionObserver { } // namespace mediums } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_MEDIUMS_WEBRTC_CONNECTION_FLOW_H_ diff --git a/connections/implementation/mediums/webrtc/connection_flow_test.cc b/connections/implementation/mediums/webrtc/connection_flow_test.cc index 5421abf440..8c0661639b 100644 --- a/connections/implementation/mediums/webrtc/connection_flow_test.cc +++ b/connections/implementation/mediums/webrtc/connection_flow_test.cc @@ -32,7 +32,6 @@ #include "webrtc/api/rtc_error.h" #include "webrtc/api/scoped_refptr.h" -namespace location { namespace nearby { namespace connections { namespace mediums { @@ -405,4 +404,3 @@ TEST_F(ConnectionFlowTest, TerminateOfferer) { } // namespace mediums } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/mediums/webrtc/data_channel_listener.h b/connections/implementation/mediums/webrtc/data_channel_listener.h index 7464e747dc..47db2fccfd 100644 --- a/connections/implementation/mediums/webrtc/data_channel_listener.h +++ b/connections/implementation/mediums/webrtc/data_channel_listener.h @@ -19,7 +19,6 @@ #include "connections/listeners.h" #include "internal/platform/byte_array.h" -namespace location { namespace nearby { namespace connections { namespace mediums { @@ -38,6 +37,5 @@ struct DataChannelListener { } // namespace mediums } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_MEDIUMS_WEBRTC_DATA_CHANNEL_LISTENER_H_ diff --git a/connections/implementation/mediums/webrtc/local_ice_candidate_listener.h b/connections/implementation/mediums/webrtc/local_ice_candidate_listener.h index 34fefc1e02..cf61fae485 100644 --- a/connections/implementation/mediums/webrtc/local_ice_candidate_listener.h +++ b/connections/implementation/mediums/webrtc/local_ice_candidate_listener.h @@ -18,7 +18,6 @@ #include "connections/listeners.h" #include "webrtc/api/peer_connection_interface.h" -namespace location { namespace nearby { namespace connections { namespace mediums { @@ -27,13 +26,12 @@ namespace mediums { struct LocalIceCandidateListener { // Called when a new local ice candidate has been found. std::function - local_ice_candidate_found_cb = location::nearby::DefaultCallback< - const webrtc::IceCandidateInterface*>(); + local_ice_candidate_found_cb = + nearby::DefaultCallback(); }; } // namespace mediums } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_MEDIUMS_WEBRTC_LOCAL_ICE_CANDIDATE_LISTENER_H_ diff --git a/connections/implementation/mediums/webrtc/signaling_frames.cc b/connections/implementation/mediums/webrtc/signaling_frames.cc index c8077c5107..66dbf96386 100644 --- a/connections/implementation/mediums/webrtc/signaling_frames.cc +++ b/connections/implementation/mediums/webrtc/signaling_frames.cc @@ -14,7 +14,6 @@ #include "connections/implementation/mediums/webrtc/signaling_frames.h" -namespace location { namespace nearby { namespace connections { namespace mediums { @@ -130,5 +129,4 @@ location::nearby::mediums::IceCandidate EncodeIceCandidate( } // namespace webrtc_frames } // namespace mediums } // namespace connections -} // namespace nearby -} // namespace location +} // namespace nearby \ No newline at end of file diff --git a/connections/implementation/mediums/webrtc/signaling_frames.h b/connections/implementation/mediums/webrtc/signaling_frames.h index 89999b8a82..61af18fc37 100644 --- a/connections/implementation/mediums/webrtc/signaling_frames.h +++ b/connections/implementation/mediums/webrtc/signaling_frames.h @@ -22,7 +22,6 @@ #include "proto/mediums/web_rtc_signaling_frames.pb.h" #include "webrtc/api/peer_connection_interface.h" -namespace location { namespace nearby { namespace connections { namespace mediums { @@ -53,6 +52,5 @@ std::vector> DecodeIceCandidates( } // namespace mediums } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_MEDIUMS_WEBRTC_SIGNALING_FRAMES_H_ diff --git a/connections/implementation/mediums/webrtc/signaling_frames_test.cc b/connections/implementation/mediums/webrtc/signaling_frames_test.cc index 8c74d457e3..a1bb674dc8 100644 --- a/connections/implementation/mediums/webrtc/signaling_frames_test.cc +++ b/connections/implementation/mediums/webrtc/signaling_frames_test.cc @@ -22,7 +22,6 @@ #include "gtest/gtest.h" #include "connections/implementation/mediums/webrtc_peer_id.h" -namespace location { namespace nearby { namespace connections { namespace mediums { @@ -30,6 +29,8 @@ namespace webrtc_frames { namespace { +using ::location::nearby::mediums::IceCandidate; +using ::location::nearby::mediums::WebRtcSignalingFrame; const char kSampleSdp[] = "v=0\r\no=- 7859371131 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 " "0\r\na=msid-semantic: WMS\r\n"; @@ -84,7 +85,7 @@ TEST(SignalingFramesTest, SignalingPoke) { WebrtcPeerId sender_id("abc"); ByteArray encoded_poke = EncodeReadyForSignalingPoke(sender_id); - location::nearby::mediums::WebRtcSignalingFrame frame; + WebRtcSignalingFrame frame; frame.ParseFromString(std::string(encoded_poke.data(), encoded_poke.size())); EXPECT_THAT(frame, protobuf_matchers::EqualsProto(R"pb( @@ -100,7 +101,7 @@ TEST(SignalingFramesTest, EncodeValidOffer) { webrtc::CreateSessionDescription(webrtc::SdpType::kOffer, kSampleSdp); ByteArray encoded_offer = EncodeOffer(sender_id, *offer); - location::nearby::mediums::WebRtcSignalingFrame frame; + WebRtcSignalingFrame frame; frame.ParseFromString( std::string(encoded_offer.data(), encoded_offer.size())); @@ -108,7 +109,7 @@ TEST(SignalingFramesTest, EncodeValidOffer) { } TEST(SignaingFramesTest, DecodeValidOffer) { - location::nearby::mediums::WebRtcSignalingFrame frame; + WebRtcSignalingFrame frame; proto2::TextFormat::ParseFromString(kOfferProto, &frame); std::unique_ptr decoded_offer = DecodeOffer(frame); @@ -125,7 +126,7 @@ TEST(SignalingFramesTest, EncodeValidAnswer) { webrtc::CreateSessionDescription(webrtc::SdpType::kAnswer, kSampleSdp)); ByteArray encoded_answer = EncodeAnswer(sender_id, *answer); - location::nearby::mediums::WebRtcSignalingFrame frame; + WebRtcSignalingFrame frame; frame.ParseFromString( std::string(encoded_answer.data(), encoded_answer.size())); @@ -133,7 +134,7 @@ TEST(SignalingFramesTest, EncodeValidAnswer) { } TEST(SignalingFramesTest, DecodeValidAnswer) { - location::nearby::mediums::WebRtcSignalingFrame frame; + WebRtcSignalingFrame frame; proto2::TextFormat::ParseFromString(kAnswerProto, &frame); std::unique_ptr decoded_answer = DecodeAnswer(frame); @@ -153,14 +154,14 @@ TEST(SignalingFramesTest, EncodeValidIceCandidates) { kIceSdpMid, kIceSdpMLineIndex, kIceCandidateSdp1, &error)); ice_candidates.emplace_back(webrtc::CreateIceCandidate( kIceSdpMid, kIceSdpMLineIndex, kIceCandidateSdp2, &error)); - std::vector encoded_candidates_vec; + std::vector encoded_candidates_vec; for (const auto& ice_candidate : ice_candidates) { encoded_candidates_vec.push_back(EncodeIceCandidate(*ice_candidate)); } ByteArray encoded_candidates = EncodeIceCandidates(sender_id, encoded_candidates_vec); - location::nearby::mediums::WebRtcSignalingFrame frame; + WebRtcSignalingFrame frame; frame.ParseFromString( std::string(encoded_candidates.data(), encoded_candidates.size())); @@ -175,7 +176,7 @@ TEST(SignalingFramesTest, DecodeValidIceCandidates) { ice_candidates.emplace_back(webrtc::CreateIceCandidate( kIceSdpMid, kIceSdpMLineIndex, kIceCandidateSdp2, &error)); - location::nearby::mediums::WebRtcSignalingFrame frame; + WebRtcSignalingFrame frame; proto2::TextFormat::ParseFromString(kIceCandidatesProto, &frame); std::vector> decoded_candidates = DecodeIceCandidates(frame); @@ -194,4 +195,3 @@ TEST(SignalingFramesTest, DecodeValidIceCandidates) { } // namespace mediums } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/mediums/webrtc/webrtc_socket_impl.cc b/connections/implementation/mediums/webrtc/webrtc_socket_impl.cc index e5d86e788d..55c950f4cb 100644 --- a/connections/implementation/mediums/webrtc/webrtc_socket_impl.cc +++ b/connections/implementation/mediums/webrtc/webrtc_socket_impl.cc @@ -17,7 +17,6 @@ #include "internal/platform/logging.h" #include "internal/platform/mutex_lock.h" -namespace location { namespace nearby { namespace connections { namespace mediums { @@ -187,4 +186,3 @@ void WebRtcSocket::OffloadFromSignalingThread(Runnable runnable) { } // namespace mediums } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/mediums/webrtc/webrtc_socket_impl.h b/connections/implementation/mediums/webrtc/webrtc_socket_impl.h index 19c9efbe87..c348250436 100644 --- a/connections/implementation/mediums/webrtc/webrtc_socket_impl.h +++ b/connections/implementation/mediums/webrtc/webrtc_socket_impl.h @@ -28,7 +28,6 @@ #include "internal/platform/single_thread_executor.h" #include "webrtc/api/data_channel_interface.h" -namespace location { namespace nearby { namespace connections { namespace mediums { @@ -50,7 +49,7 @@ class WebRtcSocket : public Socket, public webrtc::DataChannelObserver { WebRtcSocket(const WebRtcSocket& other) = delete; WebRtcSocket& operator=(const WebRtcSocket& other) = delete; - // Overrides for location::nearby::Socket: + // Overrides for nearby::Socket: InputStream& GetInputStream() override; OutputStream& GetOutputStream() override; void Close() override; @@ -118,6 +117,5 @@ class WebRtcSocket : public Socket, public webrtc::DataChannelObserver { } // namespace mediums } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_MEDIUMS_WEBRTC_WEBRTC_SOCKET_IMPL_H_ diff --git a/connections/implementation/mediums/webrtc/webrtc_socket_impl_test.cc b/connections/implementation/mediums/webrtc/webrtc_socket_impl_test.cc index fdb8137f62..f8bd7b5260 100644 --- a/connections/implementation/mediums/webrtc/webrtc_socket_impl_test.cc +++ b/connections/implementation/mediums/webrtc/webrtc_socket_impl_test.cc @@ -22,7 +22,6 @@ #include "internal/platform/byte_array.h" #include "webrtc/api/data_channel_interface.h" -namespace location { namespace nearby { namespace connections { namespace mediums { @@ -232,4 +231,3 @@ TEST(WebRtcSocketTest, CloseStateTriggersCallback) { } // namespace mediums } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/mediums/webrtc_peer_id.cc b/connections/implementation/mediums/webrtc_peer_id.cc index c74978b825..8d11894c3c 100644 --- a/connections/implementation/mediums/webrtc_peer_id.cc +++ b/connections/implementation/mediums/webrtc_peer_id.cc @@ -20,7 +20,6 @@ #include "absl/strings/escaping.h" #include "connections/implementation/mediums/utils.h" -namespace location { namespace nearby { namespace connections { namespace mediums { @@ -51,4 +50,3 @@ bool WebrtcPeerId::IsValid() const { return !id_.empty(); } } // namespace mediums } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/mediums/webrtc_peer_id.h b/connections/implementation/mediums/webrtc_peer_id.h index 77ac1cc8d8..2027b74e4c 100644 --- a/connections/implementation/mediums/webrtc_peer_id.h +++ b/connections/implementation/mediums/webrtc_peer_id.h @@ -20,7 +20,6 @@ #include "internal/platform/byte_array.h" -namespace location { namespace nearby { namespace connections { namespace mediums { @@ -47,6 +46,5 @@ class WebrtcPeerId { } // namespace mediums } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_MEDIUMS_WEBRTC_PEER_ID_H_ diff --git a/connections/implementation/mediums/webrtc_peer_id_stub.cc b/connections/implementation/mediums/webrtc_peer_id_stub.cc index 5ac5ad6856..0b6983e0d5 100644 --- a/connections/implementation/mediums/webrtc_peer_id_stub.cc +++ b/connections/implementation/mediums/webrtc_peer_id_stub.cc @@ -20,7 +20,6 @@ #include "absl/strings/escaping.h" #include "connections/implementation/mediums/utils.h" -namespace location { namespace nearby { namespace connections { namespace mediums { @@ -34,4 +33,3 @@ bool WebrtcPeerId::IsValid() const { return false; } } // namespace mediums } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/mediums/webrtc_peer_id_stub.h b/connections/implementation/mediums/webrtc_peer_id_stub.h index 77ac1cc8d8..2027b74e4c 100644 --- a/connections/implementation/mediums/webrtc_peer_id_stub.h +++ b/connections/implementation/mediums/webrtc_peer_id_stub.h @@ -20,7 +20,6 @@ #include "internal/platform/byte_array.h" -namespace location { namespace nearby { namespace connections { namespace mediums { @@ -47,6 +46,5 @@ class WebrtcPeerId { } // namespace mediums } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_MEDIUMS_WEBRTC_PEER_ID_H_ diff --git a/connections/implementation/mediums/webrtc_peer_id_test.cc b/connections/implementation/mediums/webrtc_peer_id_test.cc index 69345ada3f..a0fef2177a 100644 --- a/connections/implementation/mediums/webrtc_peer_id_test.cc +++ b/connections/implementation/mediums/webrtc_peer_id_test.cc @@ -22,7 +22,6 @@ #include "internal/platform/byte_array.h" #include "internal/platform/crypto.h" -namespace location { namespace nearby { namespace connections { namespace mediums { @@ -54,4 +53,3 @@ TEST(WebrtcPeerIdTest, GetId) { } // namespace mediums } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/mediums/webrtc_socket.h b/connections/implementation/mediums/webrtc_socket.h index 86b0b61892..6af35b5962 100644 --- a/connections/implementation/mediums/webrtc_socket.h +++ b/connections/implementation/mediums/webrtc_socket.h @@ -19,7 +19,6 @@ #include "connections/implementation/mediums/webrtc/webrtc_socket_impl.h" -namespace location { namespace nearby { namespace connections { namespace mediums { @@ -50,6 +49,5 @@ class WebRtcSocketWrapper final { } // namespace mediums } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_MEDIUMS_WEBRTC_WEBRTC_SOCKET_H_ diff --git a/connections/implementation/mediums/webrtc_socket_stub.h b/connections/implementation/mediums/webrtc_socket_stub.h index 7270a57f55..7044865209 100644 --- a/connections/implementation/mediums/webrtc_socket_stub.h +++ b/connections/implementation/mediums/webrtc_socket_stub.h @@ -20,7 +20,6 @@ #include "internal/platform/input_stream.h" #include "internal/platform/output_stream.h" -namespace location { namespace nearby { namespace connections { namespace mediums { @@ -64,6 +63,5 @@ class WebRtcSocketWrapper final { } // namespace mediums } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_MEDIUMS_WEBRTC_SOCKET_STUB_H_ diff --git a/connections/implementation/mediums/webrtc_stub.cc b/connections/implementation/mediums/webrtc_stub.cc index 25cf72fca4..c459761c79 100644 --- a/connections/implementation/mediums/webrtc_stub.cc +++ b/connections/implementation/mediums/webrtc_stub.cc @@ -22,10 +22,10 @@ #include "internal/platform/cancelable_alarm.h" #include "internal/platform/future.h" -namespace location { namespace nearby { namespace connections { namespace mediums { +using ::location::nearby::connections::LocationHint; WebRtc::WebRtc() = default; @@ -58,4 +58,3 @@ WebRtcSocketWrapper WebRtc::Connect(const std::string& service_id, } // namespace mediums } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/mediums/webrtc_stub.h b/connections/implementation/mediums/webrtc_stub.h index f330e8f59e..41451f7071 100644 --- a/connections/implementation/mediums/webrtc_stub.h +++ b/connections/implementation/mediums/webrtc_stub.h @@ -26,7 +26,6 @@ #include "internal/platform/cancellation_flag.h" #include "internal/platform/listeners.h" -namespace location { namespace nearby { namespace connections { namespace mediums { @@ -56,10 +55,10 @@ class WebRtc { // Prepares the device to accept incoming WebRtc connections. Returns a // boolean value indicating if the device has started accepting connections. // Runs on @MainThread. - bool StartAcceptingConnections(const std::string& service_id, - const WebrtcPeerId& self_peer_id, - const LocationHint& location_hint, - AcceptedConnectionCallback callback); + bool StartAcceptingConnections( + const std::string& service_id, const WebrtcPeerId& self_peer_id, + const location::nearby::connections::LocationHint& location_hint, + AcceptedConnectionCallback callback); // Try to stop (accepting) the specific connection with provided service id. // Runs on @MainThread @@ -68,15 +67,14 @@ class WebRtc { // Initiates a WebRtc connection with peer device identified by |peer_id| // with internal retry for maximum attempts of kConnectAttemptsLimit. // Runs on @MainThread. - WebRtcSocketWrapper Connect(const std::string& service_id, - const WebrtcPeerId& peer_id, - const LocationHint& location_hint, - CancellationFlag* cancellation_flag); + WebRtcSocketWrapper Connect( + const std::string& service_id, const WebrtcPeerId& peer_id, + const location::nearby::connections::LocationHint& location_hint, + CancellationFlag* cancellation_flag); }; } // namespace mediums } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_MEDIUMS_WEBRTC_STUB_H_ diff --git a/connections/implementation/mediums/webrtc_test.cc b/connections/implementation/mediums/webrtc_test.cc index 6534e59df8..e6c8dac26e 100644 --- a/connections/implementation/mediums/webrtc_test.cc +++ b/connections/implementation/mediums/webrtc_test.cc @@ -24,7 +24,6 @@ #include "internal/platform/medium_environment.h" #include "internal/platform/mutex_lock.h" -namespace location { namespace nearby { namespace connections { namespace mediums { @@ -32,6 +31,7 @@ namespace mediums { namespace { using FeatureFlags = FeatureFlags::Flags; +using ::location::nearby::connections::LocationHint; constexpr FeatureFlags kTestCases[] = { FeatureFlags{ @@ -409,4 +409,3 @@ TEST_F(WebRtcTest, ContinueAcceptingConnectionsOnComplete) { } // namespace mediums } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/mediums/wifi.h b/connections/implementation/mediums/wifi.h index 34caa6d69e..b38027b214 100644 --- a/connections/implementation/mediums/wifi.h +++ b/connections/implementation/mediums/wifi.h @@ -21,7 +21,6 @@ #include "internal/platform/mutex_lock.h" #include "internal/platform/wifi.h" -namespace location { namespace nearby { namespace connections { @@ -75,6 +74,5 @@ class Wifi { } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_MEDIUMS_WIFI_H_ diff --git a/connections/implementation/mediums/wifi_direct.cc b/connections/implementation/mediums/wifi_direct.cc index e963ee7864..aa03650d7a 100644 --- a/connections/implementation/mediums/wifi_direct.cc +++ b/connections/implementation/mediums/wifi_direct.cc @@ -19,7 +19,6 @@ #include "internal/platform/logging.h" -namespace location { namespace nearby { namespace connections { @@ -280,4 +279,3 @@ WifiDirectSocket WifiDirect::Connect(const std::string& service_id, } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/mediums/wifi_direct.h b/connections/implementation/mediums/wifi_direct.h index 2f201d048b..ab2807ced7 100644 --- a/connections/implementation/mediums/wifi_direct.h +++ b/connections/implementation/mediums/wifi_direct.h @@ -23,7 +23,6 @@ #include "internal/platform/mutex.h" #include "internal/platform/wifi_direct.h" -namespace location { namespace nearby { namespace connections { @@ -120,6 +119,5 @@ class WifiDirect { } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_MEDIUMS_WIFI_DIRECT_H_ diff --git a/connections/implementation/mediums/wifi_direct_test.cc b/connections/implementation/mediums/wifi_direct_test.cc index 89740bf01a..7a4f482ba0 100644 --- a/connections/implementation/mediums/wifi_direct_test.cc +++ b/connections/implementation/mediums/wifi_direct_test.cc @@ -21,7 +21,6 @@ #include "internal/platform/medium_environment.h" #include "internal/platform/wifi_direct.h" -namespace location { namespace nearby { namespace connections { namespace { @@ -184,4 +183,3 @@ TEST_F(WifiDirectTest, CanStartGOTheOtherFailConnect) { } // namespace } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/mediums/wifi_hotspot.cc b/connections/implementation/mediums/wifi_hotspot.cc index e5957a94a4..27b8256e5d 100644 --- a/connections/implementation/mediums/wifi_hotspot.cc +++ b/connections/implementation/mediums/wifi_hotspot.cc @@ -22,7 +22,6 @@ #include "connections/implementation/mediums/utils.h" #include "internal/platform/logging.h" -namespace location { namespace nearby { namespace connections { @@ -283,4 +282,3 @@ WifiHotspotSocket WifiHotspot::Connect(const std::string& service_id, } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/mediums/wifi_hotspot.h b/connections/implementation/mediums/wifi_hotspot.h index 5762987372..db518f4b47 100644 --- a/connections/implementation/mediums/wifi_hotspot.h +++ b/connections/implementation/mediums/wifi_hotspot.h @@ -23,7 +23,6 @@ #include "internal/platform/mutex.h" #include "internal/platform/wifi_hotspot.h" -namespace location { namespace nearby { namespace connections { @@ -115,6 +114,5 @@ class WifiHotspot { } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_MEDIUMS_WIFI_HOTSPOT_H_ diff --git a/connections/implementation/mediums/wifi_hotspot_test.cc b/connections/implementation/mediums/wifi_hotspot_test.cc index 3fdca3d131..da01bd22be 100644 --- a/connections/implementation/mediums/wifi_hotspot_test.cc +++ b/connections/implementation/mediums/wifi_hotspot_test.cc @@ -23,7 +23,6 @@ #include "internal/platform/wifi_hotspot.h" #include "internal/platform/wifi_hotspot_credential.h" -namespace location { namespace nearby { namespace connections { namespace { @@ -185,4 +184,3 @@ TEST_F(WifiHotspotTest, CanStartHotspotTheOtherFailConnect) { } // namespace } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/mediums/wifi_lan.cc b/connections/implementation/mediums/wifi_lan.cc index a03805f213..f66d3881e8 100644 --- a/connections/implementation/mediums/wifi_lan.cc +++ b/connections/implementation/mediums/wifi_lan.cc @@ -23,7 +23,6 @@ #include "internal/platform/logging.h" #include "internal/platform/mutex_lock.h" -namespace location { namespace nearby { namespace connections { @@ -426,4 +425,3 @@ int WifiLan::GeneratePort(const std::string& service_id, } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/mediums/wifi_lan.h b/connections/implementation/mediums/wifi_lan.h index 44cb464caa..e82710603b 100644 --- a/connections/implementation/mediums/wifi_lan.h +++ b/connections/implementation/mediums/wifi_lan.h @@ -28,7 +28,6 @@ #include "internal/platform/mutex.h" #include "internal/platform/wifi_lan.h" -namespace location { namespace nearby { namespace connections { @@ -194,6 +193,5 @@ class WifiLan { } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_MEDIUMS_WIFI_LAN_H_ diff --git a/connections/implementation/mediums/wifi_lan_test.cc b/connections/implementation/mediums/wifi_lan_test.cc index 310f57fc6d..fd23f51a0a 100644 --- a/connections/implementation/mediums/wifi_lan_test.cc +++ b/connections/implementation/mediums/wifi_lan_test.cc @@ -26,7 +26,6 @@ #include "internal/platform/nsd_service_info.h" #include "internal/platform/wifi_lan.h" -namespace location { namespace nearby { namespace connections { namespace { @@ -345,4 +344,3 @@ TEST_F(WifiLanTest, CanDiscoverThatOtherMediumAdvertise) { } // namespace } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/mediums/wifi_test.cc b/connections/implementation/mediums/wifi_test.cc index 2488a0fc60..8f47f79202 100644 --- a/connections/implementation/mediums/wifi_test.cc +++ b/connections/implementation/mediums/wifi_test.cc @@ -18,7 +18,6 @@ #include "protobuf-matchers/protocol-buffer-matchers.h" #include "gtest/gtest.h" -namespace location { namespace nearby { namespace connections { namespace { @@ -46,4 +45,3 @@ TEST(WifiTest, CanInformation) { } // namespace } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/mock_service_controller.h b/connections/implementation/mock_service_controller.h index f579982407..449d2777b6 100644 --- a/connections/implementation/mock_service_controller.h +++ b/connections/implementation/mock_service_controller.h @@ -18,7 +18,6 @@ #include "gmock/gmock.h" #include "connections/implementation/service_controller.h" -namespace location { namespace nearby { namespace connections { @@ -92,6 +91,5 @@ class MockServiceController : public ServiceController { } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_MOCK_SERVICE_CONTROLLER_H_ diff --git a/connections/implementation/mock_service_controller_router.h b/connections/implementation/mock_service_controller_router.h index e8f7502f9f..7c8809fa5c 100644 --- a/connections/implementation/mock_service_controller_router.h +++ b/connections/implementation/mock_service_controller_router.h @@ -18,7 +18,6 @@ #include "gmock/gmock.h" #include "connections/implementation/service_controller_router.h" -namespace location { namespace nearby { namespace connections { @@ -101,6 +100,5 @@ class MockServiceControllerRouter : public ServiceControllerRouter { } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_MOCK_SERVICE_CONTROLLER_ROUTER_H_ diff --git a/connections/implementation/offline_frames.cc b/connections/implementation/offline_frames.cc index 4b4c928abd..e9e8bacfc6 100644 --- a/connections/implementation/offline_frames.cc +++ b/connections/implementation/offline_frames.cc @@ -23,14 +23,21 @@ #include "connections/status.h" #include "internal/platform/byte_array.h" -namespace location { namespace nearby { namespace connections { namespace parser { namespace { -using ExceptionOrOfflineFrame = ExceptionOr; +using ExceptionOrOfflineFrame = + ExceptionOr<::location::nearby::connections::OfflineFrame>; using MessageLite = ::google::protobuf::MessageLite; +using ::location::nearby::connections::BandwidthUpgradeNegotiationFrame; +using ::location::nearby::connections::ConnectionRequestFrame; +using ::location::nearby::connections::ConnectionResponseFrame; +using ::location::nearby::connections::LocationHint; +using ::location::nearby::connections::OfflineFrame; +using ::location::nearby::connections::PayloadTransferFrame; +using ::location::nearby::connections::V1Frame; ByteArray ToBytes(OfflineFrame&& frame) { ByteArray bytes(frame.ByteSizeLong()); @@ -506,4 +513,3 @@ std::vector ConnectionRequestMediumsToMediums( } // namespace parser } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/offline_frames.h b/connections/implementation/offline_frames.h index 1d79111d1b..c61fc0d739 100644 --- a/connections/implementation/offline_frames.h +++ b/connections/implementation/offline_frames.h @@ -24,23 +24,25 @@ #include "internal/platform/byte_array.h" #include "internal/platform/exception.h" -namespace location { namespace nearby { namespace connections { namespace parser { -using UpgradePathInfo = BandwidthUpgradeNegotiationFrame::UpgradePathInfo; +using UpgradePathInfo = ::location::nearby::connections:: + BandwidthUpgradeNegotiationFrame::UpgradePathInfo; // Serialize/Deserialize Nearby Connections Protocol messages. // Parses incoming message. // Returns OfflineFrame if parser was able to understand it, or // Exception::kInvalidProtocolBuffer, if parser failed. -ExceptionOr FromBytes(const ByteArray& offline_frame_bytes); +ExceptionOr FromBytes( + const ByteArray& offline_frame_bytes); // Returns FrameType of a parsed message, or // V1Frame::UNKNOWN_FRAME_TYPE, if frame contents is not recognized. -V1Frame::FrameType GetFrameType(const OfflineFrame& offline_frame); +location::nearby::connections::V1Frame::FrameType GetFrameType( + const location::nearby::connections::OfflineFrame& offline_frame); // Builds Connection Request / Response messages. ByteArray ForConnectionRequest(const ConnectionInfo& conection_info); @@ -48,11 +50,15 @@ ByteArray ForConnectionResponse(std::int32_t status); // Builds Payload transfer messages. ByteArray ForDataPayloadTransfer( - const PayloadTransferFrame::PayloadHeader& header, - const PayloadTransferFrame::PayloadChunk& chunk); + const location::nearby::connections::PayloadTransferFrame::PayloadHeader& + header, + const location::nearby::connections::PayloadTransferFrame::PayloadChunk& + chunk); ByteArray ForControlPayloadTransfer( - const PayloadTransferFrame::PayloadHeader& header, - const PayloadTransferFrame::ControlMessage& control); + const location::nearby::connections::PayloadTransferFrame::PayloadHeader& + header, + const location::nearby::connections::PayloadTransferFrame::ControlMessage& + control); // Builds Bandwidth Upgrade [BWU] messages. ByteArray ForBwuIntroduction(const std::string& endpoint_id, @@ -77,8 +83,9 @@ ByteArray ForBwuWifiDirectPathAvailable(const std::string& ssid, const std::string& gateway); ByteArray ForBwuBluetoothPathAvailable(const std::string& service_id, const std::string& mac_address); -ByteArray ForBwuWebrtcPathAvailable(const std::string& peer_id, - const LocationHint& location_hint_a); +ByteArray ForBwuWebrtcPathAvailable( + const std::string& peer_id, + const location::nearby::connections::LocationHint& location_hint_a); ByteArray ForBwuFailure(const UpgradePathInfo& info); ByteArray ForBwuLastWrite(); ByteArray ForBwuSafeToClose(); @@ -89,14 +96,16 @@ ByteArray ForDisconnection(); UpgradePathInfo::Medium MediumToUpgradePathInfoMedium(Medium medium); Medium UpgradePathInfoMediumToMedium(UpgradePathInfo::Medium medium); -ConnectionRequestFrame::Medium MediumToConnectionRequestMedium(Medium medium); -Medium ConnectionRequestMediumToMedium(ConnectionRequestFrame::Medium medium); +location::nearby::connections::ConnectionRequestFrame::Medium +MediumToConnectionRequestMedium(Medium medium); +Medium ConnectionRequestMediumToMedium( + location::nearby::connections::ConnectionRequestFrame::Medium medium); std::vector ConnectionRequestMediumsToMediums( - const ConnectionRequestFrame& connection_request_frame); + const location::nearby::connections::ConnectionRequestFrame& + connection_request_frame); } // namespace parser } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_OFFLINE_FRAMES_H_ diff --git a/connections/implementation/offline_frames_test.cc b/connections/implementation/offline_frames_test.cc index 4c41af148a..1a201e0fc1 100644 --- a/connections/implementation/offline_frames_test.cc +++ b/connections/implementation/offline_frames_test.cc @@ -27,13 +27,15 @@ #include "connections/implementation/proto/offline_wire_formats.pb.h" #include "internal/platform/byte_array.h" -namespace location { namespace nearby { namespace connections { namespace parser { namespace { -using Medium = proto::connections::Medium; +using ::location::nearby::connections::OfflineFrame; +using ::location::nearby::connections::PayloadTransferFrame; +using ::location::nearby::connections::V1Frame; +using Medium = ::location::nearby::proto::connections::Medium; using ::protobuf_matchers::EqualsProto; constexpr absl::string_view kEndpointId{"ABC"}; @@ -407,4 +409,3 @@ TEST(OfflineFramesTest, CanGenerateKeepAlive) { } // namespace parser } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/offline_frames_validator.cc b/connections/implementation/offline_frames_validator.cc index 47c99ad434..5df7a1d33b 100644 --- a/connections/implementation/offline_frames_validator.cc +++ b/connections/implementation/offline_frames_validator.cc @@ -24,22 +24,29 @@ #include "internal/platform/implementation/platform.h" #include "internal/platform/logging.h" -namespace location { namespace nearby { namespace connections { namespace parser { namespace { -using PayloadChunk = PayloadTransferFrame::PayloadChunk; -using ControlMessage = PayloadTransferFrame::ControlMessage; -using ClientIntroduction = BandwidthUpgradeNegotiationFrame::ClientIntroduction; +using PayloadChunk = + ::location::nearby::connections::PayloadTransferFrame::PayloadChunk; +using ControlMessage = + ::location::nearby::connections::PayloadTransferFrame::ControlMessage; +using ClientIntroduction = ::location::nearby::connections:: + BandwidthUpgradeNegotiationFrame::ClientIntroduction; using WifiHotspotCredentials = UpgradePathInfo::WifiHotspotCredentials; using WifiLanSocket = UpgradePathInfo::WifiLanSocket; using WifiAwareCredentials = UpgradePathInfo::WifiAwareCredentials; using WifiDirectCredentials = UpgradePathInfo::WifiDirectCredentials; using BluetoothCredentials = UpgradePathInfo::BluetoothCredentials; using WebRtcCredentials = UpgradePathInfo::WebRtcCredentials; -using Medium = ::location::nearby::connections::Medium; +using Medium = ::nearby::connections::Medium; +using ::location::nearby::connections::BandwidthUpgradeNegotiationFrame; +using ::location::nearby::connections::ConnectionRequestFrame; +using ::location::nearby::connections::ConnectionResponseFrame; +using ::location::nearby::connections::PayloadTransferFrame; +using ::location::nearby::connections::V1Frame; constexpr absl::string_view kIpv4PatternString{ "^([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\." @@ -362,7 +369,8 @@ bool CheckForIllegalCharacters(std::string toBeValidated, } // namespace -Exception EnsureValidOfflineFrame(const OfflineFrame& offline_frame) { +Exception EnsureValidOfflineFrame( + const location::nearby::connections::OfflineFrame& offline_frame) { V1Frame::FrameType frame_type = GetFrameType(offline_frame); switch (frame_type) { case V1Frame::CONNECTION_REQUEST: @@ -385,8 +393,9 @@ Exception EnsureValidOfflineFrame(const OfflineFrame& offline_frame) { if (offline_frame.has_v1() && (offline_frame.v1().payload_transfer().payload_header().has_type() && offline_frame.v1().payload_transfer().payload_header().type() == - PayloadTransferFrame_PayloadHeader_PayloadType:: - PayloadTransferFrame_PayloadHeader_PayloadType_FILE)) { + location::nearby::connections:: + PayloadTransferFrame_PayloadHeader_PayloadType:: + PayloadTransferFrame_PayloadHeader_PayloadType_FILE)) { if (offline_frame.v1() .payload_transfer() .payload_header() @@ -440,4 +449,3 @@ Exception EnsureValidOfflineFrame(const OfflineFrame& offline_frame) { } // namespace parser } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/offline_frames_validator.h b/connections/implementation/offline_frames_validator.h index 7bdbe8dab4..c3ea3b1d2a 100644 --- a/connections/implementation/offline_frames_validator.h +++ b/connections/implementation/offline_frames_validator.h @@ -22,7 +22,6 @@ #include "connections/implementation/proto/offline_wire_formats.pb.h" #include "internal/platform/exception.h" -namespace location { namespace nearby { namespace connections { namespace parser { @@ -37,11 +36,11 @@ const size_t kIllegalParentFolderPatternsSize = sizeof(kIllegalParentFolderPatterns) / sizeof(*kIllegalParentFolderPatterns); -Exception EnsureValidOfflineFrame(const OfflineFrame& offline_frame); +Exception EnsureValidOfflineFrame( + const location::nearby::connections::OfflineFrame& offline_frame); } // namespace parser } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_OFFLINE_FRAMES_VALIDATOR_H_ diff --git a/connections/implementation/offline_frames_validator_test.cc b/connections/implementation/offline_frames_validator_test.cc index 62dae89124..6439d0ad26 100644 --- a/connections/implementation/offline_frames_validator_test.cc +++ b/connections/implementation/offline_frames_validator_test.cc @@ -25,12 +25,14 @@ #include "connections/implementation/proto/offline_wire_formats.pb.h" #include "internal/platform/byte_array.h" -namespace location { namespace nearby { namespace connections { namespace parser { namespace { +using ::location::nearby::connections::OfflineFrame; +using ::location::nearby::connections::PayloadTransferFrame; + constexpr absl::string_view kEndpointId{"ABC"}; constexpr absl::string_view kEndpointName{"XYZ"}; constexpr int kNonce = 1234; @@ -695,4 +697,3 @@ TEST(OfflineFramesValidatorTest, } // namespace parser } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/offline_service_controller.cc b/connections/implementation/offline_service_controller.cc index ab445069ab..f5aecb6e47 100644 --- a/connections/implementation/offline_service_controller.cc +++ b/connections/implementation/offline_service_controller.cc @@ -20,7 +20,6 @@ #include "absl/strings/str_join.h" -namespace location { namespace nearby { namespace connections { @@ -158,4 +157,3 @@ void OfflineServiceController::ShutdownBwuManagerExecutors() { } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/offline_service_controller.h b/connections/implementation/offline_service_controller.h index 17a68a4b4a..317747c402 100644 --- a/connections/implementation/offline_service_controller.h +++ b/connections/implementation/offline_service_controller.h @@ -32,7 +32,6 @@ #include "connections/payload.h" #include "connections/status.h" -namespace location { namespace nearby { namespace connections { @@ -99,6 +98,5 @@ class OfflineServiceController : public ServiceController { } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_OFFLINE_SERVICE_CONTROLLER_H_ diff --git a/connections/implementation/offline_service_controller_test.cc b/connections/implementation/offline_service_controller_test.cc index 6d49ec217b..e0d9e198fa 100644 --- a/connections/implementation/offline_service_controller_test.cc +++ b/connections/implementation/offline_service_controller_test.cc @@ -27,7 +27,6 @@ #include "internal/platform/pipe.h" #include "internal/platform/system_clock.h" -namespace location { namespace nearby { namespace connections { namespace { @@ -400,4 +399,3 @@ TEST_F(OfflineServiceControllerTest, InjectEndpoint) { } // namespace } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/offline_simulation_user.cc b/connections/implementation/offline_simulation_user.cc index d18faafadc..1a55ba9a95 100644 --- a/connections/implementation/offline_simulation_user.cc +++ b/connections/implementation/offline_simulation_user.cc @@ -20,7 +20,6 @@ #include "internal/platform/count_down_latch.h" #include "internal/platform/system_clock.h" -namespace location { namespace nearby { namespace connections { @@ -199,4 +198,3 @@ void OfflineSimulationUser::Disconnect() { } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/offline_simulation_user.h b/connections/implementation/offline_simulation_user.h index f032d9e455..78512b38d0 100644 --- a/connections/implementation/offline_simulation_user.h +++ b/connections/implementation/offline_simulation_user.h @@ -31,7 +31,7 @@ // // This is a "standalone" version of PcpManager. It can run independently, // provided MediumEnvironment has adequate support for all medium types in use. -namespace location { + namespace nearby { namespace connections { @@ -202,6 +202,5 @@ class OfflineSimulationUser { } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_OFFLINE_SIMULATION_USER_H_ diff --git a/connections/implementation/p2p_cluster_pcp_handler.cc b/connections/implementation/p2p_cluster_pcp_handler.cc index 9a264ca381..3fb2671c9d 100644 --- a/connections/implementation/p2p_cluster_pcp_handler.cc +++ b/connections/implementation/p2p_cluster_pcp_handler.cc @@ -32,7 +32,6 @@ #include "internal/platform/types.h" #include "proto/connections_enums.pb.h" -namespace location { namespace nearby { namespace connections { @@ -70,48 +69,51 @@ P2pClusterPcpHandler::P2pClusterPcpHandler( // Returns a vector or mediums sorted in order or decreasing priority for // all the supported mediums. // Example: WiFi_LAN, WEB_RTC, BT, BLE -std::vector +std::vector P2pClusterPcpHandler::GetConnectionMediumsByPriority() { - std::vector mediums; + std::vector mediums; if (wifi_lan_medium_.IsAvailable()) { - mediums.push_back(proto::connections::WIFI_LAN); + mediums.push_back(location::nearby::proto::connections::WIFI_LAN); } if (webrtc_medium_.IsAvailable()) { - mediums.push_back(proto::connections::WEB_RTC); + mediums.push_back(location::nearby::proto::connections::WEB_RTC); } if (bluetooth_medium_.IsAvailable()) { - mediums.push_back(proto::connections::BLUETOOTH); + mediums.push_back(location::nearby::proto::connections::BLUETOOTH); } if (FeatureFlags::GetInstance().GetFlags().support_ble_v2) { if (ble_v2_medium_.IsAvailable()) { - mediums.push_back(proto::connections::BLE); + mediums.push_back(location::nearby::proto::connections::BLE); } } else { if (ble_medium_.IsAvailable()) { - mediums.push_back(proto::connections::BLE); + mediums.push_back(location::nearby::proto::connections::BLE); } } return mediums; } -proto::connections::Medium P2pClusterPcpHandler::GetDefaultUpgradeMedium() { - return proto::connections::WIFI_LAN; +location::nearby::proto::connections::Medium +P2pClusterPcpHandler::GetDefaultUpgradeMedium() { + return location::nearby::proto::connections::WIFI_LAN; } BasePcpHandler::StartOperationResult P2pClusterPcpHandler::StartAdvertisingImpl( ClientProxy* client, const std::string& service_id, const std::string& local_endpoint_id, const ByteArray& local_endpoint_info, const AdvertisingOptions& advertising_options) { - std::vector mediums_started_successfully; + std::vector + mediums_started_successfully; WebRtcState web_rtc_state{WebRtcState::kUnconnectable}; if (advertising_options.allowed.wifi_lan) { - proto::connections::Medium wifi_lan_medium = + location::nearby::proto::connections::Medium wifi_lan_medium = StartWifiLanAdvertising(client, service_id, local_endpoint_id, local_endpoint_info, web_rtc_state); - if (wifi_lan_medium != proto::connections::UNKNOWN_MEDIUM) { + if (wifi_lan_medium != + location::nearby::proto::connections::UNKNOWN_MEDIUM) { NEARBY_LOGS(INFO) << "P2pClusterPcpHandler::StartAdvertisingImpl: WifiLan added"; mediums_started_successfully.push_back(wifi_lan_medium); @@ -121,10 +123,12 @@ BasePcpHandler::StartOperationResult P2pClusterPcpHandler::StartAdvertisingImpl( if (advertising_options.allowed.bluetooth) { const ByteArray bluetooth_hash = GenerateHash(service_id, BluetoothDeviceName::kServiceIdHashLength); - proto::connections::Medium bluetooth_medium = StartBluetoothAdvertising( - client, service_id, bluetooth_hash, local_endpoint_id, - local_endpoint_info, web_rtc_state); - if (bluetooth_medium != proto::connections::UNKNOWN_MEDIUM) { + location::nearby::proto::connections::Medium bluetooth_medium = + StartBluetoothAdvertising(client, service_id, bluetooth_hash, + local_endpoint_id, local_endpoint_info, + web_rtc_state); + if (bluetooth_medium != + location::nearby::proto::connections::UNKNOWN_MEDIUM) { NEARBY_LOG(INFO, "P2pClusterPcpHandler::StartAdvertisingImpl: BT added"); mediums_started_successfully.push_back(bluetooth_medium); bluetooth_classic_advertiser_client_id_ = client->GetClientId(); @@ -133,19 +137,22 @@ BasePcpHandler::StartOperationResult P2pClusterPcpHandler::StartAdvertisingImpl( if (advertising_options.allowed.ble) { if (FeatureFlags::GetInstance().GetFlags().support_ble_v2) { - proto::connections::Medium ble_v2_medium = StartBleV2Advertising( - client, service_id, local_endpoint_id, local_endpoint_info, - advertising_options, web_rtc_state); - if (ble_v2_medium != proto::connections::UNKNOWN_MEDIUM) { + location::nearby::proto::connections::Medium ble_v2_medium = + StartBleV2Advertising(client, service_id, local_endpoint_id, + local_endpoint_info, advertising_options, + web_rtc_state); + if (ble_v2_medium != + location::nearby::proto::connections::UNKNOWN_MEDIUM) { NEARBY_LOGS(INFO) << "P2pClusterPcpHandler::StartAdvertisingImpl: Ble added"; mediums_started_successfully.push_back(ble_v2_medium); } } else { - proto::connections::Medium ble_medium = StartBleAdvertising( - client, service_id, local_endpoint_id, local_endpoint_info, - advertising_options, web_rtc_state); - if (ble_medium != proto::connections::UNKNOWN_MEDIUM) { + location::nearby::proto::connections::Medium ble_medium = + StartBleAdvertising(client, service_id, local_endpoint_id, + local_endpoint_info, advertising_options, + web_rtc_state); + if (ble_medium != location::nearby::proto::connections::UNKNOWN_MEDIUM) { NEARBY_LOGS(INFO) << "P2pClusterPcpHandler::StartAdvertisingImpl: Ble added"; mediums_started_successfully.push_back(ble_medium); @@ -270,7 +277,8 @@ void P2pClusterPcpHandler::BluetoothDeviceDiscoveredHandler( client, std::make_shared(BluetoothEndpoint{ {device_name.GetEndpointId(), device_name.GetEndpointInfo(), - service_id, proto::connections::Medium::BLUETOOTH, + service_id, + location::nearby::proto::connections::Medium::BLUETOOTH, device_name.GetWebRtcState()}, device, })); @@ -305,8 +313,8 @@ void P2pClusterPcpHandler::BluetoothNameChangedHandler( // devices are the same. We are not guaranteed to discover a match, // since the old name may not have been formatted for Nearby // Connections. - for (auto endpoint : - GetDiscoveredEndpoints(proto::connections::Medium::BLUETOOTH)) { + for (auto endpoint : GetDiscoveredEndpoints( + location::nearby::proto::connections::Medium::BLUETOOTH)) { BluetoothEndpoint* bluetoothEndpoint = static_cast(endpoint); NEARBY_LOGS(INFO) @@ -350,7 +358,8 @@ void P2pClusterPcpHandler::BluetoothNameChangedHandler( client, std::make_shared(BluetoothEndpoint{ {device_name.GetEndpointId(), device_name.GetEndpointInfo(), - service_id, proto::connections::Medium::BLUETOOTH, + service_id, + location::nearby::proto::connections::Medium::BLUETOOTH, device_name.GetWebRtcState()}, device, })); @@ -385,11 +394,12 @@ void P2pClusterPcpHandler::BluetoothDeviceLostHandler( // Report the BluetoothEndpoint as lost to the client. NEARBY_LOGS(INFO) << "Processing lost BluetoothDeviceName " << device_name_string; - OnEndpointLost(client, DiscoveredEndpoint{ - device_name.GetEndpointId(), - device_name.GetEndpointInfo(), service_id, - proto::connections::Medium::BLUETOOTH, - WebRtcState::kUndefined}); + OnEndpointLost( + client, DiscoveredEndpoint{ + device_name.GetEndpointId(), + device_name.GetEndpointInfo(), service_id, + location::nearby::proto::connections::Medium::BLUETOOTH, + WebRtcState::kUndefined}); }); } @@ -478,14 +488,14 @@ void P2pClusterPcpHandler::BlePeripheralDiscoveredHandler( << absl::BytesToHexString( advertisement.GetEndpointInfo().data()) << ").", - OnEndpointFound(client, - std::make_shared(BleEndpoint{ - {advertisement.GetEndpointId(), - advertisement.GetEndpointInfo(), service_id, - proto::connections::Medium::BLE, - advertisement.GetWebRtcState()}, - peripheral, - })); + OnEndpointFound( + client, std::make_shared(BleEndpoint{ + {advertisement.GetEndpointId(), + advertisement.GetEndpointInfo(), service_id, + location::nearby::proto::connections::Medium::BLE, + advertisement.GetWebRtcState()}, + peripheral, + })); // Make sure we can connect to this device via Classic Bluetooth. std::string remote_bluetooth_mac_address = @@ -506,17 +516,18 @@ void P2pClusterPcpHandler::BlePeripheralDiscoveredHandler( return; } - OnEndpointFound(client, - std::make_shared(BluetoothEndpoint{ - { - advertisement.GetEndpointId(), - advertisement.GetEndpointInfo(), - service_id, - proto::connections::Medium::BLUETOOTH, - advertisement.GetWebRtcState(), - }, - remote_bluetooth_device, - })); + OnEndpointFound( + client, + std::make_shared(BluetoothEndpoint{ + { + advertisement.GetEndpointId(), + advertisement.GetEndpointInfo(), + service_id, + location::nearby::proto::connections::Medium::BLUETOOTH, + advertisement.GetWebRtcState(), + }, + remote_bluetooth_device, + })); }); } @@ -550,13 +561,14 @@ void P2pClusterPcpHandler::BlePeripheralLostHandler( << " and endpoint_info=" << absl::BytesToHexString(ble_endpoint_state.endpoint_info.data()) << ")."; - OnEndpointLost(client, DiscoveredEndpoint{ - ble_endpoint_state.endpoint_id, - ble_endpoint_state.endpoint_info, - service_id, - proto::connections::Medium::BLE, - WebRtcState::kUndefined, - }); + OnEndpointLost(client, + DiscoveredEndpoint{ + ble_endpoint_state.endpoint_id, + ble_endpoint_state.endpoint_info, + service_id, + location::nearby::proto::connections::Medium::BLE, + WebRtcState::kUndefined, + }); } }); } @@ -651,7 +663,7 @@ void P2pClusterPcpHandler::BleV2PeripheralDiscoveredHandler( client, std::make_shared(BleV2Endpoint{ {advertisement.GetEndpointId(), advertisement.GetEndpointInfo(), - service_id, proto::connections::Medium::BLE, + service_id, location::nearby::proto::connections::Medium::BLE, advertisement.GetWebRtcState()}, std::move(peripheral), })); @@ -677,17 +689,18 @@ void P2pClusterPcpHandler::BleV2PeripheralDiscoveredHandler( ble_endpoint_state.bt = true; found_endpoints_in_ble_discover_cb_[peripheral_id] = ble_endpoint_state; - OnEndpointFound(client, - std::make_shared(BluetoothEndpoint{ - { - advertisement.GetEndpointId(), - advertisement.GetEndpointInfo(), - service_id, - proto::connections::Medium::BLUETOOTH, - advertisement.GetWebRtcState(), - }, - remote_bluetooth_device, - })); + OnEndpointFound( + client, + std::make_shared(BluetoothEndpoint{ + { + advertisement.GetEndpointId(), + advertisement.GetEndpointInfo(), + service_id, + location::nearby::proto::connections::Medium::BLUETOOTH, + advertisement.GetWebRtcState(), + }, + remote_bluetooth_device, + })); }); } @@ -735,13 +748,14 @@ void P2pClusterPcpHandler::BleV2PeripheralLostHandler( << " and endpoint_info=" << absl::BytesToHexString(advertisement.GetEndpointInfo().data()) << ")."; - OnEndpointLost(client, DiscoveredEndpoint{ - advertisement.GetEndpointId(), - advertisement.GetEndpointInfo(), - service_id, - proto::connections::Medium::BLE, - WebRtcState::kUndefined, - }); + OnEndpointLost(client, + DiscoveredEndpoint{ + advertisement.GetEndpointId(), + advertisement.GetEndpointInfo(), + service_id, + location::nearby::proto::connections::Medium::BLE, + WebRtcState::kUndefined, + }); } if (ble_endpoint_state.bt) { // Report the lost endpoint to the client. @@ -752,13 +766,15 @@ void P2pClusterPcpHandler::BleV2PeripheralLostHandler( << " and endpoint_info=" << absl::BytesToHexString(advertisement.GetEndpointInfo().data()) << ")."; - OnEndpointLost(client, DiscoveredEndpoint{ - advertisement.GetEndpointId(), - advertisement.GetEndpointInfo(), - service_id, - proto::connections::Medium::BLUETOOTH, - WebRtcState::kUndefined, - }); + OnEndpointLost( + client, + DiscoveredEndpoint{ + advertisement.GetEndpointId(), + advertisement.GetEndpointInfo(), + service_id, + location::nearby::proto::connections::Medium::BLUETOOTH, + WebRtcState::kUndefined, + }); } }); } @@ -827,17 +843,18 @@ void P2pClusterPcpHandler::WifiLanServiceDiscoveredHandler( << absl::BytesToHexString( wifi_lan_service_info.GetEndpointInfo().data()) << ")."; - OnEndpointFound(client, - std::make_shared(WifiLanEndpoint{ - { - wifi_lan_service_info.GetEndpointId(), - wifi_lan_service_info.GetEndpointInfo(), - service_id, - proto::connections::Medium::WIFI_LAN, - wifi_lan_service_info.GetWebRtcState(), - }, - service_info, - })); + OnEndpointFound( + client, + std::make_shared(WifiLanEndpoint{ + { + wifi_lan_service_info.GetEndpointId(), + wifi_lan_service_info.GetEndpointInfo(), + service_id, + location::nearby::proto::connections::Medium::WIFI_LAN, + wifi_lan_service_info.GetWebRtcState(), + }, + service_info, + })); }); } @@ -875,13 +892,14 @@ void P2pClusterPcpHandler::WifiLanServiceLostHandler( << absl::BytesToHexString( wifi_lan_service_info.GetEndpointInfo().data()) << ")."; - OnEndpointLost(client, DiscoveredEndpoint{ - wifi_lan_service_info.GetEndpointId(), - wifi_lan_service_info.GetEndpointInfo(), - service_id, - proto::connections::Medium::WIFI_LAN, - WebRtcState::kUndefined, - }); + OnEndpointLost( + client, DiscoveredEndpoint{ + wifi_lan_service_info.GetEndpointId(), + wifi_lan_service_info.GetEndpointInfo(), + service_id, + location::nearby::proto::connections::Medium::WIFI_LAN, + WebRtcState::kUndefined, + }); }); } @@ -895,19 +913,23 @@ BasePcpHandler::StartOperationResult P2pClusterPcpHandler::StartDiscoveryImpl( .mediums = discovery_options.allowed.GetMediums(true)}; } - std::vector mediums_started_successfully; + std::vector + mediums_started_successfully; if (discovery_options.allowed.wifi_lan) { - proto::connections::Medium wifi_lan_medium = StartWifiLanDiscovery( - { - .service_discovered_cb = absl::bind_front( - &P2pClusterPcpHandler::WifiLanServiceDiscoveredHandler, this, - client), - .service_lost_cb = absl::bind_front( - &P2pClusterPcpHandler::WifiLanServiceLostHandler, this, client), - }, - client, service_id); - if (wifi_lan_medium != proto::connections::UNKNOWN_MEDIUM) { + location::nearby::proto::connections::Medium wifi_lan_medium = + StartWifiLanDiscovery( + { + .service_discovered_cb = absl::bind_front( + &P2pClusterPcpHandler::WifiLanServiceDiscoveredHandler, + this, client), + .service_lost_cb = absl::bind_front( + &P2pClusterPcpHandler::WifiLanServiceLostHandler, this, + client), + }, + client, service_id); + if (wifi_lan_medium != + location::nearby::proto::connections::UNKNOWN_MEDIUM) { NEARBY_LOGS(INFO) << "P2pClusterPcpHandler::StartDiscoveryImpl: WifiLan added"; mediums_started_successfully.push_back(wifi_lan_medium); @@ -915,20 +937,22 @@ BasePcpHandler::StartOperationResult P2pClusterPcpHandler::StartDiscoveryImpl( } if (discovery_options.allowed.bluetooth) { - proto::connections::Medium bluetooth_medium = StartBluetoothDiscovery( - { - .device_discovered_cb = absl::bind_front( - &P2pClusterPcpHandler::BluetoothDeviceDiscoveredHandler, this, - client, service_id), - .device_name_changed_cb = absl::bind_front( - &P2pClusterPcpHandler::BluetoothNameChangedHandler, this, - client, service_id), - .device_lost_cb = absl::bind_front( - &P2pClusterPcpHandler::BluetoothDeviceLostHandler, this, client, - service_id), - }, - client, service_id); - if (bluetooth_medium != proto::connections::UNKNOWN_MEDIUM) { + location::nearby::proto::connections::Medium bluetooth_medium = + StartBluetoothDiscovery( + { + .device_discovered_cb = absl::bind_front( + &P2pClusterPcpHandler::BluetoothDeviceDiscoveredHandler, + this, client, service_id), + .device_name_changed_cb = absl::bind_front( + &P2pClusterPcpHandler::BluetoothNameChangedHandler, this, + client, service_id), + .device_lost_cb = absl::bind_front( + &P2pClusterPcpHandler::BluetoothDeviceLostHandler, this, + client, service_id), + }, + client, service_id); + if (bluetooth_medium != + location::nearby::proto::connections::UNKNOWN_MEDIUM) { NEARBY_LOG(INFO, "P2pClusterPcpHandler::StartDiscoveryImpl: BT added"); mediums_started_successfully.push_back(bluetooth_medium); bluetooth_classic_discoverer_client_id_ = client->GetClientId(); @@ -937,34 +961,37 @@ BasePcpHandler::StartOperationResult P2pClusterPcpHandler::StartDiscoveryImpl( if (discovery_options.allowed.ble) { if (FeatureFlags::GetInstance().GetFlags().support_ble_v2) { - proto::connections::Medium ble_v2_medium = StartBleV2Scanning( - { - .peripheral_discovered_cb = absl::bind_front( - &P2pClusterPcpHandler::BleV2PeripheralDiscoveredHandler, this, - client), - .peripheral_lost_cb = absl::bind_front( - &P2pClusterPcpHandler::BleV2PeripheralLostHandler, this, - client), - }, - client, service_id, discovery_options); - if (ble_v2_medium != proto::connections::UNKNOWN_MEDIUM) { + location::nearby::proto::connections::Medium ble_v2_medium = + StartBleV2Scanning( + { + .peripheral_discovered_cb = absl::bind_front( + &P2pClusterPcpHandler::BleV2PeripheralDiscoveredHandler, + this, client), + .peripheral_lost_cb = absl::bind_front( + &P2pClusterPcpHandler::BleV2PeripheralLostHandler, this, + client), + }, + client, service_id, discovery_options); + if (ble_v2_medium != + location::nearby::proto::connections::UNKNOWN_MEDIUM) { NEARBY_LOGS(INFO) << "P2pClusterPcpHandler::StartDiscoveryImpl: Ble added."; mediums_started_successfully.push_back(ble_v2_medium); } } else { - proto::connections::Medium ble_medium = StartBleScanning( - { - .peripheral_discovered_cb = absl::bind_front( - &P2pClusterPcpHandler::BlePeripheralDiscoveredHandler, this, - client), - .peripheral_lost_cb = absl::bind_front( - &P2pClusterPcpHandler::BlePeripheralLostHandler, this, - client), - }, - client, service_id, - discovery_options.fast_advertisement_service_uuid); - if (ble_medium != proto::connections::UNKNOWN_MEDIUM) { + location::nearby::proto::connections::Medium ble_medium = + StartBleScanning( + { + .peripheral_discovered_cb = absl::bind_front( + &P2pClusterPcpHandler::BlePeripheralDiscoveredHandler, + this, client), + .peripheral_lost_cb = absl::bind_front( + &P2pClusterPcpHandler::BlePeripheralLostHandler, this, + client), + }, + client, service_id, + discovery_options.fast_advertisement_service_uuid); + if (ble_medium != location::nearby::proto::connections::UNKNOWN_MEDIUM) { NEARBY_LOGS(INFO) << "P2pClusterPcpHandler::StartDiscoveryImpl: Ble added."; mediums_started_successfully.push_back(ble_medium); @@ -1043,14 +1070,14 @@ BasePcpHandler::ConnectImplResult P2pClusterPcpHandler::ConnectImpl( }; } switch (endpoint->medium) { - case proto::connections::Medium::BLUETOOTH: { + case location::nearby::proto::connections::Medium::BLUETOOTH: { auto* bluetooth_endpoint = down_cast(endpoint); if (bluetooth_endpoint) { return BluetoothConnectImpl(client, bluetooth_endpoint); } break; } - case proto::connections::Medium::BLE: { + case location::nearby::proto::connections::Medium::BLE: { if (FeatureFlags::GetInstance().GetFlags().support_ble_v2) { auto* ble_v2_endpoint = down_cast(endpoint); if (ble_v2_endpoint) { @@ -1065,14 +1092,14 @@ BasePcpHandler::ConnectImplResult P2pClusterPcpHandler::ConnectImpl( } break; } - case proto::connections::Medium::WIFI_LAN: { + case location::nearby::proto::connections::Medium::WIFI_LAN: { auto* wifi_lan_endpoint = down_cast(endpoint); if (wifi_lan_endpoint) { return WifiLanConnectImpl(client, wifi_lan_endpoint); } break; } - case proto::connections::Medium::WEB_RTC: { + case location::nearby::proto::connections::Medium::WEB_RTC: { break; } default: @@ -1084,7 +1111,8 @@ BasePcpHandler::ConnectImplResult P2pClusterPcpHandler::ConnectImpl( }; } -proto::connections::Medium P2pClusterPcpHandler::StartBluetoothAdvertising( +location::nearby::proto::connections::Medium +P2pClusterPcpHandler::StartBluetoothAdvertising( ClientProxy* client, const std::string& service_id, const ByteArray& service_id_hash, const std::string& local_endpoint_id, const ByteArray& local_endpoint_info, WebRtcState web_rtc_state) { @@ -1122,7 +1150,8 @@ proto::connections::Medium P2pClusterPcpHandler::StartBluetoothAdvertising( OnIncomingConnection( client, remote_device_info, std::move(channel), - proto::connections::Medium::BLUETOOTH); + location::nearby::proto::connections::Medium:: + BLUETOOTH); }); }})) { NEARBY_LOGS(WARNING) @@ -1132,7 +1161,7 @@ proto::connections::Medium P2pClusterPcpHandler::StartBluetoothAdvertising( << " failed to start listening for incoming Bluetooth " "connections to service_id=" << service_id; - return proto::connections::UNKNOWN_MEDIUM; + return location::nearby::proto::connections::UNKNOWN_MEDIUM; } NEARBY_LOGS(INFO) << "In StartBluetoothAdvertising(" @@ -1162,7 +1191,7 @@ proto::connections::Medium P2pClusterPcpHandler::StartBluetoothAdvertising( << absl::BytesToHexString(local_endpoint_info.data()) << "}."; bluetooth_medium_.StopAcceptingConnections(service_id); - return proto::connections::UNKNOWN_MEDIUM; + return location::nearby::proto::connections::UNKNOWN_MEDIUM; } NEARBY_LOGS(INFO) << "In StartBluetoothAdvertising(" << absl::BytesToHexString(local_endpoint_info.data()) @@ -1179,7 +1208,7 @@ proto::connections::Medium P2pClusterPcpHandler::StartBluetoothAdvertising( << " couldn't start Bluetooth advertising with BluetoothDeviceName " << device_name; bluetooth_medium_.StopAcceptingConnections(service_id); - return proto::connections::UNKNOWN_MEDIUM; + return location::nearby::proto::connections::UNKNOWN_MEDIUM; } NEARBY_LOGS(INFO) << "In StartBluetoothAdvertising(" @@ -1187,10 +1216,11 @@ proto::connections::Medium P2pClusterPcpHandler::StartBluetoothAdvertising( << "), client=" << client->GetClientId() << " started Bluetooth advertising with BluetoothDeviceName " << device_name; - return proto::connections::BLUETOOTH; + return location::nearby::proto::connections::BLUETOOTH; } -proto::connections::Medium P2pClusterPcpHandler::StartBluetoothDiscovery( +location::nearby::proto::connections::Medium +P2pClusterPcpHandler::StartBluetoothDiscovery( BluetoothDiscoveredDeviceCallback callback, ClientProxy* client, const std::string& service_id) { if (bluetooth_radio_.Enable() && @@ -1199,13 +1229,13 @@ proto::connections::Medium P2pClusterPcpHandler::StartBluetoothDiscovery( << client->GetClientId() << " started scanning for Bluetooth for service_id=" << service_id; - return proto::connections::BLUETOOTH; + return location::nearby::proto::connections::BLUETOOTH; } else { NEARBY_LOGS(INFO) << "In StartBluetoothDiscovery(), client=" << client->GetClientId() << " couldn't start scanning on Bluetooth for service_id=" << service_id; - return proto::connections::UNKNOWN_MEDIUM; + return location::nearby::proto::connections::UNKNOWN_MEDIUM; } } @@ -1236,13 +1266,14 @@ BasePcpHandler::ConnectImplResult P2pClusterPcpHandler::BluetoothConnectImpl( << " created Bluetooth endpoint channel to endpoint(id=" << endpoint->endpoint_id << ")."; return BasePcpHandler::ConnectImplResult{ - .medium = proto::connections::Medium::BLUETOOTH, + .medium = location::nearby::proto::connections::Medium::BLUETOOTH, .status = {Status::kSuccess}, .endpoint_channel = std::move(channel), }; } -proto::connections::Medium P2pClusterPcpHandler::StartBleAdvertising( +location::nearby::proto::connections::Medium +P2pClusterPcpHandler::StartBleAdvertising( ClientProxy* client, const std::string& service_id, const std::string& local_endpoint_id, const ByteArray& local_endpoint_info, const AdvertisingOptions& advertising_options, WebRtcState web_rtc_state) { @@ -1285,9 +1316,9 @@ proto::connections::Medium P2pClusterPcpHandler::StartBleAdvertising( socket.GetRemotePeripheral().GetAdvertisementBytes( service_id); - OnIncomingConnection(client, remote_peripheral_info, - std::move(channel), - proto::connections::Medium::BLE); + OnIncomingConnection( + client, remote_peripheral_info, std::move(channel), + location::nearby::proto::connections::Medium::BLE); }); }})) { NEARBY_LOGS(WARNING) @@ -1297,7 +1328,7 @@ proto::connections::Medium P2pClusterPcpHandler::StartBleAdvertising( << " failed to start accepting for incoming BLE connections to " "service_id=" << service_id; - return proto::connections::UNKNOWN_MEDIUM; + return location::nearby::proto::connections::UNKNOWN_MEDIUM; } NEARBY_LOGS(INFO) << "In StartBleAdvertising(" @@ -1339,7 +1370,8 @@ proto::connections::Medium P2pClusterPcpHandler::StartBleAdvertising( OnIncomingConnection( client, remote_device_info, std::move(channel), - proto::connections::Medium::BLUETOOTH); + location::nearby::proto::connections::Medium:: + BLUETOOTH); }); }})) { NEARBY_LOGS(WARNING) @@ -1350,7 +1382,7 @@ proto::connections::Medium P2pClusterPcpHandler::StartBleAdvertising( "service_id=" << service_id; ble_medium_.StopAcceptingConnections(service_id); - return proto::connections::UNKNOWN_MEDIUM; + return location::nearby::proto::connections::UNKNOWN_MEDIUM; } NEARBY_LOGS(INFO) << "In BT StartBleAdvertising(" @@ -1394,7 +1426,7 @@ proto::connections::Medium P2pClusterPcpHandler::StartBleAdvertising( << "), client=" << client->GetClientId() << " failed to create an advertisement."; ble_medium_.StopAcceptingConnections(service_id); - return proto::connections::UNKNOWN_MEDIUM; + return location::nearby::proto::connections::UNKNOWN_MEDIUM; } NEARBY_LOGS(INFO) << "In StartBleAdvertising(" @@ -1413,17 +1445,18 @@ proto::connections::Medium P2pClusterPcpHandler::StartBleAdvertising( << " couldn't start BLE Advertising with BleAdvertisement " << absl::BytesToHexString(advertisement_bytes.data()); ble_medium_.StopAcceptingConnections(service_id); - return proto::connections::UNKNOWN_MEDIUM; + return location::nearby::proto::connections::UNKNOWN_MEDIUM; } NEARBY_LOGS(INFO) << "In startBleAdvertising(" << absl::BytesToHexString(local_endpoint_info.data()) << "), client=" << client->GetClientId() << " started BLE Advertising with BleAdvertisement " << absl::BytesToHexString(advertisement_bytes.data()); - return proto::connections::BLE; + return location::nearby::proto::connections::BLE; } -proto::connections::Medium P2pClusterPcpHandler::StartBleScanning( +location::nearby::proto::connections::Medium +P2pClusterPcpHandler::StartBleScanning( BleDiscoveredPeripheralCallback callback, ClientProxy* client, const std::string& service_id, const std::string& fast_advertisement_service_uuid) { @@ -1434,13 +1467,13 @@ proto::connections::Medium P2pClusterPcpHandler::StartBleScanning( << "In StartBleScanning(), client=" << client->GetClientId() << " started scanning for BLE advertisements for service_id=" << service_id; - return proto::connections::BLE; + return location::nearby::proto::connections::BLE; } else { NEARBY_LOGS(INFO) << "In StartBleScanning(), client=" << client->GetClientId() << " couldn't start scanning on BLE for service_id=" << service_id; - return proto::connections::UNKNOWN_MEDIUM; + return location::nearby::proto::connections::UNKNOWN_MEDIUM; } } @@ -1469,13 +1502,14 @@ BasePcpHandler::ConnectImplResult P2pClusterPcpHandler::BleConnectImpl( endpoint->service_id, /*channel_name=*/endpoint->endpoint_id, ble_socket); return BasePcpHandler::ConnectImplResult{ - .medium = proto::connections::Medium::BLE, + .medium = location::nearby::proto::connections::Medium::BLE, .status = {Status::kSuccess}, .endpoint_channel = std::move(channel), }; } -proto::connections::Medium P2pClusterPcpHandler::StartBleV2Advertising( +location::nearby::proto::connections::Medium +P2pClusterPcpHandler::StartBleV2Advertising( ClientProxy* client, const std::string& service_id, const std::string& local_endpoint_id, const ByteArray& local_endpoint_info, const AdvertisingOptions& advertising_options, WebRtcState web_rtc_state) { @@ -1510,9 +1544,9 @@ proto::connections::Medium P2pClusterPcpHandler::StartBleV2Advertising( service_id, std::string(remote_peripheral_info), socket); - OnIncomingConnection(client, remote_peripheral_info, - std::move(channel), - proto::connections::Medium::BLE); + OnIncomingConnection( + client, remote_peripheral_info, std::move(channel), + location::nearby::proto::connections::Medium::BLE); }); }})) { NEARBY_LOGS(WARNING) @@ -1522,7 +1556,7 @@ proto::connections::Medium P2pClusterPcpHandler::StartBleV2Advertising( << " failed to start accepting for incoming BLE connections to " "service_id=" << service_id; - return proto::connections::UNKNOWN_MEDIUM; + return location::nearby::proto::connections::UNKNOWN_MEDIUM; } NEARBY_LOGS(INFO) << "In StartBleAdvertising(" @@ -1566,7 +1600,8 @@ proto::connections::Medium P2pClusterPcpHandler::StartBleV2Advertising( OnIncomingConnection( client, remote_device_info, std::move(channel), - proto::connections::Medium::BLUETOOTH); + location::nearby::proto::connections::Medium:: + BLUETOOTH); }); }})) { NEARBY_LOGS(WARNING) @@ -1577,7 +1612,7 @@ proto::connections::Medium P2pClusterPcpHandler::StartBleV2Advertising( "service_id=" << service_id; ble_v2_medium_.StopAcceptingConnections(service_id); - return proto::connections::UNKNOWN_MEDIUM; + return location::nearby::proto::connections::UNKNOWN_MEDIUM; } NEARBY_LOGS(INFO) << "In BT StartBleAdvertising(" @@ -1622,7 +1657,7 @@ proto::connections::Medium P2pClusterPcpHandler::StartBleV2Advertising( << "), client=" << client->GetClientId() << " failed to create an advertisement."; ble_v2_medium_.StopAcceptingConnections(service_id); - return proto::connections::UNKNOWN_MEDIUM; + return location::nearby::proto::connections::UNKNOWN_MEDIUM; } NEARBY_LOGS(INFO) << "In StartBleAdvertising(" @@ -1641,17 +1676,18 @@ proto::connections::Medium P2pClusterPcpHandler::StartBleV2Advertising( << " couldn't start BLE Advertising with BleAdvertisement " << absl::BytesToHexString(advertisement_bytes.data()); ble_v2_medium_.StopAcceptingConnections(service_id); - return proto::connections::UNKNOWN_MEDIUM; + return location::nearby::proto::connections::UNKNOWN_MEDIUM; } NEARBY_LOGS(INFO) << "In startBleAdvertising(" << absl::BytesToHexString(local_endpoint_info.data()) << "), client=" << client->GetClientId() << " started BLE Advertising with BleAdvertisement " << absl::BytesToHexString(advertisement_bytes.data()); - return proto::connections::BLE; + return location::nearby::proto::connections::BLE; } -proto::connections::Medium P2pClusterPcpHandler::StartBleV2Scanning( +location::nearby::proto::connections::Medium +P2pClusterPcpHandler::StartBleV2Scanning( BleV2DiscoveredPeripheralCallback callback, ClientProxy* client, const std::string& service_id, const DiscoveryOptions& discovery_options) { PowerLevel power_level = discovery_options.low_power ? PowerLevel::kLowPower @@ -1663,13 +1699,13 @@ proto::connections::Medium P2pClusterPcpHandler::StartBleV2Scanning( << "In StartBleScanning(), client=" << client->GetClientId() << " started scanning for BLE advertisements for service_id=" << service_id; - return proto::connections::BLE; + return location::nearby::proto::connections::BLE; } NEARBY_LOGS(INFO) << "In StartBleScanning(), client=" << client->GetClientId() << " couldn't start scanning on BLE for service_id=" << service_id; - return proto::connections::UNKNOWN_MEDIUM; + return location::nearby::proto::connections::UNKNOWN_MEDIUM; } BasePcpHandler::ConnectImplResult P2pClusterPcpHandler::BleV2ConnectImpl( @@ -1697,13 +1733,14 @@ BasePcpHandler::ConnectImplResult P2pClusterPcpHandler::BleV2ConnectImpl( endpoint->service_id, /*channel_name=*/endpoint->endpoint_id, ble_socket); return BasePcpHandler::ConnectImplResult{ - .medium = proto::connections::Medium::BLE, + .medium = location::nearby::proto::connections::Medium::BLE, .status = {Status::kSuccess}, .endpoint_channel = std::move(channel), }; } -proto::connections::Medium P2pClusterPcpHandler::StartWifiLanAdvertising( +location::nearby::proto::connections::Medium +P2pClusterPcpHandler::StartWifiLanAdvertising( ClientProxy* client, const std::string& service_id, const std::string& local_endpoint_id, const ByteArray& local_endpoint_info, WebRtcState web_rtc_state) { @@ -1735,10 +1772,10 @@ proto::connections::Medium P2pClusterPcpHandler::StartWifiLanAdvertising( socket); ByteArray remote_service_name_byte{remote_service_name}; - OnIncomingConnection( - client, remote_service_name_byte, - std::move(channel), - proto::connections::Medium::WIFI_LAN); + OnIncomingConnection(client, remote_service_name_byte, + std::move(channel), + location::nearby::proto:: + connections::Medium::WIFI_LAN); }); }})) { NEARBY_LOGS(WARNING) @@ -1748,7 +1785,7 @@ proto::connections::Medium P2pClusterPcpHandler::StartWifiLanAdvertising( << " failed to start listening for incoming WifiLan connections " "to service_id=" << service_id; - return proto::connections::UNKNOWN_MEDIUM; + return location::nearby::proto::connections::UNKNOWN_MEDIUM; } NEARBY_LOGS(INFO) << "In StartWifiLanAdvertising(" << absl::BytesToHexString(local_endpoint_info.data()) @@ -1784,7 +1821,7 @@ proto::connections::Medium P2pClusterPcpHandler::StartWifiLanAdvertising( << absl::BytesToHexString(local_endpoint_info.data()) << "}."; wifi_lan_medium_.StopAcceptingConnections(service_id); - return proto::connections::UNKNOWN_MEDIUM; + return location::nearby::proto::connections::UNKNOWN_MEDIUM; } NEARBY_LOGS(INFO) << "In StartWifiLanAdvertising(" << absl::BytesToHexString(local_endpoint_info.data()) @@ -1800,17 +1837,18 @@ proto::connections::Medium P2pClusterPcpHandler::StartWifiLanAdvertising( << " couldn't advertise with WifiLanServiceInfo " << nsd_service_info.GetServiceName(); wifi_lan_medium_.StopAcceptingConnections(service_id); - return proto::connections::UNKNOWN_MEDIUM; + return location::nearby::proto::connections::UNKNOWN_MEDIUM; } NEARBY_LOGS(INFO) << "In StartWifiLanAdvertising(" << absl::BytesToHexString(local_endpoint_info.data()) << "), client=" << client->GetClientId() << " advertised with WifiLanServiceInfo " << nsd_service_info.GetServiceName(); - return proto::connections::WIFI_LAN; + return location::nearby::proto::connections::WIFI_LAN; } -proto::connections::Medium P2pClusterPcpHandler::StartWifiLanDiscovery( +location::nearby::proto::connections::Medium +P2pClusterPcpHandler::StartWifiLanDiscovery( WifiLanDiscoveredServiceCallback callback, ClientProxy* client, const std::string& service_id) { if (wifi_lan_medium_.StartDiscovery(service_id, std::move(callback))) { @@ -1818,13 +1856,13 @@ proto::connections::Medium P2pClusterPcpHandler::StartWifiLanDiscovery( << client->GetClientId() << " started scanning for Wifi devices for service_id=" << service_id; - return proto::connections::WIFI_LAN; + return location::nearby::proto::connections::WIFI_LAN; } else { NEARBY_LOGS(INFO) << "In StartWifiLanDiscovery(), client=" << client->GetClientId() << " couldn't start scanning on Wifi for service_id=" << service_id; - return proto::connections::UNKNOWN_MEDIUM; + return location::nearby::proto::connections::UNKNOWN_MEDIUM; } } @@ -1855,7 +1893,7 @@ BasePcpHandler::ConnectImplResult P2pClusterPcpHandler::WifiLanConnectImpl( << " created WifiLan endpoint channel to endpoint(id=" << endpoint->endpoint_id << ")."; return BasePcpHandler::ConnectImplResult{ - .medium = proto::connections::Medium::WIFI_LAN, + .medium = location::nearby::proto::connections::Medium::WIFI_LAN, .status = {Status::kSuccess}, .endpoint_channel = std::move(channel), }; @@ -1863,4 +1901,3 @@ BasePcpHandler::ConnectImplResult P2pClusterPcpHandler::WifiLanConnectImpl( } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/p2p_cluster_pcp_handler.h b/connections/implementation/p2p_cluster_pcp_handler.h index c94f23f677..3f8b77646c 100644 --- a/connections/implementation/p2p_cluster_pcp_handler.h +++ b/connections/implementation/p2p_cluster_pcp_handler.h @@ -39,7 +39,6 @@ #include "connections/implementation/wifi_lan_service_info.h" #include "internal/platform/byte_array.h" -namespace location { namespace nearby { namespace connections { @@ -60,9 +59,10 @@ class P2pClusterPcpHandler : public BasePcpHandler { ~P2pClusterPcpHandler() override = default; protected: - std::vector GetConnectionMediumsByPriority() + std::vector + GetConnectionMediumsByPriority() override; + location::nearby::proto::connections::Medium GetDefaultUpgradeMedium() override; - proto::connections::Medium GetDefaultUpgradeMedium() override; // @PCPHandlerThread BasePcpHandler::StartOperationResult StartAdvertisingImpl( @@ -143,11 +143,11 @@ class P2pClusterPcpHandler : public BasePcpHandler { void BluetoothDeviceLostHandler(ClientProxy* client, const std::string& service_id, BluetoothDevice& device); - proto::connections::Medium StartBluetoothAdvertising( + location::nearby::proto::connections::Medium StartBluetoothAdvertising( ClientProxy* client, const std::string& service_id, const ByteArray& service_id_hash, const std::string& local_endpoint_id, const ByteArray& local_endpoint_info, WebRtcState web_rtc_state); - proto::connections::Medium StartBluetoothDiscovery( + location::nearby::proto::connections::Medium StartBluetoothDiscovery( BluetoothDiscoveredDeviceCallback callback, ClientProxy* client, const std::string& service_id); BasePcpHandler::ConnectImplResult BluetoothConnectImpl( @@ -163,12 +163,12 @@ class P2pClusterPcpHandler : public BasePcpHandler { bool fast_advertisement); void BlePeripheralLostHandler(ClientProxy* client, BlePeripheral& peripheral, const std::string& service_id); - proto::connections::Medium StartBleAdvertising( + location::nearby::proto::connections::Medium StartBleAdvertising( ClientProxy* client, const std::string& service_id, const std::string& local_endpoint_id, const ByteArray& local_endpoint_info, const AdvertisingOptions& advertising_options, WebRtcState web_rtc_state); - proto::connections::Medium StartBleScanning( + location::nearby::proto::connections::Medium StartBleScanning( BleDiscoveredPeripheralCallback callback, ClientProxy* client, const std::string& service_id, const std::string& fast_advertisement_service_uuid); @@ -188,12 +188,12 @@ class P2pClusterPcpHandler : public BasePcpHandler { const std::string& service_id, const ByteArray& advertisement_bytes, bool fast_advertisement); - proto::connections::Medium StartBleV2Advertising( + location::nearby::proto::connections::Medium StartBleV2Advertising( ClientProxy* client, const std::string& service_id, const std::string& local_endpoint_id, const ByteArray& local_endpoint_info, const AdvertisingOptions& advertising_options, WebRtcState web_rtc_state); - proto::connections::Medium StartBleV2Scanning( + location::nearby::proto::connections::Medium StartBleV2Scanning( BleV2DiscoveredPeripheralCallback callback, ClientProxy* client, const std::string& service_id, const DiscoveryOptions& discovery_options); BasePcpHandler::ConnectImplResult BleV2ConnectImpl(ClientProxy* client, @@ -209,11 +209,11 @@ class P2pClusterPcpHandler : public BasePcpHandler { void WifiLanServiceLostHandler(ClientProxy* client, NsdServiceInfo service_info, const std::string& service_id); - proto::connections::Medium StartWifiLanAdvertising( + location::nearby::proto::connections::Medium StartWifiLanAdvertising( ClientProxy* client, const std::string& service_id, const std::string& local_endpoint_id, const ByteArray& local_endpoint_info, WebRtcState web_rtc_state); - proto::connections::Medium StartWifiLanDiscovery( + location::nearby::proto::connections::Medium StartWifiLanDiscovery( WifiLanDiscoveredServiceCallback callback, ClientProxy* client, const std::string& service_id); BasePcpHandler::ConnectImplResult WifiLanConnectImpl( @@ -241,6 +241,5 @@ class P2pClusterPcpHandler : public BasePcpHandler { } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_P2P_CLUSTER_PCP_HANDLER_H_ diff --git a/connections/implementation/p2p_cluster_pcp_handler_test.cc b/connections/implementation/p2p_cluster_pcp_handler_test.cc index e347ea12e5..7e944aace5 100644 --- a/connections/implementation/p2p_cluster_pcp_handler_test.cc +++ b/connections/implementation/p2p_cluster_pcp_handler_test.cc @@ -27,7 +27,6 @@ #include "internal/platform/logging.h" #include "internal/platform/medium_environment.h" -namespace location { namespace nearby { namespace connections { namespace { @@ -316,4 +315,3 @@ INSTANTIATE_TEST_SUITE_P(ParametrisedPcpHandlerTest, P2pClusterPcpHandlerTest, } // namespace } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/p2p_point_to_point_pcp_handler.cc b/connections/implementation/p2p_point_to_point_pcp_handler.cc index deec0a1aac..1aa15b792f 100644 --- a/connections/implementation/p2p_point_to_point_pcp_handler.cc +++ b/connections/implementation/p2p_point_to_point_pcp_handler.cc @@ -16,7 +16,6 @@ #include -namespace location { namespace nearby { namespace connections { @@ -27,28 +26,28 @@ P2pPointToPointPcpHandler::P2pPointToPointPcpHandler( : P2pStarPcpHandler(mediums, endpoint_manager, channel_manager, bwu_manager, injected_bluetooth_device_store, pcp) {} -std::vector +std::vector P2pPointToPointPcpHandler::GetConnectionMediumsByPriority() { - std::vector mediums; + std::vector mediums; if (mediums_->GetWifiLan().IsAvailable()) { - mediums.push_back(proto::connections::WIFI_LAN); + mediums.push_back(location::nearby::proto::connections::WIFI_LAN); } if (mediums_->GetWifi().IsAvailable() && mediums_->GetWifiDirect().IsGCAvailable()) { - mediums.push_back(proto::connections::WIFI_DIRECT); + mediums.push_back(location::nearby::proto::connections::WIFI_DIRECT); } if (mediums_->GetWifi().IsAvailable() && mediums_->GetWifiHotspot().IsClientAvailable()) { - mediums.push_back(proto::connections::WIFI_HOTSPOT); + mediums.push_back(location::nearby::proto::connections::WIFI_HOTSPOT); } if (mediums_->GetWebRtc().IsAvailable()) { - mediums.push_back(proto::connections::WEB_RTC); + mediums.push_back(location::nearby::proto::connections::WEB_RTC); } if (mediums_->GetBluetoothClassic().IsAvailable()) { - mediums.push_back(proto::connections::BLUETOOTH); + mediums.push_back(location::nearby::proto::connections::BLUETOOTH); } if (mediums_->GetBle().IsAvailable()) { - mediums.push_back(proto::connections::BLE); + mediums.push_back(location::nearby::proto::connections::BLE); } return mediums; } @@ -71,4 +70,3 @@ bool P2pPointToPointPcpHandler::CanReceiveIncomingConnection( } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/p2p_point_to_point_pcp_handler.h b/connections/implementation/p2p_point_to_point_pcp_handler.h index fa1f74668b..a35c890ff0 100644 --- a/connections/implementation/p2p_point_to_point_pcp_handler.h +++ b/connections/implementation/p2p_point_to_point_pcp_handler.h @@ -21,7 +21,6 @@ #include "connections/implementation/pcp.h" #include "connections/strategy.h" -namespace location { namespace nearby { namespace connections { @@ -41,8 +40,8 @@ class P2pPointToPointPcpHandler : public P2pStarPcpHandler { Pcp pcp = Pcp::kP2pPointToPoint); protected: - std::vector GetConnectionMediumsByPriority() - override; + std::vector + GetConnectionMediumsByPriority() override; bool CanSendOutgoingConnection(ClientProxy* client) const override; bool CanReceiveIncomingConnection(ClientProxy* client) const override; @@ -50,6 +49,5 @@ class P2pPointToPointPcpHandler : public P2pStarPcpHandler { } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_P2P_POINT_TO_POINT_PCP_HANDLER_H_ diff --git a/connections/implementation/p2p_point_to_point_pcp_handler_test.cc b/connections/implementation/p2p_point_to_point_pcp_handler_test.cc index fdd61f3efa..56f5cb8c31 100644 --- a/connections/implementation/p2p_point_to_point_pcp_handler_test.cc +++ b/connections/implementation/p2p_point_to_point_pcp_handler_test.cc @@ -18,7 +18,6 @@ #include "protobuf-matchers/protocol-buffer-matchers.h" #include "gtest/gtest.h" -namespace location { namespace nearby { namespace connections { @@ -27,4 +26,3 @@ TEST(P2pPointToPointPcpHandlerTest, CanConnect) {} } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/p2p_star_pcp_handler.cc b/connections/implementation/p2p_star_pcp_handler.cc index 7f1357aaf6..2af6f0adcb 100644 --- a/connections/implementation/p2p_star_pcp_handler.cc +++ b/connections/implementation/p2p_star_pcp_handler.cc @@ -18,7 +18,6 @@ #include "internal/platform/logging.h" -namespace location { namespace nearby { namespace connections { @@ -30,34 +29,35 @@ P2pStarPcpHandler::P2pStarPcpHandler( &bwu_manager, injected_bluetooth_device_store, pcp) { } -std::vector +std::vector P2pStarPcpHandler::GetConnectionMediumsByPriority() { - std::vector mediums; + std::vector mediums; if (mediums_->GetWifiLan().IsAvailable()) { - mediums.push_back(proto::connections::WIFI_LAN); + mediums.push_back(location::nearby::proto::connections::WIFI_LAN); } if (mediums_->GetWifi().IsAvailable() && mediums_->GetWifiDirect().IsGCAvailable()) { - mediums.push_back(proto::connections::WIFI_DIRECT); + mediums.push_back(location::nearby::proto::connections::WIFI_DIRECT); } if (mediums_->GetWifi().IsAvailable() && mediums_->GetWifiHotspot().IsClientAvailable()) { - mediums.push_back(proto::connections::WIFI_HOTSPOT); + mediums.push_back(location::nearby::proto::connections::WIFI_HOTSPOT); } if (mediums_->GetWebRtc().IsAvailable()) { - mediums.push_back(proto::connections::WEB_RTC); + mediums.push_back(location::nearby::proto::connections::WEB_RTC); } if (mediums_->GetBluetoothClassic().IsAvailable()) { - mediums.push_back(proto::connections::BLUETOOTH); + mediums.push_back(location::nearby::proto::connections::BLUETOOTH); } if (mediums_->GetBle().IsAvailable()) { - mediums.push_back(proto::connections::BLE); + mediums.push_back(location::nearby::proto::connections::BLE); } return mediums; } -proto::connections::Medium P2pStarPcpHandler::GetDefaultUpgradeMedium() { - return proto::connections::Medium::WIFI_HOTSPOT; +location::nearby::proto::connections::Medium +P2pStarPcpHandler::GetDefaultUpgradeMedium() { + return location::nearby::proto::connections::Medium::WIFI_HOTSPOT; } bool P2pStarPcpHandler::CanSendOutgoingConnection(ClientProxy* client) const { @@ -76,4 +76,3 @@ bool P2pStarPcpHandler::CanReceiveIncomingConnection( } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/p2p_star_pcp_handler.h b/connections/implementation/p2p_star_pcp_handler.h index 83bd845f08..581e3bc552 100644 --- a/connections/implementation/p2p_star_pcp_handler.h +++ b/connections/implementation/p2p_star_pcp_handler.h @@ -24,7 +24,6 @@ #include "connections/implementation/pcp.h" #include "connections/strategy.h" -namespace location { namespace nearby { namespace connections { @@ -44,9 +43,10 @@ class P2pStarPcpHandler : public P2pClusterPcpHandler { Pcp pcp = Pcp::kP2pStar); protected: - std::vector GetConnectionMediumsByPriority() + std::vector + GetConnectionMediumsByPriority() override; + location::nearby::proto::connections::Medium GetDefaultUpgradeMedium() override; - proto::connections::Medium GetDefaultUpgradeMedium() override; bool CanSendOutgoingConnection(ClientProxy* client) const override; bool CanReceiveIncomingConnection(ClientProxy* client) const override; @@ -54,6 +54,5 @@ class P2pStarPcpHandler : public P2pClusterPcpHandler { } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_P2P_STAR_PCP_HANDLER_H_ diff --git a/connections/implementation/payload_manager.cc b/connections/implementation/payload_manager.cc index f70acf5899..e9af52c0fc 100644 --- a/connections/implementation/payload_manager.cc +++ b/connections/implementation/payload_manager.cc @@ -32,13 +32,14 @@ #include "internal/platform/mutex_lock.h" #include "internal/platform/single_thread_executor.h" -namespace location { namespace nearby { namespace connections { -using ::location::nearby::analytics::PacketMetaData; -using ::location::nearby::analytics::ThroughputRecorderContainer; -using ::location::nearby::connections::PayloadDirection; +using ::location::nearby::connections::OfflineFrame; +using ::location::nearby::connections::V1Frame; +using ::nearby::analytics::PacketMetaData; +using ::nearby::analytics::ThroughputRecorderContainer; +using ::nearby::connections::PayloadDirection; // C++14 requires to declare this. // TODO(apolyudov): remove when migration to c++17 is possible. @@ -79,9 +80,10 @@ bool PayloadManager::SendPayloadLoop( << pending_payload.GetInternalPayload()->GetId() << " at offset " << next_chunk_offset << " since it is marked canceled."; - HandleFinishedOutgoingPayload( - client, available_endpoint_ids, payload_header, next_chunk_offset, - proto::connections::PayloadStatus::LOCAL_CANCELLATION); + HandleFinishedOutgoingPayload(client, available_endpoint_ids, + payload_header, next_chunk_offset, + location::nearby::proto::connections:: + PayloadStatus::LOCAL_CANCELLATION); return false; } @@ -99,7 +101,7 @@ bool PayloadManager::SendPayloadLoop( << pending_payload.GetInternalPayload()->GetId(); HandleFinishedOutgoingPayload( client, available_endpoint_ids, payload_header, next_chunk_offset, - proto::connections::PayloadStatus::LOCAL_ERROR); + location::nearby::proto::connections::PayloadStatus::LOCAL_ERROR); return false; } NEARBY_LOGS(VERBOSE) << "PayloadManager successfully skipped " @@ -129,7 +131,7 @@ bool PayloadManager::SendPayloadLoop( << pending_payload.GetInternalPayload()->GetId(); HandleFinishedOutgoingPayload( client, available_endpoint_ids, payload_header, next_chunk_offset, - proto::connections::PayloadStatus::LOCAL_ERROR); + location::nearby::proto::connections::PayloadStatus::LOCAL_ERROR); return false; } @@ -146,9 +148,10 @@ bool PayloadManager::SendPayloadLoop( NEARBY_LOGS(INFO) << "Payload xfer: endpoints failed: payload_id=" << payload_header.id() << "; endpoint_ids={" << ToString(failed_endpoint_ids) << "}", - HandleFinishedOutgoingPayload( - client, failed_endpoint_ids, payload_header, next_chunk_offset, - proto::connections::PayloadStatus::ENDPOINT_IO_ERROR); + HandleFinishedOutgoingPayload(client, failed_endpoint_ids, + payload_header, next_chunk_offset, + location::nearby::proto::connections:: + PayloadStatus::ENDPOINT_IO_ERROR); } // Check whether at least one endpoint succeeded -- if they all failed, @@ -491,11 +494,11 @@ Status PayloadManager::CancelPayload(ClientProxy* client, } // @EndpointManagerDataPool -void PayloadManager::OnIncomingFrame(OfflineFrame& offline_frame, - const std::string& from_endpoint_id, - ClientProxy* to_client, - proto::connections::Medium current_medium, - PacketMetaData& packet_meta_data) { +void PayloadManager::OnIncomingFrame( + OfflineFrame& offline_frame, const std::string& from_endpoint_id, + ClientProxy* to_client, + location::nearby::proto::connections::Medium current_medium, + PacketMetaData& packet_meta_data) { PayloadTransferFrame& frame = *offline_frame.mutable_v1()->mutable_payload_transfer(); @@ -562,11 +565,11 @@ void PayloadManager::OnEndpointDisconnect(ClientProxy* client, if (pending_payload->IsIncoming()) { client->GetAnalyticsRecorder().OnIncomingPayloadDone( endpoint_id, pending_payload->GetId(), - proto::connections::ENDPOINT_IO_ERROR); + location::nearby::proto::connections::ENDPOINT_IO_ERROR); } else { client->GetAnalyticsRecorder().OnOutgoingPayloadDone( endpoint_id, pending_payload->GetId(), - proto::connections::ENDPOINT_IO_ERROR); + location::nearby::proto::connections::ENDPOINT_IO_ERROR); } } @@ -574,42 +577,46 @@ void PayloadManager::OnEndpointDisconnect(ClientProxy* client, }); } -proto::connections::PayloadStatus +location::nearby::proto::connections::PayloadStatus PayloadManager::EndpointInfoStatusToPayloadStatus(EndpointInfo::Status status) { switch (status) { case EndpointInfo::Status::kCanceled: - return proto::connections::PayloadStatus::REMOTE_CANCELLATION; + return location::nearby::proto::connections::PayloadStatus:: + REMOTE_CANCELLATION; case EndpointInfo::Status::kError: - return proto::connections::PayloadStatus::REMOTE_ERROR; + return location::nearby::proto::connections::PayloadStatus::REMOTE_ERROR; case EndpointInfo::Status::kAvailable: - return proto::connections::PayloadStatus::SUCCESS; + return location::nearby::proto::connections::PayloadStatus::SUCCESS; default: NEARBY_LOGS(INFO) << "PayloadManager: Unknown PayloadStatus"; - return proto::connections::PayloadStatus::UNKNOWN_PAYLOAD_STATUS; + return location::nearby::proto::connections::PayloadStatus:: + UNKNOWN_PAYLOAD_STATUS; } } -proto::connections::PayloadStatus +location::nearby::proto::connections::PayloadStatus PayloadManager::ControlMessageEventToPayloadStatus( PayloadTransferFrame::ControlMessage::EventType event) { switch (event) { case PayloadTransferFrame::ControlMessage::PAYLOAD_ERROR: - return proto::connections::PayloadStatus::REMOTE_ERROR; + return location::nearby::proto::connections::PayloadStatus::REMOTE_ERROR; case PayloadTransferFrame::ControlMessage::PAYLOAD_CANCELED: - return proto::connections::PayloadStatus::REMOTE_CANCELLATION; + return location::nearby::proto::connections::PayloadStatus:: + REMOTE_CANCELLATION; default: NEARBY_LOG(INFO, "PayloadManager: unknown event=%d", event); - return proto::connections::PayloadStatus::UNKNOWN_PAYLOAD_STATUS; + return location::nearby::proto::connections::PayloadStatus:: + UNKNOWN_PAYLOAD_STATUS; } } PayloadProgressInfo::Status PayloadManager::PayloadStatusToTransferUpdateStatus( - proto::connections::PayloadStatus status) { + location::nearby::proto::connections::PayloadStatus status) { switch (status) { - case proto::connections::LOCAL_CANCELLATION: - case proto::connections::REMOTE_CANCELLATION: + case location::nearby::proto::connections::LOCAL_CANCELLATION: + case location::nearby::proto::connections::REMOTE_CANCELLATION: return PayloadProgressInfo::Status::kCanceled; - case proto::connections::SUCCESS: + case location::nearby::proto::connections::SUCCESS: return PayloadProgressInfo::Status::kSuccess; default: return PayloadProgressInfo::Status::kFailure; @@ -648,8 +655,8 @@ PayloadTransferFrame::PayloadHeader PayloadManager::CreatePayloadHeader( payload_header.set_id(internal_payload.GetId()); payload_header.set_type(internal_payload.GetType()); if (internal_payload.GetType() == - location::nearby::connections::PayloadTransferFrame:: - PayloadTransferFrame::PayloadHeader::FILE) { + nearby::connections::PayloadTransferFrame::PayloadTransferFrame:: + PayloadHeader::FILE) { payload_header.set_file_name(file_name); payload_header.set_parent_folder(parent_folder); } @@ -700,7 +707,7 @@ void PayloadManager::SendClientCallbacksForFinishedOutgoingPayload( ClientProxy* client, const EndpointIds& finished_endpoint_ids, const PayloadTransferFrame::PayloadHeader& payload_header, std::int64_t num_bytes_successfully_transferred, - proto::connections::PayloadStatus status) { + location::nearby::proto::connections::PayloadStatus status) { RunOnStatusUpdateThread( "outgoing-payload-callbacks", [this, client, finished_endpoint_ids, payload_header, @@ -744,7 +751,8 @@ void PayloadManager::SendClientCallbacksForFinishedOutgoingPayload( void PayloadManager::SendClientCallbacksForFinishedIncomingPayload( ClientProxy* client, const std::string& endpoint_id, const PayloadTransferFrame::PayloadHeader& payload_header, - std::int64_t offset_bytes, proto::connections::PayloadStatus status) { + std::int64_t offset_bytes, + location::nearby::proto::connections::PayloadStatus status) { RunOnStatusUpdateThread( "incoming-payload-callbacks", [this, client, endpoint_id, payload_header, offset_bytes, @@ -787,19 +795,20 @@ void PayloadManager::HandleFinishedOutgoingPayload( ClientProxy* client, const EndpointIds& finished_endpoint_ids, const PayloadTransferFrame::PayloadHeader& payload_header, std::int64_t num_bytes_successfully_transferred, - proto::connections::PayloadStatus status) { + location::nearby::proto::connections::PayloadStatus status) { // This call will destroy a pending payload. SendClientCallbacksForFinishedOutgoingPayload( client, finished_endpoint_ids, payload_header, num_bytes_successfully_transferred, status); switch (status) { - case proto::connections::PayloadStatus::LOCAL_ERROR: + case location::nearby::proto::connections::PayloadStatus::LOCAL_ERROR: SendControlMessage(finished_endpoint_ids, payload_header, num_bytes_successfully_transferred, PayloadTransferFrame::ControlMessage::PAYLOAD_ERROR); break; - case proto::connections::PayloadStatus::LOCAL_CANCELLATION: + case location::nearby::proto::connections::PayloadStatus:: + LOCAL_CANCELLATION: NEARBY_LOGS(INFO) << "Sending PAYLOAD_CANCEL to receiver side; payload_id=" << payload_header.id(); @@ -808,15 +817,16 @@ void PayloadManager::HandleFinishedOutgoingPayload( num_bytes_successfully_transferred, PayloadTransferFrame::ControlMessage::PAYLOAD_CANCELED); break; - case proto::connections::PayloadStatus::ENDPOINT_IO_ERROR: + case location::nearby::proto::connections::PayloadStatus::ENDPOINT_IO_ERROR: // Unregister these endpoints, since we had an IO error on the physical // connection. for (const auto& endpoint_id : finished_endpoint_ids) { endpoint_manager_->DiscardEndpoint(client, endpoint_id); } break; - case proto::connections::PayloadStatus::REMOTE_ERROR: - case proto::connections::PayloadStatus::REMOTE_CANCELLATION: + case location::nearby::proto::connections::PayloadStatus::REMOTE_ERROR: + case location::nearby::proto::connections::PayloadStatus:: + REMOTE_CANCELLATION: // No special handling needed for these. break; default: @@ -831,18 +841,20 @@ void PayloadManager::HandleFinishedOutgoingPayload( void PayloadManager::HandleFinishedIncomingPayload( ClientProxy* client, const std::string& endpoint_id, const PayloadTransferFrame::PayloadHeader& payload_header, - std::int64_t offset_bytes, proto::connections::PayloadStatus status) { + std::int64_t offset_bytes, + location::nearby::proto::connections::PayloadStatus status) { ThroughputRecorderContainer::GetInstance().StopTPRecorder( payload_header.id(), PayloadDirection::INCOMING_PAYLOAD); SendClientCallbacksForFinishedIncomingPayload( client, endpoint_id, payload_header, offset_bytes, status); switch (status) { - case proto::connections::PayloadStatus::LOCAL_ERROR: + case location::nearby::proto::connections::PayloadStatus::LOCAL_ERROR: SendControlMessage({endpoint_id}, payload_header, offset_bytes, PayloadTransferFrame::ControlMessage::PAYLOAD_ERROR); break; - case proto::connections::PayloadStatus::LOCAL_CANCELLATION: + case location::nearby::proto::connections::PayloadStatus:: + LOCAL_CANCELLATION: SendControlMessage( {endpoint_id}, payload_header, offset_bytes, PayloadTransferFrame::ControlMessage::PAYLOAD_CANCELED); @@ -892,7 +904,8 @@ void PayloadManager::HandleSuccessfulOutgoingChunk( if (is_last_chunk) { client->GetAnalyticsRecorder().OnOutgoingPayloadDone( - endpoint_id, payload_header.id(), proto::connections::SUCCESS); + endpoint_id, payload_header.id(), + location::nearby::proto::connections::SUCCESS); // Stop tracking this endpoint. pending_payload->RemoveEndpoints({endpoint_id}); @@ -959,7 +972,8 @@ void PayloadManager::HandleSuccessfulIncomingChunk( // Analyze the success. if (is_last_chunk) { client->GetAnalyticsRecorder().OnIncomingPayloadDone( - endpoint_id, payload_header.id(), proto::connections::SUCCESS); + endpoint_id, payload_header.id(), + location::nearby::proto::connections::SUCCESS); } else { client->GetAnalyticsRecorder().OnPayloadChunkReceived( endpoint_id, payload_header.id(), payload_chunk_body_size); @@ -1043,9 +1057,10 @@ void PayloadManager::ProcessDataPacket( NEARBY_LOGS(INFO) << "ProcessDataPacket: [cancel] endpoint_id=" << from_endpoint_id << "; payload_id=" << pending_payload->GetId(); - HandleFinishedIncomingPayload( - to_client, from_endpoint_id, payload_header, payload_chunk.offset(), - proto::connections::PayloadStatus::LOCAL_CANCELLATION); + HandleFinishedIncomingPayload(to_client, from_endpoint_id, payload_header, + payload_chunk.offset(), + location::nearby::proto::connections:: + PayloadStatus::LOCAL_CANCELLATION); return; } @@ -1069,7 +1084,7 @@ void PayloadManager::ProcessDataPacket( << ", payload_chunk=" << payload_chunk.DebugString(); HandleFinishedIncomingPayload( to_client, from_endpoint_id, payload_header, payload_chunk.offset(), - proto::connections::PayloadStatus::LOCAL_ERROR); + location::nearby::proto::connections::PayloadStatus::LOCAL_ERROR); return; } packet_meta_data.StopFileIo(); @@ -1178,7 +1193,8 @@ void PayloadManager::RecordInvalidPayloadAnalytics( for (const auto& endpoint_id : endpoint_ids) { client->GetAnalyticsRecorder().OnOutgoingPayloadDone( - endpoint_id, payload_id, proto::connections::LOCAL_ERROR); + endpoint_id, payload_id, + location::nearby::proto::connections::LOCAL_ERROR); } } @@ -1383,4 +1399,3 @@ std::vector PayloadManager::PendingPayloads::GetAllPayloads() { } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/payload_manager.h b/connections/implementation/payload_manager.h index 27441e445d..cef11252b6 100644 --- a/connections/implementation/payload_manager.h +++ b/connections/implementation/payload_manager.h @@ -36,9 +36,9 @@ #include "internal/platform/count_down_latch.h" #include "internal/platform/mutex.h" -namespace location { namespace nearby { namespace connections { +using ::location::nearby::connections::PayloadTransferFrame; // Annotations for methods that need to run on PayloadStatusUpdateThread. // Use only in PayloadManager @@ -59,11 +59,11 @@ class PayloadManager : public EndpointManager::FrameProcessor { Status CancelPayload(ClientProxy* client, Payload::Id payload_id); // @EndpointManagerReaderThread - void OnIncomingFrame(OfflineFrame& offline_frame, - const std::string& from_endpoint_id, - ClientProxy* to_client, - proto::connections::Medium current_medium, - analytics::PacketMetaData& packet_meta_data) override; + void OnIncomingFrame( + location::nearby::connections::OfflineFrame& offline_frame, + const std::string& from_endpoint_id, ClientProxy* to_client, + location::nearby::proto::connections::Medium current_medium, + analytics::PacketMetaData& packet_meta_data) override; // @EndpointManagerThread void OnEndpointDisconnect(ClientProxy* client, const std::string& service_id, @@ -200,20 +200,22 @@ class PayloadManager : public EndpointManager::FrameProcessor { void SendClientCallbacksForFinishedIncomingPayloadRunnable( ClientProxy* client, const std::string& endpoint_id, const PayloadTransferFrame::PayloadHeader& payload_header, - std::int64_t offset_bytes, proto::connections::PayloadStatus status); + std::int64_t offset_bytes, + location::nearby::proto::connections::PayloadStatus status); // Converts the status of an endpoint that's been set out-of-band via a remote // ControlMessage to the PayloadStatus for handling of that endpoint-payload // pair. - static proto::connections::PayloadStatus EndpointInfoStatusToPayloadStatus( - EndpointInfo::Status status); + static location::nearby::proto::connections::PayloadStatus + EndpointInfoStatusToPayloadStatus(EndpointInfo::Status status); // Converts a ControlMessage::EventType for a particular payload to a // PayloadStatus. Called when we've received a ControlMessage with this event // from a remote endpoint; thus the PayloadStatuses are REMOTE_*. - static proto::connections::PayloadStatus ControlMessageEventToPayloadStatus( + static location::nearby::proto::connections::PayloadStatus + ControlMessageEventToPayloadStatus( PayloadTransferFrame::ControlMessage::EventType event); static PayloadProgressInfo::Status PayloadStatusToTransferUpdateStatus( - proto::connections::PayloadStatus status); + location::nearby::proto::connections::PayloadStatus status); int GetOptimalChunkSize(EndpointIds endpoint_ids); @@ -236,11 +238,12 @@ class PayloadManager : public EndpointManager::FrameProcessor { ClientProxy* client, const EndpointIds& finished_endpoint_ids, const PayloadTransferFrame::PayloadHeader& payload_header, std::int64_t num_bytes_successfully_transferred, - proto::connections::PayloadStatus status); + location::nearby::proto::connections::PayloadStatus status); void SendClientCallbacksForFinishedIncomingPayload( ClientProxy* client, const std::string& endpoint_id, const PayloadTransferFrame::PayloadHeader& payload_header, - std::int64_t offset_bytes, proto::connections::PayloadStatus status); + std::int64_t offset_bytes, + location::nearby::proto::connections::PayloadStatus status); void SendControlMessage( const EndpointIds& endpoint_ids, @@ -254,12 +257,13 @@ class PayloadManager : public EndpointManager::FrameProcessor { ClientProxy* client, const EndpointIds& finished_endpoint_ids, const PayloadTransferFrame::PayloadHeader& payload_header, std::int64_t num_bytes_successfully_transferred, - proto::connections::PayloadStatus status = - proto::connections::PayloadStatus::UNKNOWN_PAYLOAD_STATUS); + location::nearby::proto::connections::PayloadStatus status = location:: + nearby::proto::connections::PayloadStatus::UNKNOWN_PAYLOAD_STATUS); void HandleFinishedIncomingPayload( ClientProxy* client, const std::string& endpoint_id, const PayloadTransferFrame::PayloadHeader& payload_header, - std::int64_t offset_bytes, proto::connections::PayloadStatus status); + std::int64_t offset_bytes, + location::nearby::proto::connections::PayloadStatus status); void HandleSuccessfulOutgoingChunk( ClientProxy* client, const std::string& endpoint_id, @@ -329,6 +333,5 @@ class PayloadManager : public EndpointManager::FrameProcessor { } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_PAYLOAD_MANAGER_H_ diff --git a/connections/implementation/payload_manager_test.cc b/connections/implementation/payload_manager_test.cc index 8d7c52ecff..2c2c5f9f0a 100644 --- a/connections/implementation/payload_manager_test.cc +++ b/connections/implementation/payload_manager_test.cc @@ -23,7 +23,6 @@ #include "internal/platform/pipe.h" #include "internal/platform/system_clock.h" -namespace location { namespace nearby { namespace connections { namespace { @@ -385,4 +384,3 @@ INSTANTIATE_TEST_SUITE_P(ParametrisedPayloadManagerTest, PayloadManagerTest, } // namespace } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/pcp.h b/connections/implementation/pcp.h index 657db612e3..e0519ed956 100644 --- a/connections/implementation/pcp.h +++ b/connections/implementation/pcp.h @@ -15,7 +15,6 @@ #ifndef CORE_INTERNAL_PCP_H_ #define CORE_INTERNAL_PCP_H_ -namespace location { namespace nearby { namespace connections { @@ -35,6 +34,5 @@ enum class Pcp { }; } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_PCP_H_ diff --git a/connections/implementation/pcp_handler.h b/connections/implementation/pcp_handler.h index fda4cb6e79..aa89978b8e 100644 --- a/connections/implementation/pcp_handler.h +++ b/connections/implementation/pcp_handler.h @@ -25,7 +25,6 @@ #include "connections/status.h" #include "connections/strategy.h" -namespace location { namespace nearby { namespace connections { @@ -117,6 +116,5 @@ class PcpHandler { } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_PCP_HANDLER_H_ diff --git a/connections/implementation/pcp_manager.cc b/connections/implementation/pcp_manager.cc index cef8b7d722..d2f3b35586 100644 --- a/connections/implementation/pcp_manager.cc +++ b/connections/implementation/pcp_manager.cc @@ -19,7 +19,6 @@ #include "connections/implementation/p2p_star_pcp_handler.h" #include "connections/implementation/pcp_handler.h" -namespace location { namespace nearby { namespace connections { @@ -145,4 +144,3 @@ PcpHandler* PcpManager::GetPcpHandler(Pcp pcp) const { } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/pcp_manager.h b/connections/implementation/pcp_manager.h index 41a574e6a3..c1286cdfea 100644 --- a/connections/implementation/pcp_manager.h +++ b/connections/implementation/pcp_manager.h @@ -30,7 +30,6 @@ #include "connections/strategy.h" #include "internal/platform/atomic_boolean.h" -namespace location { namespace nearby { namespace connections { @@ -68,7 +67,7 @@ class PcpManager { const PayloadListener& payload_listener); Status RejectConnection(ClientProxy* client, const string& endpoint_id); - proto::connections::Medium GetBandwidthUpgradeMedium(); + location::nearby::proto::connections::Medium GetBandwidthUpgradeMedium(); void DisconnectFromEndpointManager(); private: @@ -82,6 +81,5 @@ class PcpManager { } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_PCP_MANAGER_H_ diff --git a/connections/implementation/pcp_manager_test.cc b/connections/implementation/pcp_manager_test.cc index 89a1854d6e..c48d86a6b0 100644 --- a/connections/implementation/pcp_manager_test.cc +++ b/connections/implementation/pcp_manager_test.cc @@ -26,7 +26,6 @@ #include "internal/platform/count_down_latch.h" #include "internal/platform/medium_environment.h" -namespace location { namespace nearby { namespace connections { namespace { @@ -188,4 +187,3 @@ TEST_F(PcpManagerTest, InjectEndpoint) { } // namespace } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/service_controller.h b/connections/implementation/service_controller.h index 9ec920d254..269434850e 100644 --- a/connections/implementation/service_controller.h +++ b/connections/implementation/service_controller.h @@ -27,7 +27,6 @@ #include "connections/payload.h" #include "connections/status.h" -namespace location { namespace nearby { namespace connections { @@ -38,7 +37,7 @@ namespace connections { // ResultCallback arguments are not provided for this class, because all methods // are called synchronously. // The rest of arguments have the same meaning as the corresponding -// methods in the definition of location::nearby::Core API. +// methods in the definition of nearby::Core API. // // See details here: // cpp/core/core.h @@ -106,6 +105,5 @@ class ServiceController { } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_SERVICE_CONTROLLER_H_ diff --git a/connections/implementation/service_controller_router.cc b/connections/implementation/service_controller_router.cc index 6f050eb756..418bf3c880 100644 --- a/connections/implementation/service_controller_router.cc +++ b/connections/implementation/service_controller_router.cc @@ -27,7 +27,6 @@ #include "connections/payload.h" #include "internal/platform/logging.h" -namespace location { namespace nearby { namespace connections { namespace { @@ -395,4 +394,3 @@ void ServiceControllerRouter::RouteToServiceController(const std::string& name, } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/service_controller_router.h b/connections/implementation/service_controller_router.h index 914cc10221..aa19681d18 100644 --- a/connections/implementation/service_controller_router.h +++ b/connections/implementation/service_controller_router.h @@ -28,12 +28,11 @@ #include "internal/platform/runnable.h" #include "internal/platform/single_thread_executor.h" -namespace location { namespace nearby { namespace connections { // ServiceControllerRouter: this class is an implementation detail of a -// location::nearby::Core class. The latter delegates all of its activities to +// nearby::Core class. The latter delegates all of its activities to // the former. // // All the activities are documented in the public API class: @@ -42,7 +41,7 @@ namespace connections { // In every method, ClientProxy* represents the client app which receives // notifications from Nearby Connections service and forwards them to the app. // The rest of arguments have the same meaning as the corresponding -// methods in the definition of location::nearby::Core API. +// methods in the definition of nearby::Core API. // // Every activity is handled the same way: // 1) all the arguments to the call are captured by value; @@ -127,6 +126,5 @@ class ServiceControllerRouter { } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_SERVICE_CONTROLLER_ROUTER_H_ diff --git a/connections/implementation/service_controller_router_test.cc b/connections/implementation/service_controller_router_test.cc index dbb2e48050..47b22dbfdb 100644 --- a/connections/implementation/service_controller_router_test.cc +++ b/connections/implementation/service_controller_router_test.cc @@ -36,7 +36,6 @@ #include "internal/platform/mutex.h" #include "internal/platform/mutex_lock.h" -namespace location { namespace nearby { namespace connections { @@ -306,8 +305,8 @@ class ServiceControllerRouterTest : public testing::Test { .remote_bluetooth_mac_address = ByteArray(kFakeMacAddress), }; - std::vector mediums_{ - proto::connections::Medium::BLUETOOTH}; + std::vector mediums_{ + location::nearby::proto::connections::Medium::BLUETOOTH}; const ConnectionRequestInfo kConnectionRequestInfo{ .endpoint_info = ByteArray{kRequestorName}, .listener = ConnectionListener(), @@ -444,4 +443,3 @@ TEST_F(ServiceControllerRouterTest, DisconnectFromEndpointCalled) { } // namespace } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/service_id_constants.h b/connections/implementation/service_id_constants.h index 225e6d2484..427282280b 100644 --- a/connections/implementation/service_id_constants.h +++ b/connections/implementation/service_id_constants.h @@ -20,7 +20,6 @@ #include "absl/strings/match.h" #include "absl/strings/string_view.h" -namespace location { namespace nearby { namespace connections { @@ -50,6 +49,5 @@ inline std::string WrapInitiatorUpgradeServiceId(absl::string_view service_id) { } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_SERVICE_ID_CONSTANTS_H_ diff --git a/connections/implementation/simulation_user.cc b/connections/implementation/simulation_user.cc index 01cd11f722..680b1821fe 100644 --- a/connections/implementation/simulation_user.cc +++ b/connections/implementation/simulation_user.cc @@ -19,7 +19,6 @@ #include "internal/platform/count_down_latch.h" #include "internal/platform/system_clock.h" -namespace location { namespace nearby { namespace connections { @@ -178,4 +177,3 @@ void SimulationUser::RejectConnection(CountDownLatch* latch) { } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/simulation_user.h b/connections/implementation/simulation_user.h index 03ba0c81f4..3ead57b641 100644 --- a/connections/implementation/simulation_user.h +++ b/connections/implementation/simulation_user.h @@ -35,7 +35,7 @@ // // This is a "standalone" version of PcpManager. It can run independently, // provided MediumEnvironment has adequate support for all medium types in use. -namespace location { + namespace nearby { namespace connections { @@ -175,6 +175,5 @@ class SimulationUser { } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_SIMULATION_USER_H_ diff --git a/connections/implementation/webrtc_bwu_handler.cc b/connections/implementation/webrtc_bwu_handler.cc index 2d3c4b395b..81ec54e99c 100644 --- a/connections/implementation/webrtc_bwu_handler.cc +++ b/connections/implementation/webrtc_bwu_handler.cc @@ -24,9 +24,10 @@ #include "connections/implementation/offline_frames.h" #include "connections/implementation/webrtc_endpoint_channel.h" -namespace location { namespace nearby { namespace connections { +using ::location::nearby::connections::LocationHint; +using ::location::nearby::connections::LocationStandard; WebrtcBwuHandler::WebrtcIncomingSocket::WebrtcIncomingSocket( const std::string& name, mediums::WebRtcSocketWrapper socket) @@ -151,4 +152,3 @@ void WebrtcBwuHandler::OnIncomingWebrtcConnection( } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/webrtc_bwu_handler.h b/connections/implementation/webrtc_bwu_handler.h index c604b33f00..1fd46bbb85 100644 --- a/connections/implementation/webrtc_bwu_handler.h +++ b/connections/implementation/webrtc_bwu_handler.h @@ -27,7 +27,6 @@ #include "connections/implementation/mediums/webrtc_socket.h" #endif -namespace location { namespace nearby { namespace connections { @@ -77,6 +76,5 @@ class WebrtcBwuHandler : public BaseBwuHandler { } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_WEBRTC_BWU_HANDLER_H_ diff --git a/connections/implementation/webrtc_bwu_handler_stub.cc b/connections/implementation/webrtc_bwu_handler_stub.cc index 41ce1e9253..09f66d4c05 100644 --- a/connections/implementation/webrtc_bwu_handler_stub.cc +++ b/connections/implementation/webrtc_bwu_handler_stub.cc @@ -24,7 +24,6 @@ #include "connections/implementation/offline_frames.h" #include "connections/implementation/webrtc_endpoint_channel.h" -namespace location { namespace nearby { namespace connections { @@ -71,4 +70,3 @@ void WebrtcBwuHandler::OnIncomingWebrtcConnection( } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/webrtc_bwu_handler_stub.h b/connections/implementation/webrtc_bwu_handler_stub.h index c604b33f00..1fd46bbb85 100644 --- a/connections/implementation/webrtc_bwu_handler_stub.h +++ b/connections/implementation/webrtc_bwu_handler_stub.h @@ -27,7 +27,6 @@ #include "connections/implementation/mediums/webrtc_socket.h" #endif -namespace location { namespace nearby { namespace connections { @@ -77,6 +76,5 @@ class WebrtcBwuHandler : public BaseBwuHandler { } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_WEBRTC_BWU_HANDLER_H_ diff --git a/connections/implementation/webrtc_endpoint_channel.cc b/connections/implementation/webrtc_endpoint_channel.cc index 5df4871249..b22501bfc8 100644 --- a/connections/implementation/webrtc_endpoint_channel.cc +++ b/connections/implementation/webrtc_endpoint_channel.cc @@ -16,7 +16,6 @@ #include -namespace location { namespace nearby { namespace connections { @@ -27,12 +26,12 @@ WebRtcEndpointChannel::WebRtcEndpointChannel( &socket.GetOutputStream()), webrtc_socket_(std::move(socket)) {} -proto::connections::Medium WebRtcEndpointChannel::GetMedium() const { - return proto::connections::Medium::WEB_RTC; +location::nearby::proto::connections::Medium WebRtcEndpointChannel::GetMedium() + const { + return location::nearby::proto::connections::Medium::WEB_RTC; } void WebRtcEndpointChannel::CloseImpl() { webrtc_socket_.Close(); } } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/webrtc_endpoint_channel.h b/connections/implementation/webrtc_endpoint_channel.h index 8aa91201ee..ae0eb55188 100644 --- a/connections/implementation/webrtc_endpoint_channel.h +++ b/connections/implementation/webrtc_endpoint_channel.h @@ -24,7 +24,6 @@ #include "connections/implementation/mediums/webrtc_socket.h" #endif -namespace location { namespace nearby { namespace connections { @@ -34,7 +33,7 @@ class WebRtcEndpointChannel final : public BaseEndpointChannel { const std::string& channel_name, mediums::WebRtcSocketWrapper webrtc_socket); - proto::connections::Medium GetMedium() const override; + location::nearby::proto::connections::Medium GetMedium() const override; private: void CloseImpl() override; @@ -44,6 +43,5 @@ class WebRtcEndpointChannel final : public BaseEndpointChannel { } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_WEBRTC_ENDPOINT_CHANNEL_H_ diff --git a/connections/implementation/wifi_direct_bwu_handler.cc b/connections/implementation/wifi_direct_bwu_handler.cc index 41a96cf205..02b0931b36 100644 --- a/connections/implementation/wifi_direct_bwu_handler.cc +++ b/connections/implementation/wifi_direct_bwu_handler.cc @@ -25,7 +25,6 @@ #include "connections/implementation/wifi_direct_endpoint_channel.h" #include "internal/platform/wifi_direct.h" -namespace location { namespace nearby { namespace connections { @@ -155,4 +154,3 @@ void WifiDirectBwuHandler::OnIncomingWifiDirectConnection( } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/wifi_direct_bwu_handler.h b/connections/implementation/wifi_direct_bwu_handler.h index 157dd384d5..47424259c5 100644 --- a/connections/implementation/wifi_direct_bwu_handler.h +++ b/connections/implementation/wifi_direct_bwu_handler.h @@ -22,7 +22,6 @@ #include "connections/implementation/client_proxy.h" #include "connections/implementation/mediums/mediums.h" -namespace location { namespace nearby { namespace connections { @@ -84,6 +83,5 @@ class WifiDirectBwuHandler : public BaseBwuHandler { } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_WIFI_DIRECT_BWU_HANDLER_H_ diff --git a/connections/implementation/wifi_direct_bwu_test.cc b/connections/implementation/wifi_direct_bwu_test.cc index bd59cbc7ba..6763828c20 100644 --- a/connections/implementation/wifi_direct_bwu_test.cc +++ b/connections/implementation/wifi_direct_bwu_test.cc @@ -20,11 +20,11 @@ #include "connections/implementation/wifi_direct_bwu_handler.h" #include "internal/platform/medium_environment.h" -namespace location { namespace nearby { namespace connections { namespace { +using ::location::nearby::connections::OfflineFrame; constexpr absl::Duration kWaitDuration = absl::Milliseconds(1000); } // namespace @@ -110,7 +110,7 @@ TEST_F(WifiDirectTest, SoftAPBWUInit_STACreateEndpointChannel) { /*endpoint_id=*/"1", bwu_frame.upgrade_path_info()); EXPECT_TRUE(accept_latch.Await(kWaitDuration).result()); EXPECT_EQ(new_channel->GetMedium(), - proto::connections::Medium::WIFI_DIRECT); + location::nearby::proto::connections::Medium::WIFI_DIRECT); EXPECT_TRUE(mediums_2.GetWifiDirect().IsConnectedToGO()); handler_2->RevertResponderState(/*service_id=*/"A"); end_latch.CountDown(); @@ -123,4 +123,3 @@ TEST_F(WifiDirectTest, SoftAPBWUInit_STACreateEndpointChannel) { } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/wifi_direct_endpoint_channel.cc b/connections/implementation/wifi_direct_endpoint_channel.cc index b7fb97b01a..0ec1c61901 100644 --- a/connections/implementation/wifi_direct_endpoint_channel.cc +++ b/connections/implementation/wifi_direct_endpoint_channel.cc @@ -20,7 +20,6 @@ #include "internal/platform/logging.h" #include "internal/platform/wifi_direct.h" -namespace location { namespace nearby { namespace connections { @@ -31,8 +30,9 @@ WifiDirectEndpointChannel::WifiDirectEndpointChannel( &socket.GetOutputStream()), socket_(std::move(socket)) {} -proto::connections::Medium WifiDirectEndpointChannel::GetMedium() const { - return proto::connections::Medium::WIFI_DIRECT; +location::nearby::proto::connections::Medium +WifiDirectEndpointChannel::GetMedium() const { + return location::nearby::proto::connections::Medium::WIFI_DIRECT; } void WifiDirectEndpointChannel::CloseImpl() { @@ -46,4 +46,3 @@ void WifiDirectEndpointChannel::CloseImpl() { } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/wifi_direct_endpoint_channel.h b/connections/implementation/wifi_direct_endpoint_channel.h index e2e9ddd59a..9cf735b6d3 100644 --- a/connections/implementation/wifi_direct_endpoint_channel.h +++ b/connections/implementation/wifi_direct_endpoint_channel.h @@ -21,7 +21,6 @@ #include "connections/implementation/base_endpoint_channel.h" #include "internal/platform/wifi_direct.h" -namespace location { namespace nearby { namespace connections { @@ -38,7 +37,7 @@ class WifiDirectEndpointChannel final : public BaseEndpointChannel { WifiDirectEndpointChannel(WifiDirectEndpointChannel&&) = delete; WifiDirectEndpointChannel& operator=(WifiDirectEndpointChannel&&) = delete; - proto::connections::Medium GetMedium() const override; + location::nearby::proto::connections::Medium GetMedium() const override; private: void CloseImpl() override; @@ -48,6 +47,5 @@ class WifiDirectEndpointChannel final : public BaseEndpointChannel { } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_WIFI_DIRECT_ENDPOINT_CHANNEL_H_ diff --git a/connections/implementation/wifi_hotspot_bwu_handler.cc b/connections/implementation/wifi_hotspot_bwu_handler.cc index 896d048076..58acf86d24 100644 --- a/connections/implementation/wifi_hotspot_bwu_handler.cc +++ b/connections/implementation/wifi_hotspot_bwu_handler.cc @@ -26,7 +26,6 @@ #include "connections/implementation/wifi_hotspot_endpoint_channel.h" #include "internal/platform/wifi_hotspot.h" -namespace location { namespace nearby { namespace connections { @@ -163,4 +162,3 @@ void WifiHotspotBwuHandler::OnIncomingWifiHotspotConnection( } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/wifi_hotspot_bwu_handler.h b/connections/implementation/wifi_hotspot_bwu_handler.h index 27762a9510..f7668c4500 100644 --- a/connections/implementation/wifi_hotspot_bwu_handler.h +++ b/connections/implementation/wifi_hotspot_bwu_handler.h @@ -22,7 +22,6 @@ #include "connections/implementation/endpoint_channel_manager.h" #include "connections/implementation/mediums/mediums.h" -namespace location { namespace nearby { namespace connections { @@ -74,6 +73,5 @@ class WifiHotspotBwuHandler : public BaseBwuHandler { } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_WIFI_HOTSPOT_BWU_HANDLER_H_ diff --git a/connections/implementation/wifi_hotspot_endpoint_channel.cc b/connections/implementation/wifi_hotspot_endpoint_channel.cc index 90dba8e159..8e0dd886c3 100644 --- a/connections/implementation/wifi_hotspot_endpoint_channel.cc +++ b/connections/implementation/wifi_hotspot_endpoint_channel.cc @@ -20,7 +20,6 @@ #include "internal/platform/logging.h" #include "internal/platform/wifi_hotspot.h" -namespace location { namespace nearby { namespace connections { @@ -31,8 +30,9 @@ WifiHotspotEndpointChannel::WifiHotspotEndpointChannel( &socket.GetOutputStream()), socket_(std::move(socket)) {} -proto::connections::Medium WifiHotspotEndpointChannel::GetMedium() const { - return proto::connections::Medium::WIFI_HOTSPOT; +location::nearby::proto::connections::Medium +WifiHotspotEndpointChannel::GetMedium() const { + return location::nearby::proto::connections::Medium::WIFI_HOTSPOT; } void WifiHotspotEndpointChannel::CloseImpl() { @@ -46,4 +46,3 @@ void WifiHotspotEndpointChannel::CloseImpl() { } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/wifi_hotspot_endpoint_channel.h b/connections/implementation/wifi_hotspot_endpoint_channel.h index 49ae12ab64..b44da4de3d 100644 --- a/connections/implementation/wifi_hotspot_endpoint_channel.h +++ b/connections/implementation/wifi_hotspot_endpoint_channel.h @@ -21,7 +21,6 @@ #include "connections/implementation/base_endpoint_channel.h" #include "internal/platform/wifi_hotspot.h" -namespace location { namespace nearby { namespace connections { @@ -38,7 +37,7 @@ class WifiHotspotEndpointChannel final : public BaseEndpointChannel { WifiHotspotEndpointChannel(WifiHotspotEndpointChannel&&) = delete; WifiHotspotEndpointChannel& operator=(WifiHotspotEndpointChannel&&) = delete; - proto::connections::Medium GetMedium() const override; + location::nearby::proto::connections::Medium GetMedium() const override; private: void CloseImpl() override; @@ -48,6 +47,5 @@ class WifiHotspotEndpointChannel final : public BaseEndpointChannel { } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_WIFI_HOTSPOT_ENDPOINT_CHANNEL_H_ diff --git a/connections/implementation/wifi_hotspot_test.cc b/connections/implementation/wifi_hotspot_test.cc index 34ce443d88..698bb0657c 100644 --- a/connections/implementation/wifi_hotspot_test.cc +++ b/connections/implementation/wifi_hotspot_test.cc @@ -19,11 +19,11 @@ #include "connections/implementation/wifi_hotspot_bwu_handler.h" #include "internal/platform/medium_environment.h" -namespace location { namespace nearby { namespace connections { namespace { +using ::location::nearby::connections::OfflineFrame; constexpr absl::Duration kWaitDuration = absl::Milliseconds(1000); } // namespace @@ -106,7 +106,7 @@ TEST_F(WifiHotspotTest, SoftAPBWUInit_STACreateEndpointChannel) { bwu_frame.upgrade_path_info()); EXPECT_TRUE(accept_latch.Await(kWaitDuration).result()); EXPECT_EQ(new_channel->GetMedium(), - proto::connections::Medium::WIFI_HOTSPOT); + location::nearby::proto::connections::Medium::WIFI_HOTSPOT); end_latch.CountDown(); }); @@ -116,4 +116,3 @@ TEST_F(WifiHotspotTest, SoftAPBWUInit_STACreateEndpointChannel) { } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/wifi_lan_bwu_handler.cc b/connections/implementation/wifi_lan_bwu_handler.cc index 42f566a5f0..8e0cbf9a4f 100644 --- a/connections/implementation/wifi_lan_bwu_handler.cc +++ b/connections/implementation/wifi_lan_bwu_handler.cc @@ -24,7 +24,6 @@ #include "connections/implementation/wifi_lan_endpoint_channel.h" #include "internal/platform/wifi_lan.h" -namespace location { namespace nearby { namespace connections { @@ -157,4 +156,3 @@ void WifiLanBwuHandler::OnIncomingWifiLanConnection( } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/wifi_lan_bwu_handler.h b/connections/implementation/wifi_lan_bwu_handler.h index b9f83d08b0..13d3626b77 100644 --- a/connections/implementation/wifi_lan_bwu_handler.h +++ b/connections/implementation/wifi_lan_bwu_handler.h @@ -22,7 +22,6 @@ #include "connections/implementation/endpoint_channel_manager.h" #include "connections/implementation/mediums/mediums.h" -namespace location { namespace nearby { namespace connections { @@ -73,6 +72,5 @@ class WifiLanBwuHandler : public BaseBwuHandler { } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_WIFI_LAN_BWU_HANDLER_H_ diff --git a/connections/implementation/wifi_lan_endpoint_channel.cc b/connections/implementation/wifi_lan_endpoint_channel.cc index 5390672a50..0c6081f27b 100644 --- a/connections/implementation/wifi_lan_endpoint_channel.cc +++ b/connections/implementation/wifi_lan_endpoint_channel.cc @@ -19,10 +19,8 @@ #include "internal/platform/logging.h" #include "internal/platform/wifi_lan.h" -namespace location { namespace nearby { namespace connections { - WifiLanEndpointChannel::WifiLanEndpointChannel(const std::string& service_id, const std::string& channel_name, WifiLanSocket socket) @@ -30,8 +28,9 @@ WifiLanEndpointChannel::WifiLanEndpointChannel(const std::string& service_id, &socket.GetOutputStream()), socket_(std::move(socket)) {} -proto::connections::Medium WifiLanEndpointChannel::GetMedium() const { - return proto::connections::Medium::WIFI_LAN; +location::nearby::proto::connections::Medium WifiLanEndpointChannel::GetMedium() + const { + return location::nearby::proto::connections::Medium::WIFI_LAN; } void WifiLanEndpointChannel::CloseImpl() { @@ -45,4 +44,3 @@ void WifiLanEndpointChannel::CloseImpl() { } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/wifi_lan_endpoint_channel.h b/connections/implementation/wifi_lan_endpoint_channel.h index 48ac7f53c3..1129be7cdd 100644 --- a/connections/implementation/wifi_lan_endpoint_channel.h +++ b/connections/implementation/wifi_lan_endpoint_channel.h @@ -20,7 +20,6 @@ #include "connections/implementation/base_endpoint_channel.h" #include "internal/platform/wifi_lan.h" -namespace location { namespace nearby { namespace connections { @@ -30,7 +29,7 @@ class WifiLanEndpointChannel final : public BaseEndpointChannel { WifiLanEndpointChannel(const std::string& service_id, const std::string& channel_name, WifiLanSocket socket); - proto::connections::Medium GetMedium() const override; + location::nearby::proto::connections::Medium GetMedium() const override; private: void CloseImpl() override; @@ -40,6 +39,5 @@ class WifiLanEndpointChannel final : public BaseEndpointChannel { } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_WIFI_LAN_ENDPOINT_CHANNEL_H_ diff --git a/connections/implementation/wifi_lan_service_info.cc b/connections/implementation/wifi_lan_service_info.cc index b21c90de10..af6870650b 100644 --- a/connections/implementation/wifi_lan_service_info.cc +++ b/connections/implementation/wifi_lan_service_info.cc @@ -24,7 +24,6 @@ #include "internal/platform/base_input_stream.h" #include "internal/platform/logging.h" -namespace location { namespace nearby { namespace connections { @@ -202,4 +201,3 @@ WifiLanServiceInfo::operator NsdServiceInfo() const { } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/implementation/wifi_lan_service_info.h b/connections/implementation/wifi_lan_service_info.h index 9a68adc19e..b11e1fec28 100644 --- a/connections/implementation/wifi_lan_service_info.h +++ b/connections/implementation/wifi_lan_service_info.h @@ -23,7 +23,6 @@ #include "internal/platform/byte_array.h" #include "internal/platform/nsd_service_info.h" -namespace location { namespace nearby { namespace connections { @@ -92,6 +91,5 @@ class WifiLanServiceInfo { } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_INTERNAL_WIFI_LAN_SERVICE_INFO_H_ diff --git a/connections/implementation/wifi_lan_service_info_test.cc b/connections/implementation/wifi_lan_service_info_test.cc index fc290cc890..121afc392e 100644 --- a/connections/implementation/wifi_lan_service_info_test.cc +++ b/connections/implementation/wifi_lan_service_info_test.cc @@ -21,7 +21,6 @@ #include "internal/platform/base64_utils.h" #include "internal/platform/nsd_service_info.h" -namespace location { namespace nearby { namespace connections { namespace { @@ -168,4 +167,3 @@ TEST(WifiLanServiceInfoTest, ConstructionFailsWithLongEndpointInfoLength) { } // namespace } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/listeners.h b/connections/listeners.h index b7bc105837..e45f56a1eb 100644 --- a/connections/listeners.h +++ b/connections/listeners.h @@ -34,7 +34,6 @@ #include "internal/platform/byte_utils.h" #include "internal/platform/listeners.h" -namespace location { namespace nearby { namespace connections { @@ -192,6 +191,5 @@ struct PayloadListener { } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_LISTENERS_H_ diff --git a/connections/listeners_test.cc b/connections/listeners_test.cc index 82c349419b..e8642d49a6 100644 --- a/connections/listeners_test.cc +++ b/connections/listeners_test.cc @@ -23,7 +23,6 @@ #include "gtest/gtest.h" #include "internal/platform/byte_array.h" -namespace location { namespace nearby { namespace connections { namespace { @@ -77,4 +76,3 @@ TEST(ListenersTest, PayloadListener_PayloadCb_Works) { } // namespace } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/medium_selector.h b/connections/medium_selector.h index 0572c63ebe..ceaeeb103c 100644 --- a/connections/medium_selector.h +++ b/connections/medium_selector.h @@ -16,7 +16,6 @@ #include "proto/connections_enums.pb.h" -namespace location { namespace nearby { namespace connections { @@ -80,6 +79,5 @@ using BooleanMediumSelector = MediumSelector; } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_MEDIUM_SELECTOR_H_ diff --git a/connections/options_base.h b/connections/options_base.h index 82f9c070b4..06b9c57f68 100644 --- a/connections/options_base.h +++ b/connections/options_base.h @@ -18,7 +18,6 @@ #include "connections/medium_selector.h" #include "connections/strategy.h" -namespace location { namespace nearby { namespace connections { @@ -31,6 +30,5 @@ struct OptionsBase { } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_OPTIONS_BASE_H_ diff --git a/connections/out_of_band_connection_metadata.h b/connections/out_of_band_connection_metadata.h index 0356605f33..d9cb364402 100644 --- a/connections/out_of_band_connection_metadata.h +++ b/connections/out_of_band_connection_metadata.h @@ -21,7 +21,6 @@ #include "internal/platform/byte_array.h" #include "proto/connections_enums.pb.h" -namespace location { namespace nearby { namespace connections { @@ -52,6 +51,5 @@ struct OutOfBandConnectionMetadata { } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_OUT_OF_BAND_CONNECTION_METADATA_H_ diff --git a/connections/params.h b/connections/params.h index 01f04e18e6..feb919501b 100644 --- a/connections/params.h +++ b/connections/params.h @@ -20,7 +20,6 @@ #include "connections/listeners.h" #include "internal/platform/byte_array.h" -namespace location { namespace nearby { namespace connections { @@ -37,6 +36,5 @@ struct ConnectionRequestInfo { } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_PARAMS_H_ diff --git a/connections/payload.cc b/connections/payload.cc index 61e45493fd..5e74467842 100644 --- a/connections/payload.cc +++ b/connections/payload.cc @@ -17,7 +17,6 @@ #include #include -namespace location { namespace nearby { namespace connections { @@ -144,4 +143,3 @@ const std::string& Payload::GetFileName() const { return file_name_; } } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/payload.h b/connections/payload.h index 32ae26212e..26d6e78eef 100644 --- a/connections/payload.h +++ b/connections/payload.h @@ -29,7 +29,6 @@ #include "internal/platform/payload_id.h" #include "internal/platform/prng.h" -namespace location { namespace nearby { namespace connections { @@ -122,6 +121,5 @@ class Payload { } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_PAYLOAD_H_ diff --git a/connections/payload_test.cc b/connections/payload_test.cc index 24f6981ca4..06d126cd4f 100644 --- a/connections/payload_test.cc +++ b/connections/payload_test.cc @@ -25,7 +25,6 @@ #include "internal/platform/input_stream.h" #include "internal/platform/pipe.h" -namespace location { namespace nearby { namespace connections { @@ -140,4 +139,3 @@ TEST(PayloadTest, PayloadIsNotCopyable) { } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/payload_type.h b/connections/payload_type.h index f7c1b60626..17fddfa64f 100644 --- a/connections/payload_type.h +++ b/connections/payload_type.h @@ -15,7 +15,6 @@ #ifndef CORE_PAYLOAD_TYPE_H_ #define CORE_PAYLOAD_TYPE_H_ -namespace location { namespace nearby { namespace connections { @@ -28,6 +27,5 @@ enum PayloadDirection { } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_PAYLOAD_TYPE_H_ diff --git a/connections/power_level.h b/connections/power_level.h index 1753dfec3b..a9de4fe439 100644 --- a/connections/power_level.h +++ b/connections/power_level.h @@ -15,7 +15,6 @@ #ifndef CORE_POWER_LEVEL_H_ #define CORE_POWER_LEVEL_H_ -namespace location { namespace nearby { namespace connections { // Represents the various power levels that can be // used, on mediums that support it. @@ -26,6 +25,5 @@ enum class PowerLevel { } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_POWER_LEVEL_H_ diff --git a/connections/status.cc b/connections/status.cc index ad8c4ca160..c276b92a85 100644 --- a/connections/status.cc +++ b/connections/status.cc @@ -16,7 +16,6 @@ #include -namespace location { namespace nearby { namespace connections { @@ -57,4 +56,3 @@ std::string Status::ToString() const { } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/status.h b/connections/status.h index 30e087def3..a4890a828b 100644 --- a/connections/status.h +++ b/connections/status.h @@ -17,7 +17,6 @@ #include -namespace location { namespace nearby { namespace connections { @@ -59,6 +58,5 @@ inline bool operator!=(const Status& a, const Status& b) { return !(a == b); } } // namespace connections } // namespace nearby -} // namespace location #endif // CORE_STATUS_H_ diff --git a/connections/status_test.cc b/connections/status_test.cc index ecc2dbbd3f..2cef3608d1 100644 --- a/connections/status_test.cc +++ b/connections/status_test.cc @@ -21,7 +21,6 @@ #include "protobuf-matchers/protocol-buffer-matchers.h" #include "gtest/gtest.h" -namespace location { namespace nearby { namespace connections { @@ -96,4 +95,3 @@ INSTANTIATE_TEST_CASE_P(StatusToString, StatusToString, } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/strategy.cc b/connections/strategy.cc index 2b50fa6fff..4d6d086b1c 100644 --- a/connections/strategy.cc +++ b/connections/strategy.cc @@ -14,7 +14,6 @@ #include "connections/strategy.h" -namespace location { namespace nearby { namespace connections { @@ -56,4 +55,3 @@ bool operator!=(const Strategy& lhs, const Strategy& rhs) { } // namespace connections } // namespace nearby -} // namespace location diff --git a/connections/strategy.h b/connections/strategy.h index 2e7340c2ad..095f1c3911 100644 --- a/connections/strategy.h +++ b/connections/strategy.h @@ -16,7 +16,6 @@ #include -namespace location { namespace nearby { namespace connections { @@ -66,5 +65,5 @@ class Strategy { } // namespace connections } // namespace nearby -} // namespace location + #endif // CORE_STRATEGY_H_ diff --git a/connections/strategy_test.cc b/connections/strategy_test.cc index dfa56ba5f1..f8e3723de2 100644 --- a/connections/strategy_test.cc +++ b/connections/strategy_test.cc @@ -16,7 +16,6 @@ #include "gtest/gtest.h" -namespace location { namespace nearby { namespace connections { @@ -52,4 +51,3 @@ TEST(StrategyTest, GetNameWorks) { } // namespace connections } // namespace nearby -} // namespace location diff --git a/fastpair/client/windows/fast_pair_controller_adapter.cc b/fastpair/client/windows/fast_pair_controller_adapter.cc index cb03a3a7c0..e939edfaf1 100644 --- a/fastpair/client/windows/fast_pair_controller_adapter.cc +++ b/fastpair/client/windows/fast_pair_controller_adapter.cc @@ -14,7 +14,6 @@ #include "fastpair/client/windows/fast_pair_controller_adapter.h" -namespace location { namespace nearby { namespace fastpair { @@ -34,4 +33,3 @@ void ServerAccess(FastPairController *pController) { } // namespace fastpair } // namespace nearby -} // namespace location diff --git a/fastpair/client/windows/fast_pair_controller_adapter.h b/fastpair/client/windows/fast_pair_controller_adapter.h index 947b464322..4c03ddcfda 100644 --- a/fastpair/client/windows/fast_pair_controller_adapter.h +++ b/fastpair/client/windows/fast_pair_controller_adapter.h @@ -19,7 +19,6 @@ #include "fastpair/fast_pair_controller.h" -namespace location { namespace nearby { namespace fastpair { @@ -36,6 +35,5 @@ DLL_EXPORT void __stdcall ServerAccess(FastPairController *pController); } // namespace fastpair } // namespace nearby -} // namespace location #endif // THIRD_PARTY_NEARBY_FASTPAIR_CLIENT_WINDOWS_FAST_PAIR_CONTROLLER_ADAPTER_H_ diff --git a/fastpair/client/windows/fast_pair_controller_adapter_dart.cc b/fastpair/client/windows/fast_pair_controller_adapter_dart.cc index e26fd632f5..bd3b889e8a 100644 --- a/fastpair/client/windows/fast_pair_controller_adapter_dart.cc +++ b/fastpair/client/windows/fast_pair_controller_adapter_dart.cc @@ -16,7 +16,6 @@ #include "fastpair/client/windows/fast_pair_controller_adapter.h" -namespace location { namespace nearby { namespace fastpair { @@ -30,4 +29,3 @@ void ServerAccessDart(FastPairController *pController) { } // namespace fastpair } // namespace nearby -} // namespace location diff --git a/fastpair/client/windows/fast_pair_controller_adapter_dart.h b/fastpair/client/windows/fast_pair_controller_adapter_dart.h index c96425f988..b79252f5aa 100644 --- a/fastpair/client/windows/fast_pair_controller_adapter_dart.h +++ b/fastpair/client/windows/fast_pair_controller_adapter_dart.h @@ -18,7 +18,6 @@ #include "third_party/dart_lang/v2/runtime/include/dart_api_dl.h" #include "fastpair/client/windows/fast_pair_controller_adapter.h" -namespace location { namespace nearby { namespace fastpair { @@ -28,6 +27,5 @@ DLL_EXPORT void __stdcall ServerAccessDart(FastPairController* pController); } // namespace fastpair } // namespace nearby -} // namespace location #endif // THIRD_PARTY_NEARBY_FASTPAIR_CLIENT_WINDOWS_FAST_PAIR_CONTROLLER_ADAPTER_DART_H_ diff --git a/fastpair/common/constant.h b/fastpair/common/constant.h index 195bfceb7b..64a9efb6f5 100644 --- a/fastpair/common/constant.h +++ b/fastpair/common/constant.h @@ -15,7 +15,6 @@ #ifndef THIRD_PARTY_NEARBY_FASTPAIR_COMMON_CONSTANT_H_ #define THIRD_PARTY_NEARBY_FASTPAIR_COMMON_CONSTANT_H_ -namespace location { namespace nearby { namespace fastpair { @@ -33,6 +32,5 @@ const char kAccountKeyCharacteristicUuidV2[] = } // namespace fastpair } // namespace nearby -} // namespace location #endif // THIRD_PARTY_NEARBY_FASTPAIR_COMMON_CONSTANT_H_ diff --git a/fastpair/common/fast_pair_device.cc b/fastpair/common/fast_pair_device.cc index 46ad0a0ca9..75497d584d 100644 --- a/fastpair/common/fast_pair_device.cc +++ b/fastpair/common/fast_pair_device.cc @@ -20,7 +20,6 @@ #include "fastpair/common/protocol.h" -namespace location { namespace nearby { namespace fastpair { @@ -44,4 +43,3 @@ std::ostream& operator<<(std::ostream& stream, const FastPairDevice& device) { } // namespace fastpair } // namespace nearby -} // namespace location diff --git a/fastpair/common/fast_pair_device.h b/fastpair/common/fast_pair_device.h index c05061b4e1..a540e59aea 100644 --- a/fastpair/common/fast_pair_device.h +++ b/fastpair/common/fast_pair_device.h @@ -23,7 +23,6 @@ #include "absl/container/flat_hash_map.h" #include "fastpair/common/protocol.h" -namespace location { namespace nearby { namespace fastpair { @@ -105,6 +104,5 @@ std::ostream& operator<<(std::ostream& stream, const FastPairDevice& device); } // namespace fastpair } // namespace nearby -} // namespace location #endif // THIRD_PARTY_NEARBY_FASTPAIR_COMMON_FAST_PAIR_DEVICE_H_ diff --git a/fastpair/common/fast_pair_device_test.cc b/fastpair/common/fast_pair_device_test.cc index c0f440baf5..90efb74801 100644 --- a/fastpair/common/fast_pair_device_test.cc +++ b/fastpair/common/fast_pair_device_test.cc @@ -23,7 +23,6 @@ #include "gtest/gtest.h" #include "fastpair/common/protocol.h" -namespace location { namespace nearby { namespace fastpair { namespace { @@ -91,4 +90,3 @@ TEST(FastPairDevice, GetAndPublicAddress) { } // namespace } // namespace fastpair } // namespace nearby -} // namespace location diff --git a/fastpair/common/fast_pair_http_result.cc b/fastpair/common/fast_pair_http_result.cc index 49b5aef354..d66038a67c 100644 --- a/fastpair/common/fast_pair_http_result.cc +++ b/fastpair/common/fast_pair_http_result.cc @@ -19,7 +19,6 @@ #include "absl/status/status.h" -namespace location { namespace nearby { namespace fastpair { @@ -146,4 +145,3 @@ std::ostream& operator<<(std::ostream& stream, } // namespace fastpair } // namespace nearby -} // namespace location diff --git a/fastpair/common/fast_pair_http_result.h b/fastpair/common/fast_pair_http_result.h index 8c809258fb..c69b8ed875 100644 --- a/fastpair/common/fast_pair_http_result.h +++ b/fastpair/common/fast_pair_http_result.h @@ -20,7 +20,6 @@ #include "absl/status/status.h" -namespace location { namespace nearby { namespace fastpair { @@ -62,6 +61,5 @@ std::ostream& operator<<(std::ostream& stream, } // namespace fastpair } // namespace nearby -} // namespace location #endif // THIRD_PARTY_NEARBY_FASTPAIR_COMMON_FAST_PAIR_HTTP_RESULT_H_ diff --git a/fastpair/common/protocol.cc b/fastpair/common/protocol.cc index 57906c99a4..90a165aa7a 100644 --- a/fastpair/common/protocol.cc +++ b/fastpair/common/protocol.cc @@ -16,7 +16,6 @@ #include -namespace location { namespace nearby { namespace fastpair { @@ -38,4 +37,3 @@ std::ostream& operator<<(std::ostream& stream, Protocol protocol) { } // namespace fastpair } // namespace nearby -} // namespace location diff --git a/fastpair/common/protocol.h b/fastpair/common/protocol.h index 9c2acb63bc..ae0724e6db 100644 --- a/fastpair/common/protocol.h +++ b/fastpair/common/protocol.h @@ -17,7 +17,6 @@ #include -namespace location { namespace nearby { namespace fastpair { @@ -33,6 +32,5 @@ std::ostream& operator<<(std::ostream& stream, Protocol protocol); } // namespace fastpair } // namespace nearby -} // namespace location #endif // THIRD_PARTY_NEARBY_FASTPAIR_COMMON_PROTOCOL_H_ diff --git a/fastpair/fast_pair_controller.h b/fastpair/fast_pair_controller.h index ae162a023e..909f771546 100644 --- a/fastpair/fast_pair_controller.h +++ b/fastpair/fast_pair_controller.h @@ -17,7 +17,6 @@ #include -namespace location { namespace nearby { namespace fastpair { @@ -32,6 +31,5 @@ class FastPairController { } // namespace fastpair } // namespace nearby -} // namespace location #endif // THIRD_PARTY_NEARBY_FAST_PAIR_FASTPAIR_CONTROLLER_H_ diff --git a/fastpair/internal/api/device_info.h b/fastpair/internal/api/device_info.h index 6e5cd8c182..453b8a21a9 100644 --- a/fastpair/internal/api/device_info.h +++ b/fastpair/internal/api/device_info.h @@ -20,7 +20,6 @@ #include "absl/strings/string_view.h" -namespace location { namespace nearby { namespace api { @@ -55,6 +54,5 @@ class DeviceInfo { } // namespace api } // namespace nearby -} // namespace location #endif // THIRD_PARTY_NEARBY_FASTPAIR_INTERNAL_API_DEVICE_INFO_H_ diff --git a/fastpair/internal/api/fast_pair_platform.h b/fastpair/internal/api/fast_pair_platform.h index a946df6c88..f7699ea38b 100644 --- a/fastpair/internal/api/fast_pair_platform.h +++ b/fastpair/internal/api/fast_pair_platform.h @@ -23,7 +23,6 @@ #include "fastpair/internal/api/device_info.h" #include "fastpair/internal/api/timer.h" -namespace location { namespace nearby { namespace api { @@ -37,6 +36,5 @@ class ImplementationFastPairPlatform { } // namespace api } // namespace nearby -} // namespace location #endif // THIRD_PARTY_NEARBY_FASTPAIR_INTERNAL_API_FAST_PAIR_PLATFORM_H_ diff --git a/fastpair/internal/api/timer.h b/fastpair/internal/api/timer.h index e7ba7e2e8d..c154987fa2 100644 --- a/fastpair/internal/api/timer.h +++ b/fastpair/internal/api/timer.h @@ -17,7 +17,6 @@ #include -namespace location { namespace nearby { namespace api { @@ -48,6 +47,5 @@ class Timer { } // namespace api } // namespace nearby -} // namespace location #endif // LOCATION_NEARBY_CPP_FASTPAIR_INTERNAL_API_TIMER_H_ diff --git a/fastpair/internal/base/bluetooth_address.cc b/fastpair/internal/base/bluetooth_address.cc index bb2b10b1f5..4bc6b254e0 100644 --- a/fastpair/internal/base/bluetooth_address.cc +++ b/fastpair/internal/base/bluetooth_address.cc @@ -22,7 +22,6 @@ #include "absl/strings/str_format.h" #include "absl/strings/string_view.h" -namespace location { namespace nearby { namespace fastpair { namespace { @@ -121,4 +120,3 @@ std::string CanonicalizeBluetoothAddress(uint64_t address) { } // namespace fastpair } // namespace nearby -} // namespace location diff --git a/fastpair/internal/base/bluetooth_address.h b/fastpair/internal/base/bluetooth_address.h index eaac21c94e..e3d9913663 100644 --- a/fastpair/internal/base/bluetooth_address.h +++ b/fastpair/internal/base/bluetooth_address.h @@ -24,7 +24,6 @@ #include "absl/strings/string_view.h" #include "absl/types/span.h" -namespace location { namespace nearby { namespace fastpair { @@ -48,6 +47,5 @@ std::string CanonicalizeBluetoothAddress(uint64_t address); } // namespace fastpair } // namespace nearby -} // namespace location #endif // THIRD_PARTY_NEARBY_FASTPAIR_INTERNAL_BASE_BLUETOOTH_ADDRESS_H_ diff --git a/fastpair/internal/base/bluetooth_address_test.cc b/fastpair/internal/base/bluetooth_address_test.cc index 51d90e732f..4a5f2f84d4 100644 --- a/fastpair/internal/base/bluetooth_address_test.cc +++ b/fastpair/internal/base/bluetooth_address_test.cc @@ -20,7 +20,6 @@ #include "gtest/gtest.h" #include "absl/types/span.h" -namespace location { namespace nearby { namespace fastpair { namespace { @@ -58,4 +57,3 @@ TEST(BluetoothUtil, CanonicalizeBluetoothAddress) { } // namespace } // namespace fastpair } // namespace nearby -} // namespace location diff --git a/fastpair/internal/base/observer_list.h b/fastpair/internal/base/observer_list.h index 71b3028e3a..cb6e8556d3 100644 --- a/fastpair/internal/base/observer_list.h +++ b/fastpair/internal/base/observer_list.h @@ -20,7 +20,6 @@ #include "absl/container/flat_hash_set.h" -namespace location { namespace nearby { namespace fastpair { @@ -57,6 +56,5 @@ class ObserverList { } // namespace fastpair } // namespace nearby -} // namespace location #endif // THIRD_PARTY_NEARBY_FASTPAIR_INTERNAL_BASE_OBSERVER_LIST_H_ diff --git a/fastpair/internal/ble/ble.cc b/fastpair/internal/ble/ble.cc index 8186b3c3ae..f9b5e6f59b 100644 --- a/fastpair/internal/ble/ble.cc +++ b/fastpair/internal/ble/ble.cc @@ -22,7 +22,6 @@ #include "internal/platform/logging.h" #include "internal/platform/system_clock.h" -namespace location { namespace nearby { namespace fastpair { @@ -205,4 +204,3 @@ bool Ble::IsScanningLocked() { return is_scanning_; } } // namespace fastpair } // namespace nearby -} // namespace location diff --git a/fastpair/internal/ble/ble.h b/fastpair/internal/ble/ble.h index 46452ddbe7..e6839975ac 100644 --- a/fastpair/internal/ble/ble.h +++ b/fastpair/internal/ble/ble.h @@ -27,7 +27,6 @@ #include "internal/platform/multi_thread_executor.h" #include "internal/platform/mutex.h" -namespace location { namespace nearby { namespace fastpair { @@ -125,6 +124,5 @@ class Ble { } // namespace fastpair } // namespace nearby -} // namespace location #endif // THIRD_PARTY_NEARBY_FASTPAIR_INTERNAL_BLE_BLE_H_ diff --git a/fastpair/internal/ble/ble_test.cc b/fastpair/internal/ble/ble_test.cc index 34983a0be4..52ce1a0ed9 100644 --- a/fastpair/internal/ble/ble_test.cc +++ b/fastpair/internal/ble/ble_test.cc @@ -21,7 +21,6 @@ #include "internal/platform/count_down_latch.h" #include "internal/platform/medium_environment.h" -namespace location { namespace nearby { namespace fastpair { namespace { @@ -126,4 +125,3 @@ TEST_F(BleTest, CanStartDiscovery) { } // namespace } // namespace fastpair } // namespace nearby -} // namespace location diff --git a/fastpair/internal/impl/g3/device_info.h b/fastpair/internal/impl/g3/device_info.h index e606c4861b..837050811e 100644 --- a/fastpair/internal/impl/g3/device_info.h +++ b/fastpair/internal/impl/g3/device_info.h @@ -23,7 +23,6 @@ #include "absl/strings/string_view.h" #include "fastpair/internal/api/device_info.h" -namespace location { namespace nearby { namespace g3 { @@ -53,6 +52,5 @@ class DeviceInfo : public api::DeviceInfo { } // namespace g3 } // namespace nearby -} // namespace location #endif // THIRD_PARTY_NEARBY_FASTPAIR_INTERNAL_IMPL_G3_DEVICE_INFO_H_ diff --git a/fastpair/internal/impl/g3/device_info_test.cc b/fastpair/internal/impl/g3/device_info_test.cc index 1f5f8de7e6..c48b012fca 100644 --- a/fastpair/internal/impl/g3/device_info_test.cc +++ b/fastpair/internal/impl/g3/device_info_test.cc @@ -21,7 +21,6 @@ #include "absl/synchronization/notification.h" #include "fastpair/internal/api/device_info.h" -namespace location { namespace nearby { namespace g3 { namespace { @@ -73,4 +72,3 @@ TEST(DeviceInfo, UnregisterScreenLockedListener) { } // namespace } // namespace g3 } // namespace nearby -} // namespace location diff --git a/fastpair/internal/impl/g3/fast_pair_platform.cc b/fastpair/internal/impl/g3/fast_pair_platform.cc index e4b9546063..d50c966ec1 100644 --- a/fastpair/internal/impl/g3/fast_pair_platform.cc +++ b/fastpair/internal/impl/g3/fast_pair_platform.cc @@ -19,7 +19,6 @@ #include "fastpair/internal/impl/g3/device_info.h" #include "fastpair/internal/impl/g3/timer.h" -namespace location { namespace nearby { namespace api { @@ -34,4 +33,3 @@ std::unique_ptr ImplementationFastPairPlatform::CreateTimer() { } // namespace api } // namespace nearby -} // namespace location diff --git a/fastpair/internal/impl/g3/timer.h b/fastpair/internal/impl/g3/timer.h index 898d6b501c..1ca6d5f854 100644 --- a/fastpair/internal/impl/g3/timer.h +++ b/fastpair/internal/impl/g3/timer.h @@ -20,7 +20,6 @@ #include "fastpair/internal/api/timer.h" -namespace location { namespace nearby { namespace g3 { @@ -68,6 +67,5 @@ class Timer : public api::Timer { } // namespace g3 } // namespace nearby -} // namespace location #endif // THIRD_PARTY_NEARBY_FASTPAIR_INTERNAL_IMPL_G3_TIMER_H_ diff --git a/fastpair/internal/impl/windows/ble_gatt_client.cc b/fastpair/internal/impl/windows/ble_gatt_client.cc index 675da21ad5..b58bb7e532 100644 --- a/fastpair/internal/impl/windows/ble_gatt_client.cc +++ b/fastpair/internal/impl/windows/ble_gatt_client.cc @@ -37,7 +37,6 @@ #include "winrt/Windows.Storage.Streams.h" #include "winrt/base.h" -namespace location { namespace nearby { namespace windows { @@ -372,4 +371,3 @@ void BleGattClient::OnValueChanged(GattCharacteristic const& characteristic, } // namespace windows } // namespace nearby -} // namespace location diff --git a/fastpair/internal/impl/windows/ble_gatt_client.h b/fastpair/internal/impl/windows/ble_gatt_client.h index e002f52cf2..3015794f49 100644 --- a/fastpair/internal/impl/windows/ble_gatt_client.h +++ b/fastpair/internal/impl/windows/ble_gatt_client.h @@ -28,7 +28,6 @@ #include "winrt/Windows.Devices.Bluetooth.GenericAttributeProfile.h" #include "winrt/Windows.Devices.Bluetooth.h" -namespace location { namespace nearby { namespace windows { @@ -133,6 +132,5 @@ class BleGattClient { } // namespace windows } // namespace nearby -} // namespace location #endif // THIRD_PARTY_NEARBY_FASTPAIR_INTERNAL_IMPL_WINDOWS_BLE_GATT_CLIENT_H_ diff --git a/fastpair/internal/impl/windows/device_info.cc b/fastpair/internal/impl/windows/device_info.cc index 688018b3ba..2b65465d08 100644 --- a/fastpair/internal/impl/windows/device_info.cc +++ b/fastpair/internal/impl/windows/device_info.cc @@ -31,7 +31,6 @@ #include "winrt/Windows.Foundation.h" #include "winrt/Windows.System.h" -namespace location { namespace nearby { namespace windows { @@ -199,4 +198,3 @@ void DeviceInfo::UnregisterScreenLockedListener( } // namespace windows } // namespace nearby -} // namespace location diff --git a/fastpair/internal/impl/windows/device_info.h b/fastpair/internal/impl/windows/device_info.h index 7b11c8ff80..4e7f6b29fd 100644 --- a/fastpair/internal/impl/windows/device_info.h +++ b/fastpair/internal/impl/windows/device_info.h @@ -25,7 +25,6 @@ #include "absl/strings/string_view.h" #include "fastpair/internal/api/device_info.h" -namespace location { namespace nearby { namespace windows { @@ -51,5 +50,5 @@ class DeviceInfo : public api::DeviceInfo { } // namespace windows } // namespace nearby -} // namespace location + #endif // THIRD_PARTY_NEARBY_FASTPAIR_INTERNAL_IMPL_WINDOWS_DEVICE_INFO_H_ diff --git a/fastpair/internal/impl/windows/device_info_test.cc b/fastpair/internal/impl/windows/device_info_test.cc index 8609dd7d66..6fd4b296a6 100644 --- a/fastpair/internal/impl/windows/device_info_test.cc +++ b/fastpair/internal/impl/windows/device_info_test.cc @@ -21,7 +21,6 @@ #include "absl/synchronization/notification.h" #include "fastpair/internal/api/device_info.h" -namespace location { namespace nearby { namespace windows { namespace { @@ -92,4 +91,3 @@ TEST(DeviceInfo, DISABLED_UpdateScreenLockedListener) { } // namespace } // namespace windows } // namespace nearby -} // namespace location diff --git a/fastpair/internal/impl/windows/fast_pair_platform.cc b/fastpair/internal/impl/windows/fast_pair_platform.cc index 4e7ee14925..f7f217eb22 100644 --- a/fastpair/internal/impl/windows/fast_pair_platform.cc +++ b/fastpair/internal/impl/windows/fast_pair_platform.cc @@ -22,7 +22,6 @@ #include "fastpair/internal/impl/windows/device_info.h" #include "fastpair/internal/impl/windows/timer.h" -namespace location { namespace nearby { namespace api { @@ -37,4 +36,3 @@ std::unique_ptr ImplementationFastPairPlatform::CreateTimer() { } // namespace api } // namespace nearby -} // namespace location diff --git a/fastpair/internal/impl/windows/timer.cc b/fastpair/internal/impl/windows/timer.cc index 9533988d14..5260add2b1 100644 --- a/fastpair/internal/impl/windows/timer.cc +++ b/fastpair/internal/impl/windows/timer.cc @@ -20,7 +20,6 @@ #include "internal/platform/logging.h" -namespace location { namespace nearby { namespace windows { @@ -111,4 +110,3 @@ void CALLBACK Timer::TimerRoutine(PVOID lpParam, BOOLEAN TimerOrWaitFired) { } // namespace windows } // namespace nearby -} // namespace location diff --git a/fastpair/internal/impl/windows/timer.h b/fastpair/internal/impl/windows/timer.h index 26ab8b7717..76937ac812 100644 --- a/fastpair/internal/impl/windows/timer.h +++ b/fastpair/internal/impl/windows/timer.h @@ -21,7 +21,6 @@ #include "fastpair/internal/api/timer.h" -namespace location { namespace nearby { namespace windows { @@ -46,6 +45,5 @@ class Timer : public api::Timer { } // namespace windows } // namespace nearby -} // namespace location #endif // THIRD_PARTY_NEARBY_FASTPAIR_INTERNAL_IMPL_WINDOWS_TIMER_H_ diff --git a/fastpair/internal/impl/windows/timer_test.cc b/fastpair/internal/impl/windows/timer_test.cc index f81523c644..29278bbb31 100644 --- a/fastpair/internal/impl/windows/timer_test.cc +++ b/fastpair/internal/impl/windows/timer_test.cc @@ -20,7 +20,6 @@ #include "gtest/gtest.h" #include "fastpair/internal/api/fast_pair_platform.h" -namespace location { namespace nearby { namespace windows { namespace { @@ -66,4 +65,3 @@ TEST(Timer, DISABLED_TestFireNow) { } // namespace } // namespace windows } // namespace nearby -} // namespace location diff --git a/fastpair/internal/impl/windows/utils.cc b/fastpair/internal/impl/windows/utils.cc index e90881ae22..0a51d15f5e 100644 --- a/fastpair/internal/impl/windows/utils.cc +++ b/fastpair/internal/impl/windows/utils.cc @@ -26,7 +26,6 @@ #include "internal/platform/bluetooth_utils.h" #include "internal/platform/byte_array.h" -namespace location { namespace nearby { namespace windows { @@ -41,8 +40,8 @@ std::string uint64_to_mac_address_string(uint64_t bluetoothAddress) { } uint64_t mac_address_string_to_uint64(absl::string_view mac_address) { - location::nearby::ByteArray mac_address_array = - location::nearby::BluetoothUtils::FromString(mac_address); + nearby::ByteArray mac_address_array = + nearby::BluetoothUtils::FromString(mac_address); uint64_t mac_address_uint64 = 0; for (int i = 0; i < mac_address_array.size(); i++) { mac_address_uint64 <<= 8; @@ -54,4 +53,3 @@ uint64_t mac_address_string_to_uint64(absl::string_view mac_address) { } // namespace windows } // namespace nearby -} // namespace location diff --git a/fastpair/internal/impl/windows/utils.h b/fastpair/internal/impl/windows/utils.h index fc369a65e4..79bdfc6bfa 100644 --- a/fastpair/internal/impl/windows/utils.h +++ b/fastpair/internal/impl/windows/utils.h @@ -25,7 +25,6 @@ #include "winrt/Windows.Foundation.h" #include "winrt/base.h" -namespace location { namespace nearby { namespace windows { @@ -34,6 +33,5 @@ uint64_t mac_address_string_to_uint64(absl::string_view mac_address); } // namespace windows } // namespace nearby -} // namespace location #endif // THIRD_PARTY_NEARBY_FASTPAIR_INTERNAL_IMPL_WINDOWS_UTILS_H_ diff --git a/fastpair/internal/public/device_info.h b/fastpair/internal/public/device_info.h index 0696e8b19c..ecd9780f2d 100644 --- a/fastpair/internal/public/device_info.h +++ b/fastpair/internal/public/device_info.h @@ -22,7 +22,6 @@ #include "fastpair/internal/api/device_info.h" #include "fastpair/internal/api/fast_pair_platform.h" -namespace location { namespace nearby { namespace fastpair { @@ -42,6 +41,5 @@ class DeviceInfo { } // namespace fastpair } // namespace nearby -} // namespace location #endif // THIRD_PARTY_NEARBY_FASTPAIR_INTERNAL_PUBLIC_DEVICE_INFO_H_ diff --git a/fastpair/internal/public/device_info_impl.cc b/fastpair/internal/public/device_info_impl.cc index e8dffa4fce..aaae6127e0 100644 --- a/fastpair/internal/public/device_info_impl.cc +++ b/fastpair/internal/public/device_info_impl.cc @@ -17,7 +17,6 @@ #include #include -namespace location { namespace nearby { namespace fastpair { @@ -42,4 +41,3 @@ void DeviceInfoImpl::UnregisterScreenLockedListener( } // namespace fastpair } // namespace nearby -} // namespace location diff --git a/fastpair/internal/public/device_info_impl.h b/fastpair/internal/public/device_info_impl.h index 192d29e061..d75a9056d8 100644 --- a/fastpair/internal/public/device_info_impl.h +++ b/fastpair/internal/public/device_info_impl.h @@ -22,7 +22,6 @@ #include "fastpair/internal/api/fast_pair_platform.h" #include "fastpair/internal/public/device_info.h" -namespace location { namespace nearby { namespace fastpair { @@ -46,6 +45,5 @@ class DeviceInfoImpl : public DeviceInfo { } // namespace fastpair } // namespace nearby -} // namespace location #endif // THIRD_PARTY_NEARBY_FASTPAIR_INTERNAL_PUBLIC_DEVICE_INFO_IMPL_H_ diff --git a/fastpair/internal/public/task_runner.h b/fastpair/internal/public/task_runner.h index 502c7c6c7a..bb363f0c00 100644 --- a/fastpair/internal/public/task_runner.h +++ b/fastpair/internal/public/task_runner.h @@ -19,7 +19,6 @@ #include "absl/time/time.h" -namespace location { namespace nearby { namespace fastpair { @@ -43,6 +42,5 @@ class TaskRunner { } // namespace fastpair } // namespace nearby -} // namespace location #endif // THIRD_PARTY_NEARBY_FASTPAIR_INTERNAL_PUBLIC_TASK_RUNNER_H_ diff --git a/fastpair/internal/public/task_runner_impl.cc b/fastpair/internal/public/task_runner_impl.cc index 836eb70bfc..effd8e6ae3 100644 --- a/fastpair/internal/public/task_runner_impl.cc +++ b/fastpair/internal/public/task_runner_impl.cc @@ -23,13 +23,11 @@ #include "absl/random/random.h" #include "fastpair/internal/public/timer_impl.h" -namespace location { namespace nearby { namespace fastpair { TaskRunnerImpl::TaskRunnerImpl(uint32_t runner_count) { - executor_ = - std::make_unique<::location::nearby::MultiThreadExecutor>(runner_count); + executor_ = std::make_unique<::nearby::MultiThreadExecutor>(runner_count); } TaskRunnerImpl::~TaskRunnerImpl() = default; @@ -79,4 +77,3 @@ uint64_t TaskRunnerImpl::GenerateId() { } // namespace fastpair } // namespace nearby -} // namespace location diff --git a/fastpair/internal/public/task_runner_impl.h b/fastpair/internal/public/task_runner_impl.h index 091cd0e547..a4bb1e8ef5 100644 --- a/fastpair/internal/public/task_runner_impl.h +++ b/fastpair/internal/public/task_runner_impl.h @@ -26,7 +26,6 @@ #include "fastpair/internal/public/timer.h" #include "internal/platform/multi_thread_executor.h" -namespace location { namespace nearby { namespace fastpair { @@ -44,13 +43,12 @@ class TaskRunnerImpl : public TaskRunner { uint64_t GenerateId(); mutable absl::Mutex mutex_; - std::unique_ptr<::location::nearby::MultiThreadExecutor> executor_; + std::unique_ptr<::nearby::MultiThreadExecutor> executor_; absl::flat_hash_map> timers_map_ ABSL_GUARDED_BY(mutex_); }; } // namespace fastpair } // namespace nearby -} // namespace location #endif // THIRD_PARTY_NEARBY_FASTPAIR_INTERNAL_PUBLIC_TASK_RUNNER_IMPL_H_ diff --git a/fastpair/internal/public/task_runner_impl_test.cc b/fastpair/internal/public/task_runner_impl_test.cc index ba01b3e566..10733d2990 100644 --- a/fastpair/internal/public/task_runner_impl_test.cc +++ b/fastpair/internal/public/task_runner_impl_test.cc @@ -22,7 +22,6 @@ #include "absl/synchronization/notification.h" #include "absl/time/clock.h" -namespace location { namespace nearby { namespace fastpair { namespace { @@ -163,4 +162,3 @@ TEST(TaskRunnerImpl, PostEmptyTask) { } // namespace } // namespace fastpair } // namespace nearby -} // namespace location diff --git a/fastpair/internal/public/timer.h b/fastpair/internal/public/timer.h index 6467b55a41..3f9c29d023 100644 --- a/fastpair/internal/public/timer.h +++ b/fastpair/internal/public/timer.h @@ -17,7 +17,6 @@ #include -namespace location { namespace nearby { namespace fastpair { @@ -46,6 +45,5 @@ class Timer { } // namespace fastpair } // namespace nearby -} // namespace location #endif // THIRD_PARTY_NEARBY_FASTPAIR_INTERNAL_PUBLIC_TIMER_H_ diff --git a/fastpair/internal/public/timer_impl.cc b/fastpair/internal/public/timer_impl.cc index f7aa18646a..7482ac00b3 100644 --- a/fastpair/internal/public/timer_impl.cc +++ b/fastpair/internal/public/timer_impl.cc @@ -20,7 +20,6 @@ #include "absl/time/clock.h" #include "internal/platform/logging.h" -namespace location { namespace nearby { namespace fastpair { @@ -65,4 +64,3 @@ bool TimerImpl::FireNow() { } // namespace fastpair } // namespace nearby -} // namespace location diff --git a/fastpair/internal/public/timer_impl.h b/fastpair/internal/public/timer_impl.h index b2b7f58079..74c9b3ade8 100644 --- a/fastpair/internal/public/timer_impl.h +++ b/fastpair/internal/public/timer_impl.h @@ -21,7 +21,6 @@ #include "fastpair/internal/api/fast_pair_platform.h" #include "fastpair/internal/public/timer.h" -namespace location { namespace nearby { namespace fastpair { @@ -43,6 +42,5 @@ class TimerImpl : public Timer { } // namespace fastpair } // namespace nearby -} // namespace location #endif // THIRD_PARTY_NEARBY_FASTPAIR_INTERNAL_PUBLIC_TIMER_IMPL_H_ diff --git a/fastpair/internal/public/timer_impl_test.cc b/fastpair/internal/public/timer_impl_test.cc index c8e6ac2725..984a6ecc87 100644 --- a/fastpair/internal/public/timer_impl_test.cc +++ b/fastpair/internal/public/timer_impl_test.cc @@ -16,7 +16,6 @@ #include "gtest/gtest.h" -namespace location { namespace nearby { namespace fastpair { namespace { @@ -59,4 +58,3 @@ TEST(TimerImpl, TestFireNow) { } // namespace } // namespace fastpair } // namespace nearby -} // namespace location diff --git a/fastpair/internal/test/fast_pair_fake_http_client.h b/fastpair/internal/test/fast_pair_fake_http_client.h index 69107ac6b5..84824a3ae8 100644 --- a/fastpair/internal/test/fast_pair_fake_http_client.h +++ b/fastpair/internal/test/fast_pair_fake_http_client.h @@ -23,7 +23,6 @@ #include "internal/network/http_client.h" -namespace location { namespace nearby { namespace network { @@ -146,6 +145,5 @@ class FastPairFakeHttpClient : public HttpClient { } // namespace network } // namespace nearby -} // namespace location #endif // THIRD_PARTY_NEARBY_FASTPAIR_INTERNAL_TEST_FAST_PAIR_FAKE_HTTP_CLIENT_H_ diff --git a/fastpair/internal/test/fast_pair_fake_http_client_test.cc b/fastpair/internal/test/fast_pair_fake_http_client_test.cc index 2e8e4a3ce6..3f1ba9ac24 100644 --- a/fastpair/internal/test/fast_pair_fake_http_client_test.cc +++ b/fastpair/internal/test/fast_pair_fake_http_client_test.cc @@ -29,7 +29,6 @@ #include "absl/status/statusor.h" #include "absl/strings/string_view.h" -namespace location { namespace nearby { namespace network { namespace { @@ -147,4 +146,3 @@ TEST_F(FastPairFakeHttpClientTest, TestCompleteNotExistingRequest) { } // namespace } // namespace network } // namespace nearby -} // namespace location diff --git a/fastpair/repository/fast_pair_metadata_fetcher.h b/fastpair/repository/fast_pair_metadata_fetcher.h index 8f47fa20b1..d6ed33e144 100644 --- a/fastpair/repository/fast_pair_metadata_fetcher.h +++ b/fastpair/repository/fast_pair_metadata_fetcher.h @@ -26,7 +26,6 @@ #include "internal/network/http_client.h" #include "internal/network/url.h" -namespace location { namespace nearby { namespace fastpair { @@ -58,6 +57,5 @@ class FastPairMetadataFetcher { } // namespace fastpair } // namespace nearby -} // namespace location #endif // THIRD_PARTY_NEARBY_FASTPAIR_REPOSITORY_FAST_PAIR_METADATA_FETCHER_H_ diff --git a/fastpair/repository/fast_pair_metadata_fetcher_impl.cc b/fastpair/repository/fast_pair_metadata_fetcher_impl.cc index 8dc89851f7..c20b7dbab6 100644 --- a/fastpair/repository/fast_pair_metadata_fetcher_impl.cc +++ b/fastpair/repository/fast_pair_metadata_fetcher_impl.cc @@ -22,7 +22,6 @@ #include "fastpair/internal/api/device_info.h" #include "internal/platform/logging.h" -namespace location { namespace nearby { namespace fastpair { @@ -112,4 +111,3 @@ void FastPairMetadataFetcherImpl::Execute() { } // namespace fastpair } // namespace nearby -} // namespace location diff --git a/fastpair/repository/fast_pair_metadata_fetcher_impl.h b/fastpair/repository/fast_pair_metadata_fetcher_impl.h index 78331cbb1c..825a39721c 100644 --- a/fastpair/repository/fast_pair_metadata_fetcher_impl.h +++ b/fastpair/repository/fast_pair_metadata_fetcher_impl.h @@ -27,7 +27,6 @@ #include "internal/network/http_client.h" #include "internal/network/url.h" -namespace location { namespace nearby { namespace fastpair { @@ -81,6 +80,5 @@ class FastPairMetadataFetcherImpl : public FastPairMetadataFetcher { } // namespace fastpair } // namespace nearby -} // namespace location #endif // THIRD_PARTY_NEARBY_FASTPAIR_REPOSITORY_FAST_PAIR_METADATA_FETCHER_IMPL_H_ diff --git a/fastpair/repository/fast_pair_metadata_fetcher_impl_test.cc b/fastpair/repository/fast_pair_metadata_fetcher_impl_test.cc index 6ff04b606e..ba76880cf3 100644 --- a/fastpair/repository/fast_pair_metadata_fetcher_impl_test.cc +++ b/fastpair/repository/fast_pair_metadata_fetcher_impl_test.cc @@ -28,14 +28,13 @@ #include "fastpair/internal/test/fast_pair_fake_http_client.h" #include "internal/network/http_client.h" -namespace location { namespace nearby { namespace fastpair { namespace { -using ::location::nearby::network::FastPairFakeHttpClient; -using ::location::nearby::network::Url; -using OsType = ::location::nearby::api::DeviceInfo::OsType; +using ::nearby::network::FastPairFakeHttpClient; +using ::nearby::network::Url; +using OsType = ::nearby::api::DeviceInfo::OsType; constexpr char kResponseProto[] = "result_proto"; constexpr char kRequestUrl[] = "https://googleapis.com/nearbysharing/test"; @@ -193,4 +192,3 @@ TEST_F(FastPairMetadataFetcherImplTest, GetUnauthRequestStatus500) { } // namespace } // namespace fastpair } // namespace nearby -} // namespace location diff --git a/fastpair/scanning/fastpair/fast_pair_scanner_impl.cc b/fastpair/scanning/fastpair/fast_pair_scanner_impl.cc index cdf42683a7..84e00266d7 100644 --- a/fastpair/scanning/fastpair/fast_pair_scanner_impl.cc +++ b/fastpair/scanning/fastpair/fast_pair_scanner_impl.cc @@ -22,7 +22,6 @@ #include "internal/platform/byte_array.h" #include "internal/platform/logging.h" -namespace location { namespace nearby { namespace fastpair { @@ -67,4 +66,3 @@ void FastPairScannerImpl::OnDeviceLost(BlePeripheral& peripheral, } // namespace fastpair } // namespace nearby -} // namespace location diff --git a/fastpair/scanning/fastpair/fast_pair_scanner_impl.h b/fastpair/scanning/fastpair/fast_pair_scanner_impl.h index d37fbb4437..95783e98ca 100644 --- a/fastpair/scanning/fastpair/fast_pair_scanner_impl.h +++ b/fastpair/scanning/fastpair/fast_pair_scanner_impl.h @@ -20,7 +20,6 @@ #include "fastpair/internal/ble/ble.h" #include "internal/platform/bluetooth_adapter.h" -namespace location { namespace nearby { namespace fastpair { @@ -47,6 +46,5 @@ class FastPairScannerImpl { } // namespace fastpair } // namespace nearby -} // namespace location #endif // THIRD_PARTY_NEARBY_FASTPAIR_SCANNING_FASTPAIR_FAST_PAIR_SCANNER_IMPL_H_ diff --git a/internal/device.h b/internal/device.h index ef5f5c75bc..c8958f0694 100644 --- a/internal/device.h +++ b/internal/device.h @@ -24,7 +24,6 @@ #include "internal/platform/bluetooth_connection_info.h" #include "internal/platform/wifi_lan_connection_info.h" -namespace location { namespace nearby { using ConnectionInfoVariant = @@ -53,6 +52,5 @@ class NearbyDevice { }; } // namespace nearby -} // namespace location #endif // THIRD_PARTY_NEARBY_CONNECTIONS_IMPLEMENTATION_DEVICE_H_ diff --git a/internal/network/debug.h b/internal/network/debug.h index 9236cb07a0..c6d4f85ec3 100644 --- a/internal/network/debug.h +++ b/internal/network/debug.h @@ -15,7 +15,6 @@ #ifndef THIRD_PARTY_NEARBY_INTERNAL_NETWORK_DEBUG_H_ #define THIRD_PARTY_NEARBY_INTERNAL_NETWORK_DEBUG_H_ -namespace location { namespace nearby { namespace network { namespace debug { @@ -29,6 +28,5 @@ constexpr bool kResponseEnabled = false; } // namespace debug } // namespace network } // namespace nearby -} // namespace location #endif // THIRD_PARTY_NEARBY_INTERNAL_NETWORK_DEBUG_H_ diff --git a/internal/network/http_body.h b/internal/network/http_body.h index 57d890811b..8d2d28b081 100644 --- a/internal/network/http_body.h +++ b/internal/network/http_body.h @@ -20,7 +20,6 @@ #include "absl/strings/string_view.h" -namespace location { namespace nearby { namespace network { @@ -62,6 +61,5 @@ using HttpResponseBody = HttpBody; } // namespace network } // namespace nearby -} // namespace location #endif // THIRD_PARTY_NEARBY_INTERNAL_NETWORK_HTTP_BODY_H_ diff --git a/internal/network/http_client.h b/internal/network/http_client.h index b28361c5b5..38a697d214 100644 --- a/internal/network/http_client.h +++ b/internal/network/http_client.h @@ -21,7 +21,6 @@ #include "internal/network/http_request.h" #include "internal/network/http_response.h" -namespace location { namespace nearby { namespace network { @@ -36,6 +35,5 @@ class HttpClient { } // namespace network } // namespace nearby -} // namespace location #endif // THIRD_PARTY_NEARBY_INTERNAL_NETWORK_HTTP_CLIENT_H_ diff --git a/internal/network/http_client_factory.h b/internal/network/http_client_factory.h index d9c560cd40..43c0a387eb 100644 --- a/internal/network/http_client_factory.h +++ b/internal/network/http_client_factory.h @@ -20,7 +20,6 @@ #include "internal/network/http_client.h" -namespace location { namespace nearby { namespace network { @@ -33,6 +32,5 @@ class HttpClientFactory { } // namespace network } // namespace nearby -} // namespace location #endif // THIRD_PARTY_NEARBY_INTERNAL_NETWORK_HTTP_CLIENT_FACTORY_H_ diff --git a/internal/network/http_client_factory_impl.h b/internal/network/http_client_factory_impl.h index c1bd6e8e27..ff730805e6 100644 --- a/internal/network/http_client_factory_impl.h +++ b/internal/network/http_client_factory_impl.h @@ -20,7 +20,6 @@ #include "internal/network/http_client_factory.h" #include "internal/network/http_client_impl.h" -namespace location { namespace nearby { namespace network { @@ -33,6 +32,5 @@ class HttpClientFactoryImpl : public HttpClientFactory { } // namespace network } // namespace nearby -} // namespace location #endif // THIRD_PARTY_NEARBY_INTERNAL_NETWORK_HTTP_CLIENT_FACTORY_IMPL_H_ diff --git a/internal/network/http_client_impl.cc b/internal/network/http_client_impl.cc index d0cde7d92b..3f7b4a779a 100644 --- a/internal/network/http_client_impl.cc +++ b/internal/network/http_client_impl.cc @@ -25,7 +25,6 @@ #include "internal/platform/implementation/platform.h" #include "internal/platform/logging.h" -namespace location { namespace nearby { namespace network { @@ -120,4 +119,3 @@ void NearbyHttpClient::CleanThreads() { } // namespace network } // namespace nearby -} // namespace location diff --git a/internal/network/http_client_impl.h b/internal/network/http_client_impl.h index 5d0d108985..d0e0646c9a 100644 --- a/internal/network/http_client_impl.h +++ b/internal/network/http_client_impl.h @@ -25,7 +25,6 @@ #include "absl/synchronization/mutex.h" #include "internal/network/http_client.h" -namespace location { namespace nearby { namespace network { @@ -52,6 +51,5 @@ class NearbyHttpClient : public HttpClient { } // namespace network } // namespace nearby -} // namespace location #endif // THIRD_PARTY_NEARBY_INTERNAL_NETWORK_HTTP_CLIENT_IMPL_H_ diff --git a/internal/network/http_client_impl_test.cc b/internal/network/http_client_impl_test.cc index 88fd3c8574..2f24e8ad89 100644 --- a/internal/network/http_client_impl_test.cc +++ b/internal/network/http_client_impl_test.cc @@ -30,7 +30,6 @@ #include "internal/platform/implementation/http_loader.h" #include "internal/platform/implementation/platform.h" -namespace location { namespace nearby { namespace api { namespace { @@ -272,4 +271,3 @@ TEST_F(NearbyHttpClientTest, TestRequestWithCleanThreads) { } // namespace } // namespace network } // namespace nearby -} // namespace location diff --git a/internal/network/http_request.cc b/internal/network/http_request.cc index d58f96964c..418562d8e9 100644 --- a/internal/network/http_request.cc +++ b/internal/network/http_request.cc @@ -20,7 +20,6 @@ #include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" -namespace location { namespace nearby { namespace network { @@ -101,4 +100,3 @@ const HttpRequestBody& HttpRequest::GetBody() const { return body_; } } // namespace network } // namespace nearby -} // namespace location diff --git a/internal/network/http_request.h b/internal/network/http_request.h index 2f90ff6eb4..693412a7e3 100644 --- a/internal/network/http_request.h +++ b/internal/network/http_request.h @@ -24,7 +24,6 @@ #include "internal/network/http_body.h" #include "internal/network/url.h" -namespace location { namespace nearby { namespace network { @@ -87,6 +86,5 @@ class HttpRequest { } // namespace network } // namespace nearby -} // namespace location #endif // THIRD_PARTY_NEARBY_INTERNAL_NETWORK_HTTP_REQUEST_H_ diff --git a/internal/network/http_request_test.cc b/internal/network/http_request_test.cc index 9149363c8d..e31aabdc3b 100644 --- a/internal/network/http_request_test.cc +++ b/internal/network/http_request_test.cc @@ -19,7 +19,6 @@ #include "gtest/gtest.h" #include "internal/network/http_body.h" -namespace location { namespace nearby { namespace network { namespace { @@ -85,4 +84,3 @@ TEST(HttpRequest, TestGetMethodString) { } // namespace } // namespace network } // namespace nearby -} // namespace location diff --git a/internal/network/http_response.cc b/internal/network/http_response.cc index c00c7e3671..c2f6cdc9f4 100644 --- a/internal/network/http_response.cc +++ b/internal/network/http_response.cc @@ -19,7 +19,6 @@ #include "absl/strings/str_cat.h" -namespace location { namespace nearby { namespace network { @@ -71,4 +70,3 @@ const HttpResponseBody& HttpResponse::GetBody() const { return body_; } } // namespace network } // namespace nearby -} // namespace location diff --git a/internal/network/http_response.h b/internal/network/http_response.h index 2791cdac18..f7b43ed257 100644 --- a/internal/network/http_response.h +++ b/internal/network/http_response.h @@ -25,7 +25,6 @@ #include "internal/network/http_request.h" #include "internal/network/http_status_code.h" -namespace location { namespace nearby { namespace network { @@ -72,6 +71,5 @@ class HttpResponse { } // namespace network } // namespace nearby -} // namespace location #endif // THIRD_PARTY_NEARBY_INTERNAL_NETWORK_HTTP_RESPONSE_H_ diff --git a/internal/network/http_response_test.cc b/internal/network/http_response_test.cc index 53114a008c..5ece8f91e5 100644 --- a/internal/network/http_response_test.cc +++ b/internal/network/http_response_test.cc @@ -18,7 +18,6 @@ #include "protobuf-matchers/protocol-buffer-matchers.h" #include "gtest/gtest.h" -namespace location { namespace nearby { namespace network { namespace { @@ -44,4 +43,3 @@ TEST(HttpResponse, TestBuildResponse) { } // namespace } // namespace network } // namespace nearby -} // namespace location diff --git a/internal/network/http_status_code.cc b/internal/network/http_status_code.cc index 25c010cd4d..eae94fa71f 100644 --- a/internal/network/http_status_code.cc +++ b/internal/network/http_status_code.cc @@ -14,7 +14,6 @@ #include "internal/network/http_status_code.h" -namespace location { namespace nearby { namespace network { @@ -115,4 +114,3 @@ absl::string_view GetHttpReasonPhrase(HttpStatusCode code) { } // namespace network } // namespace nearby -} // namespace location diff --git a/internal/network/http_status_code.h b/internal/network/http_status_code.h index 4f8f8c8d95..4a1f1976b4 100644 --- a/internal/network/http_status_code.h +++ b/internal/network/http_status_code.h @@ -17,7 +17,6 @@ #include "absl/strings/string_view.h" -namespace location { namespace nearby { namespace network { @@ -88,6 +87,5 @@ absl::string_view GetHttpReasonPhrase(HttpStatusCode code); } // namespace network } // namespace nearby -} // namespace location #endif // THIRD_PARTY_NEARBY_INTERNAL_NETWORK_HTTP_STATUS_CODE_H_ diff --git a/internal/network/http_status_code_test.cc b/internal/network/http_status_code_test.cc index 9e67455304..3179281c51 100644 --- a/internal/network/http_status_code_test.cc +++ b/internal/network/http_status_code_test.cc @@ -16,7 +16,6 @@ #include "gtest/gtest.h" -namespace location { namespace nearby { namespace network { namespace { @@ -106,4 +105,3 @@ TEST(HttpStatusCode, TestReturnCorrectReasonPhrase) { } // namespace } // namespace network } // namespace nearby -} // namespace location diff --git a/internal/network/url.cc b/internal/network/url.cc index dfc394572a..0bcff8e172 100644 --- a/internal/network/url.cc +++ b/internal/network/url.cc @@ -24,7 +24,6 @@ #include "absl/strings/string_view.h" #include "internal/network/utils.h" -namespace location { namespace nearby { namespace network { @@ -256,4 +255,3 @@ bool operator==(const Url& url1, const Url& url2) { } // namespace network } // namespace nearby -} // namespace location diff --git a/internal/network/url.h b/internal/network/url.h index 9ba06f5e02..9bdfb565c7 100644 --- a/internal/network/url.h +++ b/internal/network/url.h @@ -24,7 +24,6 @@ #include "absl/status/statusor.h" #include "absl/strings/string_view.h" -namespace location { namespace nearby { namespace network { @@ -79,6 +78,5 @@ bool operator==(const Url& url1, const Url& url2); } // namespace network } // namespace nearby -} // namespace location #endif // THIRD_PARTY_NEARBY_INTERNAL_NETWORK_URL_H_ diff --git a/internal/network/url_test.cc b/internal/network/url_test.cc index a564212ed8..f8125f637b 100644 --- a/internal/network/url_test.cc +++ b/internal/network/url_test.cc @@ -19,7 +19,6 @@ #include "protobuf-matchers/protocol-buffer-matchers.h" #include "gtest/gtest.h" -namespace location { namespace nearby { namespace network { namespace { @@ -156,4 +155,3 @@ TEST(Url, TestCompareUrl) { } // namespace } // namespace network } // namespace nearby -} // namespace location diff --git a/internal/network/utils.cc b/internal/network/utils.cc index 93c58f3b5d..dd7a7501e2 100644 --- a/internal/network/utils.cc +++ b/internal/network/utils.cc @@ -20,7 +20,6 @@ #include #include -namespace location { namespace nearby { namespace network { @@ -89,4 +88,3 @@ std::string UrlDecode(absl::string_view url_string) { } // namespace network } // namespace nearby -} // namespace location diff --git a/internal/network/utils.h b/internal/network/utils.h index d8a9b24cc5..bc0e0d7640 100644 --- a/internal/network/utils.h +++ b/internal/network/utils.h @@ -20,7 +20,6 @@ #include "absl/strings/string_view.h" #include "internal/network/url.h" -namespace location { namespace nearby { namespace network { @@ -40,6 +39,5 @@ std::string UrlDecode(absl::string_view url_string); } // namespace network } // namespace nearby -} // namespace location #endif // THIRD_PARTY_NEARBY_INTERNAL_NETWORK_UTILS_H_ diff --git a/internal/network/utils_test.cc b/internal/network/utils_test.cc index 7715b45ba9..4dce7f93a4 100644 --- a/internal/network/utils_test.cc +++ b/internal/network/utils_test.cc @@ -18,7 +18,6 @@ #include "gtest/gtest.h" -namespace location { namespace nearby { namespace network { namespace { @@ -45,4 +44,3 @@ TEST(UrlDecode, TestDecodeMatch) { } // namespace } // namespace network } // namespace nearby -} // namespace location diff --git a/internal/platform/atomic_boolean.h b/internal/platform/atomic_boolean.h index 7bd991a75c..41be6b949c 100644 --- a/internal/platform/atomic_boolean.h +++ b/internal/platform/atomic_boolean.h @@ -20,7 +20,6 @@ #include "internal/platform/implementation/atomic_boolean.h" #include "internal/platform/implementation/platform.h" -namespace location { namespace nearby { // A boolean value that may be updated atomically. @@ -45,6 +44,5 @@ class AtomicBoolean final : public api::AtomicBoolean { }; } // namespace nearby -} // namespace location #endif // PLATFORM_PUBLIC_ATOMIC_BOOLEAN_H_ diff --git a/internal/platform/atomic_boolean_test.cc b/internal/platform/atomic_boolean_test.cc index 8c4ef8beef..b83449d77c 100644 --- a/internal/platform/atomic_boolean_test.cc +++ b/internal/platform/atomic_boolean_test.cc @@ -18,7 +18,6 @@ #include "protobuf-matchers/protocol-buffer-matchers.h" #include "gtest/gtest.h" -namespace location { namespace nearby { namespace { @@ -47,4 +46,3 @@ TEST(AtomicBooleanTest, ImplicitGetFalseValue) { } } // namespace } // namespace nearby -} // namespace location diff --git a/internal/platform/atomic_reference.h b/internal/platform/atomic_reference.h index c2b014bce9..830861190b 100644 --- a/internal/platform/atomic_reference.h +++ b/internal/platform/atomic_reference.h @@ -23,7 +23,6 @@ #include "internal/platform/mutex.h" #include "internal/platform/mutex_lock.h" -namespace location { namespace nearby { // An object reference that may be updated atomically. @@ -82,6 +81,5 @@ class AtomicReference BaseInputStream::Read(std::int64_t size) { @@ -96,4 +95,3 @@ ByteArray BaseInputStream::ReadBytes(int size) { } } // namespace nearby -} // namespace location diff --git a/internal/platform/base_input_stream.h b/internal/platform/base_input_stream.h index 7324e0a22a..a7116de3d4 100644 --- a/internal/platform/base_input_stream.h +++ b/internal/platform/base_input_stream.h @@ -19,7 +19,6 @@ #include "internal/platform/exception.h" #include "internal/platform/input_stream.h" -namespace location { namespace nearby { // A base {@link InputStream } for reading the contents of a byte array. @@ -58,6 +57,5 @@ class BaseInputStream : public InputStream { }; } // namespace nearby -} // namespace location #endif // PLATFORM_BASE_BASE_INPUT_STREAM_H_ diff --git a/internal/platform/base_mutex_lock.h b/internal/platform/base_mutex_lock.h index 5f59391ec0..90f27a29cd 100644 --- a/internal/platform/base_mutex_lock.h +++ b/internal/platform/base_mutex_lock.h @@ -18,7 +18,6 @@ #include "absl/base/thread_annotations.h" #include "internal/platform/implementation/mutex.h" -namespace location { namespace nearby { // An RAII mechanism to acquire a Lock over a block of code. @@ -35,6 +34,5 @@ class ABSL_SCOPED_LOCKABLE BaseMutexLock final { }; } // namespace nearby -} // namespace location #endif // PLATFORM_BASE_BASE_MUTEX_LOCK_H_ diff --git a/internal/platform/base_pipe.cc b/internal/platform/base_pipe.cc index b97357ad5e..7d1ee35d28 100644 --- a/internal/platform/base_pipe.cc +++ b/internal/platform/base_pipe.cc @@ -18,7 +18,6 @@ #include "internal/platform/input_stream.h" #include "internal/platform/output_stream.h" -namespace location { namespace nearby { ExceptionOr BasePipe::Read(size_t size) { @@ -106,4 +105,3 @@ Exception BasePipe::WriteLocked(const ByteArray& data) { } } // namespace nearby -} // namespace location diff --git a/internal/platform/base_pipe.h b/internal/platform/base_pipe.h index f36266baed..3b8987de08 100644 --- a/internal/platform/base_pipe.h +++ b/internal/platform/base_pipe.h @@ -27,7 +27,6 @@ #include "internal/platform/input_stream.h" #include "internal/platform/output_stream.h" -namespace location { namespace nearby { // Common Pipe implementation. @@ -133,6 +132,5 @@ class BasePipe { }; } // namespace nearby -} // namespace location #endif // PLATFORM_BASE_BASE_PIPE_H_ diff --git a/internal/platform/ble.cc b/internal/platform/ble.cc index 54945e04e0..a47f1852fc 100644 --- a/internal/platform/ble.cc +++ b/internal/platform/ble.cc @@ -17,7 +17,6 @@ #include "internal/platform/logging.h" #include "internal/platform/mutex_lock.h" -namespace location { namespace nearby { bool BleMedium::StartAdvertising( @@ -135,4 +134,3 @@ BleSocket BleMedium::Connect(BlePeripheral& peripheral, } } // namespace nearby -} // namespace location diff --git a/internal/platform/ble.h b/internal/platform/ble.h index e3ba127b5d..0147c6a13d 100644 --- a/internal/platform/ble.h +++ b/internal/platform/ble.h @@ -25,7 +25,6 @@ #include "internal/platform/bluetooth_adapter.h" #include "internal/platform/mutex.h" -namespace location { namespace nearby { class BleSocket final { @@ -161,6 +160,5 @@ class BleMedium final { }; } // namespace nearby -} // namespace location #endif // PLATFORM_PUBLIC_BLE_H_ diff --git a/internal/platform/ble_connection_info.cc b/internal/platform/ble_connection_info.cc index c3c37b5a72..eee8872157 100644 --- a/internal/platform/ble_connection_info.cc +++ b/internal/platform/ble_connection_info.cc @@ -17,7 +17,6 @@ #include #include -namespace location { namespace nearby { ByteArray BleConnectionInfo::ToBytes() const { return ByteArray(mac_address_); } @@ -27,4 +26,3 @@ BleConnectionInfo BleConnectionInfo::FromBytes(ByteArray bytes) { return BleConnectionInfo(serial.substr(0, kMacAddressLength)); } } // namespace nearby -} // namespace location diff --git a/internal/platform/ble_connection_info.h b/internal/platform/ble_connection_info.h index 9cf00621be..46c303d7c0 100644 --- a/internal/platform/ble_connection_info.h +++ b/internal/platform/ble_connection_info.h @@ -22,7 +22,6 @@ #include "internal/platform/connection_info.h" #include "internal/platform/logging.h" -namespace location { namespace nearby { // 6 bytes that spell "BADMAC" @@ -61,6 +60,5 @@ inline bool operator!=(const BleConnectionInfo& a, const BleConnectionInfo& b) { } } // namespace nearby -} // namespace location #endif // THIRD_PARTY_NEARBY_INTERNAL_PLATFORM_BLE_CONNECTION_INFO_H_ diff --git a/internal/platform/ble_connection_info_test.cc b/internal/platform/ble_connection_info_test.cc index d10da1337d..2a572bc606 100644 --- a/internal/platform/ble_connection_info_test.cc +++ b/internal/platform/ble_connection_info_test.cc @@ -23,7 +23,6 @@ #include "absl/strings/string_view.h" #include "internal/platform/byte_array.h" -namespace location { namespace nearby { namespace { @@ -83,4 +82,3 @@ TEST(BleConnectionInfoTest, TestEquals) { } // namespace } // namespace nearby -} // namespace location diff --git a/internal/platform/ble_test.cc b/internal/platform/ble_test.cc index 57b3300fc6..d526e3dfbc 100644 --- a/internal/platform/ble_test.cc +++ b/internal/platform/ble_test.cc @@ -23,7 +23,6 @@ #include "internal/platform/logging.h" #include "internal/platform/medium_environment.h" -namespace location { namespace nearby { namespace { @@ -301,4 +300,3 @@ TEST_F(BleMediumTest, CanStopDiscovery) { } // namespace } // namespace nearby -} // namespace location diff --git a/internal/platform/ble_v2.cc b/internal/platform/ble_v2.cc index f5e76fbbca..0d71bda420 100644 --- a/internal/platform/ble_v2.cc +++ b/internal/platform/ble_v2.cc @@ -23,12 +23,11 @@ #include "internal/platform/logging.h" #include "internal/platform/mutex_lock.h" -namespace location { namespace nearby { -using ::location::nearby::api::ble_v2::BleAdvertisementData; -using ::location::nearby::api::ble_v2::GattCharacteristic; -using ::location::nearby::api::ble_v2::TxPowerLevel; +using ::nearby::api::ble_v2::BleAdvertisementData; +using ::nearby::api::ble_v2::GattCharacteristic; +using ::nearby::api::ble_v2::TxPowerLevel; bool BleV2Medium::StartAdvertising( const BleAdvertisementData& advertising_data, @@ -189,4 +188,3 @@ bool BleV2Medium::IsExtendedAdvertisementsAvailable() { } } // namespace nearby -} // namespace location diff --git a/internal/platform/ble_v2.h b/internal/platform/ble_v2.h index 410e7ce916..2497180635 100644 --- a/internal/platform/ble_v2.h +++ b/internal/platform/ble_v2.h @@ -29,7 +29,6 @@ #include "internal/platform/mutex.h" #include "internal/platform/uuid.h" -namespace location { namespace nearby { // Container of operations that can be performed over the BLE GATT client @@ -241,22 +240,22 @@ class BleV2Medium final { std::function - advertisement_found_cb = location::nearby::DefaultCallback< - BleV2Peripheral, const api::ble_v2::BleAdvertisementData&>(); + advertisement_found_cb = + nearby::DefaultCallback(); }; struct ServerGattConnectionCallback { std::function - characteristic_subscription_cb = location::nearby::DefaultCallback< - const api::ble_v2::GattCharacteristic&>(); + characteristic_subscription_cb = + nearby::DefaultCallback(); std::function - characteristic_unsubscription_cb = location::nearby::DefaultCallback< - const api::ble_v2::GattCharacteristic&>(); + characteristic_unsubscription_cb = + nearby::DefaultCallback(); }; // TODO(b/231318879): Remove this wrapper callback and use impl callback if // there is only disconnect function here in the end. struct ClientGattConnectionCallback { - std::function disconnected_cb = - location::nearby::DefaultCallback<>(); + std::function disconnected_cb = nearby::DefaultCallback<>(); }; explicit BleV2Medium(BluetoothAdapter& adapter) @@ -328,6 +327,5 @@ class BleV2Medium final { }; } // namespace nearby -} // namespace location #endif // PLATFORM_PUBLIC_BLE_V2_H_ diff --git a/internal/platform/ble_v2_test.cc b/internal/platform/ble_v2_test.cc index 1a9ac81154..e8a772b938 100644 --- a/internal/platform/ble_v2_test.cc +++ b/internal/platform/ble_v2_test.cc @@ -27,7 +27,6 @@ #include "internal/platform/implementation/ble_v2.h" #include "internal/platform/medium_environment.h" -namespace location { namespace nearby { namespace { @@ -42,9 +41,9 @@ constexpr FeatureFlags kTestCases[] = { }, }; -using ::location::nearby::api::ble_v2::BleAdvertisementData; -using ::location::nearby::api::ble_v2::GattCharacteristic; -using ::location::nearby::api::ble_v2::TxPowerLevel; +using ::nearby::api::ble_v2::BleAdvertisementData; +using ::nearby::api::ble_v2::GattCharacteristic; +using ::nearby::api::ble_v2::TxPowerLevel; using ::testing::Optional; constexpr absl::Duration kWaitDuration = absl::Milliseconds(1000); @@ -547,4 +546,3 @@ TEST_F(BleV2MediumTest, GattClientConnectToGattServerWorks) { } // namespace } // namespace nearby -} // namespace location diff --git a/internal/platform/bluetooth_adapter.h b/internal/platform/bluetooth_adapter.h index 6c2adcfd6c..75edcc5a39 100644 --- a/internal/platform/bluetooth_adapter.h +++ b/internal/platform/bluetooth_adapter.h @@ -23,7 +23,6 @@ #include "internal/platform/implementation/bluetooth_classic.h" #include "internal/platform/implementation/platform.h" -namespace location { namespace nearby { // Opaque wrapper over a BLE peripheral. Must contain enough data about a @@ -189,6 +188,5 @@ class BluetoothAdapter final { }; } // namespace nearby -} // namespace location #endif // PLATFORM_PUBLIC_BLUETOOTH_ADAPTER_H_ diff --git a/internal/platform/bluetooth_adapter_test.cc b/internal/platform/bluetooth_adapter_test.cc index 3bbfe5d459..35377c4d96 100644 --- a/internal/platform/bluetooth_adapter_test.cc +++ b/internal/platform/bluetooth_adapter_test.cc @@ -23,7 +23,6 @@ #include "internal/platform/bluetooth_utils.h" #include "internal/platform/logging.h" -namespace location { namespace nearby { namespace { @@ -165,4 +164,3 @@ TEST(BluetoothAdapterTest, CanGetMacAddress) { } // namespace } // namespace nearby -} // namespace location diff --git a/internal/platform/bluetooth_classic.cc b/internal/platform/bluetooth_classic.cc index 9eb6bafb2a..c30fdf06ee 100644 --- a/internal/platform/bluetooth_classic.cc +++ b/internal/platform/bluetooth_classic.cc @@ -17,7 +17,6 @@ #include "internal/platform/logging.h" #include "internal/platform/mutex_lock.h" -namespace location { namespace nearby { BluetoothClassicMedium::~BluetoothClassicMedium() { StopDiscovery(); } @@ -96,4 +95,3 @@ bool BluetoothClassicMedium::StopDiscovery() { } } // namespace nearby -} // namespace location diff --git a/internal/platform/bluetooth_classic.h b/internal/platform/bluetooth_classic.h index a2dde684a7..e0ba230c57 100644 --- a/internal/platform/bluetooth_classic.h +++ b/internal/platform/bluetooth_classic.h @@ -31,7 +31,6 @@ #include "internal/platform/logging.h" #include "internal/platform/mutex.h" -namespace location { namespace nearby { // https://developer.android.com/reference/android/bluetooth/BluetoothSocket.html. @@ -230,6 +229,5 @@ class BluetoothClassicMedium final { }; } // namespace nearby -} // namespace location #endif // PLATFORM_PUBLIC_BLUETOOTH_CLASSIC_H_ diff --git a/internal/platform/bluetooth_classic_test.cc b/internal/platform/bluetooth_classic_test.cc index 7012069ae6..a68fe9add2 100644 --- a/internal/platform/bluetooth_classic_test.cc +++ b/internal/platform/bluetooth_classic_test.cc @@ -26,7 +26,6 @@ #include "internal/platform/medium_environment.h" #include "internal/platform/single_thread_executor.h" -namespace location { namespace nearby { namespace { @@ -289,4 +288,3 @@ TEST_F(BluetoothClassicMediumTest, FailIfDiscovering) { } // namespace } // namespace nearby -} // namespace location diff --git a/internal/platform/bluetooth_connection_info.cc b/internal/platform/bluetooth_connection_info.cc index f8cdb2a125..db0f24a04a 100644 --- a/internal/platform/bluetooth_connection_info.cc +++ b/internal/platform/bluetooth_connection_info.cc @@ -17,7 +17,6 @@ #include #include -namespace location { namespace nearby { ByteArray BluetoothConnectionInfo::ToBytes() const { @@ -31,4 +30,3 @@ BluetoothConnectionInfo BluetoothConnectionInfo::FromBytes(ByteArray bytes) { return BluetoothConnectionInfo(mac_address, service_id); } } // namespace nearby -} // namespace location diff --git a/internal/platform/bluetooth_connection_info.h b/internal/platform/bluetooth_connection_info.h index 51b42887c6..78f924a7e1 100644 --- a/internal/platform/bluetooth_connection_info.h +++ b/internal/platform/bluetooth_connection_info.h @@ -21,7 +21,6 @@ #include "internal/platform/byte_array.h" #include "internal/platform/connection_info.h" -namespace location { namespace nearby { class BluetoothConnectionInfo : public ConnectionInfo { @@ -60,6 +59,5 @@ inline bool operator!=(const BluetoothConnectionInfo& a, } } // namespace nearby -} // namespace location #endif // THIRD_PARTY_NEARBY_INTERNAL_PLATFORM_BLUETOOTH_CONNECTION_INFO_H_ diff --git a/internal/platform/bluetooth_connection_info_test.cc b/internal/platform/bluetooth_connection_info_test.cc index 822ec25df1..03518445ea 100644 --- a/internal/platform/bluetooth_connection_info_test.cc +++ b/internal/platform/bluetooth_connection_info_test.cc @@ -22,7 +22,6 @@ #include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" -namespace location { namespace nearby { namespace { @@ -96,4 +95,3 @@ TEST(BluetoothConnectionInfoTest, TestEquals) { } // namespace } // namespace nearby -} // namespace location diff --git a/internal/platform/bluetooth_utils.cc b/internal/platform/bluetooth_utils.cc index 91f007bd68..181324db31 100644 --- a/internal/platform/bluetooth_utils.cc +++ b/internal/platform/bluetooth_utils.cc @@ -17,7 +17,6 @@ #include "absl/strings/escaping.h" #include "absl/strings/str_format.h" -namespace location { namespace nearby { std::string BluetoothUtils::ToString(const ByteArray& bluetooth_mac_address) { @@ -72,4 +71,3 @@ bool BluetoothUtils::IsBluetoothMacAddressUnset( } } // namespace nearby -} // namespace location diff --git a/internal/platform/bluetooth_utils.h b/internal/platform/bluetooth_utils.h index 46f23022c9..b76ab556c3 100644 --- a/internal/platform/bluetooth_utils.h +++ b/internal/platform/bluetooth_utils.h @@ -18,7 +18,6 @@ #include "absl/strings/string_view.h" #include "internal/platform/byte_array.h" -namespace location { namespace nearby { class BluetoothUtils { @@ -41,6 +40,5 @@ class BluetoothUtils { }; } // namespace nearby -} // namespace location #endif // PLATFORM_BASE_BLUETOOTH_UTILS_H_ diff --git a/internal/platform/bluetooth_utils_test.cc b/internal/platform/bluetooth_utils_test.cc index 369d121dfe..645627b82e 100644 --- a/internal/platform/bluetooth_utils_test.cc +++ b/internal/platform/bluetooth_utils_test.cc @@ -16,7 +16,6 @@ #include "gtest/gtest.h" -namespace location { namespace nearby { constexpr absl::string_view kBluetoothMacAddress{"00:00:E6:88:64:13"}; @@ -86,4 +85,3 @@ TEST(BluetoothUtilsTest, InvalidStringReturnsEmptyByteArray) { } } // namespace nearby -} // namespace location diff --git a/internal/platform/borrowable.h b/internal/platform/borrowable.h index 8601429330..5b024ec8bf 100644 --- a/internal/platform/borrowable.h +++ b/internal/platform/borrowable.h @@ -48,7 +48,6 @@ #include "internal/platform/mutex.h" #include "internal/platform/mutex_lock.h" -namespace location { namespace nearby { template @@ -164,6 +163,5 @@ class Lender { }; } // namespace nearby -} // namespace location #endif // THIRD_PARTY_NEARBY_INTERNAL_PLATFORM_BORROWABLE_H_ diff --git a/internal/platform/borrowable_test.cc b/internal/platform/borrowable_test.cc index 45cd84261c..b7e913becf 100644 --- a/internal/platform/borrowable_test.cc +++ b/internal/platform/borrowable_test.cc @@ -23,7 +23,6 @@ #include "internal/platform/multi_thread_executor.h" #include "internal/platform/single_thread_executor.h" -namespace location { namespace nearby { namespace { @@ -128,4 +127,3 @@ TEST(Borrowable, BorrowIsExclusive) { } // namespace } // namespace nearby -} // namespace location diff --git a/internal/platform/byte_array.h b/internal/platform/byte_array.h index fdafb6901c..45b82d9726 100644 --- a/internal/platform/byte_array.h +++ b/internal/platform/byte_array.h @@ -25,7 +25,6 @@ #include "absl/strings/str_cat.h" -namespace location { namespace nearby { class ByteArray { @@ -122,6 +121,5 @@ inline bool operator<(const ByteArray& lhs, const ByteArray& rhs) { } } // namespace nearby -} // namespace location #endif // PLATFORM_BASE_BYTE_ARRAY_H_ diff --git a/internal/platform/byte_array_test.cc b/internal/platform/byte_array_test.cc index b7c29bcee4..832b1af167 100644 --- a/internal/platform/byte_array_test.cc +++ b/internal/platform/byte_array_test.cc @@ -21,7 +21,7 @@ namespace { -using ::location::nearby::ByteArray; +using ::nearby::ByteArray; TEST(ByteArrayTest, DefaultSizeIsZero) { ByteArray bytes; diff --git a/internal/platform/byte_utils.cc b/internal/platform/byte_utils.cc index f964279481..dd2a54d75a 100644 --- a/internal/platform/byte_utils.cc +++ b/internal/platform/byte_utils.cc @@ -19,7 +19,6 @@ #include "absl/strings/str_format.h" #include "internal/platform/base_input_stream.h" -namespace location { namespace nearby { std::string ByteUtils::ToFourDigitString(ByteArray& bytes) { @@ -36,4 +35,3 @@ std::string ByteUtils::ToFourDigitString(ByteArray& bytes) { } } // namespace nearby -} // namespace location diff --git a/internal/platform/byte_utils.h b/internal/platform/byte_utils.h index ba81a8fbf1..9d4690a5c9 100644 --- a/internal/platform/byte_utils.h +++ b/internal/platform/byte_utils.h @@ -17,7 +17,6 @@ #include "internal/platform/byte_array.h" -namespace location { namespace nearby { class ByteUtils { @@ -33,6 +32,5 @@ class ByteUtils { }; } // namespace nearby -} // namespace location #endif // PLATFORM_BASE_BYTE_UTILS_H_ diff --git a/internal/platform/byte_utils_test.cc b/internal/platform/byte_utils_test.cc index f81cc7fccb..f6ec691637 100644 --- a/internal/platform/byte_utils_test.cc +++ b/internal/platform/byte_utils_test.cc @@ -17,7 +17,6 @@ #include "gtest/gtest.h" #include "internal/platform/byte_array.h" -namespace location { namespace nearby { constexpr absl::string_view kFooBytes{"rawABCDE"}; @@ -41,4 +40,3 @@ TEST(ByteUtilsTest, TestEmptyByteArrayCorrect) { } } // namespace nearby -} // namespace location diff --git a/internal/platform/callable.h b/internal/platform/callable.h index d68d31b0a4..9e6d1fb926 100644 --- a/internal/platform/callable.h +++ b/internal/platform/callable.h @@ -19,7 +19,6 @@ #include "internal/platform/exception.h" -namespace location { namespace nearby { // The Callable is and object intended to be executed by a thread, that is able @@ -32,6 +31,5 @@ template using Callable = std::function()>; } // namespace nearby -} // namespace location #endif // PLATFORM_BASE_CALLABLE_H_ diff --git a/internal/platform/cancelable.h b/internal/platform/cancelable.h index a261d80f23..abcff32e28 100644 --- a/internal/platform/cancelable.h +++ b/internal/platform/cancelable.h @@ -21,7 +21,6 @@ #include "internal/platform/implementation/cancelable.h" #include "internal/platform/cancellable_task.h" -namespace location { namespace nearby { // An interface to provide a cancellation mechanism for objects that represent @@ -55,6 +54,5 @@ class Cancelable final { }; } // namespace nearby -} // namespace location #endif // PLATFORM_PUBLIC_CANCELABLE_H_ diff --git a/internal/platform/cancelable_alarm.h b/internal/platform/cancelable_alarm.h index 860edac0ae..b8ddccf0c6 100644 --- a/internal/platform/cancelable_alarm.h +++ b/internal/platform/cancelable_alarm.h @@ -26,7 +26,6 @@ #include "internal/platform/mutex_lock.h" #include "internal/platform/scheduled_executor.h" -namespace location { namespace nearby { /** @@ -80,6 +79,5 @@ class CancelableAlarm { }; } // namespace nearby -} // namespace location #endif // PLATFORM_PUBLIC_CANCELABLE_ALARM_H_ diff --git a/internal/platform/cancelable_alarm_test.cc b/internal/platform/cancelable_alarm_test.cc index 8dfd29707c..be9d67ef0d 100644 --- a/internal/platform/cancelable_alarm_test.cc +++ b/internal/platform/cancelable_alarm_test.cc @@ -22,7 +22,6 @@ #include "internal/platform/atomic_reference.h" #include "internal/platform/scheduled_executor.h" -namespace location { namespace nearby { namespace { @@ -79,4 +78,3 @@ TEST(CancelableAlarmTest, CanCreateRecurringAlarm) { } // namespace } // namespace nearby -} // namespace location diff --git a/internal/platform/cancellable_task.h b/internal/platform/cancellable_task.h index fbcdf9530a..903e1c2295 100644 --- a/internal/platform/cancellable_task.h +++ b/internal/platform/cancellable_task.h @@ -22,7 +22,6 @@ #include "internal/platform/atomic_boolean.h" #include "internal/platform/future.h" -namespace location { namespace nearby { /** @@ -65,6 +64,5 @@ class CancellableTask { }; } // namespace nearby -} // namespace location #endif // PLATFORM_PUBLIC_CANCELLABLE_TASK_H_ diff --git a/internal/platform/cancellation_flag.cc b/internal/platform/cancellation_flag.cc index 5e176efdb4..c6b3bf5d6d 100644 --- a/internal/platform/cancellation_flag.cc +++ b/internal/platform/cancellation_flag.cc @@ -16,7 +16,6 @@ #include "internal/platform/feature_flags.h" -namespace location { namespace nearby { CancellationFlag::CancellationFlag() { @@ -77,4 +76,3 @@ void CancellationFlag::UnregisterOnCancelListener(CancelListener *listener) { } } // namespace nearby -} // namespace location diff --git a/internal/platform/cancellation_flag.h b/internal/platform/cancellation_flag.h index 903572b571..b158cf7e26 100644 --- a/internal/platform/cancellation_flag.h +++ b/internal/platform/cancellation_flag.h @@ -21,7 +21,6 @@ #include "absl/functional/any_invocable.h" #include "absl/synchronization/mutex.h" -namespace location { namespace nearby { // A cancellation flag to mark an operation has been cancelled and should be @@ -76,6 +75,5 @@ class CancellationFlag { }; } // namespace nearby -} // namespace location #endif // PLATFORM_BASE_CANCELLATION_FLAG_H_ diff --git a/internal/platform/cancellation_flag_listener.h b/internal/platform/cancellation_flag_listener.h index 172d909e43..7715aa9992 100644 --- a/internal/platform/cancellation_flag_listener.h +++ b/internal/platform/cancellation_flag_listener.h @@ -17,7 +17,6 @@ #include "internal/platform/cancellation_flag.h" -namespace location { namespace nearby { // An RAII mechanism to register CancelListener over a life cycle of medium @@ -38,6 +37,5 @@ class CancellationFlagListener { }; } // namespace nearby -} // namespace location #endif // PLATFORM_BASE_CANCELLATION_FLAG_LISTENER_H_ diff --git a/internal/platform/cancellation_flag_test.cc b/internal/platform/cancellation_flag_test.cc index 807e5ef320..5e9e3967e8 100644 --- a/internal/platform/cancellation_flag_test.cc +++ b/internal/platform/cancellation_flag_test.cc @@ -25,7 +25,6 @@ #include "internal/platform/feature_flags.h" #include "internal/platform/medium_environment.h" -namespace location { namespace nearby { class CancellationFlagPeer { @@ -157,10 +156,9 @@ INSTANTIATE_TEST_SUITE_P(ParametrisedCancellationFlagTest, CancellationFlagTest, TEST(CancellationFlagTest, CancelMultiplesIfMultiplePointersToTheSameFunctionRegistered) { - location::nearby::FeatureFlags::Flags feature_flags_ = - location::nearby::FeatureFlags::Flags{ - .enable_cancellation_flag = true, - }; + nearby::FeatureFlags::Flags feature_flags_ = nearby::FeatureFlags::Flags{ + .enable_cancellation_flag = true, + }; MediumEnvironment::Instance().SetFeatureFlags(feature_flags_); StrictMock> mock_cancel_callback; @@ -190,10 +188,9 @@ TEST(CancellationFlagTest, } TEST(CancellationFlagTest, RegisteredMultuipleTimesOnlyCancelOnce) { - location::nearby::FeatureFlags::Flags feature_flags_ = - location::nearby::FeatureFlags::Flags{ - .enable_cancellation_flag = true, - }; + nearby::FeatureFlags::Flags feature_flags_ = nearby::FeatureFlags::Flags{ + .enable_cancellation_flag = true, + }; MediumEnvironment::Instance().SetFeatureFlags(feature_flags_); StrictMock> mock_cancel_callback; @@ -215,4 +212,3 @@ TEST(CancellationFlagTest, RegisteredMultuipleTimesOnlyCancelOnce) { } } // namespace nearby -} // namespace location diff --git a/internal/platform/condition_variable.h b/internal/platform/condition_variable.h index 26898be4b6..ef6d344f0f 100644 --- a/internal/platform/condition_variable.h +++ b/internal/platform/condition_variable.h @@ -20,7 +20,6 @@ #include "internal/platform/exception.h" #include "internal/platform/mutex.h" -namespace location { namespace nearby { // The ConditionVariable class is a synchronization primitive that can be used @@ -44,6 +43,5 @@ class ConditionVariable final { }; } // namespace nearby -} // namespace location #endif // PLATFORM_PUBLIC_CONDITION_VARIABLE_H_ diff --git a/internal/platform/condition_variable_test.cc b/internal/platform/condition_variable_test.cc index f11ee2f13c..9a743a4c2b 100644 --- a/internal/platform/condition_variable_test.cc +++ b/internal/platform/condition_variable_test.cc @@ -23,7 +23,6 @@ #include "internal/platform/single_thread_executor.h" #include "internal/platform/system_clock.h" -namespace location { namespace nearby { namespace { @@ -80,4 +79,3 @@ TEST(ConditionVariableTest, WaitTerminatesOnTimeoutWithoutNotify) { } // namespace } // namespace nearby -} // namespace location diff --git a/internal/platform/connection_info.h b/internal/platform/connection_info.h index fb542d2bd6..fb3a1733f5 100644 --- a/internal/platform/connection_info.h +++ b/internal/platform/connection_info.h @@ -17,7 +17,6 @@ #include "internal/platform/byte_array.h" -namespace location { namespace nearby { constexpr int kMacAddressLength = 6; @@ -35,6 +34,5 @@ class ConnectionInfo { virtual ByteArray ToBytes() const = 0; }; } // namespace nearby -} // namespace location #endif // THIRD_PARTY_NEARBY_INTERNAL_PLATFORM_CONNECTION_INFO_H_ diff --git a/internal/platform/count_down_latch.h b/internal/platform/count_down_latch.h index 5d10c54e08..8d79bffa9f 100644 --- a/internal/platform/count_down_latch.h +++ b/internal/platform/count_down_latch.h @@ -22,7 +22,6 @@ #include "internal/platform/implementation/platform.h" #include "internal/platform/exception.h" -namespace location { namespace nearby { // A synchronization aid that allows one or more threads to wait until a set of @@ -49,6 +48,5 @@ class CountDownLatch final { }; } // namespace nearby -} // namespace location #endif // PLATFORM_PUBLIC_COUNT_DOWN_LATCH_H_ diff --git a/internal/platform/count_down_latch_test.cc b/internal/platform/count_down_latch_test.cc index 260317a7f9..9e79800fcd 100644 --- a/internal/platform/count_down_latch_test.cc +++ b/internal/platform/count_down_latch_test.cc @@ -17,7 +17,6 @@ #include "gtest/gtest.h" #include "internal/platform/single_thread_executor.h" -namespace location { namespace nearby { namespace { @@ -67,4 +66,3 @@ TEST(CountDownLatch, InitialCountZero_AwaitDoesNotBlock) { } // namespace } // namespace nearby -} // namespace location diff --git a/internal/platform/credential_storage_impl.cc b/internal/platform/credential_storage_impl.cc index c7ba4334cc..4be1e4fdd1 100644 --- a/internal/platform/credential_storage_impl.cc +++ b/internal/platform/credential_storage_impl.cc @@ -18,7 +18,6 @@ #include "internal/platform/implementation/credential_callbacks.h" -namespace location { namespace nearby { using ::nearby::internal::PrivateCredential; @@ -55,4 +54,3 @@ void CredentialStorageImpl::GetPublicCredentials( } } // namespace nearby -} // namespace location diff --git a/internal/platform/credential_storage_impl.h b/internal/platform/credential_storage_impl.h index e2a1e73cde..d0b7bc5039 100644 --- a/internal/platform/credential_storage_impl.h +++ b/internal/platform/credential_storage_impl.h @@ -24,7 +24,6 @@ #include "internal/platform/implementation/credential_storage.h" #include "internal/platform/implementation/platform.h" -namespace location { namespace nearby { /* @@ -64,6 +63,5 @@ class CredentialStorageImpl : public api::CredentialStorage { }; } // namespace nearby -} // namespace location #endif // THIRD_PARTY_NEARBY_INTERNAL_PLATFORM_CREDENTIAL_STORAGE_IMPL_H_ diff --git a/internal/platform/credential_storage_impl_test.cc b/internal/platform/credential_storage_impl_test.cc index 084cc15698..bfcb84e4ad 100644 --- a/internal/platform/credential_storage_impl_test.cc +++ b/internal/platform/credential_storage_impl_test.cc @@ -29,7 +29,6 @@ #include "internal/platform/implementation/credential_callbacks.h" #include "internal/proto/credential.pb.h" -namespace location { namespace nearby { namespace { @@ -497,4 +496,3 @@ INSTANTIATE_TEST_SUITE_P( } // namespace } // namespace nearby -} // namespace location diff --git a/internal/platform/crypto_test.cc b/internal/platform/crypto_test.cc index bfa3a39c75..4967900f25 100644 --- a/internal/platform/crypto_test.cc +++ b/internal/platform/crypto_test.cc @@ -19,7 +19,6 @@ #include "gtest/gtest.h" #include "internal/platform/byte_array.h" -namespace location { namespace nearby { TEST(CryptoTest, Md5GeneratesHash) { @@ -46,4 +45,3 @@ TEST(CryptoTest, Sha256ReturnsEmptyOnError) { } } // namespace nearby -} // namespace location diff --git a/internal/platform/direct_executor.h b/internal/platform/direct_executor.h index a04064235b..53eba48b7a 100644 --- a/internal/platform/direct_executor.h +++ b/internal/platform/direct_executor.h @@ -18,7 +18,6 @@ #include "internal/platform/implementation/executor.h" #include "internal/platform/submittable_executor.h" -namespace location { namespace nearby { // An Executor that executes the tasks immediately on the thread calling @@ -47,6 +46,5 @@ class ABSL_LOCKABLE DirectExecutor final : public api::Executor { }; } // namespace nearby -} // namespace location #endif // THIRD_PARTY_NEARBY_INTERNAL_PLATFORM_DIRECT_EXECUTOR_H_ diff --git a/internal/platform/direct_executor_test.cc b/internal/platform/direct_executor_test.cc index fa397307d4..8c25ead729 100644 --- a/internal/platform/direct_executor_test.cc +++ b/internal/platform/direct_executor_test.cc @@ -17,7 +17,6 @@ #include "gtest/gtest.h" -namespace location { namespace nearby { TEST(DirectExecutorTest, ExecutesRunnable) { @@ -29,4 +28,3 @@ TEST(DirectExecutorTest, ExecutesRunnable) { } } // namespace nearby -} // namespace location diff --git a/internal/platform/error_code_params.h b/internal/platform/error_code_params.h index ad380b6399..8b394a88b6 100644 --- a/internal/platform/error_code_params.h +++ b/internal/platform/error_code_params.h @@ -18,7 +18,6 @@ #include "proto/connections_enums.pb.h" #include "proto/errorcode/error_code_enums.pb.h" -namespace location { namespace nearby { // A struct to construct error code parameters for the analytics recorder. @@ -59,6 +58,5 @@ struct ErrorCodeParams { }; } // namespace nearby -} // namespace location #endif // PLATFORM_BASE_ERROR_CORE_PARAMS_H_ diff --git a/internal/platform/error_code_recorder.cc b/internal/platform/error_code_recorder.cc index 82e1d83f11..373313a3bc 100644 --- a/internal/platform/error_code_recorder.cc +++ b/internal/platform/error_code_recorder.cc @@ -17,10 +17,10 @@ #include "internal/platform/logging.h" #include "proto/errorcode/error_code_enums.pb.h" -namespace location { namespace nearby { using ::location::nearby::errorcode::proto::CommonError; +using ::location::nearby::errorcode::proto::CommonError_IsValid; using ::location::nearby::errorcode::proto::CONNECT; using ::location::nearby::errorcode::proto::ConnectError; using ::location::nearby::errorcode::proto::Description; @@ -41,6 +41,7 @@ using ::location::nearby::errorcode::proto::StopAdvertisingError; using ::location::nearby::errorcode::proto::StopDiscoveringError; using ::location::nearby::errorcode::proto:: StopListeningIncomingConnectionError; +using ::location::nearby::errorcode::proto::UNKNOWN_ERROR; using ::location::nearby::proto::connections::Medium; // Default static no-op listener @@ -66,7 +67,7 @@ ErrorCodeParams ErrorCodeRecorder::BuildErrorCodeParams( .pii_message = pii_message, .connection_token = connection_token}; - if (errorcode::proto::CommonError_IsValid(error)) { + if (CommonError_IsValid(error)) { params.common_error = static_cast(error); params.is_common_error = true; } else { @@ -104,7 +105,7 @@ ErrorCodeParams ErrorCodeRecorder::BuildErrorCodeParams( break; // Set the error as unknown if undefined event passed in. default: - params.common_error = errorcode::proto::UNKNOWN_ERROR; + params.common_error = UNKNOWN_ERROR; params.is_common_error = true; break; } @@ -113,4 +114,3 @@ ErrorCodeParams ErrorCodeRecorder::BuildErrorCodeParams( } } // namespace nearby -} // namespace location diff --git a/internal/platform/error_code_recorder.h b/internal/platform/error_code_recorder.h index d603a5422d..53d71bd53a 100644 --- a/internal/platform/error_code_recorder.h +++ b/internal/platform/error_code_recorder.h @@ -19,7 +19,6 @@ #include "internal/platform/error_code_params.h" -namespace location { namespace nearby { // Deploys the error code of the platform medium to the analytics recorder. @@ -81,6 +80,5 @@ class ErrorCodeRecorder { }; } // namespace nearby -} // namespace location #endif // PLATFORM_BASE_ERROR_CODE_RECORDER_H_ diff --git a/internal/platform/error_code_recorder_test.cc b/internal/platform/error_code_recorder_test.cc index a45b8db788..6697ccb2c5 100644 --- a/internal/platform/error_code_recorder_test.cc +++ b/internal/platform/error_code_recorder_test.cc @@ -18,7 +18,6 @@ #include "protobuf-matchers/protocol-buffer-matchers.h" #include "gtest/gtest.h" -namespace location { namespace nearby { using ::testing::Field; @@ -32,10 +31,12 @@ TEST(ErrorCodeRecorderTest, TestListenerWork) { ErrorCodeRecorder error_code_recorder(listener); ErrorCodeRecorder::LogErrorCode( - proto::connections::BLE, errorcode::proto::START_ADVERTISING, - errorcode::proto::MULTIPLE_FAST_ADVERTISEMENT_NOT_ALLOWED, - errorcode::proto::FEATURE_BLUETOOTH_NOT_SUPPORTED, "pii_message", - "connection_token"); + location::nearby::proto::connections::BLE, + location::nearby::errorcode::proto::START_ADVERTISING, + location::nearby::errorcode::proto:: + MULTIPLE_FAST_ADVERTISEMENT_NOT_ALLOWED, + location::nearby::errorcode::proto::FEATURE_BLUETOOTH_NOT_SUPPORTED, + "pii_message", "connection_token"); } TEST(ErrorCodeRecorderTest, TestBuildErrorCodeParamsWork) { @@ -49,23 +50,28 @@ TEST(ErrorCodeRecorderTest, TestBuildErrorCodeParamsWork) { }); ErrorCodeRecorder::LogErrorCode( - proto::connections::BLE, errorcode::proto::START_ADVERTISING, - errorcode::proto::MULTIPLE_FAST_ADVERTISEMENT_NOT_ALLOWED, - errorcode::proto::FEATURE_BLUETOOTH_NOT_SUPPORTED, pii_message, - connection_token); + location::nearby::proto::connections::BLE, + location::nearby::errorcode::proto::START_ADVERTISING, + location::nearby::errorcode::proto:: + MULTIPLE_FAST_ADVERTISEMENT_NOT_ALLOWED, + location::nearby::errorcode::proto::FEATURE_BLUETOOTH_NOT_SUPPORTED, + pii_message, connection_token); EXPECT_THAT( error_code_params, - AllOf(Field("medium", &ErrorCodeParams::medium, proto::connections::BLE), + AllOf(Field("medium", &ErrorCodeParams::medium, + location::nearby::proto::connections::BLE), Field("event", &ErrorCodeParams::event, - errorcode::proto::START_ADVERTISING), + location::nearby::errorcode::proto::START_ADVERTISING), Field("description", &ErrorCodeParams::description, - errorcode::proto::FEATURE_BLUETOOTH_NOT_SUPPORTED), + location::nearby::errorcode::proto:: + FEATURE_BLUETOOTH_NOT_SUPPORTED), Field("pii_message", &ErrorCodeParams::pii_message, pii_message), Field("is_common_error", &ErrorCodeParams::is_common_error, false), Field("start_advertising_error", &ErrorCodeParams::start_advertising_error, - errorcode::proto::MULTIPLE_FAST_ADVERTISEMENT_NOT_ALLOWED), + location::nearby::errorcode::proto:: + MULTIPLE_FAST_ADVERTISEMENT_NOT_ALLOWED), Field("connection_token", &ErrorCodeParams::connection_token, connection_token))); } @@ -81,21 +87,24 @@ TEST(ErrorCodeRecorderTest, TestBuildErrorCodeParamsWorkForCommonError) { }); ErrorCodeRecorder::LogErrorCode( - proto::connections::BLE, errorcode::proto::START_ADVERTISING, - errorcode::proto::INVALID_PARAMETER, errorcode::proto::NULL_SERVICE_ID, - pii_message, connection_token); + location::nearby::proto::connections::BLE, + location::nearby::errorcode::proto::START_ADVERTISING, + location::nearby::errorcode::proto::INVALID_PARAMETER, + location::nearby::errorcode::proto::NULL_SERVICE_ID, pii_message, + connection_token); EXPECT_THAT( error_code_params, - AllOf(Field("medium", &ErrorCodeParams::medium, proto::connections::BLE), + AllOf(Field("medium", &ErrorCodeParams::medium, + location::nearby::proto::connections::BLE), Field("event", &ErrorCodeParams::event, - errorcode::proto::START_ADVERTISING), + location::nearby::errorcode::proto::START_ADVERTISING), Field("description", &ErrorCodeParams::description, - errorcode::proto::NULL_SERVICE_ID), + location::nearby::errorcode::proto::NULL_SERVICE_ID), Field("pii_message", &ErrorCodeParams::pii_message, pii_message), Field("is_common_error", &ErrorCodeParams::is_common_error, true), Field("common_error", &ErrorCodeParams::common_error, - errorcode::proto::INVALID_PARAMETER), + location::nearby::errorcode::proto::INVALID_PARAMETER), Field("connection_token", &ErrorCodeParams::connection_token, connection_token))); } @@ -113,25 +122,28 @@ TEST(ErrorCodeRecorderTest, TestBuildErrorCodeParamsWorkForUnknownEvent) { // If event is UNKNOWN_EVENT and the error is not Common_Error then the error // will be set to UNKNOWN_ERROR. ErrorCodeRecorder::LogErrorCode( - proto::connections::BLE, errorcode::proto::UNKNOWN_EVENT, - errorcode::proto::MULTIPLE_FAST_ADVERTISEMENT_NOT_ALLOWED, - errorcode::proto::FEATURE_BLUETOOTH_NOT_SUPPORTED, pii_message, - connection_token); + location::nearby::proto::connections::BLE, + location::nearby::errorcode::proto::UNKNOWN_EVENT, + location::nearby::errorcode::proto:: + MULTIPLE_FAST_ADVERTISEMENT_NOT_ALLOWED, + location::nearby::errorcode::proto::FEATURE_BLUETOOTH_NOT_SUPPORTED, + pii_message, connection_token); EXPECT_THAT( error_code_params, - AllOf(Field("medium", &ErrorCodeParams::medium, proto::connections::BLE), + AllOf(Field("medium", &ErrorCodeParams::medium, + location::nearby::proto::connections::BLE), Field("event", &ErrorCodeParams::event, - errorcode::proto::UNKNOWN_EVENT), + location::nearby::errorcode::proto::UNKNOWN_EVENT), Field("description", &ErrorCodeParams::description, - errorcode::proto::FEATURE_BLUETOOTH_NOT_SUPPORTED), + location::nearby::errorcode::proto:: + FEATURE_BLUETOOTH_NOT_SUPPORTED), Field("pii_message", &ErrorCodeParams::pii_message, pii_message), Field("is_common_error", &ErrorCodeParams::is_common_error, true), Field("common_error", &ErrorCodeParams::common_error, - errorcode::proto::UNKNOWN_ERROR), + location::nearby::errorcode::proto::UNKNOWN_ERROR), Field("connection_token", &ErrorCodeParams::connection_token, connection_token))); } } // namespace nearby -} // namespace location diff --git a/internal/platform/exception.h b/internal/platform/exception.h index dbed1ee139..2ce4618b2e 100644 --- a/internal/platform/exception.h +++ b/internal/platform/exception.h @@ -19,7 +19,6 @@ #include "absl/meta/type_traits.h" -namespace location { namespace nearby { struct Exception { @@ -109,6 +108,5 @@ class ExceptionOr { }; } // namespace nearby -} // namespace location #endif // PLATFORM_BASE_EXCEPTION_H_ diff --git a/internal/platform/exception_test.cc b/internal/platform/exception_test.cc index 63aed3d686..9402435142 100644 --- a/internal/platform/exception_test.cc +++ b/internal/platform/exception_test.cc @@ -21,7 +21,7 @@ #include "gtest/gtest.h" #include "internal/platform/exception_test.nc.h" -namespace location::nearby { +namespace nearby { TEST(ExceptionOr, Result_Copy_NonConst) { ExceptionOr> exception_or_vector({1, 2, 3}); @@ -118,4 +118,4 @@ TEST(ExceptionOr, ExplicitConversionFailsToCompile) { EXPECT_NON_COMPILE("no matching constructor", { ExceptionOr b(a); }); } -} // namespace location::nearby +} // namespace nearby diff --git a/internal/platform/feature_flags.h b/internal/platform/feature_flags.h index 9a28774619..86017fdf61 100644 --- a/internal/platform/feature_flags.h +++ b/internal/platform/feature_flags.h @@ -18,7 +18,6 @@ #include "absl/synchronization/mutex.h" #include "absl/time/time.h" -namespace location { namespace nearby { // Global flags that control feature availability. This may be used to gating @@ -80,6 +79,5 @@ class FeatureFlags { mutable absl::Mutex mutex_; }; } // namespace nearby -} // namespace location #endif // PLATFORM_BASE_FEATURE_FLAGS_H_ diff --git a/internal/platform/feature_flags_test.cc b/internal/platform/feature_flags_test.cc index 21e7405d25..3d4925ef80 100644 --- a/internal/platform/feature_flags_test.cc +++ b/internal/platform/feature_flags_test.cc @@ -17,7 +17,6 @@ #include "gtest/gtest.h" #include "internal/platform/medium_environment.h" -namespace location { namespace nearby { namespace { @@ -43,4 +42,3 @@ TEST(FeatureFlagsTest, ToSetFeatureWorks) { } // namespace } // namespace nearby -} // namespace location diff --git a/internal/platform/file.cc b/internal/platform/file.cc index c1516467b0..5bb258a41c 100644 --- a/internal/platform/file.cc +++ b/internal/platform/file.cc @@ -14,7 +14,6 @@ #include "internal/platform/file.h" -namespace location { namespace nearby { InputFile::InputFile(PayloadId id, std::int64_t size) @@ -86,4 +85,3 @@ Exception OutputFile::Close() { return impl_->Close(); } OutputStream& OutputFile::GetOutputStream() { return *impl_; } } // namespace nearby -} // namespace location diff --git a/internal/platform/file.h b/internal/platform/file.h index ff08fbce32..d72f9d8d95 100644 --- a/internal/platform/file.h +++ b/internal/platform/file.h @@ -27,7 +27,6 @@ #include "internal/platform/input_stream.h" #include "internal/platform/output_stream.h" -namespace location { namespace nearby { class InputFile final { @@ -104,6 +103,5 @@ class OutputFile final { }; } // namespace nearby -} // namespace location #endif // PLATFORM_PUBLIC_FILE_H_ diff --git a/internal/platform/future.h b/internal/platform/future.h index 88286b8451..07218b229d 100644 --- a/internal/platform/future.h +++ b/internal/platform/future.h @@ -17,7 +17,6 @@ #include "internal/platform/settable_future.h" -namespace location { namespace nearby { template @@ -51,6 +50,5 @@ class Future final { }; } // namespace nearby -} // namespace location #endif // PLATFORM_PUBLIC_FUTURE_H_ diff --git a/internal/platform/future_test.cc b/internal/platform/future_test.cc index 1637bf9a59..7e6f151ce4 100644 --- a/internal/platform/future_test.cc +++ b/internal/platform/future_test.cc @@ -20,7 +20,6 @@ #include "internal/platform/exception.h" #include "internal/platform/single_thread_executor.h" -namespace location { namespace nearby { namespace { @@ -234,4 +233,3 @@ TEST(FutureTest, AddListenerWhenAlreadySetExceptionCallsCallback) { } } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/apple/Tests/GNCBleTest.mm b/internal/platform/implementation/apple/Tests/GNCBleTest.mm index 3fec192c76..dfece3c1e3 100644 --- a/internal/platform/implementation/apple/Tests/GNCBleTest.mm +++ b/internal/platform/implementation/apple/Tests/GNCBleTest.mm @@ -24,15 +24,15 @@ #include "internal/platform/implementation/bluetooth_adapter.h" #include "internal/platform/implementation/platform.h" -using ::location::nearby::ByteArray; -using ::location::nearby::Uuid; -using ::location::nearby::api::BluetoothAdapter; -using ::location::nearby::api::ImplementationPlatform; -using ::location::nearby::api::ble_v2::BleAdvertisementData; -using ::location::nearby::api::ble_v2::BleMedium; -using ::location::nearby::api::ble_v2::GattCharacteristic; -using ::location::nearby::api::ble_v2::TxPowerLevel; -using IOSBluetoothAdapter = ::location::nearby::apple::BluetoothAdapter; +using ::nearby::ByteArray; +using ::nearby::Uuid; +using ::nearby::api::BluetoothAdapter; +using ::nearby::api::ImplementationPlatform; +using ::nearby::api::ble_v2::BleAdvertisementData; +using ::nearby::api::ble_v2::BleMedium; +using ::nearby::api::ble_v2::GattCharacteristic; +using ::nearby::api::ble_v2::TxPowerLevel; +using IOSBluetoothAdapter = ::nearby::apple::BluetoothAdapter; static const char *const kAdvertisementString = "\x0a\x0b\x0c\x0d"; static const TxPowerLevel kTxPowerLevel = TxPowerLevel::kHigh; diff --git a/internal/platform/implementation/apple/Tests/GNCBluetoothAdapterTest.mm b/internal/platform/implementation/apple/Tests/GNCBluetoothAdapterTest.mm index b05306b4e0..bb4955c813 100644 --- a/internal/platform/implementation/apple/Tests/GNCBluetoothAdapterTest.mm +++ b/internal/platform/implementation/apple/Tests/GNCBluetoothAdapterTest.mm @@ -20,10 +20,10 @@ #include "internal/platform/implementation/ble_v2.h" #include "internal/platform/implementation/bluetooth_adapter.h" -using ::location::nearby::apple::BlePeripheral; -using ::location::nearby::apple::BluetoothAdapter; -using ScanMode = ::location::nearby::api::BluetoothAdapter::ScanMode; -using Status = ::location::nearby::api::BluetoothAdapter::Status; +using ::nearby::apple::BlePeripheral; +using ::nearby::apple::BluetoothAdapter; +using ScanMode = ::nearby::api::BluetoothAdapter::ScanMode; +using Status = ::nearby::api::BluetoothAdapter::Status; static const char kAdapterName[] = "MyBtAdapter"; static const char kMacAddress[] = "4C:8B:1D:CE:BA:D1"; diff --git a/internal/platform/implementation/apple/Tests/GNCCryptoTest.mm b/internal/platform/implementation/apple/Tests/GNCCryptoTest.mm index 42c231d3f9..a3bcaa70dc 100644 --- a/internal/platform/implementation/apple/Tests/GNCCryptoTest.mm +++ b/internal/platform/implementation/apple/Tests/GNCCryptoTest.mm @@ -35,7 +35,7 @@ - (void)testHashValues { 0x1d, 0xe7, 0x5b, 0xcf, 0xda, 0xb5, 0x62, 0xd3, 0xde, 0xba, 0x14, 0x49, 0xbd, 0xf5, 0x95, 0x04, 0x1f, 0x1d, 0x99, 0x84, 0x87, 0xc3, 0xcb, 0x8a, }; - location::nearby::ByteArray sha256Hash = location::nearby::Crypto::Sha256(string); + nearby::ByteArray sha256Hash = nearby::Crypto::Sha256(string); XCTAssert(sha256Hash.size() == sizeof(sha256ExpectedHash) && memcmp(sha256Hash.data(), sha256ExpectedHash, sizeof(sha256ExpectedHash)) == 0); } @@ -45,7 +45,7 @@ - (void)testHashValues { const uint8_t md5ExpectedHash[] = { 0x97, 0x78, 0x1d, 0x3d, 0xee, 0xd7, 0xdc, 0x5a, 0x6e, 0xee, 0x50, 0x08, 0xce, 0xd1, 0xb2, 0xe8 }; - location::nearby::ByteArray md5Hash = location::nearby::Crypto::Md5(string); + nearby::ByteArray md5Hash = nearby::Crypto::Md5(string); XCTAssert(md5Hash.size() == sizeof(md5ExpectedHash) && memcmp(md5Hash.data(), md5ExpectedHash, sizeof(md5ExpectedHash)) == 0); } diff --git a/internal/platform/implementation/apple/Tests/GNCMultiThreadExecutorTest.mm b/internal/platform/implementation/apple/Tests/GNCMultiThreadExecutorTest.mm index 37a9e08649..f91a8388a1 100644 --- a/internal/platform/implementation/apple/Tests/GNCMultiThreadExecutorTest.mm +++ b/internal/platform/implementation/apple/Tests/GNCMultiThreadExecutorTest.mm @@ -23,9 +23,9 @@ #include "internal/platform/implementation/submittable_executor.h" #include "internal/platform/runnable.h" -using ::location::nearby::Runnable; -using ::location::nearby::api::ImplementationPlatform; -using MultiThreadExecutor = ::location::nearby::api::SubmittableExecutor; +using ::nearby::Runnable; +using ::nearby::api::ImplementationPlatform; +using MultiThreadExecutor = ::nearby::api::SubmittableExecutor; @interface GNCMultiThreadExecutorTest : XCTestCase @property(atomic) int counter; diff --git a/internal/platform/implementation/apple/Tests/GNCScheduledExecutorTest.mm b/internal/platform/implementation/apple/Tests/GNCScheduledExecutorTest.mm index 9b247101ff..2ef2f1f712 100644 --- a/internal/platform/implementation/apple/Tests/GNCScheduledExecutorTest.mm +++ b/internal/platform/implementation/apple/Tests/GNCScheduledExecutorTest.mm @@ -23,9 +23,9 @@ #include "internal/platform/implementation/scheduled_executor.h" #include "internal/platform/runnable.h" -using ::location::nearby::Runnable; -using ::location::nearby::api::ImplementationPlatform; -using ::location::nearby::api::ScheduledExecutor; +using ::nearby::Runnable; +using ::nearby::api::ImplementationPlatform; +using ::nearby::api::ScheduledExecutor; @interface GNCScheduledExecutorTest : XCTestCase @property(atomic) int counter; diff --git a/internal/platform/implementation/apple/Tests/GNCSingleThreadExecutorTest.mm b/internal/platform/implementation/apple/Tests/GNCSingleThreadExecutorTest.mm index 8265ea05a5..92d9c01743 100644 --- a/internal/platform/implementation/apple/Tests/GNCSingleThreadExecutorTest.mm +++ b/internal/platform/implementation/apple/Tests/GNCSingleThreadExecutorTest.mm @@ -23,9 +23,9 @@ #include "internal/platform/implementation/submittable_executor.h" #include "internal/platform/runnable.h" -using ::location::nearby::Runnable; -using ::location::nearby::api::ImplementationPlatform; -using SingleThreadExecutor = ::location::nearby::api::SubmittableExecutor; +using ::nearby::Runnable; +using ::nearby::api::ImplementationPlatform; +using SingleThreadExecutor = ::nearby::api::SubmittableExecutor; @interface GNCSingleThreadExecutorTest : XCTestCase @property(atomic) int counter; diff --git a/internal/platform/implementation/apple/Tests/GNCUtilsTest.mm b/internal/platform/implementation/apple/Tests/GNCUtilsTest.mm index 70688352e1..fc38449776 100644 --- a/internal/platform/implementation/apple/Tests/GNCUtilsTest.mm +++ b/internal/platform/implementation/apple/Tests/GNCUtilsTest.mm @@ -17,10 +17,10 @@ #include "internal/platform/byte_array.h" #include "internal/platform/implementation/apple/utils.h" -using ::location::nearby::ByteArray; -using ::location::nearby::ByteArrayFromNSData; -using ::location::nearby::CppStringFromObjCString; -using ::location::nearby::ObjCStringFromCppString; +using ::nearby::ByteArray; +using ::nearby::ByteArrayFromNSData; +using ::nearby::CppStringFromObjCString; +using ::nearby::ObjCStringFromCppString; @interface GNCUtilsTest : XCTestCase @end diff --git a/internal/platform/implementation/apple/atomic_boolean.h b/internal/platform/implementation/apple/atomic_boolean.h index 3e8c22e244..a469d3fb18 100644 --- a/internal/platform/implementation/apple/atomic_boolean.h +++ b/internal/platform/implementation/apple/atomic_boolean.h @@ -19,7 +19,6 @@ #include "internal/platform/implementation/atomic_boolean.h" -namespace location { namespace nearby { namespace apple { @@ -41,6 +40,5 @@ class AtomicBoolean : public api::AtomicBoolean { } // namespace apple } // namespace nearby -} // namespace location #endif // PLATFORM_IMPL_APPLE_ATOMIC_BOOLEAN_H_ diff --git a/internal/platform/implementation/apple/atomic_boolean_test.cc b/internal/platform/implementation/apple/atomic_boolean_test.cc index 1fa24ece48..26c6b4f7aa 100644 --- a/internal/platform/implementation/apple/atomic_boolean_test.cc +++ b/internal/platform/implementation/apple/atomic_boolean_test.cc @@ -17,7 +17,6 @@ #include "gtest/gtest.h" #include "thread/fiber/fiber.h" -namespace location { namespace nearby { namespace apple { namespace { @@ -75,4 +74,3 @@ TEST(AtomicBooleanTest, GetOnNewThread) { } // namespace } // namespace apple } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/apple/atomic_uint32.h b/internal/platform/implementation/apple/atomic_uint32.h index 266d3ee007..53c05b692d 100644 --- a/internal/platform/implementation/apple/atomic_uint32.h +++ b/internal/platform/implementation/apple/atomic_uint32.h @@ -20,7 +20,6 @@ #include "internal/platform/implementation/atomic_reference.h" -namespace location { namespace nearby { namespace apple { @@ -42,6 +41,5 @@ class AtomicUint32 : public api::AtomicUint32 { } // namespace apple } // namespace nearby -} // namespace location #endif // PLATFORM_IMPL_APPLE_ATOMIC_UINT32_H_ diff --git a/internal/platform/implementation/apple/atomic_uint32_test.cc b/internal/platform/implementation/apple/atomic_uint32_test.cc index 3e573c2a15..54c2ac79e8 100644 --- a/internal/platform/implementation/apple/atomic_uint32_test.cc +++ b/internal/platform/implementation/apple/atomic_uint32_test.cc @@ -17,7 +17,6 @@ #include "gtest/gtest.h" #include "thread/fiber/fiber.h" -namespace location { namespace nearby { namespace apple { namespace { @@ -61,4 +60,3 @@ TEST(AtomicUint32Test, GetOnNewThread) { } // namespace } // namespace apple } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/apple/ble.h b/internal/platform/implementation/apple/ble.h index bb8f59bd34..b3c0412b2b 100644 --- a/internal/platform/implementation/apple/ble.h +++ b/internal/platform/implementation/apple/ble.h @@ -31,7 +31,6 @@ @class GNCMBlePeripheral, GNCMBleCentral; -namespace location { namespace nearby { namespace apple { @@ -158,7 +157,7 @@ class BleMedium : public api::ble_v2::BleMedium { const std::vector &properties) override; bool UpdateCharacteristic(const api::ble_v2::GattCharacteristic &characteristic, - const location::nearby::ByteArray &value) override; + const nearby::ByteArray &value) override; void Stop() override; private: @@ -204,7 +203,6 @@ class BleMedium : public api::ble_v2::BleMedium { } // namespace apple } // namespace nearby -} // namespace location #endif #endif // THIRD_PARTY_NEARBY_INTERNAL_PLATFORM_IMPLEMENTATION_APPLE_BLE_H_ diff --git a/internal/platform/implementation/apple/ble.mm b/internal/platform/implementation/apple/ble.mm index c13543081c..0f5ad9850c 100644 --- a/internal/platform/implementation/apple/ble.mm +++ b/internal/platform/implementation/apple/ble.mm @@ -26,7 +26,6 @@ #import "internal/platform/implementation/apple/Mediums/Ble/GNCMBleCentral.h" #import "internal/platform/implementation/apple/Mediums/Ble/GNCMBlePeripheral.h" -namespace location { namespace nearby { namespace apple { @@ -75,9 +74,9 @@ CBCharacteristicProperties PropertiesToCBProperties( } // namespace -using ::location::nearby::api::ble_v2::BleAdvertisementData; -using ::location::nearby::api::ble_v2::TxPowerLevel; -using ScanCallback = ::location::nearby::api::ble_v2::BleMedium::ScanCallback; +using ::nearby::api::ble_v2::BleAdvertisementData; +using ::nearby::api::ble_v2::TxPowerLevel; +using ScanCallback = ::nearby::api::ble_v2::BleMedium::ScanCallback; /** InputStream that reads from GNCMConnection. */ BleInputStream::BleInputStream() @@ -312,12 +311,12 @@ CBCharacteristicProperties PropertiesToCBProperties( } /** BleMedium implementation. */ -BleMedium::BleMedium(::location::nearby::api::BluetoothAdapter& adapter) +BleMedium::BleMedium(::nearby::api::BluetoothAdapter& adapter) : adapter_(static_cast(&adapter)) {} bool BleMedium::StartAdvertising( const BleAdvertisementData& advertising_data, - ::location::nearby::api::ble_v2::AdvertiseParameters advertise_set_parameters) { + ::nearby::api::ble_v2::AdvertiseParameters advertise_set_parameters) { if (advertising_data.service_data.empty()) { return false; } @@ -505,8 +504,7 @@ CBCharacteristicProperties PropertiesToCBProperties( } bool BleMedium::GattServer::UpdateCharacteristic( - const api::ble_v2::GattCharacteristic& characteristic, - const location::nearby::ByteArray& value) { + const api::ble_v2::GattCharacteristic& characteristic, const nearby::ByteArray& value) { [peripheral_ updateValue:NSDataFromByteArray(value) forCharacteristic:[CBUUID UUIDWithString:ObjCStringFromCppString( std::string(characteristic.uuid))]]; @@ -593,4 +591,3 @@ CBCharacteristicProperties PropertiesToCBProperties( } // namespace apple } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/apple/bluetooth_adapter.h b/internal/platform/implementation/apple/bluetooth_adapter.h index 55a17ae2b2..2194b59897 100644 --- a/internal/platform/implementation/apple/bluetooth_adapter.h +++ b/internal/platform/implementation/apple/bluetooth_adapter.h @@ -23,7 +23,6 @@ #import "internal/platform/implementation/apple/Mediums/Ble/GNCMBleCentral.h" -namespace location { namespace nearby { namespace apple { @@ -99,7 +98,6 @@ class BluetoothAdapter : public api::BluetoothAdapter { } // namespace apple } // namespace nearby -} // namespace location #endif #endif // THIRD_PARTY_NEARBY_INTERNAL_PLATFORM_IMPLEMENTATION_APPLE_BLUETOOTH_ADAPTER_H_ diff --git a/internal/platform/implementation/apple/bluetooth_adapter.mm b/internal/platform/implementation/apple/bluetooth_adapter.mm index a7a5beeb66..7369e63c1e 100644 --- a/internal/platform/implementation/apple/bluetooth_adapter.mm +++ b/internal/platform/implementation/apple/bluetooth_adapter.mm @@ -19,7 +19,6 @@ #include "absl/strings/string_view.h" #include "internal/platform/implementation/bluetooth_adapter.h" -namespace location { namespace nearby { namespace apple { @@ -27,4 +26,3 @@ } // namespace apple } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/apple/condition_variable.cc b/internal/platform/implementation/apple/condition_variable.cc index 621443d35e..cb9370a7b3 100644 --- a/internal/platform/implementation/apple/condition_variable.cc +++ b/internal/platform/implementation/apple/condition_variable.cc @@ -16,7 +16,6 @@ #include "internal/platform/implementation/apple/mutex.h" -namespace location { namespace nearby { namespace apple { @@ -34,4 +33,3 @@ void ConditionVariable::Notify() { condition_variable_.SignalAll(); } } // namespace apple } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/apple/condition_variable.h b/internal/platform/implementation/apple/condition_variable.h index bc174ada17..b18cb07c68 100644 --- a/internal/platform/implementation/apple/condition_variable.h +++ b/internal/platform/implementation/apple/condition_variable.h @@ -19,7 +19,6 @@ #include "internal/platform/implementation/condition_variable.h" #include "internal/platform/implementation/apple/mutex.h" -namespace location { namespace nearby { namespace apple { @@ -43,6 +42,5 @@ class ConditionVariable : public api::ConditionVariable { } // namespace apple } // namespace nearby -} // namespace location #endif // PLATFORM_IMPL_APPLE_CONDITION_VARIABLE_H_ diff --git a/internal/platform/implementation/apple/condition_variable_test.cc b/internal/platform/implementation/apple/condition_variable_test.cc index 67ce47a95d..846ad438b1 100644 --- a/internal/platform/implementation/apple/condition_variable_test.cc +++ b/internal/platform/implementation/apple/condition_variable_test.cc @@ -19,7 +19,6 @@ #include "internal/platform/implementation/apple/mutex.h" #include "thread/fiber/fiber.h" -namespace location { namespace nearby { namespace apple { namespace { @@ -81,4 +80,3 @@ TEST(ConditionVariableTest, WaitTerminatesOnTimeoutWithoutNotify) { } // namespace } // namespace apple } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/apple/count_down_latch.cc b/internal/platform/implementation/apple/count_down_latch.cc index 3763a5e2b5..e081e9a930 100644 --- a/internal/platform/implementation/apple/count_down_latch.cc +++ b/internal/platform/implementation/apple/count_down_latch.cc @@ -14,7 +14,6 @@ #include "internal/platform/implementation/apple/count_down_latch.h" -namespace location { namespace nearby { namespace apple { @@ -37,4 +36,3 @@ void CountDownLatch::CountDown() { } // namespace apple } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/apple/count_down_latch.h b/internal/platform/implementation/apple/count_down_latch.h index d508ea1c81..7504df19ef 100644 --- a/internal/platform/implementation/apple/count_down_latch.h +++ b/internal/platform/implementation/apple/count_down_latch.h @@ -18,7 +18,6 @@ #include "absl/synchronization/mutex.h" #include "internal/platform/implementation/count_down_latch.h" -namespace location { namespace nearby { namespace apple { @@ -44,6 +43,5 @@ class CountDownLatch : public api::CountDownLatch { } // namespace apple } // namespace nearby -} // namespace location #endif // PLATFORM_IMPL_APPLE_COUNT_DOWN_LATCH_H_ diff --git a/internal/platform/implementation/apple/count_down_latch_test.cc b/internal/platform/implementation/apple/count_down_latch_test.cc index 47d74c6972..50012813b1 100644 --- a/internal/platform/implementation/apple/count_down_latch_test.cc +++ b/internal/platform/implementation/apple/count_down_latch_test.cc @@ -17,7 +17,6 @@ #include "gtest/gtest.h" #include "thread/fiber/fiber.h" -namespace location { namespace nearby { namespace apple { namespace { @@ -80,4 +79,3 @@ TEST(CountDownLatchTest, InitialCountNegative_AwaitDoesNotBlock) { } // namespace } // namespace apple } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/apple/crypto.mm b/internal/platform/implementation/apple/crypto.mm index b2c4c03e56..9919d559b4 100644 --- a/internal/platform/implementation/apple/crypto.mm +++ b/internal/platform/implementation/apple/crypto.mm @@ -18,7 +18,6 @@ #import "internal/platform/implementation/apple/GNCUtils.h" #import "internal/platform/implementation/apple/utils.h" -namespace location { namespace nearby { void Crypto::Init() {} @@ -36,4 +35,3 @@ } } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/apple/log_message.h b/internal/platform/implementation/apple/log_message.h index 6166f79be3..04a968779d 100644 --- a/internal/platform/implementation/apple/log_message.h +++ b/internal/platform/implementation/apple/log_message.h @@ -23,7 +23,6 @@ #endif #include "internal/platform/implementation/log_message.h" -namespace location { namespace nearby { namespace apple { @@ -51,7 +50,6 @@ class LogMessage : public api::LogMessage { } // namespace apple } // namespace nearby -} // namespace location #endif #endif // PLATFORM_IMPL_APPLE_LOG_MESSAGE_H_ diff --git a/internal/platform/implementation/apple/log_message.mm b/internal/platform/implementation/apple/log_message.mm index 181add5dc5..a7af76b288 100644 --- a/internal/platform/implementation/apple/log_message.mm +++ b/internal/platform/implementation/apple/log_message.mm @@ -20,7 +20,6 @@ #include "internal/platform/implementation/log_message.h" #include "GoogleToolboxForMac/GTMLogger.h" -namespace location { namespace nearby { namespace apple { @@ -94,4 +93,3 @@ GTMLoggerLevel ConvertSeverity(api::LogMessage::Severity severity) { } // namespace api } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/apple/multi_thread_executor.h b/internal/platform/implementation/apple/multi_thread_executor.h index 06c135d4ee..503e983eb0 100644 --- a/internal/platform/implementation/apple/multi_thread_executor.h +++ b/internal/platform/implementation/apple/multi_thread_executor.h @@ -20,7 +20,6 @@ #include "internal/platform/implementation/submittable_executor.h" #import "internal/platform/runnable.h" -namespace location { namespace nearby { namespace apple { @@ -43,7 +42,6 @@ class MultiThreadExecutor : public api::SubmittableExecutor { } // namespace apple } // namespace nearby -} // namespace location #endif #endif // PLATFORM_IMPL_APPLE_MULTI_THREAD_EXECUTOR_H_ diff --git a/internal/platform/implementation/apple/multi_thread_executor.mm b/internal/platform/implementation/apple/multi_thread_executor.mm index 1783713c28..9761794dce 100644 --- a/internal/platform/implementation/apple/multi_thread_executor.mm +++ b/internal/platform/implementation/apple/multi_thread_executor.mm @@ -17,7 +17,6 @@ #import "internal/platform/implementation/apple/scheduled_executor.h" #include "internal/platform/runnable.h" -namespace location { namespace nearby { namespace apple { @@ -37,4 +36,3 @@ } // namespace apple } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/apple/mutex.h b/internal/platform/implementation/apple/mutex.h index 36f90f691e..3a7890b2eb 100644 --- a/internal/platform/implementation/apple/mutex.h +++ b/internal/platform/implementation/apple/mutex.h @@ -18,7 +18,6 @@ #include "absl/synchronization/mutex.h" #include "internal/platform/implementation/mutex.h" -namespace location { namespace nearby { namespace apple { @@ -79,6 +78,5 @@ class ABSL_LOCKABLE RecursiveMutex : public api::Mutex { } // namespace apple } // namespace nearby -} // namespace location #endif // PLATFORM_IMPL_APPLE_MUTEX_H_ diff --git a/internal/platform/implementation/apple/mutex_test.cc b/internal/platform/implementation/apple/mutex_test.cc index a49c921b5b..4a9bded4c2 100644 --- a/internal/platform/implementation/apple/mutex_test.cc +++ b/internal/platform/implementation/apple/mutex_test.cc @@ -21,7 +21,6 @@ #include "absl/time/time.h" #include "thread/fiber/fiber.h" -namespace location { namespace nearby { namespace apple { namespace { @@ -89,4 +88,3 @@ TEST(MutexTest, RecursiveLockingForNestedWorks) { } // namespace } // namespace apple } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/apple/platform.mm b/internal/platform/implementation/apple/platform.mm index cd9b13f72f..ce494b6277 100644 --- a/internal/platform/implementation/apple/platform.mm +++ b/internal/platform/implementation/apple/platform.mm @@ -33,7 +33,6 @@ #include "internal/platform/implementation/shared/file.h" #include "internal/platform/payload_id.h" -namespace location { namespace nearby { namespace api { @@ -179,4 +178,3 @@ } // namespace api } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/apple/scheduled_executor.h b/internal/platform/implementation/apple/scheduled_executor.h index 2cfcd3218c..a256c99f99 100644 --- a/internal/platform/implementation/apple/scheduled_executor.h +++ b/internal/platform/implementation/apple/scheduled_executor.h @@ -34,7 +34,6 @@ @property(atomic) BOOL shuttingDown; @end -namespace location { namespace nearby { namespace apple { @@ -64,7 +63,6 @@ class ScheduledExecutor : public api::ScheduledExecutor { } // namespace apple } // namespace nearby -} // namespace location #endif #endif // PLATFORM_IMPL_APPLE_SCHEDULED_EXECUTOR_H_ diff --git a/internal/platform/implementation/apple/scheduled_executor.mm b/internal/platform/implementation/apple/scheduled_executor.mm index 1c7495cb5e..c24efbd67b 100644 --- a/internal/platform/implementation/apple/scheduled_executor.mm +++ b/internal/platform/implementation/apple/scheduled_executor.mm @@ -26,17 +26,17 @@ // dispatch block below, and deleted when the block is released. @interface GNCRunnableWrapper : NSObject { @public - location::nearby::Runnable _runnable; - std::unique_ptr _canceled; + nearby::Runnable _runnable; + std::unique_ptr _canceled; } @end @implementation GNCRunnableWrapper -+ (instancetype)wrapperWithRunnable:(location::nearby::Runnable)runnable { ++ (instancetype)wrapperWithRunnable:(nearby::Runnable)runnable { GNCRunnableWrapper *wrapper = [[GNCRunnableWrapper alloc] init]; wrapper->_runnable = runnable; - wrapper->_canceled = std::make_unique(false); + wrapper->_canceled = std::make_unique(false); return wrapper; } @@ -53,7 +53,6 @@ + (instancetype)implWithMaxConcurrency:(int)maxConcurrency { @end -namespace location { namespace nearby { namespace apple { @@ -143,4 +142,3 @@ bool Cancel() override { } // namespace apple } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/apple/single_thread_executor.h b/internal/platform/implementation/apple/single_thread_executor.h index 35bd8aefc9..60026f3f53 100644 --- a/internal/platform/implementation/apple/single_thread_executor.h +++ b/internal/platform/implementation/apple/single_thread_executor.h @@ -18,7 +18,6 @@ #import "internal/platform/implementation/apple/multi_thread_executor.h" -namespace location { namespace nearby { namespace apple { @@ -30,7 +29,6 @@ class SingleThreadExecutor : public MultiThreadExecutor { } // namespace apple } // namespace nearby -} // namespace location #endif #endif // PLATFORM_IMPL_APPLE_SINGLE_THREAD_EXECUTOR_H_ diff --git a/internal/platform/implementation/apple/system_clock.cc b/internal/platform/implementation/apple/system_clock.cc index db7c722ff8..efef191673 100644 --- a/internal/platform/implementation/apple/system_clock.cc +++ b/internal/platform/implementation/apple/system_clock.cc @@ -16,7 +16,6 @@ #include "absl/time/clock.h" -namespace location { namespace nearby { void SystemClock::Init() {} @@ -30,4 +29,3 @@ Exception SystemClock::Sleep(absl::Duration duration) { } } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/apple/utils.h b/internal/platform/implementation/apple/utils.h index 3f4a0c8caf..88c34717ee 100644 --- a/internal/platform/implementation/apple/utils.h +++ b/internal/platform/implementation/apple/utils.h @@ -26,7 +26,6 @@ NS_ASSUME_NONNULL_BEGIN -namespace location { namespace nearby { /// Converts an Obj-C BOOL to a C++ bool. @@ -71,7 +70,6 @@ absl::flat_hash_map AbslHashMapFromObjCTxtRecords( NSDictionary *txtRecords); } // namespace nearby -} // namespace location NS_ASSUME_NONNULL_END diff --git a/internal/platform/implementation/apple/utils.mm b/internal/platform/implementation/apple/utils.mm index f2c1749f14..386e10363f 100644 --- a/internal/platform/implementation/apple/utils.mm +++ b/internal/platform/implementation/apple/utils.mm @@ -20,7 +20,6 @@ NS_ASSUME_NONNULL_BEGIN -namespace location { namespace nearby { bool CppBoolFromObjCBool(BOOL b) { return b ? true : false; } @@ -99,6 +98,5 @@ ByteArray ByteArrayFromNSData(NSData* data) { } } // namespace nearby -} // namespace location NS_ASSUME_NONNULL_END diff --git a/internal/platform/implementation/apple/wifi_lan.h b/internal/platform/implementation/apple/wifi_lan.h index 7d32db4a75..eedb7b862d 100644 --- a/internal/platform/implementation/apple/wifi_lan.h +++ b/internal/platform/implementation/apple/wifi_lan.h @@ -28,7 +28,6 @@ @class GNCMBonjourBrowser; @class GNCMBonjourService; -namespace location { namespace nearby { namespace apple { @@ -201,7 +200,6 @@ class WifiLanMedium : public api::WifiLanMedium { } // namespace apple } // namespace nearby -} // namespace location #endif #endif // PLATFORM_IMPL_APPLE_WIFI_LAN_H_ diff --git a/internal/platform/implementation/apple/wifi_lan.mm b/internal/platform/implementation/apple/wifi_lan.mm index 94948796ed..5db8e472de 100644 --- a/internal/platform/implementation/apple/wifi_lan.mm +++ b/internal/platform/implementation/apple/wifi_lan.mm @@ -35,7 +35,6 @@ #include "internal/platform/prng.h" #import "GoogleToolboxForMac/GTMLogger.h" -namespace location { namespace nearby { namespace apple { @@ -494,4 +493,3 @@ } // namespace apple } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/atomic_boolean.h b/internal/platform/implementation/atomic_boolean.h index e00179243d..514c58df2f 100644 --- a/internal/platform/implementation/atomic_boolean.h +++ b/internal/platform/implementation/atomic_boolean.h @@ -15,7 +15,6 @@ #ifndef PLATFORM_API_ATOMIC_BOOLEAN_H_ #define PLATFORM_API_ATOMIC_BOOLEAN_H_ -namespace location { namespace nearby { namespace api { @@ -33,6 +32,5 @@ class AtomicBoolean { } // namespace api } // namespace nearby -} // namespace location #endif // PLATFORM_API_ATOMIC_BOOLEAN_H_ diff --git a/internal/platform/implementation/atomic_reference.h b/internal/platform/implementation/atomic_reference.h index a6f4c93dc1..742d9ada13 100644 --- a/internal/platform/implementation/atomic_reference.h +++ b/internal/platform/implementation/atomic_reference.h @@ -17,7 +17,6 @@ #include -namespace location { namespace nearby { namespace api { @@ -35,6 +34,5 @@ class AtomicUint32 { } // namespace api } // namespace nearby -} // namespace location #endif // PLATFORM_API_ATOMIC_REFERENCE_H_ diff --git a/internal/platform/implementation/ble.h b/internal/platform/implementation/ble.h index fdc1e85d66..f1b8da59b0 100644 --- a/internal/platform/implementation/ble.h +++ b/internal/platform/implementation/ble.h @@ -21,7 +21,6 @@ #include "internal/platform/input_stream.h" #include "internal/platform/output_stream.h" -namespace location { namespace nearby { namespace api { @@ -120,6 +119,5 @@ class BleMedium { } // namespace api } // namespace nearby -} // namespace location #endif // PLATFORM_API_BLE_H_ diff --git a/internal/platform/implementation/ble_v2.h b/internal/platform/implementation/ble_v2.h index cf30b1922b..d617ee5da8 100644 --- a/internal/platform/implementation/ble_v2.h +++ b/internal/platform/implementation/ble_v2.h @@ -35,7 +35,6 @@ #include "internal/platform/output_stream.h" #include "internal/platform/uuid.h" -namespace location { namespace nearby { namespace api { namespace ble_v2 { @@ -78,7 +77,7 @@ struct BleAdvertisementData { // iOS : 16 bit service UUID (type=0x03) + LocalName data (type=0x08) // Windows: Service data (type=0x16) // Android: 16 bit service UUID (type=0x03) + Service data (type=0x16) - absl::flat_hash_map service_data; + absl::flat_hash_map service_data; }; // Opaque wrapper over a BLE peripheral. Must be able to uniquely identify a @@ -214,9 +213,8 @@ class GattServer { // // Locally updates the value of a characteristic and returns whether or not // it was successful. - virtual bool UpdateCharacteristic( - const GattCharacteristic& characteristic, - const location::nearby::ByteArray& value) = 0; + virtual bool UpdateCharacteristic(const GattCharacteristic& characteristic, + const nearby::ByteArray& value) = 0; // Stops a GATT server. virtual void Stop() = 0; @@ -425,6 +423,5 @@ class BleMedium { } // namespace ble_v2 } // namespace api } // namespace nearby -} // namespace location #endif // PLATFORM_API_BLE_V2_H_ diff --git a/internal/platform/implementation/bluetooth_adapter.h b/internal/platform/implementation/bluetooth_adapter.h index 476c764281..46632893ca 100644 --- a/internal/platform/implementation/bluetooth_adapter.h +++ b/internal/platform/implementation/bluetooth_adapter.h @@ -19,7 +19,6 @@ #include "absl/strings/string_view.h" -namespace location { namespace nearby { namespace api { @@ -71,6 +70,5 @@ class BluetoothAdapter { } // namespace api } // namespace nearby -} // namespace location #endif // PLATFORM_API_BLUETOOTH_ADAPTER_H_ diff --git a/internal/platform/implementation/bluetooth_classic.h b/internal/platform/implementation/bluetooth_classic.h index a1685c750a..64367386af 100644 --- a/internal/platform/implementation/bluetooth_classic.h +++ b/internal/platform/implementation/bluetooth_classic.h @@ -25,7 +25,6 @@ #include "internal/platform/listeners.h" #include "internal/platform/output_stream.h" -namespace location { namespace nearby { namespace api { @@ -157,6 +156,5 @@ class BluetoothClassicMedium { } // namespace api } // namespace nearby -} // namespace location #endif // PLATFORM_API_BLUETOOTH_CLASSIC_H_ diff --git a/internal/platform/implementation/cancelable.h b/internal/platform/implementation/cancelable.h index c90faf0cbe..3626af1a2e 100644 --- a/internal/platform/implementation/cancelable.h +++ b/internal/platform/implementation/cancelable.h @@ -15,7 +15,6 @@ #ifndef PLATFORM_API_CANCELABLE_H_ #define PLATFORM_API_CANCELABLE_H_ -namespace location { namespace nearby { namespace api { @@ -30,6 +29,5 @@ class Cancelable { } // namespace api } // namespace nearby -} // namespace location #endif // PLATFORM_API_CANCELABLE_H_ diff --git a/internal/platform/implementation/condition_variable.h b/internal/platform/implementation/condition_variable.h index a607b61ba0..42fc5337fa 100644 --- a/internal/platform/implementation/condition_variable.h +++ b/internal/platform/implementation/condition_variable.h @@ -18,7 +18,6 @@ #include "absl/time/clock.h" #include "internal/platform/exception.h" -namespace location { namespace nearby { namespace api { @@ -46,6 +45,5 @@ class ConditionVariable { } // namespace api } // namespace nearby -} // namespace location #endif // PLATFORM_API_CONDITION_VARIABLE_H_ diff --git a/internal/platform/implementation/count_down_latch.h b/internal/platform/implementation/count_down_latch.h index 1ac4f0107e..66c3238eba 100644 --- a/internal/platform/implementation/count_down_latch.h +++ b/internal/platform/implementation/count_down_latch.h @@ -20,7 +20,6 @@ #include "absl/time/time.h" #include "internal/platform/exception.h" -namespace location { namespace nearby { namespace api { @@ -40,6 +39,5 @@ class CountDownLatch { } // namespace api } // namespace nearby -} // namespace location #endif // PLATFORM_API_COUNT_DOWN_LATCH_H_ diff --git a/internal/platform/implementation/credential_storage.h b/internal/platform/implementation/credential_storage.h index 3b086f14c3..025c5c7c1c 100644 --- a/internal/platform/implementation/credential_storage.h +++ b/internal/platform/implementation/credential_storage.h @@ -23,7 +23,6 @@ #include "internal/platform/implementation/credential_callbacks.h" #include "internal/proto/credential.pb.h" -namespace location { namespace nearby { namespace api { @@ -82,6 +81,5 @@ class CredentialStorage { } // namespace api } // namespace nearby -} // namespace location #endif // THIRD_PARTY_NEARBY_INTERNAL_PLATFORM_IMPLEMENTATION_CREDENTIAL_STORAGE_H_ diff --git a/internal/platform/implementation/crypto.h b/internal/platform/implementation/crypto.h index e0bc4aa99d..393f4d1f48 100644 --- a/internal/platform/implementation/crypto.h +++ b/internal/platform/implementation/crypto.h @@ -18,7 +18,6 @@ #include "absl/strings/string_view.h" #include "internal/platform/byte_array.h" -namespace location { namespace nearby { // A provider of standard hashing algorithms. @@ -33,6 +32,5 @@ class Crypto { }; } // namespace nearby -} // namespace location #endif // PLATFORM_API_CRYPTO_H_ diff --git a/internal/platform/implementation/executor.h b/internal/platform/implementation/executor.h index c41bc313f7..2336ed1e91 100644 --- a/internal/platform/implementation/executor.h +++ b/internal/platform/implementation/executor.h @@ -17,7 +17,6 @@ #include "internal/platform/runnable.h" -namespace location { namespace nearby { namespace api { @@ -39,6 +38,5 @@ class Executor { } // namespace api } // namespace nearby -} // namespace location #endif // PLATFORM_API_EXECUTOR_H_ diff --git a/internal/platform/implementation/future.h b/internal/platform/implementation/future.h index 0fbc99c7cc..837b591184 100644 --- a/internal/platform/implementation/future.h +++ b/internal/platform/implementation/future.h @@ -18,7 +18,6 @@ #include "absl/time/clock.h" #include "internal/platform/exception.h" -namespace location { namespace nearby { namespace api { @@ -41,6 +40,5 @@ class Future { } // namespace api } // namespace nearby -} // namespace location #endif // PLATFORM_API_FUTURE_H_ diff --git a/internal/platform/implementation/g3/atomic_boolean.h b/internal/platform/implementation/g3/atomic_boolean.h index 14b8810451..cef9cc7e92 100644 --- a/internal/platform/implementation/g3/atomic_boolean.h +++ b/internal/platform/implementation/g3/atomic_boolean.h @@ -19,7 +19,6 @@ #include "internal/platform/implementation/atomic_boolean.h" -namespace location { namespace nearby { namespace g3 { @@ -39,6 +38,5 @@ class AtomicBoolean : public api::AtomicBoolean { } // namespace g3 } // namespace nearby -} // namespace location #endif // PLATFORM_IMPL_G3_ATOMIC_BOOLEAN_H_ diff --git a/internal/platform/implementation/g3/atomic_reference.h b/internal/platform/implementation/g3/atomic_reference.h index 85d89bb943..f49fa9718a 100644 --- a/internal/platform/implementation/g3/atomic_reference.h +++ b/internal/platform/implementation/g3/atomic_reference.h @@ -20,7 +20,6 @@ #include "internal/platform/implementation/atomic_reference.h" -namespace location { namespace nearby { namespace g3 { @@ -38,6 +37,5 @@ class AtomicUint32 : public api::AtomicUint32 { } // namespace g3 } // namespace nearby -} // namespace location #endif // PLATFORM_IMPL_G3_ATOMIC_REFERENCE_H_ diff --git a/internal/platform/implementation/g3/ble.cc b/internal/platform/implementation/g3/ble.cc index 8de0d3903b..ef3407645c 100644 --- a/internal/platform/implementation/g3/ble.cc +++ b/internal/platform/implementation/g3/ble.cc @@ -25,7 +25,6 @@ #include "internal/platform/medium_environment.h" #include "internal/platform/implementation/shared/count_down_latch.h" -namespace location { namespace nearby { namespace g3 { @@ -375,4 +374,3 @@ std::unique_ptr BleMedium::Connect( } // namespace g3 } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/g3/ble.h b/internal/platform/implementation/g3/ble.h index 412635e9ca..7d105a9eae 100644 --- a/internal/platform/implementation/g3/ble.h +++ b/internal/platform/implementation/g3/ble.h @@ -31,7 +31,6 @@ #include "internal/platform/implementation/g3/multi_thread_executor.h" #include "internal/platform/implementation/g3/pipe.h" -namespace location { namespace nearby { namespace g3 { @@ -223,6 +222,5 @@ class BleMedium : public api::BleMedium { } // namespace g3 } // namespace nearby -} // namespace location #endif // PLATFORM_IMPL_G3_BLE_H_ diff --git a/internal/platform/implementation/g3/ble_v2.cc b/internal/platform/implementation/g3/ble_v2.cc index 6b0b8f3d44..4213e3b396 100644 --- a/internal/platform/implementation/g3/ble_v2.cc +++ b/internal/platform/implementation/g3/ble_v2.cc @@ -30,14 +30,13 @@ #include "internal/platform/logging.h" #include "internal/platform/medium_environment.h" -namespace location { namespace nearby { namespace g3 { namespace { -using ::location::nearby::api::ble_v2::BleAdvertisementData; -using ::location::nearby::api::ble_v2::TxPowerLevel; +using ::nearby::api::ble_v2::BleAdvertisementData; +using ::nearby::api::ble_v2::TxPowerLevel; std::string TxPowerLevelToName(TxPowerLevel power_mode) { switch (power_mode) { @@ -364,7 +363,7 @@ BleV2Medium::GattServer::CreateCharacteristic( bool BleV2Medium::GattServer::UpdateCharacteristic( const api::ble_v2::GattCharacteristic& characteristic, - const location::nearby::ByteArray& value) { + const nearby::ByteArray& value) { NEARBY_LOGS(INFO) << "G3 Ble GattServer UpdateCharacteristic, characteristic=(" << characteristic.service_uuid.Get16BitAsString() << "," @@ -540,4 +539,3 @@ std::unique_ptr BleV2Medium::Connect( } // namespace g3 } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/g3/ble_v2.h b/internal/platform/implementation/g3/ble_v2.h index a02e488eda..6977d55e42 100644 --- a/internal/platform/implementation/g3/ble_v2.h +++ b/internal/platform/implementation/g3/ble_v2.h @@ -30,7 +30,7 @@ #include "internal/platform/implementation/g3/pipe.h" #include "internal/platform/prng.h" #include "internal/platform/uuid.h" -namespace location { + namespace nearby { namespace g3 { @@ -219,7 +219,7 @@ class BleV2Medium : public api::ble_v2::BleMedium { bool UpdateCharacteristic( const api::ble_v2::GattCharacteristic& characteristic, - const location::nearby::ByteArray& value) override; + const nearby::ByteArray& value) override; void Stop() override; }; @@ -264,6 +264,5 @@ class BleV2Medium : public api::ble_v2::BleMedium { } // namespace g3 } // namespace nearby -} // namespace location #endif // PLATFORM_IMPL_G3_BLE_V2_H_ diff --git a/internal/platform/implementation/g3/bluetooth_adapter.cc b/internal/platform/implementation/g3/bluetooth_adapter.cc index e030a292b0..3bd5eb281b 100644 --- a/internal/platform/implementation/g3/bluetooth_adapter.cc +++ b/internal/platform/implementation/g3/bluetooth_adapter.cc @@ -21,7 +21,6 @@ #include "internal/platform/medium_environment.h" #include "internal/platform/prng.h" -namespace location { namespace nearby { namespace g3 { @@ -151,4 +150,3 @@ bool BluetoothAdapter::SetName(absl::string_view name, } // namespace g3 } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/g3/bluetooth_adapter.h b/internal/platform/implementation/g3/bluetooth_adapter.h index f9f7a0a7bc..b34e5ebad2 100644 --- a/internal/platform/implementation/g3/bluetooth_adapter.h +++ b/internal/platform/implementation/g3/bluetooth_adapter.h @@ -26,7 +26,6 @@ #include "internal/platform/implementation/bluetooth_classic.h" #include "internal/platform/implementation/g3/single_thread_executor.h" -namespace location { namespace nearby { namespace g3 { @@ -161,6 +160,5 @@ class BluetoothAdapter : public api::BluetoothAdapter { } // namespace g3 } // namespace nearby -} // namespace location #endif // PLATFORM_IMPL_G3_BLUETOOTH_ADAPTER_H_ diff --git a/internal/platform/implementation/g3/bluetooth_classic.cc b/internal/platform/implementation/g3/bluetooth_classic.cc index 8034778749..4fda2891c8 100644 --- a/internal/platform/implementation/g3/bluetooth_classic.cc +++ b/internal/platform/implementation/g3/bluetooth_classic.cc @@ -24,7 +24,6 @@ #include "internal/platform/medium_environment.h" #include "internal/platform/implementation/g3/bluetooth_adapter.h" -namespace location { namespace nearby { namespace g3 { @@ -275,4 +274,3 @@ api::BluetoothDevice* BluetoothClassicMedium::GetRemoteDevice( } // namespace g3 } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/g3/bluetooth_classic.h b/internal/platform/implementation/g3/bluetooth_classic.h index 93c82c4f11..ea60e4d513 100644 --- a/internal/platform/implementation/g3/bluetooth_classic.h +++ b/internal/platform/implementation/g3/bluetooth_classic.h @@ -30,7 +30,6 @@ #include "internal/platform/implementation/g3/bluetooth_adapter.h" #include "internal/platform/implementation/g3/pipe.h" -namespace location { namespace nearby { namespace g3 { @@ -233,6 +232,5 @@ class BluetoothClassicMedium : public api::BluetoothClassicMedium { } // namespace g3 } // namespace nearby -} // namespace location #endif // PLATFORM_IMPL_G3_BLUETOOTH_CLASSIC_H_ diff --git a/internal/platform/implementation/g3/condition_variable.h b/internal/platform/implementation/g3/condition_variable.h index ae513d269b..790749ef71 100644 --- a/internal/platform/implementation/g3/condition_variable.h +++ b/internal/platform/implementation/g3/condition_variable.h @@ -20,7 +20,6 @@ #include "internal/platform/exception.h" #include "internal/platform/implementation/g3/mutex.h" -namespace location { namespace nearby { namespace g3 { @@ -46,6 +45,5 @@ class ConditionVariable : public api::ConditionVariable { } // namespace g3 } // namespace nearby -} // namespace location #endif // PLATFORM_IMPL_G3_CONDITION_VARIABLE_H_ diff --git a/internal/platform/implementation/g3/credential_storage_impl.cc b/internal/platform/implementation/g3/credential_storage_impl.cc index f0f1fade83..f1a446fc22 100644 --- a/internal/platform/implementation/g3/credential_storage_impl.cc +++ b/internal/platform/implementation/g3/credential_storage_impl.cc @@ -24,7 +24,6 @@ #include "internal/platform/logging.h" #include "internal/proto/credential.pb.h" -namespace location { namespace nearby { namespace g3 { @@ -158,4 +157,3 @@ void CredentialStorageImpl::GetPublicCredentials( } } // namespace g3 } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/g3/credential_storage_impl.h b/internal/platform/implementation/g3/credential_storage_impl.h index 55f67529d9..01956dd4e2 100644 --- a/internal/platform/implementation/g3/credential_storage_impl.h +++ b/internal/platform/implementation/g3/credential_storage_impl.h @@ -28,7 +28,6 @@ #include "internal/platform/implementation/credential_storage.h" #include "internal/proto/credential.pb.h" -namespace location { namespace nearby { namespace g3 { @@ -90,6 +89,5 @@ class CredentialStorageImpl : public api::CredentialStorage { } // namespace g3 } // namespace nearby -} // namespace location #endif // THIRD_PARTY_NEARBY_INTERNAL_PLATFORM_IMPLEMENTATION_G3_CREDENTIAL_STORAGE_H_ diff --git a/internal/platform/implementation/g3/crypto.cc b/internal/platform/implementation/g3/crypto.cc index 40b079562e..adf4598641 100644 --- a/internal/platform/implementation/g3/crypto.cc +++ b/internal/platform/implementation/g3/crypto.cc @@ -21,7 +21,6 @@ #include "internal/platform/byte_array.h" #include -namespace location { namespace nearby { // Initialize global crypto state. @@ -50,4 +49,3 @@ ByteArray Crypto::Sha256(absl::string_view input) { } } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/g3/log_message.cc b/internal/platform/implementation/g3/log_message.cc index 045e1649a2..27ccb7d4d0 100644 --- a/internal/platform/implementation/g3/log_message.cc +++ b/internal/platform/implementation/g3/log_message.cc @@ -17,7 +17,6 @@ #include #include -namespace location { namespace nearby { namespace g3 { @@ -83,4 +82,3 @@ bool LogMessage::ShouldCreateLogMessage(Severity severity) { } // namespace api } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/g3/log_message.h b/internal/platform/implementation/g3/log_message.h index 4c5c8a4c35..423db804ac 100644 --- a/internal/platform/implementation/g3/log_message.h +++ b/internal/platform/implementation/g3/log_message.h @@ -18,7 +18,6 @@ #include "glog/logging.h" #include "internal/platform/implementation/log_message.h" -namespace location { namespace nearby { namespace g3 { @@ -39,6 +38,5 @@ class LogMessage : public api::LogMessage { } // namespace g3 } // namespace nearby -} // namespace location #endif // PLATFORM_IMPL_G3_LOG_MESSAGE_H_ diff --git a/internal/platform/implementation/g3/multi_thread_executor.h b/internal/platform/implementation/g3/multi_thread_executor.h index 106fb8eeae..8394d473cd 100644 --- a/internal/platform/implementation/g3/multi_thread_executor.h +++ b/internal/platform/implementation/g3/multi_thread_executor.h @@ -22,7 +22,6 @@ #include "internal/platform/implementation/shared/count_down_latch.h" #include "nisaba/port/thread_pool.h" -namespace location { namespace nearby { namespace g3 { @@ -61,6 +60,5 @@ class MultiThreadExecutor : public api::SubmittableExecutor { } // namespace g3 } // namespace nearby -} // namespace location #endif // PLATFORM_IMPL_G3_MULTI_THREAD_EXECUTOR_H_ diff --git a/internal/platform/implementation/g3/mutex.h b/internal/platform/implementation/g3/mutex.h index 962c506d0d..c808731fee 100644 --- a/internal/platform/implementation/g3/mutex.h +++ b/internal/platform/implementation/g3/mutex.h @@ -19,7 +19,6 @@ #include "internal/platform/implementation/mutex.h" #include "internal/platform/implementation/shared/posix_mutex.h" -namespace location { namespace nearby { namespace g3 { @@ -56,6 +55,5 @@ class ABSL_LOCKABLE RecursiveMutex : public posix::Mutex { } // namespace g3 } // namespace nearby -} // namespace location #endif // PLATFORM_IMPL_G3_MUTEX_H_ diff --git a/internal/platform/implementation/g3/pipe.h b/internal/platform/implementation/g3/pipe.h index 842cf7d6a3..3c2f7f2423 100644 --- a/internal/platform/implementation/g3/pipe.h +++ b/internal/platform/implementation/g3/pipe.h @@ -21,7 +21,6 @@ #include "internal/platform/implementation/g3/condition_variable.h" #include "internal/platform/implementation/g3/mutex.h" -namespace location { namespace nearby { namespace g3 { @@ -39,6 +38,5 @@ class Pipe : public BasePipe { } // namespace g3 } // namespace nearby -} // namespace location #endif // PLATFORM_IMPL_G3_PIPE_H_ diff --git a/internal/platform/implementation/g3/platform.cc b/internal/platform/implementation/g3/platform.cc index 7a1513810d..2dc4b19c71 100644 --- a/internal/platform/implementation/g3/platform.cc +++ b/internal/platform/implementation/g3/platform.cc @@ -61,7 +61,6 @@ #include "internal/platform/implementation/wifi.h" #include "internal/platform/medium_environment.h" -namespace location { namespace nearby { namespace api { @@ -227,4 +226,3 @@ ImplementationPlatform::CreateConditionVariable(Mutex* mutex) { } // namespace api } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/g3/scheduled_executor.cc b/internal/platform/implementation/g3/scheduled_executor.cc index 2013f20f4f..f198cb24cd 100644 --- a/internal/platform/implementation/g3/scheduled_executor.cc +++ b/internal/platform/implementation/g3/scheduled_executor.cc @@ -21,7 +21,6 @@ #include "internal/platform/implementation/cancelable.h" #include "internal/platform/runnable.h" -namespace location { namespace nearby { namespace g3 { @@ -76,4 +75,3 @@ std::shared_ptr ScheduledExecutor::Schedule( } // namespace g3 } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/g3/scheduled_executor.h b/internal/platform/implementation/g3/scheduled_executor.h index 2c1c3baae6..5b5a7537b5 100644 --- a/internal/platform/implementation/g3/scheduled_executor.h +++ b/internal/platform/implementation/g3/scheduled_executor.h @@ -25,7 +25,6 @@ #include "internal/platform/implementation/g3/single_thread_executor.h" #include "nisaba/port/thread_pool.h" -namespace location { namespace nearby { namespace g3 { @@ -49,6 +48,5 @@ class ScheduledExecutor final : public api::ScheduledExecutor { } // namespace g3 } // namespace nearby -} // namespace location #endif // PLATFORM_IMPL_G3_SCHEDULED_EXECUTOR_H_ diff --git a/internal/platform/implementation/g3/single_thread_executor.h b/internal/platform/implementation/g3/single_thread_executor.h index 1164e62904..2aecce573e 100644 --- a/internal/platform/implementation/g3/single_thread_executor.h +++ b/internal/platform/implementation/g3/single_thread_executor.h @@ -17,7 +17,6 @@ #include "internal/platform/implementation/g3/multi_thread_executor.h" -namespace location { namespace nearby { namespace g3 { @@ -31,6 +30,5 @@ class SingleThreadExecutor final : public MultiThreadExecutor { } // namespace g3 } // namespace nearby -} // namespace location #endif // PLATFORM_IMPL_G3_SINGLE_THREAD_EXECUTOR_H_ diff --git a/internal/platform/implementation/g3/system_clock.cc b/internal/platform/implementation/g3/system_clock.cc index 2a860aa273..5c32210a6d 100644 --- a/internal/platform/implementation/g3/system_clock.cc +++ b/internal/platform/implementation/g3/system_clock.cc @@ -17,7 +17,6 @@ #include "absl/time/clock.h" #include "internal/platform/exception.h" -namespace location { namespace nearby { absl::Time SystemClock::ElapsedRealtime() { return absl::Now(); } @@ -27,4 +26,3 @@ Exception SystemClock::Sleep(absl::Duration duration) { } } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/g3/webrtc.cc b/internal/platform/implementation/g3/webrtc.cc index 55da077d6a..69ccb160f6 100644 --- a/internal/platform/implementation/g3/webrtc.cc +++ b/internal/platform/implementation/g3/webrtc.cc @@ -20,12 +20,12 @@ #include "webrtc/api/task_queue/default_task_queue_factory.h" #include "webrtc/rtc_base/checks.h" -namespace location { namespace nearby { namespace g3 { +using ::location::nearby::connections::LocationHint; WebRtcSignalingMessenger::WebRtcSignalingMessenger( - absl::string_view self_id, const connections::LocationHint& location_hint) + absl::string_view self_id, const LocationHint& location_hint) : self_id_(self_id), location_hint_(location_hint) {} bool WebRtcSignalingMessenger::SendMessage(absl::string_view peer_id, @@ -90,11 +90,10 @@ void WebRtcMedium::CreatePeerConnection( } std::unique_ptr -WebRtcMedium::GetSignalingMessenger( - absl::string_view self_id, const connections::LocationHint& location_hint) { +WebRtcMedium::GetSignalingMessenger(absl::string_view self_id, + const LocationHint& location_hint) { return std::make_unique(self_id, location_hint); } } // namespace g3 } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/g3/webrtc.h b/internal/platform/implementation/g3/webrtc.h index 2edeb8dff0..bb88a0cc29 100644 --- a/internal/platform/implementation/g3/webrtc.h +++ b/internal/platform/implementation/g3/webrtc.h @@ -22,7 +22,6 @@ #include "internal/platform/implementation/g3/single_thread_executor.h" #include "webrtc/api/peer_connection_interface.h" -namespace location { namespace nearby { namespace g3 { @@ -35,7 +34,7 @@ class WebRtcSignalingMessenger : public api::WebRtcSignalingMessenger { explicit WebRtcSignalingMessenger( absl::string_view self_id, - const connections::LocationHint& location_hint); + const location::nearby::connections::LocationHint& location_hint); ~WebRtcSignalingMessenger() override = default; bool SendMessage(absl::string_view peer_id, @@ -47,7 +46,7 @@ class WebRtcSignalingMessenger : public api::WebRtcSignalingMessenger { private: std::string self_id_; - connections::LocationHint location_hint_; + location::nearby::connections::LocationHint location_hint_; }; class WebRtcMedium : public api::WebRtcMedium { @@ -67,7 +66,8 @@ class WebRtcMedium : public api::WebRtcMedium { // Returns a signaling messenger for sending WebRTC signaling messages. std::unique_ptr GetSignalingMessenger( absl::string_view self_id, - const connections::LocationHint& location_hint) override; + const location::nearby::connections::LocationHint& location_hint) + override; private: // Executor for handling calls to create a peer connection. @@ -76,6 +76,5 @@ class WebRtcMedium : public api::WebRtcMedium { } // namespace g3 } // namespace nearby -} // namespace location #endif // PLATFORM_IMPL_G3_WEBRTC_H_ diff --git a/internal/platform/implementation/g3/wifi.h b/internal/platform/implementation/g3/wifi.h index be7f12bc47..0d8014afcd 100644 --- a/internal/platform/implementation/g3/wifi.h +++ b/internal/platform/implementation/g3/wifi.h @@ -23,7 +23,6 @@ #include "internal/platform/logging.h" #include "internal/platform/medium_environment.h" -namespace location { namespace nearby { namespace g3 { @@ -115,6 +114,5 @@ class WifiMedium : public api::WifiMedium { } // namespace g3 } // namespace nearby -} // namespace location #endif // PLATFORM_IMPL_G3_WIFI_H_ diff --git a/internal/platform/implementation/g3/wifi_direct.cc b/internal/platform/implementation/g3/wifi_direct.cc index 0c8f56f047..f1fc4af30c 100644 --- a/internal/platform/implementation/g3/wifi_direct.cc +++ b/internal/platform/implementation/g3/wifi_direct.cc @@ -27,7 +27,6 @@ #include "internal/platform/logging.h" #include "internal/platform/medium_environment.h" -namespace location { namespace nearby { namespace g3 { @@ -321,4 +320,3 @@ WifiDirectMedium::ListenForService(int port) { } // namespace g3 } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/g3/wifi_direct.h b/internal/platform/implementation/g3/wifi_direct.h index 5866f391d6..edcbceb0b9 100644 --- a/internal/platform/implementation/g3/wifi_direct.h +++ b/internal/platform/implementation/g3/wifi_direct.h @@ -28,7 +28,6 @@ #include "internal/platform/input_stream.h" #include "internal/platform/output_stream.h" -namespace location { namespace nearby { namespace g3 { @@ -216,6 +215,5 @@ class WifiDirectMedium : public api::WifiDirectMedium { } // namespace g3 } // namespace nearby -} // namespace location #endif // PLATFORM_IMPL_G3_WIFI_DIRECT_H_ diff --git a/internal/platform/implementation/g3/wifi_hotspot.cc b/internal/platform/implementation/g3/wifi_hotspot.cc index b74115f46e..a772ea74cb 100644 --- a/internal/platform/implementation/g3/wifi_hotspot.cc +++ b/internal/platform/implementation/g3/wifi_hotspot.cc @@ -28,7 +28,6 @@ #include "internal/platform/logging.h" #include "internal/platform/medium_environment.h" -namespace location { namespace nearby { namespace g3 { @@ -343,4 +342,3 @@ WifiHotspotMedium::ListenForService(int port) { } // namespace g3 } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/g3/wifi_hotspot.h b/internal/platform/implementation/g3/wifi_hotspot.h index 7ab67258b0..e6d4891898 100644 --- a/internal/platform/implementation/g3/wifi_hotspot.h +++ b/internal/platform/implementation/g3/wifi_hotspot.h @@ -29,7 +29,6 @@ #include "internal/platform/implementation/g3/multi_thread_executor.h" #include "internal/platform/implementation/g3/pipe.h" -namespace location { namespace nearby { namespace g3 { @@ -224,6 +223,5 @@ class WifiHotspotMedium : public api::WifiHotspotMedium { } // namespace g3 } // namespace nearby -} // namespace location #endif // PLATFORM_IMPL_G3_WIFI_HOTSPOT_H_ diff --git a/internal/platform/implementation/g3/wifi_lan.cc b/internal/platform/implementation/g3/wifi_lan.cc index e07de9a699..70aaef3b4e 100644 --- a/internal/platform/implementation/g3/wifi_lan.cc +++ b/internal/platform/implementation/g3/wifi_lan.cc @@ -28,7 +28,6 @@ #include "internal/platform/medium_environment.h" #include "internal/platform/nsd_service_info.h" -namespace location { namespace nearby { namespace g3 { @@ -368,4 +367,3 @@ std::unique_ptr WifiLanMedium::ListenForService( } // namespace g3 } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/g3/wifi_lan.h b/internal/platform/implementation/g3/wifi_lan.h index 8b560f80c3..12634e44b4 100644 --- a/internal/platform/implementation/g3/wifi_lan.h +++ b/internal/platform/implementation/g3/wifi_lan.h @@ -30,7 +30,6 @@ #include "internal/platform/implementation/g3/multi_thread_executor.h" #include "internal/platform/implementation/g3/pipe.h" -namespace location { namespace nearby { namespace g3 { @@ -283,6 +282,5 @@ class WifiLanMedium : public api::WifiLanMedium { } // namespace g3 } // namespace nearby -} // namespace location #endif // PLATFORM_IMPL_G3_WIFI_LAN_H_ diff --git a/internal/platform/implementation/http_loader.h b/internal/platform/implementation/http_loader.h index ba4d11a43e..ceca08fcca 100644 --- a/internal/platform/implementation/http_loader.h +++ b/internal/platform/implementation/http_loader.h @@ -18,7 +18,6 @@ #include #include -namespace location { namespace nearby { namespace api { @@ -38,6 +37,5 @@ struct WebResponse { } // namespace api } // namespace nearby -} // namespace location #endif // THIRD_PARTY_NEARBY_INTERNAL_PLATFORM_IMPLEMENTATION_HTTP_LOADER_H_ diff --git a/internal/platform/implementation/input_file.h b/internal/platform/implementation/input_file.h index 4129b52a9f..45d2d74adf 100644 --- a/internal/platform/implementation/input_file.h +++ b/internal/platform/implementation/input_file.h @@ -21,7 +21,6 @@ #include "internal/platform/exception.h" #include "internal/platform/input_stream.h" -namespace location { namespace nearby { namespace api { @@ -35,6 +34,5 @@ class InputFile : public InputStream { } // namespace api } // namespace nearby -} // namespace location #endif // PLATFORM_API_INPUT_FILE_H_ diff --git a/internal/platform/implementation/listenable_future.h b/internal/platform/implementation/listenable_future.h index f91a83dc34..acedb7ac64 100644 --- a/internal/platform/implementation/listenable_future.h +++ b/internal/platform/implementation/listenable_future.h @@ -23,7 +23,6 @@ #include "internal/platform/exception.h" #include "internal/platform/runnable.h" -namespace location { namespace nearby { namespace api { @@ -40,6 +39,5 @@ class ListenableFuture : public Future { } // namespace api } // namespace nearby -} // namespace location #endif // PLATFORM_API_LISTENABLE_FUTURE_H_ diff --git a/internal/platform/implementation/log_message.h b/internal/platform/implementation/log_message.h index 3f43c0bc35..ffa9c41fdf 100644 --- a/internal/platform/implementation/log_message.h +++ b/internal/platform/implementation/log_message.h @@ -17,7 +17,6 @@ #include -namespace location { namespace nearby { namespace api { @@ -54,6 +53,5 @@ class LogMessage { } // namespace api } // namespace nearby -} // namespace location #endif // PLATFORM_API_LOG_MESSAGE_H_ diff --git a/internal/platform/implementation/mutex.h b/internal/platform/implementation/mutex.h index 19c11adcf1..622f105621 100644 --- a/internal/platform/implementation/mutex.h +++ b/internal/platform/implementation/mutex.h @@ -17,7 +17,6 @@ #include "absl/base/thread_annotations.h" -namespace location { namespace nearby { namespace api { @@ -50,6 +49,5 @@ class ABSL_LOCKABLE Mutex { } // namespace api } // namespace nearby -} // namespace location #endif // PLATFORM_API_MUTEX_H_ diff --git a/internal/platform/implementation/output_file.h b/internal/platform/implementation/output_file.h index 9c21f9eca6..f82502ce9c 100644 --- a/internal/platform/implementation/output_file.h +++ b/internal/platform/implementation/output_file.h @@ -19,7 +19,6 @@ #include "internal/platform/exception.h" #include "internal/platform/output_stream.h" -namespace location { namespace nearby { namespace api { @@ -31,6 +30,5 @@ class OutputFile : public OutputStream { } // namespace api } // namespace nearby -} // namespace location #endif // PLATFORM_API_OUTPUT_FILE_H_ diff --git a/internal/platform/implementation/platform.h b/internal/platform/implementation/platform.h index a6b9a87bc8..9fda07a562 100644 --- a/internal/platform/implementation/platform.h +++ b/internal/platform/implementation/platform.h @@ -51,7 +51,6 @@ #include "internal/platform/os_name.h" #include "internal/platform/payload_id.h" -namespace location { namespace nearby { namespace api { @@ -145,6 +144,5 @@ class ImplementationPlatform { } // namespace api } // namespace nearby -} // namespace location #endif // PLATFORM_API_PLATFORM_H_ diff --git a/internal/platform/implementation/scheduled_executor.h b/internal/platform/implementation/scheduled_executor.h index 95676a119e..65f30dfe3c 100644 --- a/internal/platform/implementation/scheduled_executor.h +++ b/internal/platform/implementation/scheduled_executor.h @@ -24,7 +24,6 @@ #include "internal/platform/implementation/executor.h" #include "internal/platform/runnable.h" -namespace location { namespace nearby { namespace api { @@ -45,6 +44,5 @@ class ScheduledExecutor : public Executor { } // namespace api } // namespace nearby -} // namespace location #endif // PLATFORM_API_SCHEDULED_EXECUTOR_H_ diff --git a/internal/platform/implementation/server_sync.h b/internal/platform/implementation/server_sync.h index e51f6f891a..400af7d71d 100644 --- a/internal/platform/implementation/server_sync.h +++ b/internal/platform/implementation/server_sync.h @@ -20,7 +20,6 @@ #include "absl/strings/string_view.h" #include "internal/platform/byte_array.h" -namespace location { namespace nearby { namespace api { @@ -71,6 +70,5 @@ class ServerSyncMedium { } // namespace api } // namespace nearby -} // namespace location #endif // PLATFORM_API_SERVER_SYNC_H_ diff --git a/internal/platform/implementation/settable_future.h b/internal/platform/implementation/settable_future.h index ee49d29121..beb32f0bac 100644 --- a/internal/platform/implementation/settable_future.h +++ b/internal/platform/implementation/settable_future.h @@ -18,7 +18,6 @@ #include "internal/platform/implementation/listenable_future.h" #include "internal/platform/exception.h" -namespace location { namespace nearby { namespace api { @@ -44,6 +43,5 @@ class SettableFuture : public ListenableFuture { } // namespace api } // namespace nearby -} // namespace location #endif // PLATFORM_API_SETTABLE_FUTURE_H_ diff --git a/internal/platform/implementation/shared/count_down_latch.cc b/internal/platform/implementation/shared/count_down_latch.cc index 3a667152db..f951196b62 100644 --- a/internal/platform/implementation/shared/count_down_latch.cc +++ b/internal/platform/implementation/shared/count_down_latch.cc @@ -14,7 +14,6 @@ #include "internal/platform/implementation/shared/count_down_latch.h" -namespace location { namespace nearby { namespace shared { @@ -51,4 +50,3 @@ void CountDownLatch::CountDown() { } // namespace shared } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/shared/count_down_latch.h b/internal/platform/implementation/shared/count_down_latch.h index 2a7db549ec..1b909eb06e 100644 --- a/internal/platform/implementation/shared/count_down_latch.h +++ b/internal/platform/implementation/shared/count_down_latch.h @@ -20,7 +20,6 @@ #include "absl/time/clock.h" #include "internal/platform/implementation/count_down_latch.h" -namespace location { namespace nearby { namespace shared { @@ -48,6 +47,5 @@ class CountDownLatch final : public api::CountDownLatch { } // namespace shared } // namespace nearby -} // namespace location #endif // PLATFORM_IMPL_G3_COUNT_DOWN_LATCH_H_ diff --git a/internal/platform/implementation/shared/file.cc b/internal/platform/implementation/shared/file.cc index ee5f4966df..97ffe94761 100644 --- a/internal/platform/implementation/shared/file.cc +++ b/internal/platform/implementation/shared/file.cc @@ -24,7 +24,6 @@ #include "absl/strings/string_view.h" #include "internal/platform/exception.h" -namespace location { namespace nearby { namespace shared { @@ -103,4 +102,3 @@ Exception IOFile::Flush() { } // namespace shared } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/shared/file.h b/internal/platform/implementation/shared/file.h index fa96bbf55b..bf4b77a0c5 100644 --- a/internal/platform/implementation/shared/file.h +++ b/internal/platform/implementation/shared/file.h @@ -24,7 +24,6 @@ #include "internal/platform/implementation/input_file.h" #include "internal/platform/implementation/output_file.h" -namespace location { namespace nearby { namespace shared { @@ -56,6 +55,5 @@ class IOFile final : public api::InputFile, public api::OutputFile { } // namespace shared } // namespace nearby -} // namespace location #endif // PLATFORM_IMPL_SHARED_FILE_H_ diff --git a/internal/platform/implementation/shared/file_test.cc b/internal/platform/implementation/shared/file_test.cc index b4abf193cb..eb65d5c19a 100644 --- a/internal/platform/implementation/shared/file_test.cc +++ b/internal/platform/implementation/shared/file_test.cc @@ -25,7 +25,6 @@ #include "absl/strings/string_view.h" #include "internal/platform/byte_array.h" -namespace location { namespace nearby { namespace shared { @@ -148,4 +147,3 @@ TEST_F(FileTest, IOFile_CloseOutput) { } // namespace shared } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/shared/posix_condition_variable.cc b/internal/platform/implementation/shared/posix_condition_variable.cc index 97cabc8c16..d239fee5d0 100644 --- a/internal/platform/implementation/shared/posix_condition_variable.cc +++ b/internal/platform/implementation/shared/posix_condition_variable.cc @@ -14,7 +14,6 @@ #include "internal/platform/implementation/shared/posix_condition_variable.h" -namespace location { namespace nearby { namespace posix { @@ -41,4 +40,3 @@ Exception ConditionVariable::Wait() { } // namespace posix } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/shared/posix_condition_variable.h b/internal/platform/implementation/shared/posix_condition_variable.h index 69b10a854a..2bb66f24e7 100644 --- a/internal/platform/implementation/shared/posix_condition_variable.h +++ b/internal/platform/implementation/shared/posix_condition_variable.h @@ -20,7 +20,6 @@ #include "internal/platform/implementation/condition_variable.h" #include "internal/platform/implementation/shared/posix_mutex.h" -namespace location { namespace nearby { namespace posix { @@ -40,6 +39,5 @@ class ConditionVariable : public api::ConditionVariable { } // namespace posix } // namespace nearby -} // namespace location #endif // PLATFORM_IMPL_SHARED_POSIX_CONDITION_VARIABLE_H_ diff --git a/internal/platform/implementation/shared/posix_mutex.cc b/internal/platform/implementation/shared/posix_mutex.cc index efd769f2f9..e5d3ac155e 100644 --- a/internal/platform/implementation/shared/posix_mutex.cc +++ b/internal/platform/implementation/shared/posix_mutex.cc @@ -14,7 +14,6 @@ #include "internal/platform/implementation/shared/posix_mutex.h" -namespace location { namespace nearby { namespace posix { @@ -37,4 +36,3 @@ void Mutex::Unlock() { pthread_mutex_unlock(&mutex_); } } // namespace posix } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/shared/posix_mutex.h b/internal/platform/implementation/shared/posix_mutex.h index 2de9bf7aab..b1d15d0a03 100644 --- a/internal/platform/implementation/shared/posix_mutex.h +++ b/internal/platform/implementation/shared/posix_mutex.h @@ -19,7 +19,6 @@ #include "internal/platform/implementation/mutex.h" -namespace location { namespace nearby { namespace posix { @@ -40,6 +39,5 @@ class ABSL_LOCKABLE Mutex : public api::Mutex { } // namespace posix } // namespace nearby -} // namespace location #endif // PLATFORM_IMPL_SHARED_POSIX_MUTEX_H_ diff --git a/internal/platform/implementation/submittable_executor.h b/internal/platform/implementation/submittable_executor.h index 347d01531c..d4b30e95b9 100644 --- a/internal/platform/implementation/submittable_executor.h +++ b/internal/platform/implementation/submittable_executor.h @@ -22,7 +22,6 @@ #include "internal/platform/implementation/future.h" #include "internal/platform/runnable.h" -namespace location { namespace nearby { namespace api { @@ -42,6 +41,5 @@ class SubmittableExecutor : public Executor { } // namespace api } // namespace nearby -} // namespace location #endif // PLATFORM_API_SUBMITTABLE_EXECUTOR_H_ diff --git a/internal/platform/implementation/system_clock.h b/internal/platform/implementation/system_clock.h index 4e0e1a25f2..ad7597f433 100644 --- a/internal/platform/implementation/system_clock.h +++ b/internal/platform/implementation/system_clock.h @@ -18,7 +18,6 @@ #include "absl/time/clock.h" #include "internal/platform/exception.h" -namespace location { namespace nearby { class SystemClock final { @@ -32,6 +31,5 @@ class SystemClock final { }; } // namespace nearby -} // namespace location #endif // PLATFORM_API_SYSTEM_CLOCK_H_ diff --git a/internal/platform/implementation/webrtc.h b/internal/platform/implementation/webrtc.h index 723d682eae..581eb502aa 100644 --- a/internal/platform/implementation/webrtc.h +++ b/internal/platform/implementation/webrtc.h @@ -24,7 +24,6 @@ #include "internal/platform/byte_array.h" #include "webrtc/api/peer_connection_interface.h" -namespace location { namespace nearby { namespace api { @@ -63,11 +62,10 @@ class WebRtcMedium { // Returns a signaling messenger for sending WebRTC signaling messages. virtual std::unique_ptr GetSignalingMessenger( absl::string_view self_id, - const connections::LocationHint& location_hint) = 0; + const location::nearby::connections::LocationHint& location_hint) = 0; }; } // namespace api } // namespace nearby -} // namespace location #endif // PLATFORM_API_WEBRTC_H_ diff --git a/internal/platform/implementation/wifi.h b/internal/platform/implementation/wifi.h index 81f718379c..1a0df38e40 100644 --- a/internal/platform/implementation/wifi.h +++ b/internal/platform/implementation/wifi.h @@ -21,7 +21,6 @@ #include "absl/strings/string_view.h" -namespace location { namespace nearby { namespace api { @@ -139,6 +138,5 @@ class WifiMedium { } // namespace api } // namespace nearby -} // namespace location #endif // PLATFORM_API_WIFI_H_ diff --git a/internal/platform/implementation/wifi_direct.h b/internal/platform/implementation/wifi_direct.h index 431f41fab4..db88d13dab 100644 --- a/internal/platform/implementation/wifi_direct.h +++ b/internal/platform/implementation/wifi_direct.h @@ -24,7 +24,6 @@ #include "internal/platform/output_stream.h" #include "internal/platform/wifi_hotspot_credential.h" -namespace location { namespace nearby { namespace api { @@ -115,6 +114,5 @@ class WifiDirectMedium { } // namespace api } // namespace nearby -} // namespace location #endif // PLATFORM_API_WIFI_DIRECT_H_ diff --git a/internal/platform/implementation/wifi_hotspot.h b/internal/platform/implementation/wifi_hotspot.h index 29b519ca41..f9ff2c8003 100644 --- a/internal/platform/implementation/wifi_hotspot.h +++ b/internal/platform/implementation/wifi_hotspot.h @@ -23,7 +23,6 @@ #include "internal/platform/output_stream.h" #include "internal/platform/wifi_hotspot_credential.h" -namespace location { namespace nearby { namespace api { @@ -112,6 +111,5 @@ class WifiHotspotMedium { } // namespace api } // namespace nearby -} // namespace location #endif // PLATFORM_API_WIFI_HOTSPOT_H_ diff --git a/internal/platform/implementation/wifi_lan.h b/internal/platform/implementation/wifi_lan.h index 34788f9e8a..3e82eb1b7e 100644 --- a/internal/platform/implementation/wifi_lan.h +++ b/internal/platform/implementation/wifi_lan.h @@ -23,7 +23,6 @@ #include "internal/platform/nsd_service_info.h" #include "internal/platform/output_stream.h" -namespace location { namespace nearby { namespace api { @@ -155,6 +154,5 @@ class WifiLanMedium { } // namespace api } // namespace nearby -} // namespace location #endif // PLATFORM_API_WIFI_LAN_H_ diff --git a/internal/platform/implementation/windows/atomic_boolean.h b/internal/platform/implementation/windows/atomic_boolean.h index 142d17c1ab..53b477739a 100644 --- a/internal/platform/implementation/windows/atomic_boolean.h +++ b/internal/platform/implementation/windows/atomic_boolean.h @@ -19,7 +19,6 @@ #include "internal/platform/implementation/atomic_boolean.h" -namespace location { namespace nearby { namespace windows { @@ -40,6 +39,5 @@ class AtomicBoolean : public api::AtomicBoolean { } // namespace windows } // namespace nearby -} // namespace location #endif // PLATFORM_IMPL_WINDOWS_ATOMIC_BOOLEAN_H_ diff --git a/internal/platform/implementation/windows/atomic_boolean_test.cc b/internal/platform/implementation/windows/atomic_boolean_test.cc index 7c20d6e2d8..9adfef48ec 100644 --- a/internal/platform/implementation/windows/atomic_boolean_test.cc +++ b/internal/platform/implementation/windows/atomic_boolean_test.cc @@ -18,7 +18,7 @@ TEST(atomic_boolean, SuccessfulCreation) { // Arrange - location::nearby::windows::AtomicBoolean atomicBoolean; + nearby::windows::AtomicBoolean atomicBoolean; bool oldValue = true; bool result = false; diff --git a/internal/platform/implementation/windows/atomic_reference.h b/internal/platform/implementation/windows/atomic_reference.h index 1e83c2a77b..c6684074cd 100644 --- a/internal/platform/implementation/windows/atomic_reference.h +++ b/internal/platform/implementation/windows/atomic_reference.h @@ -19,7 +19,6 @@ #include "internal/platform/implementation/atomic_reference.h" -namespace location { namespace nearby { namespace windows { @@ -40,6 +39,5 @@ class AtomicUint32 : public api::AtomicUint32 { } // namespace windows } // namespace nearby -} // namespace location #endif // PLATFORM_IMPL_WINDOWS_ATOMIC_REFERENCE_H_ diff --git a/internal/platform/implementation/windows/atomic_reference_test.cc b/internal/platform/implementation/windows/atomic_reference_test.cc index c5565b3abc..d118b8c676 100644 --- a/internal/platform/implementation/windows/atomic_reference_test.cc +++ b/internal/platform/implementation/windows/atomic_reference_test.cc @@ -18,7 +18,7 @@ TEST(atomic_reference, SuccessfulCreation) { // Arrange - location::nearby::windows::AtomicUint32 atomicUint32; + nearby::windows::AtomicUint32 atomicUint32; uint32_t result = UINT32_MAX; const uint32_t expected = 0; @@ -31,7 +31,7 @@ TEST(atomic_reference, SuccessfulCreation) { TEST(atomic_reference, SuccessfulMaxSet) { // Arrange - location::nearby::windows::AtomicUint32 atomicUint32; + nearby::windows::AtomicUint32 atomicUint32; uint32_t result = 0; const uint32_t expected = UINT32_MAX; @@ -45,7 +45,7 @@ TEST(atomic_reference, SuccessfulMaxSet) { TEST(atomic_reference, SuccessfulMinSet) { // Arrange - location::nearby::windows::AtomicUint32 atomicUint32; + nearby::windows::AtomicUint32 atomicUint32; uint32_t result = UINT32_MAX; const uint32_t expected = 0; @@ -59,7 +59,7 @@ TEST(atomic_reference, SuccessfulMinSet) { TEST(atomic_reference, SetNegativeOneReturnsMAXUINT) { // Arrange - location::nearby::windows::AtomicUint32 atomicUint32; + nearby::windows::AtomicUint32 atomicUint32; uint32_t result = 0; const uint32_t expected = UINT32_MAX; diff --git a/internal/platform/implementation/windows/ble_medium.cc b/internal/platform/implementation/windows/ble_medium.cc index c8459cf62e..d903cc1ad9 100644 --- a/internal/platform/implementation/windows/ble_medium.cc +++ b/internal/platform/implementation/windows/ble_medium.cc @@ -35,7 +35,6 @@ #include "winrt/Windows.Storage.Streams.h" #include "winrt/base.h" -namespace location { namespace nearby { namespace windows { namespace { @@ -609,4 +608,3 @@ void BleMedium::AdvertisementReceivedHandler( } // namespace windows } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/windows/ble_medium.h b/internal/platform/implementation/windows/ble_medium.h index e04ab8e41e..0ef77678e2 100644 --- a/internal/platform/implementation/windows/ble_medium.h +++ b/internal/platform/implementation/windows/ble_medium.h @@ -31,7 +31,6 @@ #include "internal/platform/implementation/windows/bluetooth_adapter.h" #include "winrt/Windows.Devices.Bluetooth.Advertisement.h" -namespace location { namespace nearby { namespace windows { @@ -120,7 +119,6 @@ class BleMedium : public api::BleMedium { } // namespace windows } // namespace nearby -} // namespace location #endif // THIRD_PARTY_NEARBY_INTERNAL_PLATFORM_IMPLEMENTATION_WINDOWS_BLE_MEDIUM_H_ diff --git a/internal/platform/implementation/windows/ble_medium_test.cc b/internal/platform/implementation/windows/ble_medium_test.cc index 5a894411a6..027f3cce3e 100644 --- a/internal/platform/implementation/windows/ble_medium_test.cc +++ b/internal/platform/implementation/windows/ble_medium_test.cc @@ -25,7 +25,6 @@ #include "internal/platform/implementation/windows/ble.h" #include "internal/platform/implementation/windows/bluetooth_adapter.h" -namespace location { namespace nearby { namespace windows { namespace { @@ -308,4 +307,3 @@ TEST(BleMedium, DISABLED_StopScanning) { } // namespace } // namespace windows } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/windows/ble_peripheral.h b/internal/platform/implementation/windows/ble_peripheral.h index 2aa709671a..0b57f54d24 100644 --- a/internal/platform/implementation/windows/ble_peripheral.h +++ b/internal/platform/implementation/windows/ble_peripheral.h @@ -19,7 +19,6 @@ #include "internal/platform/implementation/ble.h" -namespace location { namespace nearby { namespace windows { @@ -57,6 +56,5 @@ class BlePeripheral : public api::BlePeripheral { } // namespace windows } // namespace nearby -} // namespace location #endif // THIRD_PARTY_NEARBY_INTERNAL_PLATFORM_IMPLEMENTATION_WINDOWS_BLE_PERIPHERAL_H_ diff --git a/internal/platform/implementation/windows/ble_socket.cc b/internal/platform/implementation/windows/ble_socket.cc index 1bb516b3d5..1b3210e6b7 100644 --- a/internal/platform/implementation/windows/ble_socket.cc +++ b/internal/platform/implementation/windows/ble_socket.cc @@ -17,7 +17,6 @@ #include "absl/synchronization/mutex.h" #include "internal/platform/implementation/ble.h" -namespace location { namespace nearby { namespace windows { @@ -46,4 +45,3 @@ BlePeripheral* BleSocket::GetRemotePeripheral() { } // namespace windows } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/windows/ble_socket.h b/internal/platform/implementation/windows/ble_socket.h index a1232ef726..fdf28e8fdd 100644 --- a/internal/platform/implementation/windows/ble_socket.h +++ b/internal/platform/implementation/windows/ble_socket.h @@ -21,7 +21,6 @@ #include "internal/platform/input_stream.h" #include "internal/platform/output_stream.h" -namespace location { namespace nearby { namespace windows { @@ -78,6 +77,5 @@ class BleSocket : public api::BleSocket { } // namespace windows } // namespace nearby -} // namespace location #endif // THIRD_PARTY_NEARBY_INTERNAL_PLATFORM_IMPLEMENTATION_WINDOWS_BLE_SOCKET_H_ diff --git a/internal/platform/implementation/windows/ble_v2.cc b/internal/platform/implementation/windows/ble_v2.cc index 1d52aaa5d7..61031de4d6 100644 --- a/internal/platform/implementation/windows/ble_v2.cc +++ b/internal/platform/implementation/windows/ble_v2.cc @@ -25,19 +25,18 @@ #include "winrt/Windows.Devices.Bluetooth.h" #include "winrt/Windows.Foundation.Collections.h" -namespace location { namespace nearby { namespace windows { namespace { -using ::location::nearby::api::ble_v2::AdvertiseParameters; -using ::location::nearby::api::ble_v2::BleAdvertisementData; -using ::location::nearby::api::ble_v2::BleServerSocket; -using ::location::nearby::api::ble_v2::BleSocket; -using ::location::nearby::api::ble_v2::GattClient; -using ::location::nearby::api::ble_v2::ServerGattConnectionCallback; -using ::location::nearby::api::ble_v2::TxPowerLevel; +using ::nearby::api::ble_v2::AdvertiseParameters; +using ::nearby::api::ble_v2::BleAdvertisementData; +using ::nearby::api::ble_v2::BleServerSocket; +using ::nearby::api::ble_v2::BleSocket; +using ::nearby::api::ble_v2::GattClient; +using ::nearby::api::ble_v2::ServerGattConnectionCallback; +using ::nearby::api::ble_v2::TxPowerLevel; using ::winrt::Windows::Devices::Bluetooth::BluetoothError; using ::winrt::Windows::Devices::Bluetooth::Advertisement:: BluetoothLEAdvertisement; @@ -444,4 +443,3 @@ void BleV2Medium::AdvertisementReceivedHandler( } // namespace windows } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/windows/ble_v2.h b/internal/platform/implementation/windows/ble_v2.h index a5ddc0cd3d..02285c44da 100644 --- a/internal/platform/implementation/windows/ble_v2.h +++ b/internal/platform/implementation/windows/ble_v2.h @@ -28,7 +28,6 @@ #include "internal/platform/output_stream.h" #include "winrt/Windows.Devices.Bluetooth.Advertisement.h" -namespace location { namespace nearby { namespace windows { @@ -132,6 +131,5 @@ class BleV2Medium : public api::ble_v2::BleMedium { } // namespace windows } // namespace nearby -} // namespace location #endif // THIRD_PARTY_NEARBY_INTERNAL_PLATFORM_IMPLEMENTATION_WINDOWS_BLE_V2_H_ diff --git a/internal/platform/implementation/windows/ble_v2_test.cc b/internal/platform/implementation/windows/ble_v2_test.cc index b24470e1fa..a3ca4cfccc 100644 --- a/internal/platform/implementation/windows/ble_v2_test.cc +++ b/internal/platform/implementation/windows/ble_v2_test.cc @@ -21,7 +21,6 @@ #include "internal/platform/implementation/ble_v2.h" #include "internal/platform/implementation/windows/bluetooth_adapter.h" -namespace location { namespace nearby { namespace windows { namespace { @@ -94,4 +93,3 @@ TEST(BleV2Medium, DISABLED_StopScanning) { } // namespace } // namespace windows } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/windows/bluetooth_adapter.cc b/internal/platform/implementation/windows/bluetooth_adapter.cc index ac119327f6..a0dd910465 100644 --- a/internal/platform/implementation/windows/bluetooth_adapter.cc +++ b/internal/platform/implementation/windows/bluetooth_adapter.cc @@ -45,7 +45,6 @@ typedef std::basic_string tstring; #define BLUETOOTH_RADIO_REGISTRY_NAME_KEY "Local Name" -namespace location { namespace nearby { namespace windows { namespace { @@ -199,12 +198,10 @@ void BluetoothAdapter::RestoreRadioNameIfNecessary() { std::string settings_path(kLocalSettingsFileName); auto full_path = - location::nearby::api::ImplementationPlatform::GetAppDataPath( - settings_path); + nearby::api::ImplementationPlatform::GetAppDataPath(settings_path); auto settings_file = - location::nearby::api::ImplementationPlatform::CreateInputFile(full_path, - 0); + nearby::api::ImplementationPlatform::CreateInputFile(full_path, 0); if (settings_file == nullptr) { return; } @@ -245,12 +242,10 @@ void BluetoothAdapter::StoreRadioNames(absl::string_view original_radio_name, std::string settings_path(kLocalSettingsFileName); auto full_path = - location::nearby::api::ImplementationPlatform::GetAppDataPath( - settings_path); + nearby::api::ImplementationPlatform::GetAppDataPath(settings_path); auto settings_file = - location::nearby::api::ImplementationPlatform::CreateOutputFile( - full_path); + nearby::api::ImplementationPlatform::CreateOutputFile(full_path); if (settings_file == nullptr) { return; @@ -760,4 +755,3 @@ std::string BluetoothAdapter::GetNameFromComputerName() const { } // namespace windows } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/windows/bluetooth_adapter.h b/internal/platform/implementation/windows/bluetooth_adapter.h index f36c440074..95c47839bf 100644 --- a/internal/platform/implementation/windows/bluetooth_adapter.h +++ b/internal/platform/implementation/windows/bluetooth_adapter.h @@ -27,7 +27,6 @@ #include "internal/platform/implementation/windows/generated/winrt/Windows.Devices.Radios.h" #include "internal/platform/implementation/windows/generated/winrt/base.h" -namespace location { namespace nearby { namespace windows { @@ -119,6 +118,5 @@ class BluetoothAdapter : public api::BluetoothAdapter { } // namespace windows } // namespace nearby -} // namespace location #endif // PLATFORM_IMPL_WINDOWS_BLUETOOTH_ADAPTER_H_ diff --git a/internal/platform/implementation/windows/bluetooth_adapter_test.cc b/internal/platform/implementation/windows/bluetooth_adapter_test.cc index 2b05f455b9..a1b7e13180 100644 --- a/internal/platform/implementation/windows/bluetooth_adapter_test.cc +++ b/internal/platform/implementation/windows/bluetooth_adapter_test.cc @@ -21,7 +21,6 @@ #include "absl/synchronization/notification.h" #include "internal/platform/implementation/bluetooth_adapter.h" -namespace location { namespace nearby { namespace windows { namespace { @@ -194,4 +193,3 @@ TEST(BluetoothAdapter, DISABLED_GetNameFromComputerName) { } // namespace } // namespace windows } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/windows/bluetooth_classic_device.cc b/internal/platform/implementation/windows/bluetooth_classic_device.cc index bff4c99c98..a2e3a4e8aa 100644 --- a/internal/platform/implementation/windows/bluetooth_classic_device.cc +++ b/internal/platform/implementation/windows/bluetooth_classic_device.cc @@ -30,7 +30,6 @@ #include "internal/platform/implementation/windows/utils.h" #include "internal/platform/logging.h" -namespace location { namespace nearby { namespace windows { @@ -134,4 +133,3 @@ RfcommDeviceService BluetoothDevice::GetRfcommServiceForIdAsync( } // namespace windows } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/windows/bluetooth_classic_device.h b/internal/platform/implementation/windows/bluetooth_classic_device.h index 74b2f9a769..7c16e3c7d7 100644 --- a/internal/platform/implementation/windows/bluetooth_classic_device.h +++ b/internal/platform/implementation/windows/bluetooth_classic_device.h @@ -28,7 +28,6 @@ #include "internal/platform/input_stream.h" #include "internal/platform/output_stream.h" -namespace location { namespace nearby { namespace windows { @@ -97,6 +96,5 @@ class BluetoothDevice : public api::BluetoothDevice { } // namespace windows } // namespace nearby -} // namespace location #endif // PLATFORM_IMPL_WINDOWS_BLUETOOTH_CLASSIC_DEVICE_H_ diff --git a/internal/platform/implementation/windows/bluetooth_classic_medium.cc b/internal/platform/implementation/windows/bluetooth_classic_medium.cc index ef4013611d..f507377254 100644 --- a/internal/platform/implementation/windows/bluetooth_classic_medium.cc +++ b/internal/platform/implementation/windows/bluetooth_classic_medium.cc @@ -42,7 +42,6 @@ #include "internal/platform/implementation/windows/wifi_lan.h" #include "internal/platform/logging.h" -namespace location { namespace nearby { namespace windows { namespace { @@ -309,7 +308,7 @@ std::unique_ptr BluetoothClassicMedium::ConnectToService( << winrt::to_string(device_id) << ", service: " << service_uuid; return nullptr; } - location::nearby::CancellationFlagListener cancellation_flag_listener( + nearby::CancellationFlagListener cancellation_flag_listener( cancellation_flag, [&rfcomm_socket]() { rfcomm_socket->CancelIOAsync().get(); rfcomm_socket->Close(); @@ -800,4 +799,3 @@ bool BluetoothClassicMedium::InitializeServiceSdpAttributes( } // namespace windows } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/windows/bluetooth_classic_medium.h b/internal/platform/implementation/windows/bluetooth_classic_medium.h index 6b11fe115f..81a86a69b3 100644 --- a/internal/platform/implementation/windows/bluetooth_classic_medium.h +++ b/internal/platform/implementation/windows/bluetooth_classic_medium.h @@ -28,7 +28,6 @@ #include "internal/platform/implementation/windows/generated/winrt/Windows.Networking.Sockets.h" #include "internal/platform/implementation/windows/generated/winrt/base.h" -namespace location { namespace nearby { namespace windows { @@ -209,6 +208,5 @@ class BluetoothClassicMedium : public api::BluetoothClassicMedium { } // namespace windows } // namespace nearby -} // namespace location #endif // PLATFORM_IMPL_WINDOWS_BLUETOOTH_CLASSIC_MEDIUM_H_ diff --git a/internal/platform/implementation/windows/bluetooth_classic_medium_test.cc b/internal/platform/implementation/windows/bluetooth_classic_medium_test.cc index f731723a9e..5ee375d5eb 100644 --- a/internal/platform/implementation/windows/bluetooth_classic_medium_test.cc +++ b/internal/platform/implementation/windows/bluetooth_classic_medium_test.cc @@ -35,19 +35,16 @@ // STOP/HANG AND IS INTENDED SOLELY FOR DEBUG AND DEMONSTRATION PURPOSES. DO NOT // ATTEMPT TO BUILD AND RUN THIS TEST ON GOOGLE3 YOU HAVE BEEN WARNED -using ::location::nearby::windows::BluetoothDevice; +using ::nearby::windows::BluetoothDevice; -typedef std::map - DeviceMap; +typedef std::map DeviceMap; class BluetoothClassicMediumTests : public testing::Test { protected: - static void device_discovered_cb( - location::nearby::api::BluetoothDevice& device) { + static void device_discovered_cb(nearby::api::BluetoothDevice& device) { const std::string address = device.GetMacAddress(); - std::map::const_iterator it = + std::map::const_iterator it = deviceList.find(address); std::string buffer = @@ -63,10 +60,9 @@ class BluetoothClassicMediumTests : public testing::Test { } } - static void device_name_changed_cb( - location::nearby::api::BluetoothDevice& device) {} + static void device_name_changed_cb(nearby::api::BluetoothDevice& device) {} - static void device_lost_cb(location::nearby::api::BluetoothDevice& device) { + static void device_lost_cb(nearby::api::BluetoothDevice& device) { deviceList.erase(device.GetMacAddress()); } @@ -76,7 +72,7 @@ class BluetoothClassicMediumTests : public testing::Test { #ifdef TESTING_LOCALLY TEST_F(BluetoothClassicMediumTests, ManualTest) { - auto bluetoothAdapter = location::nearby::windows::BluetoothAdapter(); + auto bluetoothAdapter = nearby::windows::BluetoothAdapter(); std::string bluetoothAdapterName = bluetoothAdapter.GetName(); bluetoothAdapter.SetName("BluetoothTestName"); @@ -84,21 +80,20 @@ TEST_F(BluetoothClassicMediumTests, ManualTest) { bluetoothAdapter.SetName(""); bluetoothAdapterName = bluetoothAdapter.GetName(); - std::unique_ptr bcm = - std::make_unique( + std::unique_ptr bcm = + std::make_unique( bluetoothAdapter); - bluetoothAdapter.SetScanMode(location::nearby::windows::BluetoothAdapter:: - ScanMode::kConnectableDiscoverable); + bluetoothAdapter.SetScanMode( + nearby::windows::BluetoothAdapter::ScanMode::kConnectableDiscoverable); auto mode = bluetoothAdapter.GetScanMode(); - bcm->StartDiscovery( - location::nearby::api::BluetoothClassicMedium::DiscoveryCallback{ - .device_discovered_cb = device_discovered_cb, - .device_name_changed_cb = device_name_changed_cb, - .device_lost_cb = device_lost_cb, - }); + bcm->StartDiscovery(nearby::api::BluetoothClassicMedium::DiscoveryCallback{ + .device_discovered_cb = device_discovered_cb, + .device_name_changed_cb = device_name_changed_cb, + .device_lost_cb = device_lost_cb, + }); Sleep(30000); @@ -107,7 +102,7 @@ TEST_F(BluetoothClassicMediumTests, ManualTest) { winrt::Windows::Devices::Bluetooth::Rfcomm::RfcommServiceId::SerialPort() .AsString()); - location::nearby::CancellationFlag cancellationFlag; + nearby::CancellationFlag cancellationFlag; bcm->ConnectToService(*currentDevice, // "a82efa21-ae5c-3dde-9bbc-f16da7b16c5a", "00001101-0000-1000-8000-00805F9B34FB", @@ -119,17 +114,16 @@ TEST_F(BluetoothClassicMediumTests, ManualTest) { #endif TEST_F(BluetoothClassicMediumTests, ConnectToServiceNullUuid) { // Arrange - auto bluetoothAdapter = location::nearby::windows::BluetoothAdapter(); + auto bluetoothAdapter = nearby::windows::BluetoothAdapter(); - std::unique_ptr + std::unique_ptr bluetoothClassicMedium = - std::make_unique( + std::make_unique( bluetoothAdapter); - location::nearby::windows::BluetoothDevice bluetoothDevice = - location::nearby::windows::BluetoothDevice( - std::string("1D:EA:DB:EE:B9:00")); - location::nearby::CancellationFlag cancellationFlag; + nearby::windows::BluetoothDevice bluetoothDevice = + nearby::windows::BluetoothDevice(std::string("1D:EA:DB:EE:B9:00")); + nearby::CancellationFlag cancellationFlag; auto bluetoothClassicMediumImpl = bluetoothClassicMedium.get(); @@ -143,16 +137,15 @@ TEST_F(BluetoothClassicMediumTests, ConnectToServiceNullUuid) { TEST_F(BluetoothClassicMediumTests, ConnectToServiceNullCancellationFlag) { // Arrange - auto bluetoothAdapter = location::nearby::windows::BluetoothAdapter(); + auto bluetoothAdapter = nearby::windows::BluetoothAdapter(); - std::unique_ptr + std::unique_ptr bluetoothClassicMedium = - std::make_unique( + std::make_unique( bluetoothAdapter); - location::nearby::windows::BluetoothDevice bluetoothDevice = - location::nearby::windows::BluetoothDevice( - std::string("1D:EA:DB:EE:B9:00")); + nearby::windows::BluetoothDevice bluetoothDevice = + nearby::windows::BluetoothDevice(std::string("1D:EA:DB:EE:B9:00")); auto bluetoothClassicMediumImpl = bluetoothClassicMedium.get(); @@ -166,17 +159,16 @@ TEST_F(BluetoothClassicMediumTests, ConnectToServiceNullCancellationFlag) { TEST_F(BluetoothClassicMediumTests, ConnectToServiceWithInvalidServiceUuid) { // Arrange - auto bluetoothAdapter = location::nearby::windows::BluetoothAdapter(); + auto bluetoothAdapter = nearby::windows::BluetoothAdapter(); - std::unique_ptr + std::unique_ptr bluetoothClassicMedium = - std::make_unique( + std::make_unique( bluetoothAdapter); - location::nearby::windows::BluetoothDevice bluetoothDevice = - location::nearby::windows::BluetoothDevice( - std::string("1D:EA:DB:EE:B9:00")); - location::nearby::CancellationFlag cancellationFlag; + nearby::windows::BluetoothDevice bluetoothDevice = + nearby::windows::BluetoothDevice(std::string("1D:EA:DB:EE:B9:00")); + nearby::CancellationFlag cancellationFlag; auto bluetoothClassicMediumImpl = bluetoothClassicMedium.get(); diff --git a/internal/platform/implementation/windows/bluetooth_classic_server_socket.cc b/internal/platform/implementation/windows/bluetooth_classic_server_socket.cc index 16eccfb846..6a5b3a9edf 100644 --- a/internal/platform/implementation/windows/bluetooth_classic_server_socket.cc +++ b/internal/platform/implementation/windows/bluetooth_classic_server_socket.cc @@ -25,7 +25,6 @@ #include "internal/platform/implementation/windows/bluetooth_classic_socket.h" #include "internal/platform/logging.h" -namespace location { namespace nearby { namespace windows { @@ -158,4 +157,3 @@ ::winrt::fire_and_forget BluetoothServerSocket::Listener_ConnectionReceived( } // namespace windows } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/windows/bluetooth_classic_server_socket.h b/internal/platform/implementation/windows/bluetooth_classic_server_socket.h index 5c54df2665..0e56bedc45 100644 --- a/internal/platform/implementation/windows/bluetooth_classic_server_socket.h +++ b/internal/platform/implementation/windows/bluetooth_classic_server_socket.h @@ -28,7 +28,6 @@ #include "internal/platform/implementation/windows/bluetooth_classic_socket.h" #include "internal/platform/implementation/windows/generated/winrt/base.h" -namespace location { namespace nearby { namespace windows { @@ -111,5 +110,5 @@ class BluetoothServerSocket : public api::BluetoothServerSocket { } // namespace windows } // namespace nearby -} // namespace location + #endif // PLATFORM_IMPL_WINDOWS_BLUETOOTH_CLASSIC_SERVER_SOCKET_H_ diff --git a/internal/platform/implementation/windows/bluetooth_classic_socket.cc b/internal/platform/implementation/windows/bluetooth_classic_socket.cc index 01ccb57a86..a8f2967b6b 100644 --- a/internal/platform/implementation/windows/bluetooth_classic_socket.cc +++ b/internal/platform/implementation/windows/bluetooth_classic_socket.cc @@ -21,7 +21,6 @@ #include "internal/platform/implementation/windows/generated/winrt/base.h" #include "internal/platform/logging.h" -namespace location { namespace nearby { namespace windows { @@ -277,4 +276,3 @@ Exception BluetoothSocket::BluetoothOutputStream::Close() { } // namespace windows } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/windows/bluetooth_classic_socket.h b/internal/platform/implementation/windows/bluetooth_classic_socket.h index 4e71f24020..6a7ec52f5a 100644 --- a/internal/platform/implementation/windows/bluetooth_classic_socket.h +++ b/internal/platform/implementation/windows/bluetooth_classic_socket.h @@ -23,7 +23,6 @@ #include "internal/platform/implementation/windows/generated/winrt/Windows.Networking.Sockets.h" #include "internal/platform/implementation/windows/generated/winrt/Windows.Storage.Streams.h" -namespace location { namespace nearby { namespace windows { @@ -137,6 +136,5 @@ class BluetoothSocket : public api::BluetoothSocket { } // namespace windows } // namespace nearby -} // namespace location #endif // PLATFORM_IMPL_WINDOWS_BLUETOOTH_CLASSIC_SOCKET_H_ diff --git a/internal/platform/implementation/windows/bluetooth_pairing.cc b/internal/platform/implementation/windows/bluetooth_pairing.cc index b6438e477f..f038fa4d34 100644 --- a/internal/platform/implementation/windows/bluetooth_pairing.cc +++ b/internal/platform/implementation/windows/bluetooth_pairing.cc @@ -19,7 +19,6 @@ #include "winrt/Windows.Foundation.Collections.h" #include "winrt/base.h" -namespace location { namespace nearby { namespace windows { @@ -115,4 +114,3 @@ void BluetoothPairing::OnPair(DevicePairingResult& pairing_result) { } // namespace windows } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/windows/bluetooth_pairing.h b/internal/platform/implementation/windows/bluetooth_pairing.h index ab52ae7d2a..05cf5c75f7 100644 --- a/internal/platform/implementation/windows/bluetooth_pairing.h +++ b/internal/platform/implementation/windows/bluetooth_pairing.h @@ -21,7 +21,6 @@ #include "winrt/Windows.Devices.Enumeration.h" -namespace location { namespace nearby { namespace windows { @@ -56,6 +55,5 @@ class BluetoothPairing { } // namespace windows } // namespace nearby -} // namespace location #endif // THIRD_PARTY_NEARBY_INTERNAL_PLATFORM_IMPLEMENTATION_WINDOWS_BLUETOOTH_PAIRING_H_ diff --git a/internal/platform/implementation/windows/condition_variable.h b/internal/platform/implementation/windows/condition_variable.h index 3a82fa666a..992b817674 100644 --- a/internal/platform/implementation/windows/condition_variable.h +++ b/internal/platform/implementation/windows/condition_variable.h @@ -23,7 +23,6 @@ #include "internal/platform/implementation/windows/mutex.h" #include "internal/platform/mutex.h" -namespace location { namespace nearby { namespace windows { @@ -51,5 +50,5 @@ class ConditionVariable : public api::ConditionVariable { }; } // namespace windows } // namespace nearby -} // namespace location + #endif // PLATFORM_IMPL_WINDOWS_CONDITION_VARIABLE_H_ diff --git a/internal/platform/implementation/windows/condition_variable_test.cc b/internal/platform/implementation/windows/condition_variable_test.cc index 03626b5d0e..8b208025fe 100644 --- a/internal/platform/implementation/windows/condition_variable_test.cc +++ b/internal/platform/implementation/windows/condition_variable_test.cc @@ -37,7 +37,7 @@ class ConditionVariableTests : public testing::Test { if (timedWait == true) { auto result = this->condition_variable_actual_.Wait(*timeout); - if (result.value == location::nearby::Exception::kSuccess) { + if (result.value == nearby::Exception::kSuccess) { return true; } else { return false; @@ -55,13 +55,12 @@ class ConditionVariableTests : public testing::Test { } private: - location::nearby::windows::Mutex mutex_actual_ = - location::nearby::windows::Mutex( - location::nearby::windows::Mutex::Mode::kRegular); - location::nearby::windows::Mutex& mutex_ = mutex_actual_; - location::nearby::windows::ConditionVariable condition_variable_actual_ = - location::nearby::windows::ConditionVariable(&mutex_); - location::nearby::windows::ConditionVariable& condition_variable_ = + nearby::windows::Mutex mutex_actual_ = + nearby::windows::Mutex(nearby::windows::Mutex::Mode::kRegular); + nearby::windows::Mutex& mutex_ = mutex_actual_; + nearby::windows::ConditionVariable condition_variable_actual_ = + nearby::windows::ConditionVariable(&mutex_); + nearby::windows::ConditionVariable& condition_variable_ = condition_variable_actual_; }; }; diff --git a/internal/platform/implementation/windows/count_down_latch_test.cc b/internal/platform/implementation/windows/count_down_latch_test.cc index d3c3ddb11f..abdf4b08e1 100644 --- a/internal/platform/implementation/windows/count_down_latch_test.cc +++ b/internal/platform/implementation/windows/count_down_latch_test.cc @@ -23,7 +23,7 @@ class CountDownLatchTests : public testing::Test { public: class TestData { public: - std::unique_ptr& countDownLatch; + std::unique_ptr& countDownLatch; LONG volatile& count; }; @@ -58,8 +58,8 @@ TEST_F(CountDownLatchTests, CountDownLatchAwaitSucceeds) { // Arrange LONG volatile count = 0; - std::unique_ptr countDownLatch = - location::nearby::api::ImplementationPlatform::CreateCountDownLatch(3); + std::unique_ptr countDownLatch = + nearby::api::ImplementationPlatform::CreateCountDownLatch(3); HANDLE hThreads[3]; DWORD dwThreadID; @@ -83,11 +83,11 @@ TEST_F(CountDownLatchTests, CountDownLatchAwaitSucceeds) { } // Act - location::nearby::Exception result = countDownLatch->Await(); + nearby::Exception result = countDownLatch->Await(); // // Assert - EXPECT_EQ(result.value, location::nearby::Exception::kSuccess); + EXPECT_EQ(result.value, nearby::Exception::kSuccess); EXPECT_EQ(count, 3); } @@ -95,11 +95,11 @@ TEST_F(CountDownLatchTests, CountDownLatchAwaitTimeoutTimesOut) { // Arrange LONG volatile count = 0; - std::unique_ptr countDownLatch = - location::nearby::api::ImplementationPlatform::CreateCountDownLatch(3); + std::unique_ptr countDownLatch = + nearby::api::ImplementationPlatform::CreateCountDownLatch(3); // Act - location::nearby::ExceptionOr result = + nearby::ExceptionOr result = countDownLatch->Await(absl::Milliseconds(5)); Sleep(40); @@ -109,15 +109,15 @@ TEST_F(CountDownLatchTests, CountDownLatchAwaitTimeoutTimesOut) { // TODO(jfcarroll)I think there's a bug in the shared version of this, it's // not returning a timeout exception, need to look at it some more. // EXPECT_EQ(result.GetException().value, - // location::nearby::Exception::kTimeout); + // nearby::Exception::kTimeout); } TEST_F(CountDownLatchTests, CountDownLatchAwaitNoTimeoutSucceeds) { // Arrange LONG volatile count = 0; - std::unique_ptr countDownLatch = - location::nearby::api::ImplementationPlatform::CreateCountDownLatch(3); + std::unique_ptr countDownLatch = + nearby::api::ImplementationPlatform::CreateCountDownLatch(3); TestData testData{countDownLatch, count}; @@ -142,20 +142,20 @@ TEST_F(CountDownLatchTests, CountDownLatchAwaitNoTimeoutSucceeds) { WaitForMultipleObjects(3, hThreads, true, INFINITE); // Act - location::nearby::ExceptionOr result = + nearby::ExceptionOr result = countDownLatch->Await(absl::Milliseconds(100)); // Assert EXPECT_TRUE(result.GetResult()); - EXPECT_EQ(result.GetException().value, location::nearby::Exception::kSuccess); + EXPECT_EQ(result.GetException().value, nearby::Exception::kSuccess); EXPECT_EQ(count, 3); } TEST_F(CountDownLatchTests, CountDownLatchCountDownBeforeAwaitSucceeds) { // Arrange LONG volatile count = 0; - std::unique_ptr countDownLatch = - location::nearby::api::ImplementationPlatform::CreateCountDownLatch(1); + std::unique_ptr countDownLatch = + nearby::api::ImplementationPlatform::CreateCountDownLatch(1); HANDLE hThread; DWORD dwThreadID; diff --git a/internal/platform/implementation/windows/crypto.cc b/internal/platform/implementation/windows/crypto.cc index 80f57cce83..dd933cf18b 100644 --- a/internal/platform/implementation/windows/crypto.cc +++ b/internal/platform/implementation/windows/crypto.cc @@ -26,7 +26,7 @@ #endif // Function implementations for platform/api/crypto.h. -namespace location { + namespace nearby { // Initialize global crypto state. @@ -55,4 +55,3 @@ ByteArray Crypto::Sha256(absl::string_view input) { } } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/windows/crypto_test.cc b/internal/platform/implementation/windows/crypto_test.cc index 5d182810ef..1071cd6606 100644 --- a/internal/platform/implementation/windows/crypto_test.cc +++ b/internal/platform/implementation/windows/crypto_test.cc @@ -18,7 +18,6 @@ #include "gtest/gtest.h" -namespace location { namespace nearby { namespace { @@ -49,4 +48,3 @@ TEST(CryptoTest, Sha256HashOnEmptyInput) { } // namespace } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/windows/executor.cc b/internal/platform/implementation/windows/executor.cc index 2a26e8a001..d15bc5901a 100644 --- a/internal/platform/implementation/windows/executor.cc +++ b/internal/platform/implementation/windows/executor.cc @@ -18,7 +18,6 @@ #include "internal/platform/logging.h" -namespace location { namespace nearby { namespace windows { @@ -54,4 +53,3 @@ void Executor::Shutdown() { } // namespace windows } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/windows/executor.h b/internal/platform/implementation/windows/executor.h index 9a87550e16..4a90572c72 100644 --- a/internal/platform/implementation/windows/executor.h +++ b/internal/platform/implementation/windows/executor.h @@ -20,7 +20,6 @@ #include "internal/platform/implementation/executor.h" #include "internal/platform/implementation/windows/thread_pool.h" -namespace location { namespace nearby { namespace windows { @@ -46,6 +45,5 @@ class Executor : public api::Executor { } // namespace windows } // namespace nearby -} // namespace location #endif // PLATFORM_IMPL_WINDOWS_EXECUTOR_H_ diff --git a/internal/platform/implementation/windows/executor_test.cc b/internal/platform/implementation/windows/executor_test.cc index 3902f39e6d..598c6701a3 100644 --- a/internal/platform/implementation/windows/executor_test.cc +++ b/internal/platform/implementation/windows/executor_test.cc @@ -24,7 +24,6 @@ #include "absl/time/time.h" #include "internal/platform/implementation/windows/test_data.h" -namespace location { namespace nearby { namespace windows { namespace { @@ -321,4 +320,3 @@ TEST(ExecutorTests, } // namespace } // namespace windows } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/windows/file.cc b/internal/platform/implementation/windows/file.cc index df0aecb794..bd1269c9e4 100644 --- a/internal/platform/implementation/windows/file.cc +++ b/internal/platform/implementation/windows/file.cc @@ -25,7 +25,6 @@ #include "internal/platform/exception.h" #include "internal/platform/implementation/windows/utils.h" -namespace location { namespace nearby { namespace windows { @@ -108,4 +107,3 @@ Exception IOFile::Flush() { } // namespace windows } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/windows/file.h b/internal/platform/implementation/windows/file.h index 435ea3337b..ad26f16e34 100644 --- a/internal/platform/implementation/windows/file.h +++ b/internal/platform/implementation/windows/file.h @@ -25,7 +25,6 @@ #include "internal/platform/implementation/input_file.h" #include "internal/platform/implementation/output_file.h" -namespace location { namespace nearby { namespace windows { @@ -57,6 +56,5 @@ class IOFile final : public api::InputFile, public api::OutputFile { } // namespace windows } // namespace nearby -} // namespace location #endif // PLATFORM_IMPL_WINDOWS_FILE_H_ diff --git a/internal/platform/implementation/windows/file_path.cc b/internal/platform/implementation/windows/file_path.cc index 43db2de10f..8a5f9d0a09 100644 --- a/internal/platform/implementation/windows/file_path.cc +++ b/internal/platform/implementation/windows/file_path.cc @@ -34,7 +34,6 @@ #include "internal/platform/implementation/windows/utils.h" #include "internal/platform/logging.h" -namespace location { namespace nearby { namespace windows { @@ -268,4 +267,3 @@ void FilePath::ReplaceInvalidCharacters(std::wstring& path) { } // namespace windows } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/windows/file_path.h b/internal/platform/implementation/windows/file_path.h index 5c6c7342cc..17cceb998c 100644 --- a/internal/platform/implementation/windows/file_path.h +++ b/internal/platform/implementation/windows/file_path.h @@ -19,7 +19,6 @@ #include "absl/strings/string_view.h" -namespace location { namespace nearby { namespace windows { @@ -46,6 +45,5 @@ class FilePath { } // namespace windows } // namespace nearby -} // namespace location #endif // THIRD_PARTY_NEARBY_INTERNAL_PLATFORM_IMPLEMENTATION_WINDOWS_FILE_PATH_H_ diff --git a/internal/platform/implementation/windows/file_path_test.cc b/internal/platform/implementation/windows/file_path_test.cc index dca3a6200c..2056ceab3e 100644 --- a/internal/platform/implementation/windows/file_path_test.cc +++ b/internal/platform/implementation/windows/file_path_test.cc @@ -26,7 +26,6 @@ #include "gtest/gtest.h" -namespace location { namespace nearby { namespace windows { @@ -855,4 +854,3 @@ AHoleBetweenRenamedFiles) { } } // namespace windows } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/windows/future.h b/internal/platform/implementation/windows/future.h index 5d7a034e2f..32dc4c0227 100644 --- a/internal/platform/implementation/windows/future.h +++ b/internal/platform/implementation/windows/future.h @@ -17,7 +17,6 @@ #include "internal/platform/implementation/future.h" -namespace location { namespace nearby { namespace windows { @@ -45,6 +44,5 @@ class Future : public api::Future { } // namespace windows } // namespace nearby -} // namespace location #endif // PLATFORM_IMPL_WINDOWS_FUTURE_H_ diff --git a/internal/platform/implementation/windows/http_loader.cc b/internal/platform/implementation/windows/http_loader.cc index c30adecdc9..5c5ee1db9f 100644 --- a/internal/platform/implementation/windows/http_loader.cc +++ b/internal/platform/implementation/windows/http_loader.cc @@ -24,7 +24,6 @@ #include "absl/strings/str_cat.h" #include "internal/platform/logging.h" -namespace location { namespace nearby { namespace windows { namespace { @@ -32,7 +31,7 @@ namespace { constexpr DWORD kSchemaMaximumLength = 10; constexpr DWORD kHostNameMaximumLength = 256; -using ::location::nearby::api::WebResponse; +using ::nearby::api::WebResponse; } // namespace @@ -410,4 +409,3 @@ absl::Status HttpLoader::HTTPCodeToStatus(int status_code, } // namespace windows } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/windows/http_loader.h b/internal/platform/implementation/windows/http_loader.h index 9eedad1baa..6da8a8c939 100644 --- a/internal/platform/implementation/windows/http_loader.h +++ b/internal/platform/implementation/windows/http_loader.h @@ -25,7 +25,6 @@ #include "absl/strings/string_view.h" #include "internal/platform/implementation/http_loader.h" -namespace location { namespace nearby { namespace windows { @@ -35,11 +34,11 @@ namespace windows { // WinInet APIs to get HTTP response. The platform handles HTTP/HTTPS sessions. class HttpLoader { public: - explicit HttpLoader(const location::nearby::api::WebRequest& request) + explicit HttpLoader(const nearby::api::WebRequest& request) : request_(request) {} ~HttpLoader() = default; - absl::StatusOr GetResponse(); + absl::StatusOr GetResponse(); private: // Defines the buffer size. It is used to init a buffer for receiving HTTP @@ -48,7 +47,7 @@ class HttpLoader { absl::Status ConnectWebServer(); absl::Status SendRequest(); - absl::StatusOr ProcessResponse(); + absl::StatusOr ProcessResponse(); void DisconnectWebServer(); absl::StatusOr QueryStatusCode(HINTERNET file_handle); @@ -68,7 +67,7 @@ class HttpLoader { absl::Status HTTPCodeToStatus(int status_code, absl::string_view status_message); - location::nearby::api::WebRequest request_; + nearby::api::WebRequest request_; std::string host_; std::string path_; std::string schema_; @@ -82,6 +81,5 @@ class HttpLoader { } // namespace windows } // namespace nearby -} // namespace location #endif // THIRD_PARTY_NEARBY_INTERNAL_PLATFORM_IMPLEMENTATION_WINDOWS_HTTP_LOADER_H_ diff --git a/internal/platform/implementation/windows/http_loader_test.cc b/internal/platform/implementation/windows/http_loader_test.cc index d0bf65cabf..9c557b717c 100644 --- a/internal/platform/implementation/windows/http_loader_test.cc +++ b/internal/platform/implementation/windows/http_loader_test.cc @@ -18,11 +18,10 @@ #include "gtest/gtest.h" -namespace location { namespace nearby { namespace windows { namespace { -using ::location::nearby::api::WebRequest; +using ::nearby::api::WebRequest; TEST(HttpLoader, DISABLED_TestGetUrl) { WebRequest request; @@ -50,4 +49,3 @@ TEST(HttpLoader, DISABLED_TestInvalidUrl) { } // namespace } // namespace windows } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/windows/input_file.h b/internal/platform/implementation/windows/input_file.h index c9ac8792df..618c514505 100644 --- a/internal/platform/implementation/windows/input_file.h +++ b/internal/platform/implementation/windows/input_file.h @@ -19,7 +19,6 @@ #include "internal/platform/byte_array.h" #include "internal/platform/exception.h" -namespace location { namespace nearby { namespace windows { @@ -45,6 +44,5 @@ class InputFile : public api::InputFile { } // namespace windows } // namespace nearby -} // namespace location #endif // PLATFORM_IMPL_WINDOWS_INPUT_FILE_H_ diff --git a/internal/platform/implementation/windows/input_file_test.cc b/internal/platform/implementation/windows/input_file_test.cc index a4cca290c7..0ad20be609 100644 --- a/internal/platform/implementation/windows/input_file_test.cc +++ b/internal/platform/implementation/windows/input_file_test.cc @@ -24,7 +24,7 @@ class InputFileTests : public testing::Test { protected: // You can define per-test set-up logic as usual. void SetUp() override { - location::nearby::PayloadId payloadId(TEST_PAYLOAD_ID); + nearby::PayloadId payloadId(TEST_PAYLOAD_ID); auto path = test_utils::GetPayloadPath(payloadId); hFile_ = CreateFileA(path.c_str(), // name of the write @@ -52,7 +52,7 @@ class InputFileTests : public testing::Test { // You can define per-test tear-down logic as usual. void TearDown() override { - location::nearby::PayloadId payloadId(TEST_PAYLOAD_ID); + nearby::PayloadId payloadId(TEST_PAYLOAD_ID); if (FileExists(test_utils::GetPayloadPath(payloadId).c_str())) { DeleteFileA(test_utils::GetPayloadPath(payloadId).c_str()); } @@ -70,71 +70,67 @@ class InputFileTests : public testing::Test { }; TEST_F(InputFileTests, SuccessfulCreation) { - location::nearby::PayloadId payloadId(TEST_PAYLOAD_ID); - std::unique_ptr inputFile = nullptr; + nearby::PayloadId payloadId(TEST_PAYLOAD_ID); + std::unique_ptr inputFile = nullptr; - inputFile = location::nearby::api::ImplementationPlatform::CreateInputFile( + inputFile = nearby::api::ImplementationPlatform::CreateInputFile( payloadId, strlen(TEST_STRING)); EXPECT_NE(inputFile, nullptr); - EXPECT_EQ(inputFile->Close(), - location::nearby::Exception{location::nearby::Exception::kSuccess}); + EXPECT_EQ(inputFile->Close(), nearby::Exception{nearby::Exception::kSuccess}); } TEST_F(InputFileTests, SuccessfulGetFilePath) { - location::nearby::PayloadId payloadId(TEST_PAYLOAD_ID); - std::unique_ptr inputFile = nullptr; + nearby::PayloadId payloadId(TEST_PAYLOAD_ID); + std::unique_ptr inputFile = nullptr; std::string fileName; - inputFile = location::nearby::api::ImplementationPlatform::CreateInputFile( + inputFile = nearby::api::ImplementationPlatform::CreateInputFile( payloadId, strlen(TEST_STRING)); fileName = inputFile->GetFilePath(); - EXPECT_EQ(inputFile->Close(), - location::nearby::Exception{location::nearby::Exception::kSuccess}); + EXPECT_EQ(inputFile->Close(), nearby::Exception{nearby::Exception::kSuccess}); EXPECT_EQ(fileName, test_utils::GetPayloadPath(payloadId).c_str()); } TEST_F(InputFileTests, SuccessfulGetTotalSize) { - location::nearby::PayloadId payloadId(TEST_PAYLOAD_ID); - std::unique_ptr inputFile = nullptr; + nearby::PayloadId payloadId(TEST_PAYLOAD_ID); + std::unique_ptr inputFile = nullptr; int64_t size = -1; - inputFile = location::nearby::api::ImplementationPlatform::CreateInputFile( + inputFile = nearby::api::ImplementationPlatform::CreateInputFile( payloadId, strlen(TEST_STRING)); size = inputFile->GetTotalSize(); - EXPECT_EQ(inputFile->Close(), - location::nearby::Exception{location::nearby::Exception::kSuccess}); + EXPECT_EQ(inputFile->Close(), nearby::Exception{nearby::Exception::kSuccess}); EXPECT_EQ(size, strlen(TEST_STRING)); } TEST_F(InputFileTests, SuccessfulRead) { - location::nearby::PayloadId payloadId(TEST_PAYLOAD_ID); - std::unique_ptr inputFile = nullptr; + nearby::PayloadId payloadId(TEST_PAYLOAD_ID); + std::unique_ptr inputFile = nullptr; - inputFile = location::nearby::api::ImplementationPlatform::CreateInputFile( + inputFile = nearby::api::ImplementationPlatform::CreateInputFile( payloadId, strlen(TEST_STRING)); auto fileSize = inputFile->GetTotalSize(); auto dataRead = inputFile->Read(fileSize); EXPECT_TRUE(dataRead.ok()); - EXPECT_EQ(inputFile->Close(), - location::nearby::Exception{location::nearby::Exception::kSuccess}); + EXPECT_EQ(inputFile->Close(), nearby::Exception{nearby::Exception::kSuccess}); EXPECT_STREQ(std::string(dataRead.result()).c_str(), TEST_STRING); } TEST_F(InputFileTests, FailedRead) { - location::nearby::PayloadId payloadId(TEST_PAYLOAD_ID); - std::unique_ptr inputFile = nullptr; + nearby::PayloadId payloadId(TEST_PAYLOAD_ID); + std::unique_ptr inputFile = nullptr; - inputFile = location::nearby::api::ImplementationPlatform::CreateInputFile( + inputFile = nearby::api::ImplementationPlatform::CreateInputFile( payloadId, strlen(TEST_STRING)); auto fileSize = inputFile->GetTotalSize(); diff --git a/internal/platform/implementation/windows/listenable_future.h b/internal/platform/implementation/windows/listenable_future.h index 8c47ab5ad2..e12d6539f9 100644 --- a/internal/platform/implementation/windows/listenable_future.h +++ b/internal/platform/implementation/windows/listenable_future.h @@ -17,7 +17,6 @@ #include "internal/platform/implementation/listenable_future.h" -namespace location { namespace nearby { namespace windows { @@ -36,6 +35,5 @@ class ListenableFuture : public api::ListenableFuture { } // namespace windows } // namespace nearby -} // namespace location #endif // PLATFORM_IMPL_WINDOWS_LISTENABLE_FUTURE_H_ diff --git a/internal/platform/implementation/windows/log_message.cc b/internal/platform/implementation/windows/log_message.cc index f1632f932b..23eb145850 100644 --- a/internal/platform/implementation/windows/log_message.cc +++ b/internal/platform/implementation/windows/log_message.cc @@ -19,7 +19,6 @@ // no "base" in OSS. #include "base/stringprintf.h" -namespace location { namespace nearby { namespace windows { @@ -71,4 +70,3 @@ bool LogMessage::ShouldCreateLogMessage(Severity severity) { } } // namespace api } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/windows/log_message.h b/internal/platform/implementation/windows/log_message.h index fe2bdf20e9..1e6176e335 100644 --- a/internal/platform/implementation/windows/log_message.h +++ b/internal/platform/implementation/windows/log_message.h @@ -18,7 +18,6 @@ #include "glog/logging.h" #include "internal/platform/implementation/log_message.h" -namespace location { namespace nearby { namespace windows { @@ -40,6 +39,5 @@ class LogMessage : public api::LogMessage { } // namespace windows } // namespace nearby -} // namespace location #endif // PLATFORM_IMPL_WINDOWS_LOG_MESSAGE_H_ diff --git a/internal/platform/implementation/windows/mediums_api.h b/internal/platform/implementation/windows/mediums_api.h index 9b51254b71..ade07773a6 100644 --- a/internal/platform/implementation/windows/mediums_api.h +++ b/internal/platform/implementation/windows/mediums_api.h @@ -21,7 +21,6 @@ #include "internal/platform/implementation/windows/mediums_manager/mediums_manager.h" -namespace location { namespace nearby { namespace api { @@ -33,6 +32,5 @@ class MediumsApi { } // namespace api } // namespace nearby -} // namespace location #endif // THIRD_PARTY_NEARBY_INTERNAL_PLATFORM_IMPLEMENTATION_WINDOWS_MEDIUMS_API_H_ diff --git a/internal/platform/implementation/windows/mediums_manager/mediums_api.cc b/internal/platform/implementation/windows/mediums_manager/mediums_api.cc index 8e03258e98..89f4dee60e 100644 --- a/internal/platform/implementation/windows/mediums_manager/mediums_api.cc +++ b/internal/platform/implementation/windows/mediums_manager/mediums_api.cc @@ -20,7 +20,6 @@ #include "internal/platform/implementation/windows/mediums_manager/mediums_manager_impl.h" -namespace location { namespace nearby { namespace api { @@ -30,4 +29,3 @@ std::unique_ptr MediumsApi::CreateMediumsManager() { } // namespace api } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/windows/mediums_manager/mediums_manager.h b/internal/platform/implementation/windows/mediums_manager/mediums_manager.h index 685c918b75..17b287b555 100644 --- a/internal/platform/implementation/windows/mediums_manager/mediums_manager.h +++ b/internal/platform/implementation/windows/mediums_manager/mediums_manager.h @@ -20,7 +20,6 @@ #include "absl/strings/string_view.h" #include "internal/platform/byte_array.h" -namespace location { namespace nearby { namespace api { @@ -42,6 +41,5 @@ class MediumsManager { } // namespace api } // namespace nearby -} // namespace location #endif // THIRD_PARTY_NEARBY_INTERNAL_PLATFORM_IMPLEMENTATION_WINDOWS_MEDIUMS_MANAGER_MEDIUMS_MANAGER_H_ diff --git a/internal/platform/implementation/windows/mediums_manager/mediums_manager_impl.cc b/internal/platform/implementation/windows/mediums_manager/mediums_manager_impl.cc index a23d823172..21f338c5d7 100644 --- a/internal/platform/implementation/windows/mediums_manager/mediums_manager_impl.cc +++ b/internal/platform/implementation/windows/mediums_manager/mediums_manager_impl.cc @@ -24,7 +24,6 @@ #include "winrt/Windows.Storage.Streams.h" #include "winrt/base.h" -namespace location { namespace nearby { namespace windows { namespace { @@ -287,4 +286,3 @@ void MediumsManager::PublisherHandler( } // namespace windows } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/windows/mediums_manager/mediums_manager_impl.h b/internal/platform/implementation/windows/mediums_manager/mediums_manager_impl.h index b8d0d808c1..ea250c4f8f 100644 --- a/internal/platform/implementation/windows/mediums_manager/mediums_manager_impl.h +++ b/internal/platform/implementation/windows/mediums_manager/mediums_manager_impl.h @@ -24,7 +24,6 @@ #include "internal/platform/implementation/windows/mediums_manager/mediums_manager.h" #include "winrt/Windows.Devices.Bluetooth.Advertisement.h" -namespace location { namespace nearby { namespace windows { @@ -55,6 +54,5 @@ class MediumsManager : public api::MediumsManager { } // namespace windows } // namespace nearby -} // namespace location #endif // THIRD_PARTY_NEARBY_INTERNAL_PLATFORM_IMPLEMENTATION_WINDOWS_MEDIUMS_MANAGER_MEDIUMS_MANAGER_IMPL_H_ diff --git a/internal/platform/implementation/windows/mutex.h b/internal/platform/implementation/windows/mutex.h index 4241082757..db30d65ab2 100644 --- a/internal/platform/implementation/windows/mutex.h +++ b/internal/platform/implementation/windows/mutex.h @@ -23,7 +23,7 @@ #include "absl/memory/memory.h" #include "absl/synchronization/mutex.h" #include "internal/platform/implementation/mutex.h" -namespace location { + namespace nearby { namespace windows { @@ -68,5 +68,5 @@ class ABSL_LOCKABLE Mutex : public api::Mutex { } // namespace windows } // namespace nearby -} // namespace location + #endif // PLATFORM_IMPL_WINDOWS_MUTEX_H_ diff --git a/internal/platform/implementation/windows/mutex_test.cc b/internal/platform/implementation/windows/mutex_test.cc index f8223a3ec3..211b441d53 100644 --- a/internal/platform/implementation/windows/mutex_test.cc +++ b/internal/platform/implementation/windows/mutex_test.cc @@ -22,7 +22,7 @@ class MutexTests : public testing::Test { public: class MutexTest { public: - MutexTest(location::nearby::windows::Mutex& mutex) : mutex_(mutex) {} + MutexTest(nearby::windows::Mutex& mutex) : mutex_(mutex) {} std::future WaitForLock() { // NOLINT return std::async(std::launch::async, @@ -39,14 +39,14 @@ class MutexTests : public testing::Test { } private: - location::nearby::windows::Mutex& mutex_; + nearby::windows::Mutex& mutex_; }; }; TEST_F(MutexTests, SuccessfulRecursiveCreation) { // Arrange - location::nearby::windows::Mutex mutex = location::nearby::windows::Mutex( - location::nearby::windows::Mutex::Mode::kRecursive); + nearby::windows::Mutex mutex = + nearby::windows::Mutex(nearby::windows::Mutex::Mode::kRecursive); // Act std::recursive_mutex& actual = mutex.GetRecursiveMutex(); @@ -57,8 +57,7 @@ TEST_F(MutexTests, SuccessfulRecursiveCreation) { TEST_F(MutexTests, SuccessfulCreation) { // Arrange - location::nearby::windows::Mutex mutex( - location::nearby::windows::Mutex::Mode::kRegular); + nearby::windows::Mutex mutex(nearby::windows::Mutex::Mode::kRegular); // Act absl::Mutex& actual = mutex.GetMutex(); @@ -69,10 +68,9 @@ TEST_F(MutexTests, SuccessfulCreation) { TEST_F(MutexTests, SuccessfulSignal) { // Arrange - location::nearby::windows::Mutex mutex( - location::nearby::windows::Mutex::Mode::kRegular); + nearby::windows::Mutex mutex(nearby::windows::Mutex::Mode::kRegular); - location::nearby::windows::Mutex& mutexRef = mutex; + nearby::windows::Mutex& mutexRef = mutex; MutexTest mutexTest(mutexRef); mutex.Lock(); @@ -87,10 +85,9 @@ TEST_F(MutexTests, SuccessfulSignal) { TEST_F(MutexTests, SuccessfulRecursiveSignal) { // Arrange - location::nearby::windows::Mutex mutex( - location::nearby::windows::Mutex::Mode::kRecursive); + nearby::windows::Mutex mutex(nearby::windows::Mutex::Mode::kRecursive); - location::nearby::windows::Mutex& mutexRef = mutex; + nearby::windows::Mutex& mutexRef = mutex; MutexTest mutexTest(mutexRef); mutex.Lock(); diff --git a/internal/platform/implementation/windows/output_file.h b/internal/platform/implementation/windows/output_file.h index 764907d1e5..7a7d6b8537 100644 --- a/internal/platform/implementation/windows/output_file.h +++ b/internal/platform/implementation/windows/output_file.h @@ -19,7 +19,6 @@ #include "internal/platform/byte_array.h" #include "internal/platform/exception.h" -namespace location { namespace nearby { namespace windows { @@ -42,6 +41,5 @@ class OutputFile : public api::OutputFile { } // namespace windows } // namespace nearby -} // namespace location #endif // PLATFORM_IMPL_WINDOWS_OUTPUT_FILE_H_ diff --git a/internal/platform/implementation/windows/output_file_test.cc b/internal/platform/implementation/windows/output_file_test.cc index 034bc7bdc7..beb8798c8d 100644 --- a/internal/platform/implementation/windows/output_file_test.cc +++ b/internal/platform/implementation/windows/output_file_test.cc @@ -24,7 +24,7 @@ class OutputFileTests : public testing::Test { protected: // You can define per-test set-up logic as usual. void SetUp() override { - location::nearby::PayloadId payloadId(TEST_PAYLOAD_ID); + nearby::PayloadId payloadId(TEST_PAYLOAD_ID); if (FileExists(test_utils::GetPayloadPath(payloadId).c_str())) { DeleteFileA(test_utils::GetPayloadPath(payloadId).c_str()); } @@ -32,7 +32,7 @@ class OutputFileTests : public testing::Test { // You can define per-test tear-down logic as usual. void TearDown() override { - location::nearby::PayloadId payloadId(TEST_PAYLOAD_ID); + nearby::PayloadId payloadId(TEST_PAYLOAD_ID); if (FileExists(test_utils::GetPayloadPath(payloadId).c_str())) { DeleteFileA(test_utils::GetPayloadPath(payloadId).c_str()); } @@ -47,26 +47,24 @@ class OutputFileTests : public testing::Test { }; TEST_F(OutputFileTests, SuccessfulCreation) { - location::nearby::PayloadId payloadId(TEST_PAYLOAD_ID); - std::unique_ptr outputFile = nullptr; + nearby::PayloadId payloadId(TEST_PAYLOAD_ID); + std::unique_ptr outputFile = nullptr; EXPECT_NO_THROW( outputFile = - location::nearby::api::ImplementationPlatform::CreateOutputFile( - payloadId)); + nearby::api::ImplementationPlatform::CreateOutputFile(payloadId)); EXPECT_NE(outputFile, nullptr); EXPECT_NO_THROW(outputFile->Close()); } TEST_F(OutputFileTests, SuccessfulClose) { - location::nearby::PayloadId payloadId(TEST_PAYLOAD_ID); - std::unique_ptr outputFile = nullptr; + nearby::PayloadId payloadId(TEST_PAYLOAD_ID); + std::unique_ptr outputFile = nullptr; EXPECT_NO_THROW( outputFile = - location::nearby::api::ImplementationPlatform::CreateOutputFile( - payloadId)); + nearby::api::ImplementationPlatform::CreateOutputFile(payloadId)); EXPECT_NO_THROW(outputFile->Close()); @@ -74,14 +72,13 @@ TEST_F(OutputFileTests, SuccessfulClose) { } TEST_F(OutputFileTests, SuccessfulWrite) { - location::nearby::PayloadId payloadId(TEST_PAYLOAD_ID); - location::nearby::ByteArray data(std::string(TEST_STRING)); - std::unique_ptr outputFile = nullptr; + nearby::PayloadId payloadId(TEST_PAYLOAD_ID); + nearby::ByteArray data(std::string(TEST_STRING)); + std::unique_ptr outputFile = nullptr; EXPECT_NO_THROW( outputFile = - location::nearby::api::ImplementationPlatform::CreateOutputFile( - payloadId)); + nearby::api::ImplementationPlatform::CreateOutputFile(payloadId)); EXPECT_NO_THROW(outputFile->Write(data)); EXPECT_NO_THROW(outputFile->Close()); diff --git a/internal/platform/implementation/windows/platform.cc b/internal/platform/implementation/windows/platform.cc index 84d2b1fcfb..6c6397ef39 100644 --- a/internal/platform/implementation/windows/platform.cc +++ b/internal/platform/implementation/windows/platform.cc @@ -63,7 +63,6 @@ #include "internal/platform/implementation/windows/wifi_lan.h" #include "internal/platform/logging.h" -namespace location { namespace nearby { namespace api { @@ -310,4 +309,3 @@ absl::StatusOr ImplementationPlatform::SendRequest( } // namespace api } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/windows/scheduled_executor.cc b/internal/platform/implementation/windows/scheduled_executor.cc index 718e6fa866..8acd677a02 100644 --- a/internal/platform/implementation/windows/scheduled_executor.cc +++ b/internal/platform/implementation/windows/scheduled_executor.cc @@ -23,7 +23,6 @@ #include "absl/time/time.h" #include "internal/platform/logging.h" -namespace location { namespace nearby { namespace windows { @@ -83,4 +82,3 @@ void ScheduledExecutor::Shutdown() { } } // namespace windows } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/windows/scheduled_executor.h b/internal/platform/implementation/windows/scheduled_executor.h index 0d8df4fa74..0a0dd3d09f 100644 --- a/internal/platform/implementation/windows/scheduled_executor.h +++ b/internal/platform/implementation/windows/scheduled_executor.h @@ -27,7 +27,6 @@ #include "internal/platform/implementation/scheduled_executor.h" #include "internal/platform/implementation/windows/executor.h" -namespace location { namespace nearby { namespace windows { @@ -99,6 +98,5 @@ class ScheduledExecutor : public api::ScheduledExecutor { } // namespace windows } // namespace nearby -} // namespace location #endif // PLATFORM_IMPL_WINDOWS_SCHEDULED_EXECUTOR_H_ diff --git a/internal/platform/implementation/windows/scheduled_executor_test.cc b/internal/platform/implementation/windows/scheduled_executor_test.cc index d032963da3..f04dd95495 100644 --- a/internal/platform/implementation/windows/scheduled_executor_test.cc +++ b/internal/platform/implementation/windows/scheduled_executor_test.cc @@ -23,7 +23,6 @@ #include "absl/time/time.h" #include "internal/platform/implementation/windows/test_data.h" -namespace location { namespace nearby { namespace windows { namespace { @@ -178,4 +177,3 @@ TEST(ScheduledExecutorTests, CancelAfterStartedFails) { } // namespace } // namespace windows } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/windows/server_sync.h b/internal/platform/implementation/windows/server_sync.h index 95dd30b27c..213ac88f3e 100644 --- a/internal/platform/implementation/windows/server_sync.h +++ b/internal/platform/implementation/windows/server_sync.h @@ -17,7 +17,6 @@ #include "internal/platform/implementation/server_sync.h" -namespace location { namespace nearby { namespace windows { @@ -85,6 +84,5 @@ class ServerSyncMedium : public api::ServerSyncMedium { } // namespace windows } // namespace nearby -} // namespace location #endif // PLATFORM_IMPL_WINDOWS_SERVER_SYNC_H_ diff --git a/internal/platform/implementation/windows/settable_future.h b/internal/platform/implementation/windows/settable_future.h index 15323ead08..485d75c4f6 100644 --- a/internal/platform/implementation/windows/settable_future.h +++ b/internal/platform/implementation/windows/settable_future.h @@ -17,7 +17,6 @@ #include "internal/platform/implementation/settable_future.h" -namespace location { namespace nearby { namespace windows { @@ -46,6 +45,5 @@ class SettableFuture : public api::SettableFuture { } // namespace windows } // namespace nearby -} // namespace location #endif // PLATFORM_IMPL_WINDOWS_SETTABLE_FUTURE_H_ diff --git a/internal/platform/implementation/windows/submittable_executor.cc b/internal/platform/implementation/windows/submittable_executor.cc index a6a7b01011..21082442c3 100644 --- a/internal/platform/implementation/windows/submittable_executor.cc +++ b/internal/platform/implementation/windows/submittable_executor.cc @@ -17,7 +17,6 @@ #include "internal/platform/implementation/windows/executor.h" #include "internal/platform/logging.h" -namespace location { namespace nearby { namespace windows { @@ -62,4 +61,3 @@ void SubmittableExecutor::Shutdown() { } // namespace windows } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/windows/submittable_executor.h b/internal/platform/implementation/windows/submittable_executor.h index 165e2323d3..e45c9182f5 100644 --- a/internal/platform/implementation/windows/submittable_executor.h +++ b/internal/platform/implementation/windows/submittable_executor.h @@ -18,7 +18,6 @@ #include "internal/platform/implementation/submittable_executor.h" #include "internal/platform/implementation/windows/executor.h" -namespace location { namespace nearby { namespace windows { @@ -50,6 +49,5 @@ class SubmittableExecutor : public api::SubmittableExecutor { } // namespace windows } // namespace nearby -} // namespace location #endif // PLATFORM_IMPL_WINDOWS_SUBMITTABLE_EXECUTOR_H_ diff --git a/internal/platform/implementation/windows/submittable_executor_test.cc b/internal/platform/implementation/windows/submittable_executor_test.cc index 041c7fc2fe..3d07312685 100644 --- a/internal/platform/implementation/windows/submittable_executor_test.cc +++ b/internal/platform/implementation/windows/submittable_executor_test.cc @@ -22,7 +22,6 @@ #include "absl/time/time.h" #include "internal/platform/implementation/windows/test_data.h" -namespace location { namespace nearby { namespace windows { namespace { @@ -248,4 +247,3 @@ TEST(SubmittableExecutorTests, SingleThreadedDoSubmitMultipleTasksSucceeds) { } // namespace } // namespace windows } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/windows/system_clock.cc b/internal/platform/implementation/windows/system_clock.cc index c08f9a9c32..6d9acbc0be 100644 --- a/internal/platform/implementation/windows/system_clock.cc +++ b/internal/platform/implementation/windows/system_clock.cc @@ -17,7 +17,6 @@ #include "internal/platform/implementation/system_clock.h" -namespace location { namespace nearby { // Initialize global system state. @@ -38,6 +37,5 @@ Exception SystemClock::Sleep(absl::Duration duration) { } } // namespace nearby -} // namespace location #endif // PLATFORM_IMPL_WINDOWS_SYSTEM_CLOCK_H_ diff --git a/internal/platform/implementation/windows/test_utils.cc b/internal/platform/implementation/windows/test_utils.cc index 423709e1b1..bbde32e8df 100644 --- a/internal/platform/implementation/windows/test_utils.cc +++ b/internal/platform/implementation/windows/test_utils.cc @@ -34,7 +34,7 @@ std::wstring StringToWideString(const std::string& s) { return r; } -std::string GetPayloadPath(location::nearby::PayloadId payload_id) { +std::string GetPayloadPath(nearby::PayloadId payload_id) { PWSTR basePath; // Retrieves the full path of a known folder identified by the folder's diff --git a/internal/platform/implementation/windows/test_utils.h b/internal/platform/implementation/windows/test_utils.h index 577ab98c5f..ece72d148b 100644 --- a/internal/platform/implementation/windows/test_utils.h +++ b/internal/platform/implementation/windows/test_utils.h @@ -37,7 +37,7 @@ namespace test_utils { std::wstring StringToWideString(const std::string& s); -std::string GetPayloadPath(location::nearby::PayloadId payload_id); +std::string GetPayloadPath(nearby::PayloadId payload_id); } // namespace test_utils #endif // PLATFORM_IMPL_WINDOWS_TEST_UTILS_H_ diff --git a/internal/platform/implementation/windows/thread_pool.cc b/internal/platform/implementation/windows/thread_pool.cc index 305d04037f..fb11649fce 100644 --- a/internal/platform/implementation/windows/thread_pool.cc +++ b/internal/platform/implementation/windows/thread_pool.cc @@ -24,7 +24,6 @@ #include "internal/platform/logging.h" #include "internal/platform/runnable.h" -namespace location { namespace nearby { namespace windows { @@ -163,4 +162,3 @@ void ThreadPool::RunNextTask() { } // namespace windows } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/windows/thread_pool.h b/internal/platform/implementation/windows/thread_pool.h index 014dc10e74..95604c1f4d 100644 --- a/internal/platform/implementation/windows/thread_pool.h +++ b/internal/platform/implementation/windows/thread_pool.h @@ -23,7 +23,6 @@ #include "absl/synchronization/mutex.h" #include "internal/platform/runnable.h" -namespace location { namespace nearby { namespace windows { @@ -70,6 +69,5 @@ class ThreadPool { } // namespace windows } // namespace nearby -} // namespace location #endif // PLATFORM_IMPL_WINDOWS_THREAD_POOL_H_ diff --git a/internal/platform/implementation/windows/thread_pool_test.cc b/internal/platform/implementation/windows/thread_pool_test.cc index 456ed43838..ae1faf27c5 100644 --- a/internal/platform/implementation/windows/thread_pool_test.cc +++ b/internal/platform/implementation/windows/thread_pool_test.cc @@ -23,7 +23,6 @@ #include "absl/time/clock.h" #include "absl/time/time.h" -namespace location { namespace nearby { namespace windows { namespace { @@ -71,4 +70,3 @@ TEST(ThreadPool, TasksInMultipleThreadsRunInParallel) { } // namespace } // namespace windows } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/windows/utils.cc b/internal/platform/implementation/windows/utils.cc index 4d57d2abea..563c8613de 100644 --- a/internal/platform/implementation/windows/utils.cc +++ b/internal/platform/implementation/windows/utils.cc @@ -40,7 +40,6 @@ #include "internal/platform/implementation/windows/generated/winrt/Windows.Foundation.Collections.h" #include "internal/platform/implementation/windows/generated/winrt/Windows.Networking.Connectivity.h" -namespace location { namespace nearby { namespace windows { namespace { @@ -124,7 +123,7 @@ std::vector GetIpv4Addresses() { } ByteArray Sha256(absl::string_view input, size_t size) { - ByteArray hash = location::nearby::Crypto::Sha256(input); + ByteArray hash = nearby::Crypto::Sha256(input); return ByteArray{hash.data(), size}; } @@ -228,4 +227,3 @@ std::vector InspectableReader::ReadStringArray( } // namespace windows } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/windows/utils.h b/internal/platform/implementation/windows/utils.h index 7abe01ada6..b3e82e5c1d 100644 --- a/internal/platform/implementation/windows/utils.h +++ b/internal/platform/implementation/windows/utils.h @@ -27,7 +27,6 @@ #include "internal/platform/implementation/windows/generated/winrt/Windows.Foundation.h" #include "internal/platform/implementation/windows/generated/winrt/base.h" -namespace location { namespace nearby { namespace windows { @@ -70,6 +69,5 @@ class InspectableReader { } // namespace windows } // namespace nearby -} // namespace location #endif // PLATFORM_IMPL_WINDOWS_UTILS_H_ diff --git a/internal/platform/implementation/windows/utils_test.cc b/internal/platform/implementation/windows/utils_test.cc index 71ab7d1532..c7bf7dd670 100644 --- a/internal/platform/implementation/windows/utils_test.cc +++ b/internal/platform/implementation/windows/utils_test.cc @@ -19,8 +19,8 @@ #include "gtest/gtest.h" -// using ::location::nearby::windows::uint64_to_mac_address_string; -namespace location { +// using ::nearby::windows::uint64_to_mac_address_string; + namespace nearby { namespace windows { @@ -68,4 +68,3 @@ TEST(UtilsTests, IpDotdecimalTo4Bytes) { } // namespace windows } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/windows/webrtc.h b/internal/platform/implementation/windows/webrtc.h index e82d8449c6..0681cd360e 100644 --- a/internal/platform/implementation/windows/webrtc.h +++ b/internal/platform/implementation/windows/webrtc.h @@ -17,7 +17,6 @@ #include "internal/platform/implementation/webrtc.h" -namespace location { namespace nearby { namespace windows { @@ -66,13 +65,13 @@ class WebRtcMedium : public api::WebRtcMedium { // TODO(b/184975123): replace with real implementation. std::unique_ptr GetSignalingMessenger( absl::string_view self_id, - const connections::LocationHint& location_hint) override { + const location::nearby::connections::LocationHint& location_hint) + override { return nullptr; } }; } // namespace windows } // namespace nearby -} // namespace location #endif // PLATFORM_IMPL_WINDOWS_WEBRTC_H_ diff --git a/internal/platform/implementation/windows/wifi.h b/internal/platform/implementation/windows/wifi.h index 597b941953..b470cbe353 100644 --- a/internal/platform/implementation/windows/wifi.h +++ b/internal/platform/implementation/windows/wifi.h @@ -29,7 +29,6 @@ #include "internal/platform/implementation/windows/generated/winrt/Windows.Foundation.h" #include "internal/platform/implementation/windows/generated/winrt/Windows.Networking.Connectivity.h" -namespace location { namespace nearby { namespace windows { @@ -126,6 +125,5 @@ class WifiMedium : public api::WifiMedium { } // namespace windows } // namespace nearby -} // namespace location #endif // PLATFORM_IMPL_WINDOWS_WIFI_H_ diff --git a/internal/platform/implementation/windows/wifi_direct.h b/internal/platform/implementation/windows/wifi_direct.h index 0817ab845f..5759cad74f 100644 --- a/internal/platform/implementation/windows/wifi_direct.h +++ b/internal/platform/implementation/windows/wifi_direct.h @@ -50,7 +50,6 @@ #include "internal/platform/implementation/windows/generated/winrt/Windows.Storage.Streams.h" #include "internal/platform/implementation/windows/generated/winrt/base.h" -namespace location { namespace nearby { namespace windows { @@ -318,12 +317,11 @@ class WifiDirectMedium : public api::WifiDirectMedium { std::shared_ptr connection_timeout_ = nullptr; // Listener to connect cancellation. - std::unique_ptr + std::unique_ptr connection_cancellation_listener_ = nullptr; }; } // namespace windows } // namespace nearby -} // namespace location #endif // PLATFORM_IMPL_WINDOWS_WIFI_DIRECT_H_ diff --git a/internal/platform/implementation/windows/wifi_direct_medium.cc b/internal/platform/implementation/windows/wifi_direct_medium.cc index 85362702f6..880bbaf708 100644 --- a/internal/platform/implementation/windows/wifi_direct_medium.cc +++ b/internal/platform/implementation/windows/wifi_direct_medium.cc @@ -28,7 +28,6 @@ #include "internal/platform/implementation/windows/utils.h" #include "internal/platform/logging.h" -namespace location { namespace nearby { namespace windows { namespace { @@ -117,7 +116,7 @@ std::unique_ptr WifiDirectMedium::ConnectToService( } connection_cancellation_listener_ = - std::make_unique( + std::make_unique( cancellation_flag, [socket]() { NEARBY_LOGS(WARNING) << "connect is closed due to it is cancelled."; @@ -638,4 +637,3 @@ std::string WifiDirectMedium::GetErrorMessage(std::exception_ptr eptr) { } // namespace windows } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/windows/wifi_direct_server_socket.cc b/internal/platform/implementation/windows/wifi_direct_server_socket.cc index 776d24410b..68eb4b0e2f 100644 --- a/internal/platform/implementation/windows/wifi_direct_server_socket.cc +++ b/internal/platform/implementation/windows/wifi_direct_server_socket.cc @@ -29,7 +29,6 @@ #include "internal/platform/implementation/windows/wifi_direct.h" #include "internal/platform/logging.h" -namespace location { namespace nearby { namespace windows { namespace { @@ -279,4 +278,3 @@ std::string WifiDirectServerSocket::GetDirectGOIpAddresses() const { } // namespace windows } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/windows/wifi_direct_socket.cc b/internal/platform/implementation/windows/wifi_direct_socket.cc index bc8c64ace1..069db83a98 100644 --- a/internal/platform/implementation/windows/wifi_direct_socket.cc +++ b/internal/platform/implementation/windows/wifi_direct_socket.cc @@ -18,7 +18,6 @@ #include "internal/platform/implementation/windows/wifi_direct.h" #include "internal/platform/logging.h" -namespace location { namespace nearby { namespace windows { @@ -198,5 +197,4 @@ Exception WifiDirectSocket::SocketOutputStream::Close() { } } // namespace windows -} // namespace nearby -} // namespace location +} // namespace nearby \ No newline at end of file diff --git a/internal/platform/implementation/windows/wifi_hotspot.h b/internal/platform/implementation/windows/wifi_hotspot.h index 451f41d14b..3364779a7a 100644 --- a/internal/platform/implementation/windows/wifi_hotspot.h +++ b/internal/platform/implementation/windows/wifi_hotspot.h @@ -44,7 +44,6 @@ #include "internal/platform/implementation/windows/generated/winrt/Windows.Storage.Streams.h" #include "internal/platform/implementation/windows/generated/winrt/base.h" -namespace location { namespace nearby { namespace windows { @@ -311,12 +310,11 @@ class WifiHotspotMedium : public api::WifiHotspotMedium { std::shared_ptr connection_timeout_ = nullptr; // Listener to connect cancellation. - std::unique_ptr + std::unique_ptr connection_cancellation_listener_ = nullptr; }; } // namespace windows } // namespace nearby -} // namespace location #endif // PLATFORM_IMPL_WINDOWS_WIFI_HOTSPOT_H_ diff --git a/internal/platform/implementation/windows/wifi_hotspot_medium.cc b/internal/platform/implementation/windows/wifi_hotspot_medium.cc index 7d8b2d8ae1..4a8a978c63 100644 --- a/internal/platform/implementation/windows/wifi_hotspot_medium.cc +++ b/internal/platform/implementation/windows/wifi_hotspot_medium.cc @@ -26,7 +26,6 @@ #include "internal/platform/implementation/windows/utils.h" #include "internal/platform/logging.h" -namespace location { namespace nearby { namespace windows { namespace { @@ -118,7 +117,7 @@ std::unique_ptr WifiHotspotMedium::ConnectToService( } connection_cancellation_listener_ = - std::make_unique( + std::make_unique( cancellation_flag, [socket]() { NEARBY_LOGS(WARNING) << "connect is closed due to it is cancelled."; @@ -624,4 +623,3 @@ std::string WifiHotspotMedium::GetErrorMessage(std::exception_ptr eptr) { } // namespace windows } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/windows/wifi_hotspot_server_socket.cc b/internal/platform/implementation/windows/wifi_hotspot_server_socket.cc index 93643ace60..56e392fa0e 100644 --- a/internal/platform/implementation/windows/wifi_hotspot_server_socket.cc +++ b/internal/platform/implementation/windows/wifi_hotspot_server_socket.cc @@ -29,7 +29,6 @@ #include "internal/platform/implementation/windows/wifi_hotspot.h" #include "internal/platform/logging.h" -namespace location { namespace nearby { namespace windows { namespace { @@ -279,4 +278,3 @@ std::string WifiHotspotServerSocket::GetHotspotIpAddresses() const { } // namespace windows } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/windows/wifi_hotspot_socket.cc b/internal/platform/implementation/windows/wifi_hotspot_socket.cc index 54e28a6113..5a0c3e4d5c 100644 --- a/internal/platform/implementation/windows/wifi_hotspot_socket.cc +++ b/internal/platform/implementation/windows/wifi_hotspot_socket.cc @@ -18,7 +18,6 @@ #include "internal/platform/implementation/windows/wifi_hotspot.h" #include "internal/platform/logging.h" -namespace location { namespace nearby { namespace windows { @@ -199,4 +198,3 @@ Exception WifiHotspotSocket::SocketOutputStream::Close() { } // namespace windows } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/windows/wifi_lan.h b/internal/platform/implementation/windows/wifi_lan.h index 772bffbde0..0783d9cf5a 100644 --- a/internal/platform/implementation/windows/wifi_lan.h +++ b/internal/platform/implementation/windows/wifi_lan.h @@ -56,7 +56,6 @@ #include "internal/platform/implementation/windows/generated/winrt/Windows.Storage.Streams.h" #include "internal/platform/implementation/windows/generated/winrt/base.h" -namespace location { namespace nearby { namespace windows { @@ -375,12 +374,11 @@ class WifiLanMedium : public api::WifiLanMedium { std::shared_ptr connection_timeout_ = nullptr; // Listener to connect cancellation. - std::unique_ptr + std::unique_ptr connection_cancellation_listener_ = nullptr; }; } // namespace windows } // namespace nearby -} // namespace location #endif // PLATFORM_IMPL_WINDOWS_WIFI_LAN_H_ diff --git a/internal/platform/implementation/windows/wifi_lan_medium.cc b/internal/platform/implementation/windows/wifi_lan_medium.cc index ebed2db6cc..36e0d229f1 100644 --- a/internal/platform/implementation/windows/wifi_lan_medium.cc +++ b/internal/platform/implementation/windows/wifi_lan_medium.cc @@ -42,7 +42,6 @@ #include "internal/platform/logging.h" #include "internal/platform/runnable.h" -namespace location { namespace nearby { namespace windows { namespace { @@ -364,7 +363,7 @@ std::unique_ptr WifiLanMedium::ConnectToService( } connection_cancellation_listener_ = - std::make_unique( + std::make_unique( cancellation_flag, [socket]() { NEARBY_LOGS(WARNING) << "connect is closed due to it is cancelled."; @@ -794,4 +793,3 @@ std::string WifiLanMedium::GetErrorMessage(std::exception_ptr eptr) { } // namespace windows } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/windows/wifi_lan_server_socket.cc b/internal/platform/implementation/windows/wifi_lan_server_socket.cc index 7894b34ba8..2b75c5dc6a 100644 --- a/internal/platform/implementation/windows/wifi_lan_server_socket.cc +++ b/internal/platform/implementation/windows/wifi_lan_server_socket.cc @@ -25,7 +25,6 @@ #include "internal/platform/implementation/windows/wifi_lan.h" #include "internal/platform/logging.h" -namespace location { namespace nearby { namespace windows { namespace { @@ -248,4 +247,3 @@ std::vector WifiLanServerSocket::GetIpAddresses() const { } // namespace windows } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/windows/wifi_lan_socket.cc b/internal/platform/implementation/windows/wifi_lan_socket.cc index 7e9a7ab111..12a063702f 100644 --- a/internal/platform/implementation/windows/wifi_lan_socket.cc +++ b/internal/platform/implementation/windows/wifi_lan_socket.cc @@ -18,7 +18,6 @@ #include "internal/platform/implementation/windows/wifi_lan.h" #include "internal/platform/logging.h" -namespace location { namespace nearby { namespace windows { @@ -198,4 +197,3 @@ Exception WifiLanSocket::SocketOutputStream::Close() { } // namespace windows } // namespace nearby -} // namespace location diff --git a/internal/platform/implementation/windows/wifi_medium.cc b/internal/platform/implementation/windows/wifi_medium.cc index 034a139b05..88de705a63 100644 --- a/internal/platform/implementation/windows/wifi_medium.cc +++ b/internal/platform/implementation/windows/wifi_medium.cc @@ -20,7 +20,6 @@ #include "internal/platform/implementation/windows/wifi.h" #include "internal/platform/logging.h" -namespace location { namespace nearby { namespace windows { @@ -251,4 +250,3 @@ std::string WifiMedium::InternalGetIpAddress() { } // namespace windows } // namespace nearby -} // namespace location diff --git a/internal/platform/input_stream.cc b/internal/platform/input_stream.cc index 9bae0f7039..2aaf2d3ac7 100644 --- a/internal/platform/input_stream.cc +++ b/internal/platform/input_stream.cc @@ -21,7 +21,6 @@ #include "internal/platform/byte_array.h" #include "internal/platform/exception.h" -namespace location { namespace nearby { namespace { constexpr size_t kSkipBufferSize = 64 * 1024; @@ -41,4 +40,3 @@ ExceptionOr InputStream::Skip(size_t offset) { } } // namespace nearby -} // namespace location diff --git a/internal/platform/input_stream.h b/internal/platform/input_stream.h index 905f5aa116..82c216efe2 100644 --- a/internal/platform/input_stream.h +++ b/internal/platform/input_stream.h @@ -20,7 +20,6 @@ #include "internal/platform/byte_array.h" #include "internal/platform/exception.h" -namespace location { namespace nearby { // An InputStream represents an input stream of bytes. @@ -41,6 +40,5 @@ class InputStream { }; } // namespace nearby -} // namespace location #endif // PLATFORM_BASE_INPUT_STREAM_H_ diff --git a/internal/platform/listeners.h b/internal/platform/listeners.h index 987e4d66d5..98977c39dd 100644 --- a/internal/platform/listeners.h +++ b/internal/platform/listeners.h @@ -17,7 +17,6 @@ #include -namespace location { namespace nearby { // Provides default-initialization with a valid empty method, @@ -29,6 +28,5 @@ constexpr std::function DefaultCallback() { } } // namespace nearby -} // namespace location #endif // PLATFORM_BASE_LISTENERS_H_ diff --git a/internal/platform/lockable.h b/internal/platform/lockable.h index 73d4572127..a09823d5f8 100644 --- a/internal/platform/lockable.h +++ b/internal/platform/lockable.h @@ -17,7 +17,6 @@ #include "absl/base/thread_annotations.h" -namespace location { namespace nearby { // A resource that can be locked. This class is provided @@ -46,6 +45,5 @@ class ABSL_SCOPED_LOCKABLE ThreadLockHolder { }; } // namespace nearby -} // namespace location #endif // PLATFORM_PUBLIC_LOCKABLE_H_ diff --git a/internal/platform/logging.h b/internal/platform/logging.h index 5da04c104c..3bdc654ae8 100644 --- a/internal/platform/logging.h +++ b/internal/platform/logging.h @@ -42,7 +42,6 @@ #include "internal/platform/implementation/log_message.h" #include "internal/platform/implementation/platform.h" -namespace location { namespace nearby { // This class is used to explicitly ignore values in the conditional @@ -57,46 +56,39 @@ class LogMessageVoidify { }; } // namespace nearby -} // namespace location // Severity enum conversion -#define NEARBY_SEVERITY_VERBOSE \ - location::nearby::api::LogMessage::Severity::kVerbose -#define NEARBY_SEVERITY_INFO location::nearby::api::LogMessage::Severity::kInfo -#define NEARBY_SEVERITY_WARNING \ - location::nearby::api::LogMessage::Severity::kWarning -#define NEARBY_SEVERITY_ERROR \ - location::nearby::api::LogMessage::Severity::kError -#define NEARBY_SEVERITY_FATAL \ - location::nearby::api::LogMessage::Severity::kFatal +#define NEARBY_SEVERITY_VERBOSE nearby::api::LogMessage::Severity::kVerbose +#define NEARBY_SEVERITY_INFO nearby::api::LogMessage::Severity::kInfo +#define NEARBY_SEVERITY_WARNING nearby::api::LogMessage::Severity::kWarning +#define NEARBY_SEVERITY_ERROR nearby::api::LogMessage::Severity::kError +#define NEARBY_SEVERITY_FATAL nearby::api::LogMessage::Severity::kFatal #if defined(_WIN32) // wingdi.h defines ERROR to be 0. When we call LOG(ERROR), it gets substituted // with 0, and it expands to NEARBY_SEVERITY_0. To allow us to keep using this // syntax, we define this macro to do the same thing as NEARBY_SEVERITY_ERROR. -#define NEARBY_SEVERITY_0 location::nearby::api::LogMessage::Severity::kError +#define NEARBY_SEVERITY_0 nearby::api::LogMessage::Severity::kError #endif // defined(_WIN32) #define NEARBY_SEVERITY(severity) NEARBY_SEVERITY_##severity // Log enabling -#define NEARBY_LOG_IS_ON(severity) \ - location::nearby::api::LogMessage::ShouldCreateLogMessage( \ - NEARBY_SEVERITY(severity)) +#define NEARBY_LOG_IS_ON(severity) \ + nearby::api::LogMessage::ShouldCreateLogMessage(NEARBY_SEVERITY(severity)) -#define NEARBY_LOG_SET_SEVERITY(severity) \ - location::nearby::api::LogMessage::SetMinLogSeverity( \ - NEARBY_SEVERITY(severity)) +#define NEARBY_LOG_SET_SEVERITY(severity) \ + nearby::api::LogMessage::SetMinLogSeverity(NEARBY_SEVERITY(severity)) // Log message creation -#define NEARBY_LOG_MESSAGE(severity) \ - location::nearby::api::ImplementationPlatform::CreateLogMessage( \ +#define NEARBY_LOG_MESSAGE(severity) \ + nearby::api::ImplementationPlatform::CreateLogMessage( \ __FILE__, __LINE__, NEARBY_SEVERITY(severity)) // Public APIs // The stream statement must come last or otherwise it won't compile. -#define NEARBY_LOGS(severity) \ - !(NEARBY_LOG_IS_ON(severity)) ? (void)0 \ - : location::nearby::LogMessageVoidify() & \ - NEARBY_LOG_MESSAGE(severity)->Stream() +#define NEARBY_LOGS(severity) \ + !(NEARBY_LOG_IS_ON(severity)) \ + ? (void)0 \ + : nearby::LogMessageVoidify() & NEARBY_LOG_MESSAGE(severity)->Stream() #define NEARBY_LOG(severity, ...) \ NEARBY_LOG_IS_ON(severity) \ diff --git a/internal/platform/medium_environment.cc b/internal/platform/medium_environment.cc index 290ee1b6ef..2ab17bf56c 100644 --- a/internal/platform/medium_environment.cc +++ b/internal/platform/medium_environment.cc @@ -32,7 +32,6 @@ #include "internal/platform/logging.h" #include "internal/platform/prng.h" -namespace location { namespace nearby { MediumEnvironment& MediumEnvironment::Instance() { @@ -1109,4 +1108,3 @@ void MediumEnvironment::SetFeatureFlags(const FeatureFlags::Flags& flags) { } } // namespace nearby -} // namespace location diff --git a/internal/platform/medium_environment.h b/internal/platform/medium_environment.h index 1d357fcad2..7334b79087 100644 --- a/internal/platform/medium_environment.h +++ b/internal/platform/medium_environment.h @@ -44,7 +44,6 @@ #include "internal/platform/single_thread_executor.h" #include "internal/platform/wifi_hotspot_credential.h" -namespace location { namespace nearby { // Environment config that can control availability of certain mediums for @@ -452,11 +451,9 @@ class MediumEnvironment { absl::flat_hash_map ble_mediums_; absl::flat_hash_map ble_v2_mediums_; - absl::flat_hash_map + absl::flat_hash_map gatt_advertisement_bytes_; - absl::flat_hash_map + absl::flat_hash_map discovered_gatt_advertisement_bytes_; #ifndef NO_WEBRTC @@ -484,6 +481,5 @@ class MediumEnvironment { }; } // namespace nearby -} // namespace location #endif // PLATFORM_BASE_MEDIUM_ENVIRONMENT_H_ diff --git a/internal/platform/monitored_runnable.cc b/internal/platform/monitored_runnable.cc index b8a38dfa61..30127a2ac5 100644 --- a/internal/platform/monitored_runnable.cc +++ b/internal/platform/monitored_runnable.cc @@ -17,7 +17,6 @@ #include "internal/platform/logging.h" #include "internal/platform/pending_job_registry.h" -namespace location { namespace nearby { namespace { @@ -56,4 +55,3 @@ void MonitoredRunnable::operator()() const { } } // namespace nearby -} // namespace location diff --git a/internal/platform/monitored_runnable.h b/internal/platform/monitored_runnable.h index 61ff2ad0c3..d5770aeef8 100644 --- a/internal/platform/monitored_runnable.h +++ b/internal/platform/monitored_runnable.h @@ -21,7 +21,6 @@ #include "internal/platform/runnable.h" #include "internal/platform/system_clock.h" -namespace location { namespace nearby { // A runnable with extra logging @@ -43,6 +42,5 @@ class MonitoredRunnable { }; } // namespace nearby -} // namespace location #endif // PLATFORM_PUBLIC_MONITORED_RUNNABLE_H_ diff --git a/internal/platform/multi_thread_executor.h b/internal/platform/multi_thread_executor.h index 4e6644bcea..02605e4de4 100644 --- a/internal/platform/multi_thread_executor.h +++ b/internal/platform/multi_thread_executor.h @@ -19,7 +19,6 @@ #include "internal/platform/implementation/platform.h" #include "internal/platform/submittable_executor.h" -namespace location { namespace nearby { // An Executor that reuses a fixed number of threads operating off a shared @@ -38,6 +37,5 @@ class ABSL_LOCKABLE MultiThreadExecutor final : public SubmittableExecutor { }; } // namespace nearby -} // namespace location #endif // PLATFORM_PUBLIC_MULTI_THREAD_EXECUTOR_H_ diff --git a/internal/platform/multi_thread_executor_test.cc b/internal/platform/multi_thread_executor_test.cc index 44231e4180..d65d154b74 100644 --- a/internal/platform/multi_thread_executor_test.cc +++ b/internal/platform/multi_thread_executor_test.cc @@ -23,7 +23,6 @@ #include "absl/time/time.h" #include "internal/platform/exception.h" -namespace location { namespace nearby { namespace { @@ -135,4 +134,3 @@ TEST(MultiThreadExecutorTest, ThreadCheck_SubmitCallable) { EXPECT_EQ(future.Get().result(), 0); } } // namespace nearby -} // namespace location diff --git a/internal/platform/mutex.h b/internal/platform/mutex.h index e7b6b564e3..1bf9d054b6 100644 --- a/internal/platform/mutex.h +++ b/internal/platform/mutex.h @@ -21,7 +21,6 @@ #include "internal/platform/implementation/mutex.h" #include "internal/platform/implementation/platform.h" -namespace location { namespace nearby { // This is a classic mutex can be acquired at most once. @@ -73,6 +72,5 @@ class ABSL_LOCKABLE RecursiveMutex final { }; } // namespace nearby -} // namespace location #endif // PLATFORM_PUBLIC_MUTEX_H_ diff --git a/internal/platform/mutex_lock.h b/internal/platform/mutex_lock.h index 463ef8b7af..cb86a74167 100644 --- a/internal/platform/mutex_lock.h +++ b/internal/platform/mutex_lock.h @@ -19,7 +19,6 @@ #include "internal/platform/implementation/mutex.h" #include "internal/platform/mutex.h" -namespace location { namespace nearby { // An RAII mechanism to acquire a Lock over a block of code. @@ -40,6 +39,5 @@ class ABSL_SCOPED_LOCKABLE MutexLock final { }; } // namespace nearby -} // namespace location #endif // PLATFORM_PUBLIC_MUTEX_LOCK_H_ diff --git a/internal/platform/mutex_test.cc b/internal/platform/mutex_test.cc index 31905d250a..ad0a9b41d9 100644 --- a/internal/platform/mutex_test.cc +++ b/internal/platform/mutex_test.cc @@ -21,7 +21,6 @@ #include "internal/platform/condition_variable.h" #include "internal/platform/single_thread_executor.h" -namespace location { namespace nearby { namespace { @@ -114,4 +113,3 @@ TEST_F(MutexTest, DoubleLockIsNotDeadlock) { } // namespace } // namespace nearby -} // namespace location diff --git a/internal/platform/nsd_service_info.cc b/internal/platform/nsd_service_info.cc index 24624c301d..dc7740e797 100644 --- a/internal/platform/nsd_service_info.cc +++ b/internal/platform/nsd_service_info.cc @@ -14,10 +14,8 @@ #include "internal/platform/nsd_service_info.h" -namespace location { namespace nearby { constexpr absl::string_view NsdServiceInfo::kNsdTypeFormat; } // namespace nearby -} // namespace location diff --git a/internal/platform/nsd_service_info.h b/internal/platform/nsd_service_info.h index d870bd41f0..2696243423 100644 --- a/internal/platform/nsd_service_info.h +++ b/internal/platform/nsd_service_info.h @@ -19,7 +19,6 @@ #include "absl/container/flat_hash_map.h" -namespace location { namespace nearby { // https://developer.android.com/reference/android/net/nsd/NsdServiceInfo.html. @@ -99,6 +98,5 @@ class NsdServiceInfo { }; } // namespace nearby -} // namespace location #endif // PLATFORM_BASE_NSD_SERVICE_INFO_H_ diff --git a/internal/platform/os_name.h b/internal/platform/os_name.h index 028bfa55e0..c3163fa75f 100644 --- a/internal/platform/os_name.h +++ b/internal/platform/os_name.h @@ -15,7 +15,6 @@ #ifndef PLATFORM_OS_NAME_H_ #define PLATFORM_OS_NAME_H_ -namespace location { namespace nearby { namespace api { @@ -23,6 +22,5 @@ enum class OSName { kLinux, kWindows, kiOS, kChromeOS }; } // namespace api } // namespace nearby -} // namespace location #endif // PLATFORM_OS_NAME_H_ diff --git a/internal/platform/output_stream.h b/internal/platform/output_stream.h index fbc644e07f..8531032424 100644 --- a/internal/platform/output_stream.h +++ b/internal/platform/output_stream.h @@ -18,7 +18,6 @@ #include "internal/platform/byte_array.h" #include "internal/platform/exception.h" -namespace location { namespace nearby { // An OutputStream represents an output stream of bytes. @@ -34,6 +33,5 @@ class OutputStream { }; } // namespace nearby -} // namespace location #endif // PLATFORM_BASE_OUTPUT_STREAM_H_ diff --git a/internal/platform/payload_id.h b/internal/platform/payload_id.h index d28eebe035..fe0a2c9d07 100644 --- a/internal/platform/payload_id.h +++ b/internal/platform/payload_id.h @@ -17,12 +17,10 @@ #include -namespace location { namespace nearby { using PayloadId = std::int64_t; } // namespace nearby -} // namespace location #endif // PLATFORM_BASE_PAYLOAD_ID_H_ diff --git a/internal/platform/pending_job_registry.cc b/internal/platform/pending_job_registry.cc index c546805c63..57e02d524b 100644 --- a/internal/platform/pending_job_registry.cc +++ b/internal/platform/pending_job_registry.cc @@ -18,7 +18,6 @@ #include "internal/platform/mutex_lock.h" #include "internal/platform/system_clock.h" -namespace location { namespace nearby { namespace { @@ -88,4 +87,3 @@ std::string PendingJobRegistry::CreateKey(const std::string& name, } } // namespace nearby -} // namespace location diff --git a/internal/platform/pending_job_registry.h b/internal/platform/pending_job_registry.h index f2d85e4a37..343840bfa5 100644 --- a/internal/platform/pending_job_registry.h +++ b/internal/platform/pending_job_registry.h @@ -19,7 +19,6 @@ #include "absl/time/time.h" #include "internal/platform/mutex.h" -namespace location { namespace nearby { // A global registry of running tasks. The goal is to help us monitor @@ -50,6 +49,5 @@ class PendingJobRegistry { }; } // namespace nearby -} // namespace location #endif // PLATFORM_PUBLIC_PENDING_JOB_REGISTRY_H_ diff --git a/internal/platform/pipe.cc b/internal/platform/pipe.cc index 59de0a1521..ad630d4e8e 100644 --- a/internal/platform/pipe.cc +++ b/internal/platform/pipe.cc @@ -18,7 +18,6 @@ #include "internal/platform/implementation/mutex.h" #include "internal/platform/implementation/platform.h" -namespace location { namespace nearby { namespace { @@ -32,4 +31,3 @@ Pipe::Pipe() { } } // namespace nearby -} // namespace location diff --git a/internal/platform/pipe.h b/internal/platform/pipe.h index 35d33b6f3e..a96bfbbc46 100644 --- a/internal/platform/pipe.h +++ b/internal/platform/pipe.h @@ -17,7 +17,6 @@ #include "internal/platform/base_pipe.h" -namespace location { namespace nearby { // See for details: @@ -31,6 +30,5 @@ class Pipe final : public BasePipe { }; } // namespace nearby -} // namespace location #endif // PLATFORM_PUBLIC_PIPE_H_ diff --git a/internal/platform/pipe_test.cc b/internal/platform/pipe_test.cc index b2a3845203..3aa0e6327c 100644 --- a/internal/platform/pipe_test.cc +++ b/internal/platform/pipe_test.cc @@ -24,7 +24,6 @@ #include "internal/platform/prng.h" #include "internal/platform/runnable.h" -namespace location { namespace nearby { TEST(PipeTest, ConstructorDestructorWorks) { @@ -341,4 +340,3 @@ TEST(PipeTest, ConcurrentWriteAndRead) { } } // namespace nearby -} // namespace location diff --git a/internal/platform/prng.cc b/internal/platform/prng.cc index 4f8af54f2a..5a4f94b777 100644 --- a/internal/platform/prng.cc +++ b/internal/platform/prng.cc @@ -18,7 +18,6 @@ #include "absl/time/clock.h" -namespace location { namespace nearby { #define UNSIGNED_INT_BITMASK (std::numeric_limits::max()) @@ -56,4 +55,3 @@ std::int64_t Prng::NextInt64() { } } // namespace nearby -} // namespace location diff --git a/internal/platform/prng.h b/internal/platform/prng.h index a4afb491eb..2cdb8df08a 100644 --- a/internal/platform/prng.h +++ b/internal/platform/prng.h @@ -17,7 +17,6 @@ #include -namespace location { namespace nearby { // A (non-cryptographic) pseudo-random number generator. @@ -32,6 +31,5 @@ class Prng { }; } // namespace nearby -} // namespace location #endif // PLATFORM_BASE_PRNG_H_ diff --git a/internal/platform/prng_test.cc b/internal/platform/prng_test.cc index 959e557d6d..dc241866a0 100644 --- a/internal/platform/prng_test.cc +++ b/internal/platform/prng_test.cc @@ -22,7 +22,6 @@ #include "gtest/gtest.h" #include "absl/synchronization/mutex.h" -namespace location { namespace nearby { enum class TestMode { @@ -148,4 +147,3 @@ TEST(PrngTest, ValidateInt32) { ValidateRandom(TestMode::kInt32); } TEST(PrngTest, ValidateUint32) { ValidateRandom(TestMode::kUint32); } } // namespace nearby -} // namespace location diff --git a/internal/platform/runnable.h b/internal/platform/runnable.h index 24f2349ce2..b4786b1b4c 100644 --- a/internal/platform/runnable.h +++ b/internal/platform/runnable.h @@ -17,7 +17,6 @@ #include -namespace location { namespace nearby { // The Runnable is an object intended to be executed by a thread. @@ -28,6 +27,5 @@ namespace nearby { using Runnable = std::function; } // namespace nearby -} // namespace location #endif // PLATFORM_BASE_RUNNABLE_H_ diff --git a/internal/platform/scheduled_executor.h b/internal/platform/scheduled_executor.h index 47d87085de..5baa68bc72 100644 --- a/internal/platform/scheduled_executor.h +++ b/internal/platform/scheduled_executor.h @@ -33,7 +33,6 @@ #include "internal/platform/thread_check_callable.h" #include "internal/platform/thread_check_runnable.h" -namespace location { namespace nearby { // An Executor that can schedule commands to run after a given delay, or to @@ -104,6 +103,5 @@ class ABSL_LOCKABLE ScheduledExecutor final : public Lockable { }; } // namespace nearby -} // namespace location #endif // PLATFORM_PUBLIC_SCHEDULED_EXECUTOR_H_ diff --git a/internal/platform/scheduled_executor_test.cc b/internal/platform/scheduled_executor_test.cc index 675cf36fca..fc7c8714d9 100644 --- a/internal/platform/scheduled_executor_test.cc +++ b/internal/platform/scheduled_executor_test.cc @@ -24,7 +24,6 @@ #include "internal/platform/exception.h" #include "internal/platform/count_down_latch.h" -namespace location { namespace nearby { // kShortDelay must be significant enough to guarantee that OS under heavy load @@ -203,4 +202,3 @@ TEST(ScheduledExecutorTest, ThreadCheck_Schedule) { } } // namespace nearby -} // namespace location diff --git a/internal/platform/settable_future.h b/internal/platform/settable_future.h index 1265559beb..aab3fbdb2d 100644 --- a/internal/platform/settable_future.h +++ b/internal/platform/settable_future.h @@ -22,7 +22,6 @@ #include "internal/platform/mutex_lock.h" #include "internal/platform/system_clock.h" -namespace location { namespace nearby { template @@ -123,6 +122,5 @@ class SettableFuture : public api::SettableFuture { }; } // namespace nearby -} // namespace location #endif // PLATFORM_PUBLIC_SETTABLE_FUTURE_H_ diff --git a/internal/platform/single_thread_executor.h b/internal/platform/single_thread_executor.h index cc8159893d..27a80f40bb 100644 --- a/internal/platform/single_thread_executor.h +++ b/internal/platform/single_thread_executor.h @@ -18,7 +18,6 @@ #include "absl/base/thread_annotations.h" #include "internal/platform/submittable_executor.h" -namespace location { namespace nearby { // An Executor that uses a single worker thread operating off an unbounded @@ -36,6 +35,5 @@ class ABSL_LOCKABLE SingleThreadExecutor final : public SubmittableExecutor { }; } // namespace nearby -} // namespace location #endif // PLATFORM_PUBLIC_SINGLE_THREAD_EXECUTOR_H_ diff --git a/internal/platform/single_thread_executor_test.cc b/internal/platform/single_thread_executor_test.cc index 653629360e..3c0925abb8 100644 --- a/internal/platform/single_thread_executor_test.cc +++ b/internal/platform/single_thread_executor_test.cc @@ -23,7 +23,6 @@ #include "absl/time/clock.h" #include "internal/platform/exception.h" -namespace location { namespace nearby { TEST(SingleThreadExecutorTest, ConsructorDestructorWorks) { @@ -136,4 +135,3 @@ TEST(SingleThreadExecutorTest, ThreadCheck_SubmitCallable) { } } // namespace nearby -} // namespace location diff --git a/internal/platform/socket.h b/internal/platform/socket.h index 1d746f690c..43acd77c01 100644 --- a/internal/platform/socket.h +++ b/internal/platform/socket.h @@ -18,7 +18,6 @@ #include "internal/platform/input_stream.h" #include "internal/platform/output_stream.h" -namespace location { namespace nearby { // A socket is an endpoint for communication between two machines. @@ -34,6 +33,5 @@ class Socket { }; } // namespace nearby -} // namespace location #endif // PLATFORM_BASE_SOCKET_H_ diff --git a/internal/platform/submittable_executor.h b/internal/platform/submittable_executor.h index 12cbfd5bca..48685bf563 100644 --- a/internal/platform/submittable_executor.h +++ b/internal/platform/submittable_executor.h @@ -33,7 +33,6 @@ #include "internal/platform/thread_check_callable.h" #include "internal/platform/thread_check_runnable.h" -namespace location { namespace nearby { inline int GetCurrentTid() { return api::GetCurrentTid(); } @@ -125,6 +124,5 @@ class ABSL_LOCKABLE SubmittableExecutor : public api::SubmittableExecutor, }; } // namespace nearby -} // namespace location #endif // PLATFORM_PUBLIC_SUBMITTABLE_EXECUTOR_H_ diff --git a/internal/platform/thread_check_callable.h b/internal/platform/thread_check_callable.h index f9a4e003de..f29099c59d 100644 --- a/internal/platform/thread_check_callable.h +++ b/internal/platform/thread_check_callable.h @@ -19,7 +19,6 @@ #include "internal/platform/callable.h" #include "internal/platform/lockable.h" -namespace location { namespace nearby { // A callable that acquires a lockable resource while running. @@ -41,6 +40,5 @@ class ThreadCheckCallable { }; } // namespace nearby -} // namespace location #endif // PLATFORM_PUBLIC_THREAD_CHECK_CALLABLE_H_ diff --git a/internal/platform/thread_check_nocompile.cc b/internal/platform/thread_check_nocompile.cc index 90bde99f9a..6c5bc2dcc0 100644 --- a/internal/platform/thread_check_nocompile.cc +++ b/internal/platform/thread_check_nocompile.cc @@ -19,7 +19,7 @@ // Snippets of invalid code that should trigger an error during thread // safety analysis at compile time. // See https://g3doc.corp.google.com/googletest/g3doc/cpp_nc_test.md -namespace location { + namespace nearby { #ifdef TEST_EXECUTE_MISSING_METHOD_ANNOTATION @@ -80,4 +80,3 @@ void TestSchedule_MissingMethodAnnotation() { #endif // TEST_SCHEDULE_MISSING_METHOD_ANNOTATION } // namespace nearby -} // namespace location diff --git a/internal/platform/thread_check_runnable.h b/internal/platform/thread_check_runnable.h index df40d98762..0d9c24153b 100644 --- a/internal/platform/thread_check_runnable.h +++ b/internal/platform/thread_check_runnable.h @@ -21,7 +21,6 @@ #include "internal/platform/runnable.h" #include "internal/platform/lockable.h" -namespace location { namespace nearby { // A runnable that acquires a lockable resource while running. @@ -42,6 +41,5 @@ class ThreadCheckRunnable { }; } // namespace nearby -} // namespace location #endif // PLATFORM_PUBLIC_THREAD_CHECK_RUNNABLE_H_ diff --git a/internal/platform/types.h b/internal/platform/types.h index d082b26237..7dae576fa5 100644 --- a/internal/platform/types.h +++ b/internal/platform/types.h @@ -17,7 +17,6 @@ #include -namespace location { namespace nearby { // Similar to static_cast, but will assert that Derived is a derived type of @@ -39,6 +38,5 @@ inline Derived down_cast(Base* value) { } } // namespace nearby -} // namespace location #endif // PLATFORM_BASE_TYPES_H_ diff --git a/internal/platform/uuid.cc b/internal/platform/uuid.cc index 36951a4ced..9925ba50c5 100644 --- a/internal/platform/uuid.cc +++ b/internal/platform/uuid.cc @@ -21,7 +21,6 @@ #include "absl/strings/escaping.h" #include "internal/platform/implementation/crypto.h" -namespace location { namespace nearby { namespace { std::ostream& write_hex(std::ostream& os, absl::string_view data) { @@ -112,4 +111,3 @@ bool Uuid::operator==(const Uuid& rhs) const { } } // namespace nearby -} // namespace location diff --git a/internal/platform/uuid.h b/internal/platform/uuid.h index 7dd6b9a67b..07d453b959 100644 --- a/internal/platform/uuid.h +++ b/internal/platform/uuid.h @@ -21,7 +21,6 @@ #include "absl/strings/string_view.h" -namespace location { namespace nearby { // A type 3 name-based @@ -76,6 +75,5 @@ class Uuid final { }; } // namespace nearby -} // namespace location #endif // THIRD_PARTY_NEARBY_INTERNAL_PLATFORM_UUID_H_ diff --git a/internal/platform/uuid_test.cc b/internal/platform/uuid_test.cc index 61748b33b6..c269cb2b6c 100644 --- a/internal/platform/uuid_test.cc +++ b/internal/platform/uuid_test.cc @@ -22,7 +22,6 @@ #include "internal/platform/crypto.h" #include "internal/platform/logging.h" -namespace location { namespace nearby { namespace { @@ -127,4 +126,3 @@ TEST(UuidTest, ComparisonEqualWorksForString) { } // namespace } // namespace nearby -} // namespace location diff --git a/internal/platform/webrtc.h b/internal/platform/webrtc.h index 8d5ef58ff5..6c88c89079 100644 --- a/internal/platform/webrtc.h +++ b/internal/platform/webrtc.h @@ -21,7 +21,6 @@ #include "internal/platform/implementation/webrtc.h" #include "webrtc/api/peer_connection_interface.h" -namespace location { namespace nearby { class WebRtcSignalingMessenger final { @@ -82,7 +81,7 @@ class WebRtcMedium final { // Returns a signaling messenger for sending WebRTC signaling messages. std::unique_ptr GetSignalingMessenger( absl::string_view self_id, - const connections::LocationHint& location_hint) { + const location::nearby::connections::LocationHint& location_hint) { return std::make_unique( impl_->GetSignalingMessenger(self_id, location_hint)); } @@ -94,6 +93,5 @@ class WebRtcMedium final { }; } // namespace nearby -} // namespace location #endif // PLATFORM_PUBLIC_WEBRTC_H_ diff --git a/internal/platform/wifi.h b/internal/platform/wifi.h index d1d0785ca8..e0f27f65ef 100644 --- a/internal/platform/wifi.h +++ b/internal/platform/wifi.h @@ -21,9 +21,6 @@ #ifndef PLATFORM_PUBLIC_WIFI_H_ #define PLATFORM_PUBLIC_WIFI_H_ - - -namespace location { namespace nearby { class WifiMedium { @@ -71,6 +68,5 @@ class WifiMedium { }; } // namespace nearby -} // namespace location #endif // PLATFORM_PUBLIC_WIFI_H_ diff --git a/internal/platform/wifi_direct.cc b/internal/platform/wifi_direct.cc index eface1fafe..574424a817 100644 --- a/internal/platform/wifi_direct.cc +++ b/internal/platform/wifi_direct.cc @@ -14,7 +14,6 @@ #include "internal/platform/wifi_direct.h" -namespace location { namespace nearby { WifiDirectSocket WifiDirectMedium::ConnectToService( @@ -27,4 +26,3 @@ WifiDirectSocket WifiDirectMedium::ConnectToService( } } // namespace nearby -} // namespace location diff --git a/internal/platform/wifi_direct.h b/internal/platform/wifi_direct.h index 67c0bec419..55aaa86895 100644 --- a/internal/platform/wifi_direct.h +++ b/internal/platform/wifi_direct.h @@ -24,7 +24,6 @@ #include "internal/platform/logging.h" #include "internal/platform/mutex_lock.h" -namespace location { namespace nearby { // Socket class for both WifiDirect GO ( created through accept connection from @@ -203,6 +202,5 @@ class WifiDirectMedium { }; } // namespace nearby -} // namespace location #endif // PLATFORM_PUBLIC_WIFI_DIRECT_H_ diff --git a/internal/platform/wifi_direct_test.cc b/internal/platform/wifi_direct_test.cc index c95469c1f6..2c39f4af69 100644 --- a/internal/platform/wifi_direct_test.cc +++ b/internal/platform/wifi_direct_test.cc @@ -21,7 +21,6 @@ #include "absl/strings/match.h" #include "internal/platform/medium_environment.h" -namespace location { namespace nearby { namespace { @@ -251,4 +250,3 @@ TEST_F(WifiDirectMediumTest, CanStartDirectGOThatOtherFailConnect) { } // namespace } // namespace nearby -} // namespace location diff --git a/internal/platform/wifi_hotspot.cc b/internal/platform/wifi_hotspot.cc index ce5574b77e..91d5f82de3 100644 --- a/internal/platform/wifi_hotspot.cc +++ b/internal/platform/wifi_hotspot.cc @@ -16,7 +16,6 @@ #include "internal/platform/mutex_lock.h" -namespace location { namespace nearby { WifiHotspotSocket WifiHotspotMedium::ConnectToService( @@ -29,4 +28,3 @@ WifiHotspotSocket WifiHotspotMedium::ConnectToService( } } // namespace nearby -} // namespace location diff --git a/internal/platform/wifi_hotspot.h b/internal/platform/wifi_hotspot.h index dda86dc7b7..dbe31c0a07 100644 --- a/internal/platform/wifi_hotspot.h +++ b/internal/platform/wifi_hotspot.h @@ -31,7 +31,6 @@ #include "internal/platform/output_stream.h" #include "internal/platform/wifi_hotspot_credential.h" -namespace location { namespace nearby { // Socket class for both SoftAP ( created through accept connection from STA) @@ -215,6 +214,5 @@ class WifiHotspotMedium { }; } // namespace nearby -} // namespace location #endif // PLATFORM_PUBLIC_WIFI_HOTSPOT_H_ diff --git a/internal/platform/wifi_hotspot_credential.h b/internal/platform/wifi_hotspot_credential.h index d5f3102d03..4c53ac7a2d 100644 --- a/internal/platform/wifi_hotspot_credential.h +++ b/internal/platform/wifi_hotspot_credential.h @@ -21,7 +21,6 @@ #include "internal/platform/prng.h" #include "proto/connections_enums.pb.h" -namespace location { namespace nearby { // Credentials for the currently-hosted Wifi hotspot (if any) @@ -62,10 +61,13 @@ class HotspotCredentials { int GetFrequency() const { return frequency_; } // Gets the Band - proto::connections::ConnectionBand GetBand() const { return band_; } + location::nearby::proto::connections::ConnectionBand GetBand() const { + return band_; + } // Gets the Technology - proto::connections::ConnectionTechnology GetTechnology() const { + location::nearby::proto::connections::ConnectionTechnology GetTechnology() + const { return technology_; } @@ -76,8 +78,8 @@ class HotspotCredentials { std::string gateway_ = "0.0.0.0"; int port_ = 0; int frequency_ = -1; - proto::connections::ConnectionBand band_; - proto::connections::ConnectionTechnology technology_; + location::nearby::proto::connections::ConnectionBand band_; + location::nearby::proto::connections::ConnectionTechnology technology_; }; // Credentials for the currently-hosted WifiDirect GO (if any) @@ -118,10 +120,13 @@ class WifiDirectCredentials { int GetFrequency() const { return frequency_; } // Gets the Band - proto::connections::ConnectionBand GetBand() const { return band_; } + location::nearby::proto::connections::ConnectionBand GetBand() const { + return band_; + } // Gets the Technology - proto::connections::ConnectionTechnology GetTechnology() const { + location::nearby::proto::connections::ConnectionTechnology GetTechnology() + const { return technology_; } @@ -132,11 +137,10 @@ class WifiDirectCredentials { std::string gateway_ = "0.0.0.0"; int port_ = 0; int frequency_ = -1; - proto::connections::ConnectionBand band_; - proto::connections::ConnectionTechnology technology_; + location::nearby::proto::connections::ConnectionBand band_; + location::nearby::proto::connections::ConnectionTechnology technology_; }; } // namespace nearby -} // namespace location #endif // PLATFORM_BASE_WIFI_HOTSPOT_CREDENTIAL_H_ diff --git a/internal/platform/wifi_hotspot_test.cc b/internal/platform/wifi_hotspot_test.cc index 5f160f368f..7b5f3bee8c 100644 --- a/internal/platform/wifi_hotspot_test.cc +++ b/internal/platform/wifi_hotspot_test.cc @@ -25,7 +25,6 @@ #include "internal/platform/logging.h" #include "internal/platform/wifi_hotspot_credential.h" -namespace location { namespace nearby { namespace { @@ -265,4 +264,3 @@ TEST_F(WifiHotspotMediumTest, CanStartHotspotTheOtherFailConnect) { } // namespace } // namespace nearby -} // namespace location diff --git a/internal/platform/wifi_lan.cc b/internal/platform/wifi_lan.cc index 9e434e5762..d83311a824 100644 --- a/internal/platform/wifi_lan.cc +++ b/internal/platform/wifi_lan.cc @@ -19,7 +19,6 @@ #include "internal/platform/mutex_lock.h" -namespace location { namespace nearby { bool WifiLanMedium::StartAdvertising(const NsdServiceInfo& nsd_service_info) { @@ -174,4 +173,3 @@ WifiLanSocket WifiLanMedium::ConnectToService( } } // namespace nearby -} // namespace location diff --git a/internal/platform/wifi_lan.h b/internal/platform/wifi_lan.h index 600fc93d1c..e663c8c431 100644 --- a/internal/platform/wifi_lan.h +++ b/internal/platform/wifi_lan.h @@ -30,7 +30,6 @@ #include "internal/platform/nsd_service_info.h" #include "internal/platform/output_stream.h" -namespace location { namespace nearby { class WifiLanSocket final { @@ -222,6 +221,5 @@ class WifiLanMedium { }; } // namespace nearby -} // namespace location #endif // PLATFORM_PUBLIC_WIFI_LAN_H_ diff --git a/internal/platform/wifi_lan_connection_info.cc b/internal/platform/wifi_lan_connection_info.cc index f8f16af3b2..f20ef5e18c 100644 --- a/internal/platform/wifi_lan_connection_info.cc +++ b/internal/platform/wifi_lan_connection_info.cc @@ -20,7 +20,6 @@ #include "absl/status/statusor.h" #include "absl/strings/string_view.h" -namespace location { namespace nearby { ByteArray WifiLanConnectionInfo::ToBytes() const { @@ -52,4 +51,3 @@ absl::StatusOr WifiLanConnectionInfo::FromBytes( } } // namespace nearby -} // namespace location diff --git a/internal/platform/wifi_lan_connection_info.h b/internal/platform/wifi_lan_connection_info.h index ab490951e0..64f04580d7 100644 --- a/internal/platform/wifi_lan_connection_info.h +++ b/internal/platform/wifi_lan_connection_info.h @@ -23,7 +23,6 @@ #include "internal/platform/byte_array.h" #include "internal/platform/connection_info.h" -namespace location { namespace nearby { constexpr int kIpv4AddressLength = 4; @@ -82,6 +81,5 @@ inline bool operator!=(const WifiLanConnectionInfo& a, } } // namespace nearby -} // namespace location #endif // THIRD_PARTY_NEARBY_INTERNAL_PLATFORM_WIFI_LAN_CONNECTION_INFO_H_ diff --git a/internal/platform/wifi_lan_connection_info_test.cc b/internal/platform/wifi_lan_connection_info_test.cc index c4461682b4..52cce10ad7 100644 --- a/internal/platform/wifi_lan_connection_info_test.cc +++ b/internal/platform/wifi_lan_connection_info_test.cc @@ -23,7 +23,6 @@ #include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" -namespace location { namespace nearby { namespace { @@ -137,4 +136,3 @@ TEST(WifiLanConnectionInfoTest, TestBadBytesLength) { } // namespace } // namespace nearby -} // namespace location diff --git a/internal/platform/wifi_lan_test.cc b/internal/platform/wifi_lan_test.cc index aadfa95797..430ee910a5 100644 --- a/internal/platform/wifi_lan_test.cc +++ b/internal/platform/wifi_lan_test.cc @@ -24,7 +24,6 @@ #include "internal/platform/logging.h" #include "internal/platform/medium_environment.h" -namespace location { namespace nearby { namespace { @@ -444,4 +443,3 @@ TEST_F(WifiLanMediumTest, CanDiscoverThatOtherMediumAdvertise) { } // namespace } // namespace nearby -} // namespace location diff --git a/internal/platform/wifi_test.cc b/internal/platform/wifi_test.cc index 6789f09f9f..c7cbe78b8f 100644 --- a/internal/platform/wifi_test.cc +++ b/internal/platform/wifi_test.cc @@ -18,7 +18,6 @@ #include "protobuf-matchers/protocol-buffer-matchers.h" #include "gtest/gtest.h" -namespace location { namespace nearby { namespace { @@ -43,4 +42,3 @@ TEST(WifiMediumTest, CanInformation) { } // namespace } // namespace nearby -} // namespace location diff --git a/internal/platform/wifi_utils.cc b/internal/platform/wifi_utils.cc index 95a58eed80..b6acfea17b 100644 --- a/internal/platform/wifi_utils.cc +++ b/internal/platform/wifi_utils.cc @@ -20,7 +20,6 @@ #include "absl/strings/numbers.h" #include "absl/strings/str_split.h" -namespace location { namespace nearby { // Utility function to convert channel number to frequency in MHz @@ -117,4 +116,3 @@ bool WifiUtils::ValidateIPV4(std::string ipv4) { } } // namespace nearby -} // namespace location diff --git a/internal/platform/wifi_utils.h b/internal/platform/wifi_utils.h index 7cf856a435..2d7f554643 100644 --- a/internal/platform/wifi_utils.h +++ b/internal/platform/wifi_utils.h @@ -19,10 +19,9 @@ #include "internal/platform/implementation/wifi.h" -namespace location { namespace nearby { -using ::location::nearby::api::WifiBandType; +using ::nearby::api::WifiBandType; class WifiUtils { public: @@ -54,6 +53,5 @@ class WifiUtils { }; } // namespace nearby -} // namespace location #endif // PLATFORM_BASE_WIFI_UTILS_H_ diff --git a/internal/platform/wifi_utils_test.cc b/internal/platform/wifi_utils_test.cc index dcea2a875d..16cb6791b9 100644 --- a/internal/platform/wifi_utils_test.cc +++ b/internal/platform/wifi_utils_test.cc @@ -18,7 +18,6 @@ #include "protobuf-matchers/protocol-buffer-matchers.h" #include "gtest/gtest.h" -namespace location { namespace nearby { namespace { @@ -95,5 +94,3 @@ TEST(WifiUtilsTest, Ipv4Validation) { } // namespace } // namespace nearby -} // namespace location - diff --git a/internal/proto/analytics/connections_log_test.cc b/internal/proto/analytics/connections_log_test.cc index f83d74294f..28a3b01730 100644 --- a/internal/proto/analytics/connections_log_test.cc +++ b/internal/proto/analytics/connections_log_test.cc @@ -18,7 +18,6 @@ #include "internal/proto/analytics/connections_log.pb.h" #include "proto/connections_enums.pb.h" -namespace location { namespace nearby { namespace analytics { namespace proto { @@ -122,4 +121,3 @@ TEST(ConnectionsLogTest, TwoMessagesAreIdentical) { } // namespace proto } // namespace analytics } // namespace nearby -} // namespace location diff --git a/presence/credential_test.cc b/presence/credential_test.cc index cacd193cee..b9b6aa8702 100644 --- a/presence/credential_test.cc +++ b/presence/credential_test.cc @@ -71,7 +71,7 @@ TEST(CredentialsTest, CopyPrivateCredential) { TEST(CredentialsTest, CopyPublicCredential) { PublicCredential pc1 = {}; pc1.set_identity_type(IDENTITY_TYPE_PROVISIONED); - for (const uint8_t byte : location::nearby::Uuid().data()) { + for (const uint8_t byte : nearby::Uuid().data()) { pc1.mutable_secret_id()->push_back(byte); } PublicCredential pc1_copy = {pc1}; diff --git a/presence/implementation/advertisement_decoder_test.cc b/presence/implementation/advertisement_decoder_test.cc index 91e541954a..2ed4fec59f 100644 --- a/presence/implementation/advertisement_decoder_test.cc +++ b/presence/implementation/advertisement_decoder_test.cc @@ -34,7 +34,7 @@ namespace nearby { namespace presence { namespace { -using ::location::nearby::ByteArray; // NOLINT +using ::nearby::ByteArray; // NOLINT using ::nearby::internal::PublicCredential; // NOLINT using ::testing::ElementsAre; using ::protobuf_matchers::EqualsProto; diff --git a/presence/implementation/advertisement_factory_test.cc b/presence/implementation/advertisement_factory_test.cc index 658add1523..fa13886394 100644 --- a/presence/implementation/advertisement_factory_test.cc +++ b/presence/implementation/advertisement_factory_test.cc @@ -33,7 +33,7 @@ namespace presence { namespace { -using ::location::nearby::ByteArray; // NOLINT +using ::nearby::ByteArray; // NOLINT using ::nearby::internal::IdentityType; using ::nearby::internal::PrivateCredential; // NOLINT using ::testing::NiceMock; diff --git a/presence/implementation/broadcast_manager.cc b/presence/implementation/broadcast_manager.cc index 2915a6eed8..b938c912f9 100644 --- a/presence/implementation/broadcast_manager.cc +++ b/presence/implementation/broadcast_manager.cc @@ -26,9 +26,8 @@ namespace presence { namespace { using AdvertisingCallback = - ::location::nearby::api::ble_v2::BleMedium::AdvertisingCallback; -using AdvertisingSession = - ::location::nearby::api::ble_v2::BleMedium::AdvertisingSession; + ::nearby::api::ble_v2::BleMedium::AdvertisingCallback; +using AdvertisingSession = ::nearby::api::ble_v2::BleMedium::AdvertisingSession; } // namespace diff --git a/presence/implementation/broadcast_manager.h b/presence/implementation/broadcast_manager.h index 14edb8ebd5..26b65b6db0 100644 --- a/presence/implementation/broadcast_manager.h +++ b/presence/implementation/broadcast_manager.h @@ -38,10 +38,10 @@ namespace presence { class BroadcastManager { public: - using SingleThreadExecutor = ::location::nearby::SingleThreadExecutor; + using SingleThreadExecutor = ::nearby::SingleThreadExecutor; using AdvertisingSession = - ::location::nearby::api::ble_v2::BleMedium::AdvertisingSession; - using Runnable = ::location::nearby::Runnable; + ::nearby::api::ble_v2::BleMedium::AdvertisingSession; + using Runnable = ::nearby::Runnable; using PrivateCredential = internal::PrivateCredential; BroadcastManager(Mediums& mediums, CredentialManager& credential_manager, SingleThreadExecutor& executor) { diff --git a/presence/implementation/broadcast_manager_test.cc b/presence/implementation/broadcast_manager_test.cc index ce657bf60c..6925770cc3 100644 --- a/presence/implementation/broadcast_manager_test.cc +++ b/presence/implementation/broadcast_manager_test.cc @@ -32,10 +32,10 @@ namespace nearby { namespace presence { namespace { -using FeatureFlags = ::location::nearby::FeatureFlags::Flags; +using FeatureFlags = ::nearby::FeatureFlags::Flags; using internal::IdentityType; -using ::location::nearby::CountDownLatch; -using ::location::nearby::MediumEnvironment; +using ::nearby::CountDownLatch; +using ::nearby::MediumEnvironment; using ::testing::status::StatusIs; constexpr FeatureFlags kTestCases[] = { @@ -92,14 +92,14 @@ class BroadcastManagerTest : public testing::TestWithParam { // The medium environment must be initialized (started) before the service // controller. MediumEnvironmentStarter env_; - location::nearby::Future start_broadcast_status_; + nearby::Future start_broadcast_status_; BroadcastCallback broadcast_callback_{ .start_broadcast_cb = [this](absl::Status status) { start_broadcast_status_.Set(status); }}; Mediums mediums_; CredentialManagerImpl credential_manager_; - location::nearby::SingleThreadExecutor executor_; + nearby::SingleThreadExecutor executor_; BroadcastManager broadcast_manager_{mediums_, credential_manager_, executor_}; }; diff --git a/presence/implementation/credential_manager_impl.cc b/presence/implementation/credential_manager_impl.cc index bad595ba02..f06465cb93 100644 --- a/presence/implementation/credential_manager_impl.cc +++ b/presence/implementation/credential_manager_impl.cc @@ -37,11 +37,11 @@ namespace nearby { namespace presence { namespace { -using ::location::nearby::Base64Utils; -using ::location::nearby::Crypto; -using ::location::nearby::Exception; -using ::location::nearby::ExceptionOr; -using ::location::nearby::Future; +using ::nearby::Base64Utils; +using ::nearby::Crypto; +using ::nearby::Exception; +using ::nearby::ExceptionOr; +using ::nearby::Future; using ::nearby::internal::DeviceMetadata; using ::nearby::internal::IdentityType; using ::nearby::internal::PrivateCredential; diff --git a/presence/implementation/credential_manager_impl.h b/presence/implementation/credential_manager_impl.h index 037eb66b2c..1dd52ba391 100644 --- a/presence/implementation/credential_manager_impl.h +++ b/presence/implementation/credential_manager_impl.h @@ -34,14 +34,12 @@ namespace presence { class CredentialManagerImpl : public CredentialManager { public: CredentialManagerImpl() { - credential_storage_ptr_ = - std::make_unique(); + credential_storage_ptr_ = std::make_unique(); } // Test purpose only. explicit CredentialManagerImpl( - std::unique_ptr - credential_storage_ptr) + std::unique_ptr credential_storage_ptr) : credential_storage_ptr_(std::move(credential_storage_ptr)) {} // AES only supports key sizes of 16, 24 or 32 bytes. @@ -71,8 +69,7 @@ class CredentialManagerImpl : public CredentialManager { GetPrivateCredentialsResultCallback callback) override; // Blocking version of `GetPrivateCredentials` - location::nearby::ExceptionOr< - std::vector> + nearby::ExceptionOr> GetPrivateCredentialsSync(const CredentialSelector& credential_selector, absl::Duration timeout); @@ -83,8 +80,7 @@ class CredentialManagerImpl : public CredentialManager { GetPublicCredentialsResultCallback callback) override; // Blocking version of `GetPublicCredentials`. - ::location::nearby::ExceptionOr< - std::vector<::nearby::internal::PublicCredential>> + ::nearby::ExceptionOr> GetPublicCredentialsSync(const CredentialSelector& credential_selector, PublicCredentialType public_credential_type, absl::Duration timeout); @@ -115,8 +111,7 @@ class CredentialManagerImpl : public CredentialManager { absl::string_view device_metadata_encryption_key); private: - std::unique_ptr - credential_storage_ptr_; + std::unique_ptr credential_storage_ptr_; }; } // namespace presence diff --git a/presence/implementation/credential_manager_impl_test.cc b/presence/implementation/credential_manager_impl_test.cc index af358d6d5d..167f83775c 100644 --- a/presence/implementation/credential_manager_impl_test.cc +++ b/presence/implementation/credential_manager_impl_test.cc @@ -32,7 +32,7 @@ namespace nearby { namespace presence { namespace { -using ::location::nearby::Crypto; +using ::nearby::Crypto; using ::nearby::internal::DeviceMetadata; using ::nearby::internal::IdentityType; using ::nearby::internal::PrivateCredential; @@ -63,7 +63,7 @@ CredentialSelector BuildDefaultCredentialSelector() { class CredentialManagerImplTest : public ::testing::Test { public: - class MockCredentialStorage : public location::nearby::CredentialStorageImpl { + class MockCredentialStorage : public nearby::CredentialStorageImpl { public: MOCK_METHOD(void, SaveCredentials, (absl::string_view manager_app_id, @@ -225,7 +225,7 @@ TEST(CredentialManagerImpl, UpdateRemotePublicCredentialsSuccessfully) { std::vector publicCredentials{ {public_credential_for_test}}; - location::nearby::CountDownLatch updated_latch(1); + nearby::CountDownLatch updated_latch(1); UpdateRemotePublicCredentialsCallback update_credentials_cb{ .credentials_updated_cb = [&updated_latch](absl::Status status) { diff --git a/presence/implementation/ldt_test.cc b/presence/implementation/ldt_test.cc index ca9c7f0be4..16b310aa88 100644 --- a/presence/implementation/ldt_test.cc +++ b/presence/implementation/ldt_test.cc @@ -24,7 +24,7 @@ namespace nearby { namespace presence { namespace { -using ::location::nearby::ByteArray; +using ::nearby::ByteArray; #if USE_RUST_LDT == 1 TEST(Ldt, EncryptAndDecrypt) { diff --git a/presence/implementation/mediums/ble.h b/presence/implementation/mediums/ble.h index 24b753b806..41f10fd847 100644 --- a/presence/implementation/mediums/ble.h +++ b/presence/implementation/mediums/ble.h @@ -29,8 +29,8 @@ namespace nearby { namespace presence { /** Presence advertisement service data uuid. */ -ABSL_CONST_INIT const location::nearby::Uuid kPresenceServiceUuid( - 0x0000fcf100001000, 0x800000805f9b34fb); +ABSL_CONST_INIT const nearby::Uuid kPresenceServiceUuid(0x0000fcf100001000, + 0x800000805f9b34fb); /* * This Ble class utilizes platform/ble_v2 BleV2Medium, provides ble functions @@ -40,22 +40,18 @@ ABSL_CONST_INIT const location::nearby::Uuid kPresenceServiceUuid( */ class Ble { public: - using TxPowerLevel = ::location::nearby::api::ble_v2::TxPowerLevel; - using ScanningSession = - ::location::nearby::api::ble_v2::BleMedium::ScanningSession; - using ScanningCallback = - ::location::nearby::api::ble_v2::BleMedium::ScanningCallback; - using AdvertiseParameters = - ::location::nearby::api::ble_v2::AdvertiseParameters; + using TxPowerLevel = ::nearby::api::ble_v2::TxPowerLevel; + using ScanningSession = ::nearby::api::ble_v2::BleMedium::ScanningSession; + using ScanningCallback = ::nearby::api::ble_v2::BleMedium::ScanningCallback; + using AdvertiseParameters = ::nearby::api::ble_v2::AdvertiseParameters; using AdvertisingSession = - ::location::nearby::api::ble_v2::BleMedium::AdvertisingSession; + ::nearby::api::ble_v2::BleMedium::AdvertisingSession; using AdvertisingCallback = - ::location::nearby::api::ble_v2::BleMedium::AdvertisingCallback; - using BleAdvertisementData = - ::location::nearby::api::ble_v2::BleAdvertisementData; - using BleMedium = ::location::nearby::api::ble_v2::BleMedium; + ::nearby::api::ble_v2::BleMedium::AdvertisingCallback; + using BleAdvertisementData = ::nearby::api::ble_v2::BleAdvertisementData; + using BleMedium = ::nearby::api::ble_v2::BleMedium; - explicit Ble(location::nearby::BluetoothAdapter& bluetooth_adapter) + explicit Ble(nearby::BluetoothAdapter& bluetooth_adapter) : medium_(bluetooth_adapter) {} bool IsAvailable() const { return medium_.IsValid(); } @@ -68,7 +64,7 @@ class Ble { BleAdvertisementData advertising_data = { .is_extended_advertisement = payload.is_extended_advertisement}; advertising_data.service_data.insert( - {kPresenceServiceUuid, location::nearby::ByteArray(payload.content)}); + {kPresenceServiceUuid, nearby::ByteArray(payload.content)}); AdvertiseParameters advertise_set_parameters = { .tx_power_level = ConvertPowerModeToPowerLevel(power_mode), .is_connectable = true, @@ -104,7 +100,7 @@ class Ble { return TxPowerLevel::kUnknown; } - location::nearby::BleV2Medium medium_; + nearby::BleV2Medium medium_; }; } // namespace presence diff --git a/presence/implementation/mediums/ble_test.cc b/presence/implementation/mediums/ble_test.cc index 001369e2a3..9ca5f20203 100644 --- a/presence/implementation/mediums/ble_test.cc +++ b/presence/implementation/mediums/ble_test.cc @@ -35,21 +35,17 @@ namespace nearby { namespace presence { namespace { -using FeatureFlags = ::location::nearby::FeatureFlags::Flags; -using BleV2MediumStatus = - ::location::nearby::MediumEnvironment::BleV2MediumStatus; -using ScanningSession = - ::location::nearby::api::ble_v2::BleMedium::ScanningSession; -using TxPowerLevel = ::location::nearby::api::ble_v2::TxPowerLevel; -using ScanningCallback = - ::location::nearby::api::ble_v2::BleMedium::ScanningCallback; -using Uuid = ::location::nearby::Uuid; -using ::location::nearby::api::ble_v2::BleAdvertisementData; -using ::location::nearby::api::ble_v2::BlePeripheral; +using FeatureFlags = ::nearby::FeatureFlags::Flags; +using BleV2MediumStatus = ::nearby::MediumEnvironment::BleV2MediumStatus; +using ScanningSession = ::nearby::api::ble_v2::BleMedium::ScanningSession; +using TxPowerLevel = ::nearby::api::ble_v2::TxPowerLevel; +using ScanningCallback = ::nearby::api::ble_v2::BleMedium::ScanningCallback; +using Uuid = ::nearby::Uuid; +using ::nearby::api::ble_v2::BleAdvertisementData; +using ::nearby::api::ble_v2::BlePeripheral; using AdvertisingCallback = - ::location::nearby::api::ble_v2::BleMedium::AdvertisingCallback; -using AdvertisingSession = - ::location::nearby::api::ble_v2::BleMedium::AdvertisingSession; + ::nearby::api::ble_v2::BleMedium::AdvertisingCallback; +using AdvertisingSession = ::nearby::api::ble_v2::BleMedium::AdvertisingSession; constexpr FeatureFlags kTestCases[] = { FeatureFlags{}, @@ -89,8 +85,7 @@ class BleTest : public testing::TestWithParam { absl::optional GetBleStatus(const Ble& ble) { return env_.GetBleV2MediumStatus(*ble.GetImpl()); } - location::nearby::MediumEnvironment& env_{ - location::nearby::MediumEnvironment::Instance()}; + nearby::MediumEnvironment& env_{nearby::MediumEnvironment::Instance()}; }; INSTANTIATE_TEST_SUITE_P(ParametrisedBleTest, BleTest, @@ -100,14 +95,14 @@ INSTANTIATE_TEST_SUITE_P(ParametrisedBleTest, BleTest, // are working as intended. TEST_P(BleTest, CanStartThenStopScanning) { env_.Start(); - ::location::nearby::BluetoothAdapter adapter; + ::nearby::BluetoothAdapter adapter; Ble ble(adapter); ScanRequest scan_request{ .power_mode = PowerMode::kBalanced, }; ScanningCallback scanning_callback; - location::nearby::CountDownLatch started_scanning_latch(1); + nearby::CountDownLatch started_scanning_latch(1); std::unique_ptr scannning_session = ble.StartScanning( scan_request, ScanningCallback{ @@ -133,17 +128,17 @@ TEST_P(BleTest, AdvertiseAndScan) { // Create two Ble devices, one advertises, the other one scans, and verify // that the NP advertisement was sent from one to the other. env_.Start(); - location::nearby::BluetoothAdapter client_adapter; + nearby::BluetoothAdapter client_adapter; Ble client(client_adapter); - location::nearby::BluetoothAdapter server_adapter; + nearby::BluetoothAdapter server_adapter; Ble server(server_adapter); AdvertisementData advert_data = {.is_extended_advertisement = false, .content = "my advertisement"}; ScanRequest scan_request{ .power_mode = PowerMode::kBalanced, }; - location::nearby::CountDownLatch advertise_latch(1); - location::nearby::CountDownLatch scan_latch(1); + nearby::CountDownLatch advertise_latch(1); + nearby::CountDownLatch scan_latch(1); std::vector advertisements; std::unique_ptr scanning_session = client.StartScanning( scan_request, @@ -153,7 +148,7 @@ TEST_P(BleTest, AdvertiseAndScan) { advertisements.push_back(advertisement_data); scan_latch.CountDown(); }}); - std::unique_ptr + std::unique_ptr advertising_session = server.StartAdvertising( advert_data, PowerMode::kBalanced, AdvertisingCallback{ diff --git a/presence/implementation/mediums/mediums.h b/presence/implementation/mediums/mediums.h index 8d55722536..a47679dadd 100644 --- a/presence/implementation/mediums/mediums.h +++ b/presence/implementation/mediums/mediums.h @@ -31,7 +31,7 @@ class Mediums { Ble& GetBle() { return ble_; } private: - location::nearby::BluetoothAdapter adapter_; + nearby::BluetoothAdapter adapter_; Ble ble_{adapter_}; }; diff --git a/presence/implementation/scan_manager.cc b/presence/implementation/scan_manager.cc index 6a250cfef8..2cb9f4ba44 100644 --- a/presence/implementation/scan_manager.cc +++ b/presence/implementation/scan_manager.cc @@ -34,19 +34,16 @@ #include "presence/presence_device.h" #include "presence/scan_request.h" -namespace { -using BleAdvertisementData = - ::location::nearby::api::ble_v2::BleAdvertisementData; -using BlePeripheral = ::location::nearby::api::ble_v2::BlePeripheral; -using ScanningSession = - ::location::nearby::api::ble_v2::BleMedium::ScanningSession; -using ScanningCallback = - ::location::nearby::api::ble_v2::BleMedium::ScanningCallback; -} // namespace - namespace nearby { namespace presence { +namespace { +using BleAdvertisementData = ::nearby::api::ble_v2::BleAdvertisementData; +using BlePeripheral = ::nearby::api::ble_v2::BlePeripheral; +using ScanningSession = ::nearby::api::ble_v2::BleMedium::ScanningSession; +using ScanningCallback = ::nearby::api::ble_v2::BleMedium::ScanningCallback; +} // namespace + ScanSessionId ScanManager::StartScan(ScanRequest scan_request, ScanCallback cb) { ScanSessionId id = ::crypto::RandData(); @@ -162,7 +159,7 @@ void ScanManager::UpdateCredentials(ScanSessionId id, } int ScanManager::ScanningCallbacksLengthForTest() { - ::location::nearby::Future count; + ::nearby::Future count; RunOnServiceControllerThread("callbacks-size", [&]() ABSL_EXCLUSIVE_LOCKS_REQUIRED(*executor_) { count.Set(scan_sessions_.size()); diff --git a/presence/implementation/scan_manager.h b/presence/implementation/scan_manager.h index 0a95b2690f..422e145331 100644 --- a/presence/implementation/scan_manager.h +++ b/presence/implementation/scan_manager.h @@ -36,14 +36,12 @@ namespace presence { // Helping service controller to manage scan requests and callbacks. class ScanManager { public: - using SingleThreadExecutor = ::location::nearby::SingleThreadExecutor; - using Mutex = ::location::nearby::Mutex; - using MutexLock = ::location::nearby::MutexLock; - using ScanningSession = - ::location::nearby::api::ble_v2::BleMedium::ScanningSession; - using Runnable = ::location::nearby::Runnable; - using BleAdvertisementData = - ::location::nearby::api::ble_v2::BleAdvertisementData; + using SingleThreadExecutor = ::nearby::SingleThreadExecutor; + using Mutex = ::nearby::Mutex; + using MutexLock = ::nearby::MutexLock; + using ScanningSession = ::nearby::api::ble_v2::BleMedium::ScanningSession; + using Runnable = ::nearby::Runnable; + using BleAdvertisementData = ::nearby::api::ble_v2::BleAdvertisementData; using PublicCredential = ::nearby::internal::PublicCredential; using IdentityType = ::nearby::internal::IdentityType; diff --git a/presence/implementation/scan_manager_test.cc b/presence/implementation/scan_manager_test.cc index 2c1fae59f3..2945a0d024 100644 --- a/presence/implementation/scan_manager_test.cc +++ b/presence/implementation/scan_manager_test.cc @@ -41,13 +41,12 @@ namespace nearby { namespace presence { namespace { -using AdvertisingSession = - ::location::nearby::api::ble_v2::BleMedium::AdvertisingSession; +using AdvertisingSession = ::nearby::api::ble_v2::BleMedium::AdvertisingSession; using AdvertisingCallback = - ::location::nearby::api::ble_v2::BleMedium::AdvertisingCallback; -using ::location::nearby::SingleThreadExecutor; + ::nearby::api::ble_v2::BleMedium::AdvertisingCallback; +using ::nearby::SingleThreadExecutor; -using CountDownLatch = ::location::nearby::CountDownLatch; +using CountDownLatch = ::nearby::CountDownLatch; class ScanManagerTest : public testing::Test { protected: @@ -111,8 +110,7 @@ class ScanManagerTest : public testing::Test { return {DataElement(ActionBit::kPresenceManagerAction)}; } CredentialManagerImpl credential_manager_; - location::nearby::MediumEnvironment& env_ = { - location::nearby::MediumEnvironment::Instance()}; + nearby::MediumEnvironment& env_ = {nearby::MediumEnvironment::Instance()}; CountDownLatch start_latch_{1}; CountDownLatch found_latch_{1}; SingleThreadExecutor executor_; @@ -122,7 +120,7 @@ TEST_F(ScanManagerTest, CanStartThenStopScanning) { Mediums mediums; ScanManager manager(mediums, credential_manager_, executor_); // Set up advertiser - location::nearby::BluetoothAdapter server_adapter; + nearby::BluetoothAdapter server_adapter; Ble ble2(server_adapter); std::unique_ptr advertising_session = StartAdvertisingOn(ble2); @@ -160,7 +158,7 @@ TEST_F(ScanManagerTest, TestNoFilter) { Mediums mediums; ScanManager manager(mediums, credential_manager_, executor_); // Set up advertiser - location::nearby::BluetoothAdapter server_adapter; + nearby::BluetoothAdapter server_adapter; Ble ble2(server_adapter); std::unique_ptr advertising_session = StartAdvertisingOn(ble2); @@ -183,7 +181,7 @@ TEST_F(ScanManagerTest, PresenceDeviceMetadataIsRetained) { Mediums mediums; ScanManager manager(mediums, credential_manager_, executor_); // Set up advertiser - location::nearby::BluetoothAdapter server_adapter; + nearby::BluetoothAdapter server_adapter; Ble ble2(server_adapter); std::unique_ptr advertising_session = StartAdvertisingOn(ble2); @@ -261,7 +259,7 @@ TEST_F(ScanManagerTest, StopOneSessionFromAnotherDeadlock) { ASSERT_EQ(manager.ScanningCallbacksLengthForTest(), 2); // Set up advertiser - location::nearby::BluetoothAdapter server_adapter; + nearby::BluetoothAdapter server_adapter; Ble ble2(server_adapter); std::unique_ptr advertising_session = StartAdvertisingOn(ble2); @@ -280,7 +278,7 @@ TEST_F(ScanManagerTest, StopOneSessionFromAnotherDeadlock) { TEST_F(ScanManagerTest, NoDeviceFoundAfterStopScan) { Mediums mediums; ScanManager manager(mediums, credential_manager_, executor_); - location::nearby::BluetoothAdapter server_adapter; + nearby::BluetoothAdapter server_adapter; Ble ble2(server_adapter); std::atomic_bool stopped = false; ScanSessionId scan_session = manager.StartScan( diff --git a/presence/implementation/service_controller_impl.h b/presence/implementation/service_controller_impl.h index 7fb74a7b40..0021f085a6 100644 --- a/presence/implementation/service_controller_impl.h +++ b/presence/implementation/service_controller_impl.h @@ -36,7 +36,7 @@ namespace presence { class ServiceControllerImpl : public ServiceController { public: - using SingleThreadExecutor = ::location::nearby::SingleThreadExecutor; + using SingleThreadExecutor = ::nearby::SingleThreadExecutor; ServiceControllerImpl() = default; ~ServiceControllerImpl() override { executor_.Shutdown(); } diff --git a/presence/listeners.h b/presence/listeners.h index 09afb3fade..ab52a473b1 100644 --- a/presence/listeners.h +++ b/presence/listeners.h @@ -30,7 +30,7 @@ struct ResultCallback { // status - result of job execution; // Status::kSuccess, if successful; anything else indicates failure. std::function result_cb = - location::nearby::DefaultCallback(); + nearby::DefaultCallback(); }; } // namespace presence diff --git a/presence/presence_client.cc b/presence/presence_client.cc index 37b10c153b..8cb8e86cf3 100644 --- a/presence/presence_client.cc +++ b/presence/presence_client.cc @@ -28,7 +28,7 @@ namespace presence { absl::StatusOr PresenceClient::StartScan( ScanRequest scan_request, ScanCallback callback) { - ::location::nearby::Borrowed borrowed = service_.Borrow(); + ::nearby::Borrowed borrowed = service_.Borrow(); if (!borrowed) { return absl::FailedPreconditionError( "Can't start scan, presence service is gone"); @@ -37,7 +37,7 @@ absl::StatusOr PresenceClient::StartScan( } void PresenceClient::StopScan(ScanSessionId id) { - ::location::nearby::Borrowed borrowed = service_.Borrow(); + ::nearby::Borrowed borrowed = service_.Borrow(); if (borrowed) { (*borrowed)->StopScan(id); } @@ -45,7 +45,7 @@ void PresenceClient::StopScan(ScanSessionId id) { absl::StatusOr PresenceClient::StartBroadcast( BroadcastRequest broadcast_request, BroadcastCallback callback) { - ::location::nearby::Borrowed borrowed = service_.Borrow(); + ::nearby::Borrowed borrowed = service_.Borrow(); if (!borrowed) { return absl::FailedPreconditionError( "Can't start broadcast, presence service is gone"); @@ -54,7 +54,7 @@ absl::StatusOr PresenceClient::StartBroadcast( } void PresenceClient::StopBroadcast(BroadcastSessionId session_id) { - ::location::nearby::Borrowed borrowed = service_.Borrow(); + ::nearby::Borrowed borrowed = service_.Borrow(); if (borrowed) { (*borrowed)->StopBroadcast(session_id); } else { diff --git a/presence/presence_client.h b/presence/presence_client.h index e33e7579e2..23b7079131 100644 --- a/presence/presence_client.h +++ b/presence/presence_client.h @@ -35,8 +35,7 @@ class PresenceService; */ class PresenceClient { public: - using BorrowablePresenceService = - ::location::nearby::Borrowable; + using BorrowablePresenceService = ::nearby::Borrowable; explicit PresenceClient(BorrowablePresenceService service) : service_(service) {} diff --git a/presence/presence_client_test.cc b/presence/presence_client_test.cc index a7dc94f3c4..33f0c8e7b5 100644 --- a/presence/presence_client_test.cc +++ b/presence/presence_client_test.cc @@ -37,8 +37,7 @@ PresenceClient CreateDefunctPresenceClient() { class PresenceClientTest : public testing::Test { protected: - location::nearby::MediumEnvironment& env_{ - location::nearby::MediumEnvironment::Instance()}; + nearby::MediumEnvironment& env_{nearby::MediumEnvironment::Instance()}; }; TEST_F(PresenceClientTest, StartBroadcastWithDefaultConstructor) { @@ -75,7 +74,7 @@ TEST_F(PresenceClientTest, StartBroadcastFailsWhenPresenceServiceIsGone) { TEST_F(PresenceClientTest, StartScanWithDefaultConstructor) { env_.Start(); - ::location::nearby::Future scan_result; + ::nearby::Future scan_result; ScanCallback scan_callback = { .start_scan_cb = [&](absl::Status status) { scan_result.Set(status); }, }; diff --git a/presence/presence_device.cc b/presence/presence_device.cc index c27a2510f8..25351af05b 100644 --- a/presence/presence_device.cc +++ b/presence/presence_device.cc @@ -32,23 +32,22 @@ std::string GenerateRandomEndpointId() { } // namespace PresenceDevice::PresenceDevice(DeviceMetadata device_metadata) noexcept - : discovery_timestamp_(location::nearby::SystemClock::ElapsedRealtime()), + : discovery_timestamp_(nearby::SystemClock::ElapsedRealtime()), device_motion_(DeviceMotion()), device_metadata_(device_metadata) { endpoint_id_ = GenerateRandomEndpointId(); } PresenceDevice::PresenceDevice(DeviceMotion device_motion, DeviceMetadata device_metadata) noexcept - : discovery_timestamp_(location::nearby::SystemClock::ElapsedRealtime()), + : discovery_timestamp_(nearby::SystemClock::ElapsedRealtime()), device_motion_(device_motion), device_metadata_(device_metadata) { endpoint_id_ = GenerateRandomEndpointId(); } -std::vector -PresenceDevice::GetConnectionInfos() const { - return {location::nearby::BleConnectionInfo( - device_metadata_.bluetooth_mac_address())}; +std::vector PresenceDevice::GetConnectionInfos() + const { + return {nearby::BleConnectionInfo(device_metadata_.bluetooth_mac_address())}; } } // namespace presence } // namespace nearby diff --git a/presence/presence_device.h b/presence/presence_device.h index 48ade932c7..855b106766 100644 --- a/presence/presence_device.h +++ b/presence/presence_device.h @@ -30,7 +30,7 @@ namespace presence { constexpr int kEndpointIdLength = 4; -class PresenceDevice : public location::nearby::NearbyDevice { +class PresenceDevice : public nearby::NearbyDevice { using DeviceMetadata = ::nearby::internal::DeviceMetadata; public: @@ -46,7 +46,7 @@ class PresenceDevice : public location::nearby::NearbyDevice { return NearbyDevice::Type::kPresenceDevice; } // Add more medium ConnectionInfos as we introduce them. - std::vector GetConnectionInfos() + std::vector GetConnectionInfos() const override; DeviceMotion GetDeviceMotion() const { return device_motion_; } DeviceMetadata GetMetadata() const { return device_metadata_; } diff --git a/presence/presence_device_test.cc b/presence/presence_device_test.cc index fadec235f3..80bbdbdf23 100644 --- a/presence/presence_device_test.cc +++ b/presence/presence_device_test.cc @@ -75,12 +75,10 @@ TEST(PresenceDeviceTest, TestGetBluetoothAddress) { DeviceMetadata metadata = CreateTestDeviceMetadata(); PresenceDevice device = PresenceDevice({kDefaultMotionType}, metadata); auto info = (device.GetConnectionInfos().at(0)); - ASSERT_TRUE( - absl::holds_alternative(info)); - EXPECT_EQ(absl::get(info) - .GetMacAddress() - .AsStringView(), - kMacAddr); + ASSERT_TRUE(absl::holds_alternative(info)); + EXPECT_EQ( + absl::get(info).GetMacAddress().AsStringView(), + kMacAddr); } TEST(PresenceDeviceTest, TestEndpointIdIsCorrectLength) { diff --git a/presence/presence_service.h b/presence/presence_service.h index c4ba1b5ee3..972e6487de 100644 --- a/presence/presence_service.h +++ b/presence/presence_service.h @@ -48,7 +48,7 @@ class PresenceService { private: std::unique_ptr service_controller_; - ::location::nearby::Lender lender_{this}; + ::nearby::Lender lender_{this}; }; } // namespace presence diff --git a/presence/presence_service_test.cc b/presence/presence_service_test.cc index df02ae7a5e..190301b829 100644 --- a/presence/presence_service_test.cc +++ b/presence/presence_service_test.cc @@ -26,8 +26,7 @@ namespace { class PresenceServiceTest : public testing::Test { protected: - location::nearby::MediumEnvironment& env_{ - location::nearby::MediumEnvironment::Instance()}; + nearby::MediumEnvironment& env_{nearby::MediumEnvironment::Instance()}; }; TEST_F(PresenceServiceTest, DefaultConstructorWorks) {