Commit a8130f20 authored by Juliet Levesque's avatar Juliet Levesque Committed by Commit Bot

[Nearby] Replace logging instances with NS_LOG macro.

Allows logging instances used for Nearby Share to show up on
chrome://nearby-internals logging tab.

Bug: 1093634
Change-Id: Ic6d4efb6cc46badd16cd516fa0333dbe73683ed8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2298184Reviewed-by: default avatarJosh Nohle <nohle@chromium.org>
Commit-Queue: Juliet Levesque <julietlevesque@google.com>
Cr-Commit-Position: refs/heads/master@{#790033}
parent 7de17a2d
...@@ -22,6 +22,7 @@ source_set("certificates") { ...@@ -22,6 +22,7 @@ source_set("certificates") {
deps = [ deps = [
"//base", "//base",
"//base/util/values:values_util", "//base/util/values:values_util",
"//chrome/browser/nearby_sharing/logging",
"//chrome/browser/nearby_sharing/proto", "//chrome/browser/nearby_sharing/proto",
"//crypto", "//crypto",
] ]
......
...@@ -6,9 +6,9 @@ ...@@ -6,9 +6,9 @@
#include <utility> #include <utility>
#include "base/logging.h"
#include "chrome/browser/nearby_sharing/certificates/common.h" #include "chrome/browser/nearby_sharing/certificates/common.h"
#include "chrome/browser/nearby_sharing/certificates/constants.h" #include "chrome/browser/nearby_sharing/certificates/constants.h"
#include "chrome/browser/nearby_sharing/logging/logging.h"
#include "chrome/browser/nearby_sharing/proto/timestamp.pb.h" #include "chrome/browser/nearby_sharing/proto/timestamp.pb.h"
#include "crypto/aead.h" #include "crypto/aead.h"
#include "crypto/encryptor.h" #include "crypto/encryptor.h"
...@@ -41,7 +41,7 @@ base::Optional<std::vector<uint8_t>> DecryptMetadataKey( ...@@ -41,7 +41,7 @@ base::Optional<std::vector<uint8_t>> DecryptMetadataKey(
std::unique_ptr<crypto::Encryptor> encryptor = std::unique_ptr<crypto::Encryptor> encryptor =
CreateNearbyShareCtrEncryptor(secret_key, encrypted_metadata_key.salt()); CreateNearbyShareCtrEncryptor(secret_key, encrypted_metadata_key.salt());
if (!encryptor) { if (!encryptor) {
LOG(ERROR) NS_LOG(ERROR)
<< "Cannot decrypt metadata key: Could not create CTR encryptor."; << "Cannot decrypt metadata key: Could not create CTR encryptor.";
return base::nullopt; return base::nullopt;
} }
...@@ -139,8 +139,8 @@ NearbyShareDecryptedPublicCertificate::DecryptPublicCertificate( ...@@ -139,8 +139,8 @@ NearbyShareDecryptedPublicCertificate::DecryptPublicCertificate(
// Confirm that the decrypted metadata key agrees with key commitment tag. // Confirm that the decrypted metadata key agrees with key commitment tag.
if (!VerifyMetadataEncryptionKeyTag(*decrypted_metadata_key, if (!VerifyMetadataEncryptionKeyTag(*decrypted_metadata_key,
metadata_encryption_key_tag)) { metadata_encryption_key_tag)) {
LOG(ERROR) << "Metadata decryption failed: Failed to verify metadata " NS_LOG(ERROR) << "Metadata decryption failed: Failed to verify metadata "
<< "encryption key tag."; << "encryption key tag.";
return base::nullopt; return base::nullopt;
} }
...@@ -150,16 +150,16 @@ NearbyShareDecryptedPublicCertificate::DecryptPublicCertificate( ...@@ -150,16 +150,16 @@ NearbyShareDecryptedPublicCertificate::DecryptPublicCertificate(
DecryptMetadataPayload(encrypted_metadata, *decrypted_metadata_key, DecryptMetadataPayload(encrypted_metadata, *decrypted_metadata_key,
secret_key.get()); secret_key.get());
if (!decrypted_metadata_bytes) { if (!decrypted_metadata_bytes) {
LOG(ERROR) << "Metadata decryption failed: Failed to decrypt metadata " NS_LOG(ERROR) << "Metadata decryption failed: Failed to decrypt metadata "
<< "payload."; << "payload.";
return base::nullopt; return base::nullopt;
} }
nearbyshare::proto::EncryptedMetadata unencrypted_metadata; nearbyshare::proto::EncryptedMetadata unencrypted_metadata;
if (!unencrypted_metadata.ParseFromArray(decrypted_metadata_bytes->data(), if (!unencrypted_metadata.ParseFromArray(decrypted_metadata_bytes->data(),
decrypted_metadata_bytes->size())) { decrypted_metadata_bytes->size())) {
LOG(ERROR) << "Metadata decryption failed: Failed to parse decrypted " NS_LOG(ERROR) << "Metadata decryption failed: Failed to parse decrypted "
<< "metadata payload."; << "metadata payload.";
return base::nullopt; return base::nullopt;
} }
...@@ -192,7 +192,7 @@ bool NearbyShareDecryptedPublicCertificate::VerifySignature( ...@@ -192,7 +192,7 @@ bool NearbyShareDecryptedPublicCertificate::VerifySignature(
crypto::SignatureVerifier verifier; crypto::SignatureVerifier verifier;
if (!verifier.VerifyInit(crypto::SignatureVerifier::ECDSA_SHA256, signature, if (!verifier.VerifyInit(crypto::SignatureVerifier::ECDSA_SHA256, signature,
public_key_)) { public_key_)) {
LOG(ERROR) << "Verification failed: Initialization unsuccessful."; NS_LOG(ERROR) << "Verification failed: Initialization unsuccessful.";
return false; return false;
} }
......
...@@ -7,13 +7,13 @@ ...@@ -7,13 +7,13 @@
#include <utility> #include <utility>
#include "base/base64url.h" #include "base/base64url.h"
#include "base/logging.h"
#include "base/rand_util.h" #include "base/rand_util.h"
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/strings/string_piece.h" #include "base/strings/string_piece.h"
#include "base/util/values/values_util.h" #include "base/util/values/values_util.h"
#include "chrome/browser/nearby_sharing/certificates/common.h" #include "chrome/browser/nearby_sharing/certificates/common.h"
#include "chrome/browser/nearby_sharing/certificates/constants.h" #include "chrome/browser/nearby_sharing/certificates/constants.h"
#include "chrome/browser/nearby_sharing/logging/logging.h"
#include "chrome/browser/nearby_sharing/proto/timestamp.pb.h" #include "chrome/browser/nearby_sharing/proto/timestamp.pb.h"
#include "crypto/aead.h" #include "crypto/aead.h"
#include "crypto/ec_private_key.h" #include "crypto/ec_private_key.h"
...@@ -184,14 +184,14 @@ base::Optional<NearbyShareEncryptedMetadataKey> ...@@ -184,14 +184,14 @@ base::Optional<NearbyShareEncryptedMetadataKey>
NearbySharePrivateCertificate::EncryptMetadataKey() { NearbySharePrivateCertificate::EncryptMetadataKey() {
base::Optional<std::vector<uint8_t>> salt = GenerateUnusedSalt(); base::Optional<std::vector<uint8_t>> salt = GenerateUnusedSalt();
if (!salt) { if (!salt) {
LOG(ERROR) << "Encryption failed: Salt generation unsuccessful."; NS_LOG(ERROR) << "Encryption failed: Salt generation unsuccessful.";
return base::nullopt; return base::nullopt;
} }
std::unique_ptr<crypto::Encryptor> encryptor = std::unique_ptr<crypto::Encryptor> encryptor =
CreateNearbyShareCtrEncryptor(secret_key_.get(), *salt); CreateNearbyShareCtrEncryptor(secret_key_.get(), *salt);
if (!encryptor) { if (!encryptor) {
LOG(ERROR) << "Encryption failed: Could not create CTR encryptor."; NS_LOG(ERROR) << "Encryption failed: Could not create CTR encryptor.";
return base::nullopt; return base::nullopt;
} }
...@@ -199,7 +199,7 @@ NearbySharePrivateCertificate::EncryptMetadataKey() { ...@@ -199,7 +199,7 @@ NearbySharePrivateCertificate::EncryptMetadataKey() {
metadata_encryption_key_.size()); metadata_encryption_key_.size());
std::vector<uint8_t> encrypted_metadata_key; std::vector<uint8_t> encrypted_metadata_key;
if (!encryptor->Encrypt(metadata_encryption_key_, &encrypted_metadata_key)) { if (!encryptor->Encrypt(metadata_encryption_key_, &encrypted_metadata_key)) {
LOG(ERROR) << "Encryption failed: Could not encrypt metadata key."; NS_LOG(ERROR) << "Encryption failed: Could not encrypt metadata key.";
return base::nullopt; return base::nullopt;
} }
...@@ -213,7 +213,7 @@ base::Optional<std::vector<uint8_t>> NearbySharePrivateCertificate::Sign( ...@@ -213,7 +213,7 @@ base::Optional<std::vector<uint8_t>> NearbySharePrivateCertificate::Sign(
std::vector<uint8_t> signature; std::vector<uint8_t> signature;
if (!signer->Sign(payload.data(), payload.size(), &signature)) { if (!signer->Sign(payload.data(), payload.size(), &signature)) {
LOG(ERROR) << "Signing failed."; NS_LOG(ERROR) << "Signing failed.";
return base::nullopt; return base::nullopt;
} }
...@@ -224,21 +224,21 @@ base::Optional<nearbyshare::proto::PublicCertificate> ...@@ -224,21 +224,21 @@ base::Optional<nearbyshare::proto::PublicCertificate>
NearbySharePrivateCertificate::ToPublicCertificate() { NearbySharePrivateCertificate::ToPublicCertificate() {
std::vector<uint8_t> public_key; std::vector<uint8_t> public_key;
if (!key_pair_->ExportPublicKey(&public_key)) { if (!key_pair_->ExportPublicKey(&public_key)) {
LOG(ERROR) << "Failed to export public key."; NS_LOG(ERROR) << "Failed to export public key.";
return base::nullopt; return base::nullopt;
} }
base::Optional<std::vector<uint8_t>> encrypted_metadata_bytes = base::Optional<std::vector<uint8_t>> encrypted_metadata_bytes =
EncryptMetadata(); EncryptMetadata();
if (!encrypted_metadata_bytes) { if (!encrypted_metadata_bytes) {
LOG(ERROR) << "Failed to encrypt metadata."; NS_LOG(ERROR) << "Failed to encrypt metadata.";
return base::nullopt; return base::nullopt;
} }
base::Optional<std::vector<uint8_t>> metadata_encryption_key_tag = base::Optional<std::vector<uint8_t>> metadata_encryption_key_tag =
CreateMetadataEncryptionKeyTag(metadata_encryption_key_); CreateMetadataEncryptionKeyTag(metadata_encryption_key_);
if (!metadata_encryption_key_tag) { if (!metadata_encryption_key_tag) {
LOG(ERROR) << "Failed to compute metadata encryption key tag."; NS_LOG(ERROR) << "Failed to compute metadata encryption key tag.";
return base::nullopt; return base::nullopt;
} }
...@@ -368,7 +368,7 @@ NearbySharePrivateCertificate::FromDictionary(const base::Value& dict) { ...@@ -368,7 +368,7 @@ NearbySharePrivateCertificate::FromDictionary(const base::Value& dict) {
base::Optional<std::vector<uint8_t>> base::Optional<std::vector<uint8_t>>
NearbySharePrivateCertificate::GenerateUnusedSalt() { NearbySharePrivateCertificate::GenerateUnusedSalt() {
if (consumed_salts_.size() >= kNearbyShareMaxNumMetadataEncryptionKeySalts) { if (consumed_salts_.size() >= kNearbyShareMaxNumMetadataEncryptionKeySalts) {
LOG(ERROR) << "All salts exhausted for certificate."; NS_LOG(ERROR) << "All salts exhausted for certificate.";
return base::nullopt; return base::nullopt;
} }
...@@ -390,8 +390,8 @@ NearbySharePrivateCertificate::GenerateUnusedSalt() { ...@@ -390,8 +390,8 @@ NearbySharePrivateCertificate::GenerateUnusedSalt() {
} }
} }
LOG(ERROR) << "Salt generation exceeded max number of retries. This is " NS_LOG(ERROR) << "Salt generation exceeded max number of retries. This is "
"highly improbable."; "highly improbable.";
return base::nullopt; return base::nullopt;
} }
......
...@@ -135,7 +135,8 @@ void FastInitiationManager::OnSetAdvertisingInterval( ...@@ -135,7 +135,8 @@ void FastInitiationManager::OnSetAdvertisingInterval(
void FastInitiationManager::OnSetAdvertisingIntervalError( void FastInitiationManager::OnSetAdvertisingIntervalError(
FastInitiationManager::FastInitType type, FastInitiationManager::FastInitType type,
device::BluetoothAdvertisement::ErrorCode code) { device::BluetoothAdvertisement::ErrorCode code) {
LOG(WARNING) << "SetAdvertisingInterval() failed with error code = " << code; NS_LOG(WARNING) << "SetAdvertisingInterval() failed with error code = "
<< code;
RegisterAdvertisement(type); RegisterAdvertisement(type);
} }
...@@ -190,7 +191,8 @@ void FastInitiationManager::OnRestoreAdvertisingInterval() { ...@@ -190,7 +191,8 @@ void FastInitiationManager::OnRestoreAdvertisingInterval() {
void FastInitiationManager::OnRestoreAdvertisingIntervalError( void FastInitiationManager::OnRestoreAdvertisingIntervalError(
device::BluetoothAdvertisement::ErrorCode code) { device::BluetoothAdvertisement::ErrorCode code) {
LOG(WARNING) << "SetAdvertisingInterval() failed with error code = " << code; NS_LOG(WARNING) << "SetAdvertisingInterval() failed with error code = "
<< code;
UnregisterAdvertisement(); UnregisterAdvertisement();
} }
......
...@@ -174,8 +174,8 @@ NearbySharingServiceImpl::RegisterReceiveSurface( ...@@ -174,8 +174,8 @@ NearbySharingServiceImpl::RegisterReceiveSurface(
DCHECK_NE(state, ReceiveSurfaceState::kUnknown); DCHECK_NE(state, ReceiveSurfaceState::kUnknown);
if (foreground_receive_callbacks_.HasObserver(transfer_callback) || if (foreground_receive_callbacks_.HasObserver(transfer_callback) ||
background_receive_callbacks_.HasObserver(transfer_callback)) { background_receive_callbacks_.HasObserver(transfer_callback)) {
VLOG(1) << __func__ NS_LOG(VERBOSE) << __func__
<< ": registerReceiveSurface failed. Already registered."; << ": registerReceiveSurface failed. Already registered.";
return StatusCodes::kError; return StatusCodes::kError;
} }
...@@ -192,8 +192,9 @@ NearbySharingServiceImpl::RegisterReceiveSurface( ...@@ -192,8 +192,9 @@ NearbySharingServiceImpl::RegisterReceiveSurface(
background_receive_callbacks_.AddObserver(transfer_callback); background_receive_callbacks_.AddObserver(transfer_callback);
} }
VLOG(1) << __func__ << ": A ReceiveSurface(" NS_LOG(VERBOSE) << __func__ << ": A ReceiveSurface("
<< ReceiveSurfaceStateToString(state) << ") has been registered"; << ReceiveSurfaceStateToString(state)
<< ") has been registered";
InvalidateReceiveSurfaceState(); InvalidateReceiveSurfaceState();
return StatusCodes::kOk; return StatusCodes::kOk;
} }
...@@ -207,7 +208,7 @@ NearbySharingServiceImpl::UnregisterReceiveSurface( ...@@ -207,7 +208,7 @@ NearbySharingServiceImpl::UnregisterReceiveSurface(
bool is_background = bool is_background =
background_receive_callbacks_.HasObserver(transfer_callback); background_receive_callbacks_.HasObserver(transfer_callback);
if (!is_foreground && !is_background) { if (!is_foreground && !is_background) {
VLOG(1) NS_LOG(VERBOSE)
<< __func__ << __func__
<< ": unregisterReceiveSurface failed. Unknown TransferUpdateCallback."; << ": unregisterReceiveSurface failed. Unknown TransferUpdateCallback.";
return StatusCodes::kError; return StatusCodes::kError;
...@@ -239,9 +240,9 @@ NearbySharingServiceImpl::UnregisterReceiveSurface( ...@@ -239,9 +240,9 @@ NearbySharingServiceImpl::UnregisterReceiveSurface(
} }
} }
VLOG(1) << __func__ << ": A ReceiveSurface(" NS_LOG(VERBOSE) << __func__ << ": A ReceiveSurface("
<< (is_foreground ? "foreground" : "background") << (is_foreground ? "foreground" : "background")
<< ") has been unregistered"; << ") has been unregistered";
InvalidateReceiveSurfaceState(); InvalidateReceiveSurfaceState();
return StatusCodes::kOk; return StatusCodes::kOk;
...@@ -341,13 +342,14 @@ Visibility NearbySharingServiceImpl::GetVisibilityPref() { ...@@ -341,13 +342,14 @@ Visibility NearbySharingServiceImpl::GetVisibilityPref() {
void NearbySharingServiceImpl::OnVisibilityPrefChanged() { void NearbySharingServiceImpl::OnVisibilityPrefChanged() {
Visibility new_visibility = GetVisibilityPref(); Visibility new_visibility = GetVisibilityPref();
if (advertising_visibilty_preference_ == new_visibility) { if (advertising_visibilty_preference_ == new_visibility) {
VLOG(1) << __func__ << ": Nearby sharing visibility pref is unchanged"; NS_LOG(VERBOSE) << __func__
<< ": Nearby sharing visibility pref is unchanged";
return; return;
} }
advertising_visibilty_preference_ = new_visibility; advertising_visibilty_preference_ = new_visibility;
VLOG(1) << __func__ << ": Nearby sharing visibility changed to " NS_LOG(VERBOSE) << __func__ << ": Nearby sharing visibility changed to "
<< VisibilityToString(advertising_visibilty_preference_); << VisibilityToString(advertising_visibilty_preference_);
if (advertising_power_level_ != PowerLevel::kUnknown) { if (advertising_power_level_ != PowerLevel::kUnknown) {
StopAdvertising(); StopAdvertising();
...@@ -367,11 +369,12 @@ DataUsage NearbySharingServiceImpl::GetDataUsagePref() { ...@@ -367,11 +369,12 @@ DataUsage NearbySharingServiceImpl::GetDataUsagePref() {
void NearbySharingServiceImpl::OnDataUsagePrefChanged() { void NearbySharingServiceImpl::OnDataUsagePrefChanged() {
DataUsage new_data_usage = GetDataUsagePref(); DataUsage new_data_usage = GetDataUsagePref();
if (advertising_data_usage_preference_ == new_data_usage) { if (advertising_data_usage_preference_ == new_data_usage) {
VLOG(1) << __func__ << ": Nearby sharing data usage pref is unchanged"; NS_LOG(VERBOSE) << __func__
<< ": Nearby sharing data usage pref is unchanged";
return; return;
} }
VLOG(1) << __func__ << ": Nearby sharing data usage changed."; NS_LOG(VERBOSE) << __func__ << ": Nearby sharing data usage changed.";
if (advertising_power_level_ != PowerLevel::kUnknown) { if (advertising_power_level_ != PowerLevel::kUnknown) {
StopAdvertising(); StopAdvertising();
} }
...@@ -496,8 +499,8 @@ void NearbySharingServiceImpl::InvalidateAdvertisingState() { ...@@ -496,8 +499,8 @@ void NearbySharingServiceImpl::InvalidateAdvertisingState() {
// Screen is off. Do no work. // Screen is off. Do no work.
if (ui::CheckIdleStateIsLocked()) { if (ui::CheckIdleStateIsLocked()) {
StopAdvertising(); StopAdvertising();
VLOG(1) << __func__ NS_LOG(VERBOSE) << __func__
<< ": Stopping advertising because the screen is locked."; << ": Stopping advertising because the screen is locked.";
return; return;
} }
...@@ -512,24 +515,26 @@ void NearbySharingServiceImpl::InvalidateAdvertisingState() { ...@@ -512,24 +515,26 @@ void NearbySharingServiceImpl::InvalidateAdvertisingState() {
connection_type == connection_type ==
net::NetworkChangeNotifier::ConnectionType::CONNECTION_ETHERNET)) { net::NetworkChangeNotifier::ConnectionType::CONNECTION_ETHERNET)) {
StopAdvertising(); StopAdvertising();
VLOG(1) << __func__ NS_LOG(VERBOSE)
<< ": Stopping advertising because both bluetooth and wifi LAN are " << __func__
"disabled."; << ": Stopping advertising because both bluetooth and wifi LAN are "
"disabled.";
return; return;
} }
// Nearby Sharing is disabled. Don't advertise. // Nearby Sharing is disabled. Don't advertise.
if (!IsEnabled()) { if (!IsEnabled()) {
StopAdvertising(); StopAdvertising();
VLOG(1) << __func__ NS_LOG(VERBOSE)
<< ": Stopping advertising because Nearby Sharing is disabled."; << __func__
<< ": Stopping advertising because Nearby Sharing is disabled.";
return; return;
} }
// We're scanning for other nearby devices. Don't advertise. // We're scanning for other nearby devices. Don't advertise.
if (is_scanning_) { if (is_scanning_) {
StopAdvertising(); StopAdvertising();
VLOG(1) NS_LOG(VERBOSE)
<< __func__ << __func__
<< ": Stopping advertising because we're scanning for other devices."; << ": Stopping advertising because we're scanning for other devices.";
return; return;
...@@ -537,16 +542,17 @@ void NearbySharingServiceImpl::InvalidateAdvertisingState() { ...@@ -537,16 +542,17 @@ void NearbySharingServiceImpl::InvalidateAdvertisingState() {
if (is_transferring_files_) { if (is_transferring_files_) {
StopAdvertising(); StopAdvertising();
VLOG(1) << __func__ NS_LOG(VERBOSE)
<< ": Stopping advertising because we're currently in the midst of " << __func__
"a transfer."; << ": Stopping advertising because we're currently in the midst of "
"a transfer.";
return; return;
} }
if (!foreground_receive_callbacks_.might_have_observers() && if (!foreground_receive_callbacks_.might_have_observers() &&
!background_receive_callbacks_.might_have_observers()) { !background_receive_callbacks_.might_have_observers()) {
StopAdvertising(); StopAdvertising();
VLOG(1) NS_LOG(VERBOSE)
<< __func__ << __func__
<< ": Stopping advertising because no receive surface is registered."; << ": Stopping advertising because no receive surface is registered.";
return; return;
...@@ -555,9 +561,10 @@ void NearbySharingServiceImpl::InvalidateAdvertisingState() { ...@@ -555,9 +561,10 @@ void NearbySharingServiceImpl::InvalidateAdvertisingState() {
if (!IsVisibleInBackground(advertising_visibilty_preference_) && if (!IsVisibleInBackground(advertising_visibilty_preference_) &&
!foreground_receive_callbacks_.might_have_observers()) { !foreground_receive_callbacks_.might_have_observers()) {
StopAdvertising(); StopAdvertising();
VLOG(1) << __func__ NS_LOG(VERBOSE)
<< ": Stopping advertising because no high power receive surface " << __func__
"is registered and device is visible to NO_ONE."; << ": Stopping advertising because no high power receive surface "
"is registered and device is visible to NO_ONE.";
return; return;
} }
...@@ -575,19 +582,21 @@ void NearbySharingServiceImpl::InvalidateAdvertisingState() { ...@@ -575,19 +582,21 @@ void NearbySharingServiceImpl::InvalidateAdvertisingState() {
if (advertising_power_level_ != PowerLevel::kUnknown) { if (advertising_power_level_ != PowerLevel::kUnknown) {
if (power_level == advertising_power_level_ && if (power_level == advertising_power_level_ &&
data_usage == advertising_data_usage_preference_) { data_usage == advertising_data_usage_preference_) {
VLOG(1) << __func__ NS_LOG(VERBOSE)
<< "Failed to advertise because we're already advertising with " << __func__
"power level " << "Failed to advertise because we're already advertising with "
<< PowerLevelToString(advertising_power_level_) "power level "
<< " and data usage preference " << PowerLevelToString(advertising_power_level_)
<< DataUsageToString(advertising_data_usage_preference_); << " and data usage preference "
<< DataUsageToString(advertising_data_usage_preference_);
return; return;
} }
StopAdvertising(); StopAdvertising();
VLOG(1) << __func__ << ": Restart advertising with power level " NS_LOG(VERBOSE) << __func__ << ": Restart advertising with power level "
<< PowerLevelToString(power_level) << " and data usage preference " << PowerLevelToString(power_level)
<< DataUsageToString(data_usage); << " and data usage preference "
<< DataUsageToString(data_usage);
} }
// Starts advertising through Nearby Connections. Caller is expected to ensure // Starts advertising through Nearby Connections. Caller is expected to ensure
...@@ -609,7 +618,7 @@ void NearbySharingServiceImpl::InvalidateAdvertisingState() { ...@@ -609,7 +618,7 @@ void NearbySharingServiceImpl::InvalidateAdvertisingState() {
std::move(endpoint_info), std::move(endpoint_info),
/* listener= */ this, power_level, data_usage, /* listener= */ this, power_level, data_usage,
base::BindOnce([](NearbyConnectionsManager::ConnectionsStatus status) { base::BindOnce([](NearbyConnectionsManager::ConnectionsStatus status) {
VLOG(1) NS_LOG(VERBOSE)
<< __func__ << __func__
<< ": Advertising attempted over Nearby Connections with result " << ": Advertising attempted over Nearby Connections with result "
<< ConnectionsStatusToString(status); << ConnectionsStatusToString(status);
...@@ -617,18 +626,20 @@ void NearbySharingServiceImpl::InvalidateAdvertisingState() { ...@@ -617,18 +626,20 @@ void NearbySharingServiceImpl::InvalidateAdvertisingState() {
advertising_power_level_ = power_level; advertising_power_level_ = power_level;
advertising_data_usage_preference_ = data_usage; advertising_data_usage_preference_ = data_usage;
VLOG(1) << __func__ << ": Advertising has started over Nearby Connections: " NS_LOG(VERBOSE) << __func__
<< " power level " << PowerLevelToString(power_level) << ": Advertising has started over Nearby Connections: "
<< " visibility " << " power level " << PowerLevelToString(power_level)
<< VisibilityToString(advertising_visibilty_preference_) << " visibility "
<< " data usage " << DataUsageToString(data_usage); << VisibilityToString(advertising_visibilty_preference_)
<< " data usage " << DataUsageToString(data_usage);
return; return;
} }
void NearbySharingServiceImpl::StopAdvertising() { void NearbySharingServiceImpl::StopAdvertising() {
if (advertising_power_level_ == PowerLevel::kUnknown) { if (advertising_power_level_ == PowerLevel::kUnknown) {
VLOG(1) << __func__ NS_LOG(VERBOSE)
<< ": Failed to stop advertising because we weren't advertising"; << __func__
<< ": Failed to stop advertising because we weren't advertising";
return; return;
} }
...@@ -636,5 +647,5 @@ void NearbySharingServiceImpl::StopAdvertising() { ...@@ -636,5 +647,5 @@ void NearbySharingServiceImpl::StopAdvertising() {
advertising_data_usage_preference_ = DataUsage::kUnknown; advertising_data_usage_preference_ = DataUsage::kUnknown;
advertising_power_level_ = PowerLevel::kUnknown; advertising_power_level_ = PowerLevel::kUnknown;
VLOG(1) << __func__ << ": Advertising has stopped"; NS_LOG(VERBOSE) << __func__ << ": Advertising has stopped";
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment