mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-14 22:56:12 -04:00
Minor fixes to reduce copying.
PiperOrigin-RevId: 616927443
This commit is contained in:
committed by
Copybara-Service
parent
30c9c55d3b
commit
0c086a3c93
@@ -17,6 +17,7 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "absl/functional/any_invocable.h"
|
||||
#include "internal/platform/cancellation_flag.h"
|
||||
#include "internal/platform/input_stream.h"
|
||||
#include "internal/platform/listeners.h"
|
||||
@@ -99,10 +100,10 @@ class WifiLanMedium {
|
||||
|
||||
// Callback that is invoked when a discovered service is found or lost.
|
||||
struct DiscoveredServiceCallback {
|
||||
absl::AnyInvocable<void(NsdServiceInfo service_info)>
|
||||
service_discovered_cb = DefaultCallback<NsdServiceInfo>();
|
||||
absl::AnyInvocable<void(NsdServiceInfo service_info)> service_lost_cb =
|
||||
DefaultCallback<NsdServiceInfo>();
|
||||
absl::AnyInvocable<void(const NsdServiceInfo& service_info)>
|
||||
service_discovered_cb = DefaultCallback<const NsdServiceInfo&>();
|
||||
absl::AnyInvocable<void(const NsdServiceInfo& service_info)>
|
||||
service_lost_cb = DefaultCallback<const NsdServiceInfo&>();
|
||||
};
|
||||
|
||||
// Starts the discovery of nearby WifiLan services.
|
||||
|
||||
@@ -63,7 +63,7 @@ class NsdServiceInfo {
|
||||
|
||||
// Sets all TXTRecord.
|
||||
void SetTxtRecords(
|
||||
absl::flat_hash_map<std::string, std::string>& txt_records) {
|
||||
const absl::flat_hash_map<std::string, std::string>& txt_records) {
|
||||
txt_records_ = txt_records;
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ bool WifiLanMedium::StartDiscovery(const std::string& service_id,
|
||||
}
|
||||
api::WifiLanMedium::DiscoveredServiceCallback api_callback = {
|
||||
.service_discovered_cb =
|
||||
[this](NsdServiceInfo service_info) {
|
||||
[this](const NsdServiceInfo& service_info) {
|
||||
MutexLock lock(&mutex_);
|
||||
std::string service_type = service_info.GetServiceType();
|
||||
// Check callback for the service type.
|
||||
@@ -86,7 +86,7 @@ bool WifiLanMedium::StartDiscovery(const std::string& service_id,
|
||||
medium_callback.service_discovered_cb(service_info, service_id);
|
||||
},
|
||||
.service_lost_cb =
|
||||
[this](NsdServiceInfo service_info) {
|
||||
[this](const NsdServiceInfo& service_info) {
|
||||
MutexLock lock(&mutex_);
|
||||
std::string service_type = service_info.GetServiceType();
|
||||
std::string service_name = service_info.GetServiceName();
|
||||
|
||||
Reference in New Issue
Block a user