nearbyconnections : Implement WifiLanV2 BandwidthUpgrade functions.

PiperOrigin-RevId: 405821802
This commit is contained in:
edwinwu
2021-10-26 23:52:23 -07:00
committed by Copybara-Service
parent 7197b84e4d
commit 57ee5f10a4
6 changed files with 284 additions and 8 deletions
+3 -2
View File
@@ -245,7 +245,7 @@ class MediumEnvironment {
api::WifiLanSocket& socket,
const std::string& service_id);
// Returns WiFi LAN service matching IP address and port, or nullptr.
// Returns WifiLan service matching IP address and port, or nullptr.
api::WifiLanService* GetWifiLanService(const std::string& ip_address,
int port);
@@ -278,7 +278,8 @@ class MediumEnvironment {
// Removes medium-related info. This should correspond to device power off.
void UnregisterWifiLanMediumV2(api::WifiLanMediumV2& medium);
// Returns WiFi LAN service matching IP address and port, or nullptr.
// Returns WifiLan medium whose advertising service matching IP address and
// port, or nullptr.
api::WifiLanMediumV2* GetWifiLanV2Medium(const std::string& ip_address,
int port);
+4 -5
View File
@@ -293,9 +293,9 @@ std::unique_ptr<api::WifiLanSocketV2> WifiLanMediumV2::ConnectToService(
std::unique_ptr<api::WifiLanSocketV2> WifiLanMediumV2::ConnectToService(
const std::string& ip_address, int port,
CancellationFlag* cancellation_flag) {
std::string socket_name = WifiLanServerSocketV2::GetName(ip_address, port);
NEARBY_LOGS(INFO) << "G3 WifiLan ConnectToService [self]: medium=" << this
<< ", ip address + port="
<< WifiLanServerSocketV2::GetName(ip_address, port);
<< ", ip address + port=" << socket_name;
// First, find an instance of remote medium, that exposed this service.
auto& env = MediumEnvironment::Instance();
auto* remote_medium =
@@ -306,10 +306,9 @@ std::unique_ptr<api::WifiLanSocketV2> WifiLanMediumV2::ConnectToService(
WifiLanServerSocketV2* server_socket = nullptr;
NEARBY_LOGS(INFO) << "G3 WifiLan ConnectToService [peer]: medium="
<< remote_medium << ", remote ip address + port="
<< WifiLanServerSocketV2::GetName(ip_address, port);
<< remote_medium
<< ", remote ip address + port=" << socket_name;
// Then, find our server socket context in this medium.
std::string socket_name = WifiLanServerSocketV2::GetName(ip_address, port);
{
absl::MutexLock medium_lock(&remote_medium->mutex_);
auto item = remote_medium->server_sockets_.find(socket_name);