Format all the files in CL786733783

PiperOrigin-RevId: 786873870
This commit is contained in:
hai007
2025-07-24 16:25:18 -07:00
committed by Copybara-Service
parent b3d9a930ca
commit 00a2999269
87 changed files with 1406 additions and 1719 deletions
+56 -65
View File
@@ -39,27 +39,26 @@ void NearbyHttpClient::StartRequest(
const HttpRequest& request,
absl::AnyInvocable<void(const absl::StatusOr<HttpResponse>&)> callback) {
MutexLock lock(&mutex_);
executor_.Execute(
[request = std::move(request), callback = std::move(callback)]() mutable {
LOG(INFO) << __func__ << ": Start async request to url="
<< request.GetUrl().GetUrlPath();
absl::StatusOr<HttpResponse> response = InternalGetResponse(request);
if (response.ok()) {
LOG(INFO)
<< __func__
<< ": Got response from url=" << request.GetUrl().GetUrlPath();
} else {
LOG(ERROR) << __func__ << ": Failed to get response from url="
<< request.GetUrl().GetUrlPath() << ", status"
<< response.status();
}
executor_.Execute([request = std::move(request),
callback = std::move(callback)]() mutable {
LOG(INFO) << __func__ << ": Start async request to url="
<< request.GetUrl().GetUrlPath();
absl::StatusOr<HttpResponse> response = InternalGetResponse(request);
if (response.ok()) {
LOG(INFO) << __func__
<< ": Got response from url=" << request.GetUrl().GetUrlPath();
} else {
LOG(ERROR) << __func__ << ": Failed to get response from url="
<< request.GetUrl().GetUrlPath() << ", status"
<< response.status();
}
if (callback) {
callback(response);
}
LOG(INFO) << __func__ << ": Completed request to url="
<< request.GetUrl().GetUrlPath();
});
if (callback) {
callback(response);
}
LOG(INFO) << __func__
<< ": Completed request to url=" << request.GetUrl().GetUrlPath();
});
}
void NearbyHttpClient::StartCancellableRequest(
@@ -71,63 +70,55 @@ void NearbyHttpClient::StartCancellableRequest(
callback(absl::InvalidArgumentError("invalid cancellable request"));
return;
}
executor_
.Execute(
[cancellable_request = std::move(cancellable_request),
callback = std::move(callback)]() mutable {
LOG(INFO)
<< __func__ << ": Start async request to url="
executor_.Execute([cancellable_request = std::move(cancellable_request),
callback = std::move(callback)]() mutable {
LOG(INFO) << __func__ << ": Start async request to url="
<< cancellable_request->http_request().GetUrl().GetUrlPath();
if (cancellable_request->is_cancelled()) {
LOG(WARNING) << __func__ << ": Async request to url="
<< cancellable_request->http_request().GetUrl().GetUrlPath()
<< " is cancelled.";
return;
}
absl::StatusOr<HttpResponse> response =
InternalGetResponse(cancellable_request->http_request());
if (response.ok()) {
LOG(INFO) << __func__ << ": Got response from url="
<< cancellable_request->http_request().GetUrl().GetUrlPath();
if (cancellable_request->is_cancelled()) {
LOG(WARNING)
<< __func__ << ": Async request to url="
<< cancellable_request->http_request().GetUrl().GetUrlPath()
<< " is cancelled.";
return;
}
absl::StatusOr<HttpResponse> response =
InternalGetResponse(cancellable_request->http_request());
if (response.ok()) {
LOG(INFO)
<< __func__ << ": Got response from url="
<< cancellable_request->http_request().GetUrl().GetUrlPath();
} else {
LOG(ERROR)
<< __func__ << ": Failed to get response from url="
<< cancellable_request->http_request().GetUrl().GetUrlPath()
<< ", status" << response.status();
}
} else {
LOG(ERROR) << __func__ << ": Failed to get response from url="
<< cancellable_request->http_request().GetUrl().GetUrlPath()
<< ", status" << response.status();
}
if (cancellable_request->is_cancelled()) {
LOG(WARNING)
<< __func__ << ": Async request to url="
<< cancellable_request->http_request().GetUrl().GetUrlPath()
<< " is cancelled.";
return;
}
if (cancellable_request->is_cancelled()) {
LOG(WARNING) << __func__ << ": Async request to url="
<< cancellable_request->http_request().GetUrl().GetUrlPath()
<< " is cancelled.";
return;
}
if (callback) {
callback(response);
}
LOG(INFO)
<< __func__ << ": Completed request to url="
<< cancellable_request->http_request().GetUrl().GetUrlPath();
});
if (callback) {
callback(response);
}
LOG(INFO) << __func__ << ": Completed request to url="
<< cancellable_request->http_request().GetUrl().GetUrlPath();
});
}
absl::StatusOr<HttpResponse> NearbyHttpClient::GetResponse(
const HttpRequest& request) {
LOG(INFO) << __func__ << ": Start request to url="
<< request.GetUrl().GetUrlPath();
LOG(INFO) << __func__
<< ": Start request to url=" << request.GetUrl().GetUrlPath();
absl::StatusOr<HttpResponse> response = InternalGetResponse(request);
if (response.ok()) {
LOG(INFO) << __func__ << ": Got response from url="
<< request.GetUrl().GetUrlPath();
LOG(INFO) << __func__
<< ": Got response from url=" << request.GetUrl().GetUrlPath();
} else {
LOG(ERROR) << __func__ << ": Failed to get response from url="
<< request.GetUrl().GetUrlPath() << ", status"
<< response.status();
<< request.GetUrl().GetUrlPath() << ", status"
<< response.status();
}
return response;
+1 -1
View File
@@ -167,7 +167,7 @@ class AwdlServerSocket final {
std::unique_ptr<api::AwdlSocket> socket = impl_->Accept();
if (!socket) {
LOG(INFO) << "AwdlServerSocket Accept() failed on server socket: "
<< this;
<< this;
}
return AwdlSocket(std::move(socket));
}
+8 -10
View File
@@ -70,8 +70,8 @@ bool BleMedium::StartScanning(
auto context = peripherals_.find(&peripheral);
if (context == peripherals_.end()) return;
LOG(INFO) << "Removing peripheral="
<< context->second->peripheral.GetName()
<< ", impl=" << &peripheral;
<< context->second->peripheral.GetName()
<< ", impl=" << &peripheral;
discovered_peripheral_callback_.peripheral_lost_cb(
context->second->peripheral, service_id);
},
@@ -103,11 +103,11 @@ bool BleMedium::StartAcceptingConnections(const std::string& service_id,
auto& context = *pair.first->second;
if (!pair.second) {
LOG(INFO) << "Accepting (again) socket=" << &context.socket
<< ", impl=" << &socket;
<< ", impl=" << &socket;
} else {
context.socket = BleSocket(&socket);
LOG(INFO)
<< "Accepting socket=" << &context.socket << ", impl=" << &socket;
LOG(INFO) << "Accepting socket=" << &context.socket
<< ", impl=" << &socket;
}
if (accepted_connection_callback_) {
accepted_connection_callback_(context.socket, service_id);
@@ -120,8 +120,7 @@ bool BleMedium::StopAcceptingConnections(const std::string& service_id) {
MutexLock lock(&mutex_);
accepted_connection_callback_ = nullptr;
sockets_.clear();
LOG(INFO) << "Ble accepted connection disabled: impl="
<< &GetImpl();
LOG(INFO) << "Ble accepted connection disabled: impl=" << &GetImpl();
}
return impl_->StopAcceptingConnections(service_id);
}
@@ -131,9 +130,8 @@ BleSocket BleMedium::Connect(BlePeripheral& peripheral,
CancellationFlag* cancellation_flag) {
{
MutexLock lock(&mutex_);
LOG(INFO) << "BleMedium::Connect: peripheral="
<< peripheral.GetName()
<< ",impl=" << &peripheral.GetImpl();
LOG(INFO) << "BleMedium::Connect: peripheral=" << peripheral.GetName()
<< ",impl=" << &peripheral.GetImpl();
}
return BleSocket(
impl_->Connect(peripheral.GetImpl(), service_id, cancellation_flag));
+8 -10
View File
@@ -78,10 +78,9 @@ TEST_P(BleMediumTest, CanStartAcceptingConnectionsAndConnect) {
BlePeripheral& peripheral, const std::string& service_id,
const ByteArray& advertisement_bytes,
bool fast_advertisement) {
LOG(INFO)
<< "Discovered peripheral=" << peripheral.GetName()
<< ", impl=" << &peripheral.GetImpl()
<< ", fast advertisement=" << fast_advertisement;
LOG(INFO) << "Discovered peripheral=" << peripheral.GetName()
<< ", impl=" << &peripheral.GetImpl()
<< ", fast advertisement=" << fast_advertisement;
discovered_peripheral = &peripheral;
found_latch.CountDown();
},
@@ -91,7 +90,7 @@ TEST_P(BleMediumTest, CanStartAcceptingConnectionsAndConnect) {
ble_b.StartAcceptingConnections(
service_id, [&](BleSocket socket, const std::string& service_id) {
LOG(INFO) << "Connection accepted: socket=" << &socket
<< ", service_id=" << service_id;
<< ", service_id=" << service_id;
accepted_latch.CountDown();
});
EXPECT_TRUE(found_latch.Await(kWaitDuration).result());
@@ -136,10 +135,9 @@ TEST_P(BleMediumTest, CanCancelConnect) {
BlePeripheral& peripheral, const std::string& service_id,
const ByteArray& advertisement_bytes,
bool fast_advertisement) {
LOG(INFO)
<< "Discovered peripheral=" << peripheral.GetName()
<< ", impl=" << &peripheral.GetImpl()
<< ", fast advertisement=" << fast_advertisement;
LOG(INFO) << "Discovered peripheral=" << peripheral.GetName()
<< ", impl=" << &peripheral.GetImpl()
<< ", fast advertisement=" << fast_advertisement;
discovered_peripheral = &peripheral;
found_latch.CountDown();
},
@@ -149,7 +147,7 @@ TEST_P(BleMediumTest, CanCancelConnect) {
ble_b.StartAcceptingConnections(
service_id, [&](BleSocket socket, const std::string& service_id) {
LOG(INFO) << "Connection accepted: socket=" << &socket
<< ", service_id=" << service_id;
<< ", service_id=" << service_id;
accepted_latch.CountDown();
});
EXPECT_TRUE(found_latch.Await(kWaitDuration).result());
+5 -7
View File
@@ -27,9 +27,9 @@ namespace nearby {
BlockingQueueStream::BlockingQueueStream() {
LOG(INFO) << "Create a BlockingQueueStream with size "
<< FeatureFlags::GetInstance()
.GetFlags()
.blocking_queue_stream_queue_capacity;
<< FeatureFlags::GetInstance()
.GetFlags()
.blocking_queue_stream_queue_capacity;
}
ExceptionOr<ByteArray> BlockingQueueStream::Read(std::int64_t size) {
@@ -39,8 +39,7 @@ ExceptionOr<ByteArray> BlockingQueueStream::Read(std::int64_t size) {
}
if (is_closed_) {
LOG(INFO)
<< "Failed to read BlockingQueueStream because it was closed.";
LOG(INFO) << "Failed to read BlockingQueueStream because it was closed.";
return ExceptionOr<ByteArray>(Exception::kIo);
}
@@ -67,8 +66,7 @@ void BlockingQueueStream::Write(const ByteArray& bytes) {
return;
}
if (is_closed_) {
LOG(INFO)
<< "Failed to write BlockingQueueStream because it was closed.";
LOG(INFO) << "Failed to write BlockingQueueStream because it was closed.";
return;
}
is_writing_ = true;
+1 -2
View File
@@ -600,8 +600,7 @@ TEST_F(BluetoothClassicMediumTest, CancelBluetoothPairing) {
bt_a_->StartDiscovery(
DiscoveryCallback{.device_discovered_cb = [&](BluetoothDevice& device) {
LOG(INFO) << "Device discovered: " << device.GetName();
LOG(INFO) << "Device discovered address: "
<< device.GetMacAddress();
LOG(INFO) << "Device discovered address: " << device.GetMacAddress();
EXPECT_EQ(device.GetName(), adapter_b_->GetName());
discovered_device = &device;
found_latch.CountDown();
+22 -26
View File
@@ -65,8 +65,7 @@ bool BleServerSocket::Connect(BleSocket& socket) {
absl::MutexLock lock(&mutex_);
if (closed_) return false;
if (socket.IsConnected()) {
LOG(ERROR)
<< "Failed to connect to Ble server socket: already connected";
LOG(ERROR) << "Failed to connect to Ble server socket: already connected";
return true; // already connected.
}
// add client socket to the pending list
@@ -128,7 +127,7 @@ BleMedium::~BleMedium() {
accept_loops_runner_.Shutdown();
LOG(INFO) << "BleMedium dtor advertising_accept_thread_running_ = "
<< acceptance_thread_running_.load();
<< acceptance_thread_running_.load();
// If acceptance thread is still running, wait to finish.
if (acceptance_thread_running_) {
while (acceptance_thread_running_) {
@@ -143,11 +142,11 @@ bool BleMedium::StartAdvertising(
const std::string& service_id, const ByteArray& advertisement_bytes,
const std::string& fast_advertisement_service_uuid) {
LOG(INFO) << "G3 Ble StartAdvertising: service_id=" << service_id
<< ", advertisement bytes="
<< absl::BytesToHexString(std::string(advertisement_bytes))
<< "(" << advertisement_bytes.size() << "),"
<< ", fast advertisement service uuid="
<< absl::BytesToHexString(fast_advertisement_service_uuid);
<< ", advertisement bytes="
<< absl::BytesToHexString(std::string(advertisement_bytes)) << "("
<< advertisement_bytes.size() << "),"
<< ", fast advertisement service uuid="
<< absl::BytesToHexString(fast_advertisement_service_uuid);
auto& env = MediumEnvironment::Instance();
auto& peripheral = adapter_->GetPeripheral();
peripheral.SetAdvertisementBytes(service_id, advertisement_bytes);
@@ -181,7 +180,7 @@ bool BleMedium::StopAdvertising(const std::string& service_id) {
absl::MutexLock lock(&mutex_);
if (advertising_info_.Empty()) {
LOG(INFO) << "G3 Ble StopAdvertising: Can't stop advertising "
"because we never started advertising.";
"because we never started advertising.";
return false;
}
advertising_info_.Clear();
@@ -194,8 +193,8 @@ bool BleMedium::StopAdvertising(const std::string& service_id) {
accept_loops_runner_.Shutdown();
if (server_socket_ == nullptr) {
LOG(ERROR) << "G3 Ble StopAdvertising: Failed to find Ble Server "
"socket: service_id="
<< service_id;
"socket: service_id="
<< service_id;
// Fall through for server socket not found.
return true;
}
@@ -231,7 +230,7 @@ bool BleMedium::StopScanning(const std::string& service_id) {
absl::MutexLock lock(&mutex_);
if (scanning_info_.Empty()) {
LOG(INFO) << "G3 Ble StopDiscovery: Can't stop scanning because "
"we never started scanning.";
"we never started scanning.";
return false;
}
scanning_info_.Clear();
@@ -244,8 +243,7 @@ bool BleMedium::StopScanning(const std::string& service_id) {
bool BleMedium::StartAcceptingConnections(const std::string& service_id,
AcceptedConnectionCallback callback) {
LOG(INFO) << "G3 Ble StartAcceptingConnections: service_id="
<< service_id;
LOG(INFO) << "G3 Ble StartAcceptingConnections: service_id=" << service_id;
auto& env = MediumEnvironment::Instance();
env.UpdateBleMediumForAcceptedConnection(*this, service_id,
std::move(callback));
@@ -253,8 +251,7 @@ bool BleMedium::StartAcceptingConnections(const std::string& service_id,
}
bool BleMedium::StopAcceptingConnections(const std::string& service_id) {
LOG(INFO) << "G3 Ble StopAcceptingConnections: service_id="
<< service_id;
LOG(INFO) << "G3 Ble StopAcceptingConnections: service_id=" << service_id;
auto& env = MediumEnvironment::Instance();
env.UpdateBleMediumForAcceptedConnection(*this, service_id, {});
return true;
@@ -264,9 +261,9 @@ std::unique_ptr<api::BleSocket> BleMedium::Connect(
api::BlePeripheral& remote_peripheral, const std::string& service_id,
CancellationFlag* cancellation_flag) {
LOG(INFO) << "G3 Ble Connect [self]: medium=" << this
<< ", adapter=" << &GetAdapter()
<< ", peripheral=" << &GetAdapter().GetPeripheral()
<< ", service_id=" << service_id;
<< ", adapter=" << &GetAdapter()
<< ", peripheral=" << &GetAdapter().GetPeripheral()
<< ", service_id=" << service_id;
// First, find an instance of remote medium, that exposed this peripheral.
auto& adapter = static_cast<BlePeripheral&>(remote_peripheral).GetAdapter();
auto* medium = static_cast<BleMedium*>(adapter.GetBleMedium());
@@ -275,9 +272,8 @@ std::unique_ptr<api::BleSocket> BleMedium::Connect(
BleServerSocket* remote_server_socket = nullptr;
LOG(INFO) << "G3 Ble Connect [peer]: medium=" << medium
<< ", adapter=" << &adapter
<< ", peripheral=" << &remote_peripheral
<< ", service_id=" << service_id;
<< ", adapter=" << &adapter << ", peripheral=" << &remote_peripheral
<< ", service_id=" << service_id;
// Then, find our server socket context in this medium.
{
absl::MutexLock medium_lock(&medium->mutex_);
@@ -292,8 +288,8 @@ std::unique_ptr<api::BleSocket> BleMedium::Connect(
if (cancellation_flag->Cancelled()) {
LOG(ERROR) << "G3 BLE Connect: Has been cancelled: "
"service_id="
<< service_id;
"service_id="
<< service_id;
return {};
}
@@ -307,8 +303,8 @@ std::unique_ptr<api::BleSocket> BleMedium::Connect(
// Finally, Request to connect to this socket.
if (!remote_server_socket->Connect(*socket)) {
LOG(ERROR) << "G3 Ble Connect: Failed to connect to existing Ble "
"Server socket: service_id="
<< service_id;
"Server socket: service_id="
<< service_id;
return {};
}
@@ -65,8 +65,7 @@ bool BluetoothServerSocket::Connect(BluetoothSocket& socket) {
absl::MutexLock lock(&mutex_);
if (closed_) return false;
if (socket.IsConnected()) {
LOG(ERROR)
<< "Failed to connect to BT server socket: already connected";
LOG(ERROR) << "Failed to connect to BT server socket: already connected";
return true; // already connected.
}
// add client socket to the pending list
@@ -172,8 +171,8 @@ std::unique_ptr<api::BluetoothSocket> BluetoothClassicMedium::ConnectToService(
api::BluetoothDevice& remote_device, const std::string& service_uuid,
CancellationFlag* cancellation_flag) {
LOG(INFO) << "G3 ConnectToService [self]: medium=" << this
<< ", adapter=" << &GetAdapter()
<< ", device=" << &GetAdapter().GetDevice();
<< ", adapter=" << &GetAdapter()
<< ", device=" << &GetAdapter().GetDevice();
// First, find an instance of remote medium, that exposed this device.
auto& adapter = static_cast<BluetoothDevice&>(remote_device).GetAdapter();
auto* medium =
@@ -183,24 +182,23 @@ std::unique_ptr<api::BluetoothSocket> BluetoothClassicMedium::ConnectToService(
BluetoothServerSocket* server_socket = nullptr;
LOG(INFO) << "G3 ConnectToService [peer]: medium=" << medium
<< ", adapter=" << &adapter << ", device=" << &remote_device
<< ", uuid=" << service_uuid.c_str();
<< ", adapter=" << &adapter << ", device=" << &remote_device
<< ", uuid=" << service_uuid;
// Then, find our server socket context in this medium.
{
absl::MutexLock medium_lock(&medium->mutex_);
auto item = medium->sockets_.find(service_uuid);
server_socket = item != medium->sockets_.end() ? item->second : nullptr;
if (server_socket == nullptr) {
LOG(ERROR) << "Failed to find BT Server socket: uuid="
<< service_uuid;
LOG(ERROR) << "Failed to find BT Server socket: uuid=" << service_uuid;
return {};
}
}
if (cancellation_flag->Cancelled()) {
LOG(ERROR) << "G3 Bluetooth Connect: Has been cancelled: "
"service_uuid="
<< service_uuid;
"service_uuid="
<< service_uuid;
return {};
}
@@ -212,23 +210,20 @@ std::unique_ptr<api::BluetoothSocket> BluetoothClassicMedium::ConnectToService(
auto socket = std::make_unique<BluetoothSocket>(&GetAdapter());
// Finally, Request to connect to this socket.
if (!server_socket->Connect(*socket)) {
LOG(ERROR)
<< "Failed to connect to existing BT Server socket: uuid="
<< service_uuid;
LOG(ERROR) << "Failed to connect to existing BT Server socket: uuid="
<< service_uuid;
return {};
}
if (cancellation_flag->Cancelled()) {
LOG(ERROR)
<< "G3 Bluetooth Connect: Has been cancelled after connected: "
"service_uuid="
<< service_uuid;
LOG(ERROR) << "G3 Bluetooth Connect: Has been cancelled after connected: "
"service_uuid="
<< service_uuid;
socket->Close();
return {};
}
LOG(INFO) << "G3 ConnectToService: connected: socket="
<< socket.get();
LOG(INFO) << "G3 ConnectToService: connected: socket=" << socket.get();
return socket;
}
@@ -240,8 +235,7 @@ BluetoothClassicMedium::ListenForService(const std::string& service_name,
absl::MutexLock lock(&mutex_);
sockets_.erase(uuid);
});
LOG(INFO) << "Adding service: medium=" << this
<< ", uuid=" << service_uuid;
LOG(INFO) << "Adding service: medium=" << this << ", uuid=" << service_uuid;
absl::MutexLock lock(&mutex_);
sockets_.emplace(service_uuid, socket.get());
return socket;
@@ -64,24 +64,20 @@ void CredentialStorageImpl::SaveCredentials(
}
if (private_credentials.empty()) {
LOG(INFO) << "There are no Private Credentials for account: ["
<< account_name << "], manager app ID:[" << manager_app_id
<< "]";
<< account_name << "], manager app ID:[" << manager_app_id << "]";
} else {
LOG(INFO) << "G3 Save Private Credentials for account: ["
<< account_name << "], manager app ID:[" << manager_app_id
<< "]";
LOG(INFO) << "G3 Save Private Credentials for account: [" << account_name
<< "], manager app ID:[" << manager_app_id << "]";
SaveLocalCredentialsLocked(manager_app_id, account_name,
private_credentials);
}
if (public_credentials.empty()) {
LOG(INFO) << "There are no Public Credentials for account: ["
<< account_name << "], manager app ID:[" << manager_app_id
<< "]";
<< account_name << "], manager app ID:[" << manager_app_id << "]";
} else {
LOG(INFO) << "G3 Save Public Credentials for account: ["
<< account_name << "], manager app ID:[" << manager_app_id
<< "]";
LOG(INFO) << "G3 Save Public Credentials for account: [" << account_name
<< "], manager app ID:[" << manager_app_id << "]";
PublicCredentialKey key = CreatePublicCredentialKey(
manager_app_id, account_name, public_credential_type);
auto public_result =
@@ -111,9 +107,8 @@ void CredentialStorageImpl::SaveLocalCredentialsLocked(
void CredentialStorageImpl::UpdateLocalCredential(
absl::string_view manager_app_id, absl::string_view account_name,
LocalCredential credential, SaveCredentialsResultCallback callback) {
LOG(INFO) << "G3 Update Private Credential for for account: ["
<< account_name << "], manager app ID:[" << manager_app_id
<< "]";
LOG(INFO) << "G3 Update Private Credential for for account: [" << account_name
<< "], manager app ID:[" << manager_app_id << "]";
absl::StatusOr<std::vector<LocalCredential>> credentials =
GetLocalCredentialsLocked(CredentialSelector{
.manager_app_id = std::string(manager_app_id),
@@ -150,7 +145,7 @@ CredentialStorageImpl::GetLocalCredentialsLocked(
credential_selector.manager_app_id, credential_selector.account_name);
if (private_credentials_map_.find(key) == private_credentials_map_.end()) {
LOG(WARNING) << "There are no Private Credentials stored for key:"
<< std::get<0>(key) << ", " << std::get<1>(key);
<< std::get<0>(key) << ", " << std::get<1>(key);
return absl::NotFoundError(
absl::StrFormat("No private credentials for %v", credential_selector));
}
@@ -174,8 +169,8 @@ void CredentialStorageImpl::GetPublicCredentials(
public_credential_type);
if (public_credentials_map_.find(key) == public_credentials_map_.end()) {
LOG(WARNING) << "There are no Public Credentials stored for key:"
<< std::get<0>(key) << ", " << std::get<1>(key) << ", "
<< std::get<2>(key);
<< std::get<0>(key) << ", " << std::get<1>(key) << ", "
<< std::get<2>(key);
std::move(callback.credentials_fetched_cb)(absl::NotFoundError(
absl::StrFormat("No public credentials for %v", credential_selector)));
return;
@@ -131,7 +131,7 @@ bool WifiDirectMedium::StartWifiDirect(
wifi_direct_credentials->SetPassword(password);
LOG(INFO) << "G3 StartWifiDirect GO: ssid=" << ssid
<< ", password:" << password;
<< ", password:" << password;
auto& env = MediumEnvironment::Instance();
env.UpdateWifiDirectMediumForStartOrConnect(*this, wifi_direct_credentials,
@@ -156,8 +156,8 @@ bool WifiDirectMedium::ConnectWifiDirect(
absl::MutexLock lock(&mutex_);
LOG(INFO) << "G3 ConnectWifiDirect : ssid="
<< wifi_direct_credentials->GetSSID()
<< ", password:" << wifi_direct_credentials->GetPassword();
<< wifi_direct_credentials->GetSSID()
<< ", password:" << wifi_direct_credentials->GetPassword();
auto& env = MediumEnvironment::Instance();
auto* remote_medium = static_cast<WifiDirectMedium*>(
@@ -192,7 +192,7 @@ std::unique_ptr<api::WifiDirectSocket> WifiDirectMedium::ConnectToService(
CancellationFlag* cancellation_flag) {
std::string socket_name = WifiDirectServerSocket::GetName(ip_address, port);
LOG(INFO) << "G3 WifiDirect ConnectToService [self]: medium=" << this
<< ", ip address + port=" << socket_name;
<< ", ip address + port=" << socket_name;
// First, find an instance of remote medium, that exposed this service.
auto& env = MediumEnvironment::Instance();
auto* remote_medium =
@@ -202,9 +202,8 @@ std::unique_ptr<api::WifiDirectSocket> WifiDirectMedium::ConnectToService(
}
WifiDirectServerSocket* server_socket = nullptr;
LOG(INFO) << "G3 WifiDirect ConnectToService [peer]: medium="
<< remote_medium
<< ", remote ip address + port=" << socket_name;
LOG(INFO) << "G3 WifiDirect ConnectToService [peer]: medium=" << remote_medium
<< ", remote ip address + port=" << socket_name;
// Then, find our server socket context in this medium.
{
absl::MutexLock medium_lock(&remote_medium->mutex_);
@@ -213,16 +212,15 @@ std::unique_ptr<api::WifiDirectSocket> WifiDirectMedium::ConnectToService(
item != remote_medium->server_sockets_.end() ? item->second : nullptr;
if (server_socket == nullptr) {
LOG(ERROR) << "G3 WifiDirect Failed to find WifiDirect Server "
"socket: socket_name="
<< socket_name;
"socket: socket_name="
<< socket_name;
return nullptr;
}
}
if (cancellation_flag->Cancelled()) {
LOG(ERROR)
<< "G3 WifiDirect Connect: Has been cancelled: socket_name="
<< socket_name;
LOG(ERROR) << "G3 WifiDirect Connect: Has been cancelled: socket_name="
<< socket_name;
return nullptr;
}
@@ -231,7 +229,7 @@ std::unique_ptr<api::WifiDirectSocket> WifiDirectMedium::ConnectToService(
server_socket->Connect(*socket);
LOG(INFO) << "G3 WifiDirect GC ConnectToService: connected: socket="
<< socket.get();
<< socket.get();
return socket;
}
@@ -257,7 +255,7 @@ std::unique_ptr<api::WifiDirectServerSocket> WifiDirectMedium::ListenForService(
server_sockets_.erase(socket_name);
});
LOG(INFO) << "G3 WifiDirect GO Adding server socket: medium=" << this
<< ", socket_name=" << socket_name;
<< ", socket_name=" << socket_name;
absl::MutexLock lock(&mutex_);
server_sockets_.insert({socket_name, server_socket.get()});
return server_socket;
@@ -134,7 +134,7 @@ bool WifiHotspotMedium::StartWifiHotspot(
hotspot_credentials->SetPassword(password);
LOG(INFO) << "G3 StartWifiHotspot: ssid=" << ssid
<< ", password:" << password;
<< ", password:" << password;
auto& env = MediumEnvironment::Instance();
env.UpdateWifiHotspotMediumForStartOrConnect(*this, hotspot_credentials,
@@ -161,9 +161,8 @@ bool WifiHotspotMedium::ConnectWifiHotspot(
HotspotCredentials* hotspot_credentials) {
absl::MutexLock lock(&mutex_);
LOG(INFO) << "G3 ConnectWifiHotspot: ssid="
<< hotspot_credentials->GetSSID()
<< ", password:" << hotspot_credentials->GetPassword();
LOG(INFO) << "G3 ConnectWifiHotspot: ssid=" << hotspot_credentials->GetSSID()
<< ", password:" << hotspot_credentials->GetPassword();
auto& env = MediumEnvironment::Instance();
auto* remote_medium = static_cast<WifiHotspotMedium*>(
@@ -198,7 +197,7 @@ std::unique_ptr<api::WifiHotspotSocket> WifiHotspotMedium::ConnectToService(
CancellationFlag* cancellation_flag) {
std::string socket_name = WifiHotspotServerSocket::GetName(ip_address, port);
LOG(INFO) << "G3 WifiHotspot ConnectToService [self]: medium=" << this
<< ", ip address + port=" << socket_name;
<< ", ip address + port=" << socket_name;
// First, find an instance of remote medium, that exposed this service.
auto& env = MediumEnvironment::Instance();
auto* remote_medium =
@@ -209,8 +208,7 @@ std::unique_ptr<api::WifiHotspotSocket> WifiHotspotMedium::ConnectToService(
WifiHotspotServerSocket* server_socket = nullptr;
LOG(INFO) << "G3 WifiHotspot ConnectToService [peer]: medium="
<< remote_medium
<< ", remote ip address + port=" << socket_name;
<< remote_medium << ", remote ip address + port=" << socket_name;
// Then, find our server socket context in this medium.
{
absl::MutexLock medium_lock(&remote_medium->mutex_);
@@ -219,16 +217,15 @@ std::unique_ptr<api::WifiHotspotSocket> WifiHotspotMedium::ConnectToService(
item != remote_medium->server_sockets_.end() ? item->second : nullptr;
if (server_socket == nullptr) {
LOG(ERROR) << "G3 WifiHotspot Failed to find WifiHotspot Server "
"socket: socket_name="
<< socket_name;
"socket: socket_name="
<< socket_name;
return {};
}
}
if (cancellation_flag->Cancelled()) {
LOG(ERROR)
<< "G3 WifiHotspot Connect: Has been cancelled: socket_name="
<< socket_name;
LOG(ERROR) << "G3 WifiHotspot Connect: Has been cancelled: socket_name="
<< socket_name;
return {};
}
@@ -242,14 +239,13 @@ std::unique_ptr<api::WifiHotspotSocket> WifiHotspotMedium::ConnectToService(
auto socket = std::make_unique<WifiHotspotSocket>();
// Finally, Request to connect to this socket.
if (!server_socket->Connect(*socket)) {
LOG(ERROR)
<< "G3 WifiHotspot Failed to connect to existing WifiHotspot "
"Server socket: name="
<< socket_name;
LOG(ERROR) << "G3 WifiHotspot Failed to connect to existing WifiHotspot "
"Server socket: name="
<< socket_name;
return {};
}
LOG(INFO) << "G3 WifiHotspot ConnectToService: connected: socket="
<< socket.get();
<< socket.get();
return socket;
}
@@ -276,7 +272,7 @@ WifiHotspotMedium::ListenForService(int port) {
server_sockets_.erase(socket_name);
});
LOG(INFO) << "G3 WifiHotspot Adding server socket: medium=" << this
<< ", socket_name=" << socket_name;
<< ", socket_name=" << socket_name;
absl::MutexLock lock(&mutex_);
server_sockets_.insert({socket_name, server_socket.get()});
return server_socket;
+23 -28
View File
@@ -130,9 +130,9 @@ WifiLanMedium::~WifiLanMedium() {
bool WifiLanMedium::StartAdvertising(const NsdServiceInfo& nsd_service_info) {
std::string service_type = nsd_service_info.GetServiceType();
LOG(INFO) << "G3 WifiLan StartAdvertising: nsd_service_info="
<< &nsd_service_info
<< ", service_name=" << nsd_service_info.GetServiceName()
<< ", service_type=" << service_type;
<< &nsd_service_info
<< ", service_name=" << nsd_service_info.GetServiceName()
<< ", service_type=" << service_type;
{
absl::MutexLock lock(&mutex_);
if (advertising_info_.Existed(service_type)) {
@@ -156,16 +156,15 @@ bool WifiLanMedium::StartAdvertising(const NsdServiceInfo& nsd_service_info) {
bool WifiLanMedium::StopAdvertising(const NsdServiceInfo& nsd_service_info) {
std::string service_type = nsd_service_info.GetServiceType();
LOG(INFO) << "G3 WifiLan StopAdvertising: nsd_service_info="
<< &nsd_service_info
<< ", service_name=" << nsd_service_info.GetServiceName()
<< ", service_type=" << service_type;
<< &nsd_service_info
<< ", service_name=" << nsd_service_info.GetServiceName()
<< ", service_type=" << service_type;
{
absl::MutexLock lock(&mutex_);
if (!advertising_info_.Existed(service_type)) {
LOG(INFO)
<< "G3 WifiLan StopAdvertising: Can't stop advertising because "
"we never started advertising for service_type="
<< service_type;
LOG(INFO) << "G3 WifiLan StopAdvertising: Can't stop advertising because "
"we never started advertising for service_type="
<< service_type;
return false;
}
advertising_info_.Remove(service_type);
@@ -178,15 +177,13 @@ bool WifiLanMedium::StopAdvertising(const NsdServiceInfo& nsd_service_info) {
bool WifiLanMedium::StartDiscovery(const std::string& service_type,
DiscoveredServiceCallback callback) {
LOG(INFO) << "G3 WifiLan StartDiscovery: service_type="
<< service_type;
LOG(INFO) << "G3 WifiLan StartDiscovery: service_type=" << service_type;
{
absl::MutexLock lock(&mutex_);
if (discovering_info_.Existed(service_type)) {
LOG(INFO)
<< "G3 WifiLan StartDiscovery: Can't start discovery because "
"service_type="
<< service_type << " has started already.";
LOG(INFO) << "G3 WifiLan StartDiscovery: Can't start discovery because "
"service_type="
<< service_type << " has started already.";
return false;
}
}
@@ -201,8 +198,7 @@ bool WifiLanMedium::StartDiscovery(const std::string& service_type,
}
bool WifiLanMedium::StopDiscovery(const std::string& service_type) {
LOG(INFO) << "G3 WifiLan StopDiscovery: service_type="
<< service_type;
LOG(INFO) << "G3 WifiLan StopDiscovery: service_type=" << service_type;
{
absl::MutexLock lock(&mutex_);
if (!discovering_info_.Existed(service_type)) {
@@ -223,7 +219,7 @@ std::unique_ptr<api::WifiLanSocket> WifiLanMedium::ConnectToService(
CancellationFlag* cancellation_flag) {
std::string service_type = remote_service_info.GetServiceType();
LOG(INFO) << "G3 WifiLan ConnectToService [self]: medium=" << this
<< ", service_type=" << service_type;
<< ", service_type=" << service_type;
return ConnectToService(remote_service_info.GetIPAddress(),
remote_service_info.GetPort(), cancellation_flag);
}
@@ -233,7 +229,7 @@ std::unique_ptr<api::WifiLanSocket> WifiLanMedium::ConnectToService(
CancellationFlag* cancellation_flag) {
std::string socket_name = WifiLanServerSocket::GetName(ip_address, port);
LOG(INFO) << "G3 WifiLan ConnectToService [self]: medium=" << this
<< ", ip address + port=" << socket_name;
<< ", ip address + port=" << socket_name;
// First, find an instance of remote medium, that exposed this service.
auto& env = MediumEnvironment::Instance();
auto* remote_medium =
@@ -243,9 +239,8 @@ std::unique_ptr<api::WifiLanSocket> WifiLanMedium::ConnectToService(
}
WifiLanServerSocket* server_socket = nullptr;
LOG(INFO) << "G3 WifiLan ConnectToService [peer]: medium="
<< remote_medium
<< ", remote ip address + port=" << socket_name;
LOG(INFO) << "G3 WifiLan ConnectToService [peer]: medium=" << remote_medium
<< ", remote ip address + port=" << socket_name;
// Then, find our server socket context in this medium.
{
absl::MutexLock medium_lock(&remote_medium->mutex_);
@@ -262,7 +257,7 @@ std::unique_ptr<api::WifiLanSocket> WifiLanMedium::ConnectToService(
if (cancellation_flag->Cancelled()) {
LOG(ERROR) << "G3 WifiLan Connect: Has been cancelled: socket_name="
<< socket_name;
<< socket_name;
return {};
}
@@ -277,12 +272,12 @@ std::unique_ptr<api::WifiLanSocket> WifiLanMedium::ConnectToService(
// Finally, Request to connect to this socket.
if (!server_socket->Connect(*socket)) {
LOG(ERROR) << "G3 WifiLan Failed to connect to existing WifiLan "
"Server socket: name="
<< socket_name;
"Server socket: name="
<< socket_name;
return {};
}
LOG(INFO) << "G3 WifiLan ConnectToService: connected: socket="
<< socket.get();
<< socket.get();
return socket;
}
@@ -299,7 +294,7 @@ std::unique_ptr<api::WifiLanServerSocket> WifiLanMedium::ListenForService(
server_sockets_.erase(socket_name);
});
LOG(INFO) << "G3 WifiLan Adding server socket: medium=" << this
<< ", socket_name=" << socket_name;
<< ", socket_name=" << socket_name;
absl::MutexLock lock(&mutex_);
server_sockets_.insert({socket_name, server_socket.get()});
return server_socket;
@@ -123,7 +123,7 @@ bool WifiLanMdns::StartMdnsService(
if (status != DNS_REQUEST_PENDING) {
LOG(ERROR) << "Failed to start mDNS advertising for service type ="
<< service_type;
<< service_type;
return false;
}
+1 -2
View File
@@ -1302,8 +1302,7 @@ void MediumEnvironment::UnregisterGattServer(api::ble_v2::BleMedium& medium) {
}
auto& context = it->second;
LOG(INFO) << "Unregistered GattServer for peripheral id:"
<< context.ble_peripheral_id
<< " on medium:" << &medium;
<< context.ble_peripheral_id << " on medium:" << &medium;
context.gatt_server = nullptr;
context.ble_peripheral_id = 0LL;
latch.CountDown();
+6 -4
View File
@@ -14,6 +14,8 @@
#include "internal/platform/pending_job_registry.h"
#include "absl/time/time.h"
#include "internal/platform/implementation/system_clock.h"
#include "internal/platform/logging.h"
#include "internal/platform/mutex_lock.h"
#include "internal/platform/system_clock.h"
@@ -68,14 +70,14 @@ void PendingJobRegistry::ListJobs() {
auto age = current_time - job.second;
if (age >= kReportPendingJobsOlderThan) {
LOG(INFO) << "Task \"" << job.first << "\" is waiting for "
<< absl::ToInt64Seconds(age) << " s";
<< absl::ToInt64Seconds(age) << " s";
}
}
for (auto& job : running_jobs_) {
auto age = current_time - job.second;
if (age >= kReportRunningJobsOlderThan) {
LOG(INFO) << "Task \"" << job.first << "\" is running for "
<< absl::ToInt64Seconds(age) << " s";
<< absl::ToInt64Seconds(age) << " s";
}
}
list_jobs_time_ = current_time;
@@ -87,12 +89,12 @@ void PendingJobRegistry::ListAllJobs() {
for (auto& job : pending_jobs_) {
auto age = current_time - job.second;
LOG(INFO) << "Task \"" << job.first << "\" is waiting for "
<< absl::ToInt64Seconds(age) << " s";
<< absl::ToInt64Seconds(age) << " s";
}
for (auto& job : running_jobs_) {
auto age = current_time - job.second;
LOG(INFO) << "Task \"" << job.first << "\" is running for "
<< absl::ToInt64Seconds(age) << " s";
<< absl::ToInt64Seconds(age) << " s";
}
list_jobs_time_ = current_time;
}
+1 -3
View File
@@ -66,9 +66,7 @@ class MediumSocket : public Socket {
virtual void FeedIncomingData(ByteArray data) {}
/** Returns true if the socket is a virtual socket. */
virtual bool IsVirtualSocket() {
return false;
}
virtual bool IsVirtualSocket() { return false; }
/** Adds a listener to be invoked when the socket is closed. */
void AddOnSocketClosedListener(
+3 -3
View File
@@ -14,17 +14,17 @@
#include "internal/platform/wifi_direct.h"
#include "internal/platform/logging.h"
#include "absl/strings/string_view.h"
#include "internal/platform/cancellation_flag.h"
#include "internal/platform/logging.h"
namespace nearby {
WifiDirectSocket WifiDirectMedium::ConnectToService(
absl::string_view ip_address, int port,
CancellationFlag* cancellation_flag) {
LOG(INFO) << "WifiDirectMedium::ConnectToService: ip address="
<< ip_address << ", port=" << port;
LOG(INFO) << "WifiDirectMedium::ConnectToService: ip address=" << ip_address
<< ", port=" << port;
return WifiDirectSocket(
impl_->ConnectToService(ip_address, port, cancellation_flag));
}
+1 -2
View File
@@ -122,8 +122,7 @@ class WifiDirectServerSocket final {
WifiDirectSocket Accept() {
std::unique_ptr<api::WifiDirectSocket> socket = impl_->Accept();
if (!socket) {
LOG(INFO)
<< "WifiDirectServerSocket Accept() failed on server socket: ";
LOG(INFO) << "WifiDirectServerSocket Accept() failed on server socket: ";
}
return WifiDirectSocket(std::move(socket));
}
+25 -32
View File
@@ -20,12 +20,12 @@
#include "absl/container/flat_hash_map.h"
#include "internal/platform/cancellation_flag.h"
#include "internal/platform/implementation/wifi_utils.h"
#include "internal/platform/logging.h"
#include "internal/platform/mutex_lock.h"
#include "internal/platform/nsd_service_info.h"
#include "internal/platform/output_stream.h"
#include "internal/platform/socket.h"
#include "internal/platform/implementation/wifi_utils.h"
namespace nearby {
using location::nearby::proto::connections::Medium;
@@ -44,15 +44,14 @@ MediumSocket* WifiLanSocket::CreateVirtualSocket(
auto virtual_socket = std::make_shared<WifiLanSocket>(outputstream);
virtual_socket->impl_ = this->impl_;
LOG(WARNING) << "Created the virtual socket for Medium: "
<< Medium_Name(virtual_socket->GetMedium());
<< Medium_Name(virtual_socket->GetMedium());
if (virtual_sockets_ptr_ == nullptr) {
virtual_sockets_ptr_ = virtual_sockets_ptr;
}
(*virtual_sockets_ptr_)[salted_service_id_hash_key] = virtual_socket;
LOG(INFO) << "virtual_sockets_ size: "
<< virtual_sockets_ptr_->size();
LOG(INFO) << "virtual_sockets_ size: " << virtual_sockets_ptr_->size();
return virtual_socket.get();
}
@@ -71,7 +70,7 @@ bool WifiLanMedium::StartDiscovery(const std::string& service_id,
MutexLock lock(&mutex_);
if (service_type_to_callback_map_.contains(service_type)) {
LOG(INFO) << "WifiLan Discovery already start with service_type="
<< service_type << "; impl=" << &GetImpl();
<< service_type << "; impl=" << &GetImpl();
return false;
}
}
@@ -84,35 +83,31 @@ bool WifiLanMedium::StartDiscovery(const std::string& service_id,
const auto& it = service_type_to_callback_map_.find(service_type);
if (it == service_type_to_callback_map_.end()) {
LOG(ERROR)
<< "There is no callback found for service_type="
<< service_type;
LOG(ERROR) << "There is no callback found for service_type="
<< service_type;
return;
}
// Check whether service name is in cache.
auto services_it = service_type_to_services_map_.find(service_type);
if (services_it == service_type_to_services_map_.end()) {
LOG(ERROR)
<< "There is no service map found for service_type="
<< service_type;
LOG(ERROR) << "There is no service map found for service_type="
<< service_type;
return;
}
std::string service_name = service_info.GetServiceName();
auto pair = services_it->second.insert(service_name);
if (!pair.second) {
LOG(INFO)
<< "Discovering (again) service_info=" << &service_info
<< ", service_type=" << service_type
<< ", service_name=" << service_info.GetServiceName();
LOG(INFO) << "Discovering (again) service_info=" << &service_info
<< ", service_type=" << service_type
<< ", service_name=" << service_info.GetServiceName();
return;
}
LOG(INFO)
<< "Adding service_info=" << &service_info
<< ", service_type=" << service_type
<< ", service_name=" << service_info.GetServiceName();
LOG(INFO) << "Adding service_info=" << &service_info
<< ", service_type=" << service_type
<< ", service_name=" << service_info.GetServiceName();
std::string service_id = it->second->service_id;
DiscoveredServiceCallback& medium_callback =
@@ -126,17 +121,16 @@ bool WifiLanMedium::StartDiscovery(const std::string& service_id,
std::string service_name = service_info.GetServiceName();
auto services_it = service_type_to_services_map_.find(service_type);
if (services_it == service_type_to_services_map_.end()) {
LOG(ERROR)
<< "There is no service map found for service_type="
<< service_type;
LOG(ERROR) << "There is no service map found for service_type="
<< service_type;
return;
}
auto item = services_it->second.extract(service_name);
if (item.empty()) return;
LOG(INFO) << "Removing service_info=" << &service_info
<< ", service_type=" << service_type
<< ", service_info_name=" << service_name;
<< ", service_type=" << service_type
<< ", service_info_name=" << service_name;
// Callback service lost.
const auto& it = service_type_to_callback_map_.find(service_type);
if (it != service_type_to_callback_map_.end()) {
@@ -169,9 +163,8 @@ bool WifiLanMedium::StartDiscovery(const std::string& service_id,
service_type_to_callback_map_.erase(service_type);
service_type_to_services_map_.erase(service_type);
}
LOG(INFO) << "WifiLan Discovery started for service_type="
<< service_type << ", impl=" << &GetImpl()
<< ", success=" << success;
LOG(INFO) << "WifiLan Discovery started for service_type=" << service_type
<< ", impl=" << &GetImpl() << ", success=" << success;
return success;
}
@@ -184,8 +177,8 @@ bool WifiLanMedium::StopDiscovery(const std::string& service_type) {
if (service_type_to_services_map_.contains(service_type)) {
service_type_to_services_map_.erase(service_type);
}
LOG(INFO) << "WifiLan Discovery disabled for service_type="
<< service_type << ", impl=" << &GetImpl();
LOG(INFO) << "WifiLan Discovery disabled for service_type=" << service_type
<< ", impl=" << &GetImpl();
return impl_->StopDiscovery(service_type);
}
@@ -193,7 +186,7 @@ WifiLanSocket WifiLanMedium::ConnectToService(
const NsdServiceInfo& remote_service_info,
CancellationFlag* cancellation_flag) {
LOG(INFO) << "WifiLanMedium::ConnectToService: remote_service_name="
<< remote_service_info.GetServiceName();
<< remote_service_info.GetServiceName();
return WifiLanSocket(
impl_->ConnectToService(remote_service_info, cancellation_flag));
}
@@ -202,8 +195,8 @@ WifiLanSocket WifiLanMedium::ConnectToService(
const std::string& ip_address, int port,
CancellationFlag* cancellation_flag) {
LOG(INFO) << "WifiLanMedium::ConnectToService: ip address="
<< WifiUtils::GetHumanReadableIpAddress(ip_address)
<< ", port=" << port;
<< WifiUtils::GetHumanReadableIpAddress(ip_address)
<< ", port=" << port;
return WifiLanSocket(
impl_->ConnectToService(ip_address, port, cancellation_flag));
}
+2 -2
View File
@@ -164,8 +164,8 @@ class WifiLanServerSocket final {
WifiLanSocket Accept() {
std::unique_ptr<api::WifiLanSocket> socket = impl_->Accept();
if (!socket) {
LOG(INFO)
<< "WifiLanServerSocket Accept() failed on server socket: " << this;
LOG(INFO) << "WifiLanServerSocket Accept() failed on server socket: "
<< this;
}
return WifiLanSocket(std::move(socket));
}
+1 -3
View File
@@ -94,9 +94,7 @@ class FakeSocket : public BaseSocket {
explicit FakeSocket(const Connection& connection,
SocketCallback&& socketCallback)
: BaseSocket(connection, std::move(socketCallback)) {}
~FakeSocket() override {
ShutDown();
}
~FakeSocket() override { ShutDown(); }
MOCK_METHOD(void, Connect, (), (override));
void OnReceiveControlPacket(Packet packet) override {
control_packets_.push_back(std::move(packet));
+1 -2
View File
@@ -349,8 +349,7 @@ TEST_F(ClientSocketTest, TestSocketWithRandomDataProvider) {
MutexLock lock(&mutex_);
messages_read_.push_back(message);
},
.on_error_cb =
[](absl::Status status) { LOG(ERROR) << status; },
.on_error_cb = [](absl::Status status) { LOG(ERROR) << status; },
},
std::move(provider));
socket.Connect();
+8 -9
View File
@@ -87,9 +87,9 @@ void ServerSocket::OnReceiveControlPacket(Packet packet) {
// after the initial handshake.
if (state_ != State::kClientConnectionRequest) {
LOG(ERROR) << "Not in 'Connection Request' state, but "
"incorrectly received control packet of type "
<< Packet::ControlPacketTypeToString(
packet.GetControlCommandNumber());
"incorrectly received control packet of type "
<< Packet::ControlPacketTypeToString(
packet.GetControlCommandNumber());
GetSocketCallback().on_error_cb(
absl::InvalidArgumentError("Unexpected control packet"));
return;
@@ -97,9 +97,9 @@ void ServerSocket::OnReceiveControlPacket(Packet packet) {
if (packet.GetControlCommandNumber() !=
Packet::ControlPacketType::kControlConnectionRequest) {
LOG(ERROR) << "Expected connection request control packet, "
"received control packet of type "
<< Packet::ControlPacketTypeToString(
packet.GetControlCommandNumber());
"received control packet of type "
<< Packet::ControlPacketTypeToString(
packet.GetControlCommandNumber());
DisconnectInternal(
absl::InvalidArgumentError("Unexpected control packet type."));
return;
@@ -117,8 +117,7 @@ void ServerSocket::OnReceiveControlPacket(Packet packet) {
if (min_protocol_version > kProtocolVersion ||
max_protocol_version < kProtocolVersion) {
LOG(ERROR) << "Received unexpected min/max protocol versions: "
<< min_protocol_version << " and "
<< max_protocol_version;
<< min_protocol_version << " and " << max_protocol_version;
DisconnectInternal(
absl::InvalidArgumentError("unexpected protocol versions"));
return;
@@ -145,7 +144,7 @@ void ServerSocket::WriteConnectionConfirm() {
kProtocolVersion, max_packet_size_, "");
if (!packet.ok()) {
LOG(ERROR) << "Failed to create connection confirm packet: "
<< packet.status();
<< packet.status();
DisconnectInternal(packet.status());
return;
}