mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-16 15:36:12 -04:00
Migrate to AnyInvocable in platform code
PiperOrigin-RevId: 504104740
This commit is contained in:
committed by
Copybara-Service
parent
7f34968b78
commit
f4d85f9b90
@@ -17,7 +17,6 @@
|
||||
|
||||
#include <guiddef.h>
|
||||
|
||||
#include <functional>
|
||||
#include <future> // NOLINT
|
||||
#include <memory>
|
||||
#include <string>
|
||||
@@ -121,4 +120,3 @@ class BleMedium : public api::BleMedium {
|
||||
} // namespace nearby
|
||||
|
||||
#endif // THIRD_PARTY_NEARBY_INTERNAL_PLATFORM_IMPLEMENTATION_WINDOWS_BLE_MEDIUM_H_
|
||||
|
||||
|
||||
@@ -229,8 +229,7 @@ TEST(BleMedium, DISABLED_StartAdvertising_ExtendedAdvertising) {
|
||||
|
||||
ByteArray advertising_data(advertising_data_byte_array);
|
||||
|
||||
EXPECT_TRUE(
|
||||
ble_medium.StartAdvertising("NearbyShare", advertising_data, ""));
|
||||
EXPECT_TRUE(ble_medium.StartAdvertising("NearbyShare", advertising_data, ""));
|
||||
}
|
||||
|
||||
TEST(BleMedium, DISABLED_StopAdvertising) {
|
||||
@@ -254,35 +253,30 @@ TEST(BleMedium, DISABLED_StartScanning) {
|
||||
BluetoothAdapter bluetoothAdapter;
|
||||
BleMedium ble_medium(bluetoothAdapter);
|
||||
|
||||
BleMedium::DiscoveredPeripheralCallback discovered_peripheral_callback = {
|
||||
.peripheral_discovered_cb = [this](api::BlePeripheral& peripheral,
|
||||
const std::string& service_id,
|
||||
bool fast_advertisement) {},
|
||||
.peripheral_lost_cb = [this](api::BlePeripheral& peripheral,
|
||||
const std::string& service_id) {}};
|
||||
|
||||
EXPECT_TRUE(ble_medium.StartScanning("NearbyShare", "\xfe\xf3",
|
||||
discovered_peripheral_callback));
|
||||
EXPECT_TRUE(ble_medium.StartScanning(
|
||||
"NearbyShare", "\xfe\xf3",
|
||||
{.peripheral_discovered_cb = [](api::BlePeripheral& peripheral,
|
||||
const std::string& service_id,
|
||||
bool fast_advertisement) {},
|
||||
.peripheral_lost_cb = [](api::BlePeripheral& peripheral,
|
||||
const std::string& service_id) {}}));
|
||||
}
|
||||
|
||||
TEST(BleMedium, DISABLED_ReceiveAdvertisement) {
|
||||
absl::Notification advertisement_received_notification;
|
||||
|
||||
BluetoothAdapter bluetoothAdapter;
|
||||
BleMedium ble_medium(bluetoothAdapter);
|
||||
|
||||
BleMedium::DiscoveredPeripheralCallback discovered_peripheral_callback = {
|
||||
.peripheral_discovered_cb =
|
||||
[this, &advertisement_received_notification](
|
||||
api::BlePeripheral& peripheral, const std::string& service_id,
|
||||
bool fast_advertisement) {
|
||||
advertisement_received_notification.Notify();
|
||||
},
|
||||
.peripheral_lost_cb = [this](api::BlePeripheral& peripheral,
|
||||
const std::string& service_id) {}};
|
||||
EXPECT_TRUE(ble_medium.StartScanning(
|
||||
"NearbyShare", "\xfe\xf3",
|
||||
{.peripheral_discovered_cb =
|
||||
[&](api::BlePeripheral& peripheral, const std::string& service_id,
|
||||
bool fast_advertisement) {
|
||||
advertisement_received_notification.Notify();
|
||||
},
|
||||
.peripheral_lost_cb = [](api::BlePeripheral& peripheral,
|
||||
const std::string& service_id) {}}));
|
||||
|
||||
EXPECT_TRUE(ble_medium.StartScanning("NearbyShare", "\xfe\xf3",
|
||||
discovered_peripheral_callback));
|
||||
EXPECT_TRUE(
|
||||
advertisement_received_notification.WaitForNotificationWithTimeout(
|
||||
absl::Seconds(5)));
|
||||
@@ -292,15 +286,14 @@ TEST(BleMedium, DISABLED_StopScanning) {
|
||||
BluetoothAdapter bluetoothAdapter;
|
||||
BleMedium ble_medium(bluetoothAdapter);
|
||||
|
||||
BleMedium::DiscoveredPeripheralCallback discovered_peripheral_callback = {
|
||||
.peripheral_discovered_cb =
|
||||
[this](api::BlePeripheral& peripheral, const std::string& service_id,
|
||||
bool fast_advertisement) { EXPECT_TRUE(fast_advertisement); },
|
||||
.peripheral_lost_cb = [this](api::BlePeripheral& peripheral,
|
||||
const std::string& service_id) {}};
|
||||
EXPECT_TRUE(ble_medium.StartScanning(
|
||||
"NearbyShare", "\xfe\xf3",
|
||||
{.peripheral_discovered_cb =
|
||||
[](api::BlePeripheral& peripheral, const std::string& service_id,
|
||||
bool fast_advertisement) { EXPECT_TRUE(fast_advertisement); },
|
||||
.peripheral_lost_cb = [](api::BlePeripheral& peripheral,
|
||||
const std::string& service_id) {}}));
|
||||
|
||||
EXPECT_TRUE(ble_medium.StartScanning("NearbyShare", "\xfe\xf3",
|
||||
discovered_peripheral_callback));
|
||||
EXPECT_TRUE(ble_medium.StopScanning("NearbyShare"));
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
#ifndef THIRD_PARTY_NEARBY_INTERNAL_PLATFORM_IMPLEMENTATION_WINDOWS_BLE_V2_H_
|
||||
#define THIRD_PARTY_NEARBY_INTERNAL_PLATFORM_IMPLEMENTATION_WINDOWS_BLE_V2_H_
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
@@ -107,18 +106,20 @@ class BleV2Medium : public api::ble_v2::BleMedium {
|
||||
BluetoothLEAdvertisementPublisher publisher,
|
||||
winrt::Windows::Devices::Bluetooth::Advertisement::
|
||||
BluetoothLEAdvertisementPublisherStatusChangedEventArgs args);
|
||||
std::function<void()> publisher_started_callback_ ABSL_GUARDED_BY(mutex_);
|
||||
std::function<void()> publisher_stopped_callback_ ABSL_GUARDED_BY(mutex_);
|
||||
std::function<void()> publisher_error_callback_ ABSL_GUARDED_BY(mutex_);
|
||||
absl::AnyInvocable<void()> publisher_started_callback_
|
||||
ABSL_GUARDED_BY(mutex_);
|
||||
absl::AnyInvocable<void()> publisher_stopped_callback_
|
||||
ABSL_GUARDED_BY(mutex_);
|
||||
absl::AnyInvocable<void()> publisher_error_callback_ ABSL_GUARDED_BY(mutex_);
|
||||
|
||||
winrt::event_token watcher_token_;
|
||||
void WatcherHandler(winrt::Windows::Devices::Bluetooth::Advertisement::
|
||||
BluetoothLEAdvertisementWatcher watcher,
|
||||
winrt::Windows::Devices::Bluetooth::Advertisement::
|
||||
BluetoothLEAdvertisementWatcherStoppedEventArgs args);
|
||||
std::function<void()> watcher_started_callback_ ABSL_GUARDED_BY(mutex_);
|
||||
std::function<void()> watcher_stopped_callback_ ABSL_GUARDED_BY(mutex_);
|
||||
std::function<void()> watcher_error_callback_ ABSL_GUARDED_BY(mutex_);
|
||||
absl::AnyInvocable<void()> watcher_started_callback_ ABSL_GUARDED_BY(mutex_);
|
||||
absl::AnyInvocable<void()> watcher_stopped_callback_ ABSL_GUARDED_BY(mutex_);
|
||||
absl::AnyInvocable<void()> watcher_error_callback_ ABSL_GUARDED_BY(mutex_);
|
||||
|
||||
winrt::event_token advertisement_received_token_;
|
||||
void AdvertisementReceivedHandler(
|
||||
|
||||
@@ -20,10 +20,11 @@
|
||||
#include <guiddef.h>
|
||||
// clang-format on
|
||||
|
||||
#include <functional>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "absl/functional/any_invocable.h"
|
||||
#include "internal/platform/implementation/bluetooth_adapter.h"
|
||||
#include "internal/platform/implementation/windows/generated/winrt/Windows.Devices.Bluetooth.h"
|
||||
#include "internal/platform/implementation/windows/generated/winrt/Windows.Devices.Radios.h"
|
||||
@@ -52,7 +53,8 @@ class BluetoothAdapter : public api::BluetoothAdapter {
|
||||
|
||||
~BluetoothAdapter() override = default;
|
||||
|
||||
typedef std::function<void(api::BluetoothAdapter::ScanMode)> ScanModeCallback;
|
||||
typedef absl::AnyInvocable<void(api::BluetoothAdapter::ScanMode)>
|
||||
ScanModeCallback;
|
||||
|
||||
// Synchronously sets the status of the BluetoothAdapter to 'status', and
|
||||
// returns true if the operation was a success.
|
||||
@@ -88,8 +90,8 @@ class BluetoothAdapter : public api::BluetoothAdapter {
|
||||
std::string GetNameFromComputerName() const;
|
||||
|
||||
void SetOnScanModeChanged(ScanModeCallback callback) {
|
||||
if (scan_mode_changed_ == nullptr) {
|
||||
scan_mode_changed_ = callback;
|
||||
if (scan_mode_changed_) {
|
||||
scan_mode_changed_ = std::move(callback);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,7 +113,7 @@ class BluetoothAdapter : public api::BluetoothAdapter {
|
||||
void find_and_replace(char *source, const char *strFind,
|
||||
const char *strReplace) const;
|
||||
ScanMode scan_mode_ = ScanMode::kNone;
|
||||
ScanModeCallback scan_mode_changed_ = nullptr;
|
||||
ScanModeCallback scan_mode_changed_;
|
||||
|
||||
// Used to fake the device name when the device name is longer than android
|
||||
// limitation.
|
||||
|
||||
@@ -163,16 +163,14 @@ TEST(BluetoothAdapter, DISABLED_SetOnScanModeChanged) {
|
||||
api::BluetoothAdapter::ScanMode mode =
|
||||
api::BluetoothAdapter::ScanMode::kUnknown;
|
||||
absl::Notification scan_mode_changed_notification;
|
||||
BluetoothAdapter::ScanModeCallback callback =
|
||||
[&mode, &scan_mode_changed_notification](
|
||||
api::BluetoothAdapter::ScanMode scan_mode) {
|
||||
mode = scan_mode;
|
||||
scan_mode_changed_notification.Notify();
|
||||
};
|
||||
BluetoothAdapter bluetooth_adapter;
|
||||
bluetooth_adapter.SetScanMode(mode);
|
||||
|
||||
bluetooth_adapter.SetOnScanModeChanged(callback);
|
||||
bluetooth_adapter.SetOnScanModeChanged(
|
||||
[&](api::BluetoothAdapter::ScanMode scan_mode) {
|
||||
mode = scan_mode;
|
||||
scan_mode_changed_notification.Notify();
|
||||
});
|
||||
bluetooth_adapter.SetScanMode(
|
||||
api::BluetoothAdapter::ScanMode::kConnectableDiscoverable);
|
||||
EXPECT_TRUE(scan_mode_changed_notification.WaitForNotificationWithTimeout(
|
||||
|
||||
@@ -154,7 +154,7 @@ bool BluetoothClassicMedium::StartDiscovery(
|
||||
NEARBY_LOGS(INFO) << "StartDiscovery is called.";
|
||||
|
||||
bool result = false;
|
||||
discovery_callback_ = discovery_callback;
|
||||
discovery_callback_ = std::move(discovery_callback);
|
||||
|
||||
if (!IsWatcherStarted()) {
|
||||
result = StartScanning();
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
#include <codecvt>
|
||||
#include <exception>
|
||||
#include <functional>
|
||||
#include <locale>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
@@ -55,7 +54,8 @@ std::unique_ptr<api::BluetoothSocket> BluetoothServerSocket::Accept() {
|
||||
return std::make_unique<BluetoothSocket>(bluetooth_socket);
|
||||
}
|
||||
|
||||
void BluetoothServerSocket::SetCloseNotifier(std::function<void()> notifier) {
|
||||
void BluetoothServerSocket::SetCloseNotifier(
|
||||
absl::AnyInvocable<void()> notifier) {
|
||||
close_notifier_ = std::move(notifier);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
|
||||
#include <Windows.h>
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <queue>
|
||||
#include <string>
|
||||
@@ -74,7 +73,7 @@ class BluetoothServerSocket : public api::BluetoothServerSocket {
|
||||
// Called by the server side of a connection before passing ownership of
|
||||
// WifiLanServerSocker to user, to track validity of a pointer to this
|
||||
// server socket.
|
||||
void SetCloseNotifier(std::function<void()> notifier);
|
||||
void SetCloseNotifier(absl::AnyInvocable<void()> notifier);
|
||||
|
||||
bool listen();
|
||||
|
||||
@@ -98,7 +97,7 @@ class BluetoothServerSocket : public api::BluetoothServerSocket {
|
||||
winrt::event_token listener_event_token_{};
|
||||
|
||||
// Close notifier
|
||||
std::function<void()> close_notifier_ = nullptr;
|
||||
absl::AnyInvocable<void()> close_notifier_ = nullptr;
|
||||
|
||||
// IP addresses of the computer. mDNS uses them to advertise.
|
||||
std::vector<std::string> ip_addresses_{};
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace windows {
|
||||
// Main interface to be used by platform as a base class for
|
||||
// - MultiThreadExecutorWrapper
|
||||
// - SingleThreadExecutorWrapper
|
||||
// Platform must override bool submit(std::function<void()>) method.
|
||||
// Platform must override bool submit(absl::AnyInvocable<void()>) method.
|
||||
class SubmittableExecutor : public api::SubmittableExecutor {
|
||||
public:
|
||||
SubmittableExecutor();
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
|
||||
#include "internal/platform/implementation/windows/thread_pool.h"
|
||||
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
|
||||
#include "internal/platform/implementation/windows/timer.h"
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
|
||||
#include "internal/platform/logging.h"
|
||||
@@ -24,7 +23,8 @@ namespace windows {
|
||||
|
||||
Timer::~Timer() { Stop(); }
|
||||
|
||||
bool Timer::Create(int delay, int interval, std::function<void()> callback) {
|
||||
bool Timer::Create(int delay, int interval,
|
||||
absl::AnyInvocable<void()> callback) {
|
||||
if ((delay < 0) || (interval < 0)) {
|
||||
NEARBY_LOGS(WARNING) << "Delay and interval shouldn\'t be negative value.";
|
||||
return false;
|
||||
@@ -90,8 +90,8 @@ bool Timer::FireNow() {
|
||||
}
|
||||
|
||||
void CALLBACK Timer::TimerRoutine(PVOID lpParam, BOOLEAN TimerOrWaitFired) {
|
||||
std::function<void()>* callback =
|
||||
reinterpret_cast<std::function<void()>*>(lpParam);
|
||||
absl::AnyInvocable<void()>* callback =
|
||||
reinterpret_cast<absl::AnyInvocable<void()>*>(lpParam);
|
||||
if (*callback != NULL) {
|
||||
(*callback)();
|
||||
}
|
||||
|
||||
@@ -17,8 +17,6 @@
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include <functional>
|
||||
|
||||
#include "internal/platform/implementation/timer.h"
|
||||
|
||||
namespace nearby {
|
||||
@@ -29,7 +27,8 @@ class Timer : public api::Timer {
|
||||
Timer() = default;
|
||||
~Timer() override;
|
||||
|
||||
bool Create(int delay, int interval, std::function<void()> callback) override;
|
||||
bool Create(int delay, int interval,
|
||||
absl::AnyInvocable<void()> callback) override;
|
||||
bool Stop() override;
|
||||
bool FireNow() override;
|
||||
|
||||
@@ -38,7 +37,7 @@ class Timer : public api::Timer {
|
||||
|
||||
int delay_;
|
||||
int interval_;
|
||||
std::function<void()> callback_;
|
||||
absl::AnyInvocable<void()> callback_;
|
||||
HANDLE handle_ = NULL;
|
||||
HANDLE timer_queue_handle_ = NULL;
|
||||
};
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
|
||||
#include "internal/platform/implementation/timer.h"
|
||||
|
||||
#include <chrono> // NOLINT
|
||||
#include <functional> // NOLINT
|
||||
#include <chrono> // NOLINT
|
||||
// NOLINT
|
||||
#include <memory>
|
||||
#include <thread> // NOLINT
|
||||
|
||||
@@ -28,26 +28,24 @@ namespace {
|
||||
|
||||
TEST(Timer, TestCreateTimer) {
|
||||
int count = 0;
|
||||
std::function<void()> callback = [&count]() { ++count; };
|
||||
|
||||
std::unique_ptr<nearby::api::Timer> timer =
|
||||
nearby::api::ImplementationPlatform::CreateTimer();
|
||||
|
||||
ASSERT_TRUE(timer != nullptr);
|
||||
EXPECT_FALSE(timer->Create(-100, 0, callback));
|
||||
EXPECT_FALSE(timer->Create(-100, 0, [&]() { ++count; }));
|
||||
EXPECT_TRUE(timer->Stop());
|
||||
}
|
||||
|
||||
// This test case cannot run on Google3
|
||||
TEST(Timer, DISABLED_TestRepeatTimer) {
|
||||
int count = 0;
|
||||
std::function<void()> callback = [&count]() { count++; };
|
||||
|
||||
std::unique_ptr<nearby::api::Timer> timer =
|
||||
nearby::api::ImplementationPlatform::CreateTimer();
|
||||
|
||||
ASSERT_TRUE(timer != nullptr);
|
||||
EXPECT_TRUE(timer->Create(300, 300, callback));
|
||||
EXPECT_TRUE(timer->Create(300, 300, [&]() { ++count; }));
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
EXPECT_TRUE(timer->Stop());
|
||||
EXPECT_EQ(count, 3);
|
||||
@@ -55,10 +53,11 @@ TEST(Timer, DISABLED_TestRepeatTimer) {
|
||||
|
||||
TEST(Timer, DISABLED_TestFireNow) {
|
||||
int count = 0;
|
||||
std::function<void()> callback = [&count]() { ++count; };
|
||||
|
||||
auto timer = nearby::api::ImplementationPlatform::CreateTimer();
|
||||
|
||||
EXPECT_TRUE(timer != nullptr);
|
||||
EXPECT_TRUE(timer->Create(3000, 3000, callback));
|
||||
EXPECT_TRUE(timer->Create(3000, 3000, [&]() { ++count; }));
|
||||
EXPECT_TRUE(timer->FireNow());
|
||||
EXPECT_TRUE(timer->Stop());
|
||||
EXPECT_EQ(count, 1);
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
// Standard C/C++ headers
|
||||
#include <deque>
|
||||
#include <exception>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
@@ -191,7 +190,7 @@ class WifiDirectServerSocket : public api::WifiDirectServerSocket {
|
||||
// Called by the server side of a connection before passing ownership of
|
||||
// WifiDirectServerSocker to user, to track validity of a pointer to this
|
||||
// server socket.
|
||||
void SetCloseNotifier(std::function<void()> notifier);
|
||||
void SetCloseNotifier(absl::AnyInvocable<void()> notifier);
|
||||
|
||||
// Returns Exception::kIo on error, Exception::kSuccess otherwise.
|
||||
Exception Close() override;
|
||||
@@ -217,7 +216,7 @@ class WifiDirectServerSocket : public api::WifiDirectServerSocket {
|
||||
winrt::event_token listener_event_token_{};
|
||||
|
||||
// Close notifier
|
||||
std::function<void()> close_notifier_ = nullptr;
|
||||
absl::AnyInvocable<void()> close_notifier_ = nullptr;
|
||||
|
||||
// IP addresses of the computer. mDNS uses them to advertise.
|
||||
std::vector<std::string> ip_addresses_{};
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
#include <windows.h>
|
||||
|
||||
#include <exception>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@@ -82,7 +81,8 @@ std::unique_ptr<api::WifiDirectSocket> WifiDirectServerSocket::Accept() {
|
||||
return std::make_unique<WifiDirectSocket>(wifi_direct_socket);
|
||||
}
|
||||
|
||||
void WifiDirectServerSocket::SetCloseNotifier(std::function<void()> notifier) {
|
||||
void WifiDirectServerSocket::SetCloseNotifier(
|
||||
absl::AnyInvocable<void()> notifier) {
|
||||
close_notifier_ = std::move(notifier);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include <wlanapi.h>
|
||||
|
||||
// Standard C/C++ headers
|
||||
#include <functional>
|
||||
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
@@ -185,7 +185,7 @@ class WifiHotspotServerSocket : public api::WifiHotspotServerSocket {
|
||||
// Called by the server side of a connection before passing ownership of
|
||||
// WifiHotspotServerSocker to user, to track validity of a pointer to this
|
||||
// server socket.
|
||||
void SetCloseNotifier(std::function<void()> notifier);
|
||||
void SetCloseNotifier(absl::AnyInvocable<void()> notifier);
|
||||
|
||||
// Returns Exception::kIo on error, Exception::kSuccess otherwise.
|
||||
Exception Close() override;
|
||||
@@ -211,7 +211,7 @@ class WifiHotspotServerSocket : public api::WifiHotspotServerSocket {
|
||||
winrt::event_token listener_event_token_{};
|
||||
|
||||
// Close notifier
|
||||
std::function<void()> close_notifier_ = nullptr;
|
||||
absl::AnyInvocable<void()> close_notifier_ = nullptr;
|
||||
|
||||
// IP addresses of the computer. mDNS uses them to advertise.
|
||||
std::vector<std::string> ip_addresses_{};
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
#include <windows.h>
|
||||
|
||||
#include <exception>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@@ -82,7 +81,8 @@ std::unique_ptr<api::WifiHotspotSocket> WifiHotspotServerSocket::Accept() {
|
||||
return std::make_unique<WifiHotspotSocket>(wifi_hotspot_socket);
|
||||
}
|
||||
|
||||
void WifiHotspotServerSocket::SetCloseNotifier(std::function<void()> notifier) {
|
||||
void WifiHotspotServerSocket::SetCloseNotifier(
|
||||
absl::AnyInvocable<void()> notifier) {
|
||||
close_notifier_ = std::move(notifier);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
|
||||
// Standard C/C++ headers
|
||||
#include <exception>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
@@ -35,8 +34,8 @@
|
||||
#include "absl/synchronization/mutex.h"
|
||||
#include "absl/time/time.h"
|
||||
#include "absl/types/optional.h"
|
||||
#include "internal/platform/count_down_latch.h"
|
||||
#include "internal/platform/cancellation_flag_listener.h"
|
||||
#include "internal/platform/count_down_latch.h"
|
||||
#include "internal/platform/exception.h"
|
||||
#include "internal/platform/implementation/wifi_lan.h"
|
||||
#include "internal/platform/implementation/windows/scheduled_executor.h"
|
||||
@@ -187,7 +186,7 @@ class WifiLanServerSocket : public api::WifiLanServerSocket {
|
||||
// Called by the server side of a connection before passing ownership of
|
||||
// WifiLanServerSocker to user, to track validity of a pointer to this
|
||||
// server socket.
|
||||
void SetCloseNotifier(std::function<void()> notifier);
|
||||
void SetCloseNotifier(absl::AnyInvocable<void()> notifier);
|
||||
|
||||
// Returns Exception::kIo on error, Exception::kSuccess otherwise.
|
||||
Exception Close() override;
|
||||
@@ -208,7 +207,7 @@ class WifiLanServerSocket : public api::WifiLanServerSocket {
|
||||
winrt::event_token listener_event_token_{};
|
||||
|
||||
// Close notifier
|
||||
std::function<void()> close_notifier_ = nullptr;
|
||||
absl::AnyInvocable<void()> close_notifier_ = nullptr;
|
||||
|
||||
// IP addresses of the computer. mDNS uses them to advertise.
|
||||
std::vector<std::string> ip_addresses_{};
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
#include <windows.h>
|
||||
|
||||
#include <exception>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@@ -84,7 +83,8 @@ std::unique_ptr<api::WifiLanSocket> WifiLanServerSocket::Accept() {
|
||||
return std::make_unique<WifiLanSocket>(wifi_lan_socket);
|
||||
}
|
||||
|
||||
void WifiLanServerSocket::SetCloseNotifier(std::function<void()> notifier) {
|
||||
void WifiLanServerSocket::SetCloseNotifier(
|
||||
absl::AnyInvocable<void()> notifier) {
|
||||
close_notifier_ = std::move(notifier);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user