Index: device/bluetooth/bluetooth_adapter_bluez.cc |
diff --git a/device/bluetooth/bluetooth_adapter_bluez.cc b/device/bluetooth/bluetooth_adapter_bluez.cc |
index 0997dd98cf319ad8bfec7d764620fdc448c74db2..7aa35210c94b5a94a5311b9dff1e7d55d7b964bc 100644 |
--- a/device/bluetooth/bluetooth_adapter_bluez.cc |
+++ b/device/bluetooth/bluetooth_adapter_bluez.cc |
@@ -15,6 +15,7 @@ |
#include "base/single_thread_task_runner.h" |
#include "base/thread_task_runner_handle.h" |
#include "build/build_config.h" |
+#include "components/device_event_log/device_event_log.h" |
#include "device/bluetooth/bluetooth_adapter_profile_bluez.h" |
#include "device/bluetooth/bluetooth_advertisement_bluez.h" |
#include "device/bluetooth/bluetooth_audio_sink_bluez.h" |
@@ -127,7 +128,7 @@ void BluetoothAdapterBlueZ::Shutdown() { |
bluez::BluezDBusManager::Get()->GetBluetoothInputClient()->RemoveObserver( |
this); |
- VLOG(1) << "Unregistering pairing agent"; |
+ BLUETOOTH_LOG(EVENT) << "Unregistering pairing agent"; |
stevenjb
2016/01/19 21:54:59
Let's separate out these events from this CL and s
|
bluez::BluezDBusManager::Get() |
->GetBluetoothAgentManagerClient() |
->UnregisterAgent(dbus::ObjectPath(kAgentPath), |
@@ -162,7 +163,8 @@ BluetoothAdapterBlueZ::BluetoothAdapterBlueZ() |
->GetAdapters(); |
if (!object_paths.empty()) { |
- VLOG(1) << object_paths.size() << " Bluetooth adapter(s) available."; |
+ BLUETOOTH_LOG(EVENT) << object_paths.size() |
+ << " Bluetooth adapter(s) available."; |
SetAdapter(object_paths[0]); |
} |
} |
@@ -299,8 +301,8 @@ void BluetoothAdapterBlueZ::CreateRfcommService( |
const CreateServiceCallback& callback, |
const CreateServiceErrorCallback& error_callback) { |
DCHECK(!dbus_is_shutdown_); |
- VLOG(1) << object_path_.value() |
- << ": Creating RFCOMM service: " << uuid.canonical_value(); |
+ BLUETOOTH_LOG(EVENT) << object_path_.value() << ": Creating RFCOMM service: " |
+ << uuid.canonical_value(); |
scoped_refptr<BluetoothSocketBlueZ> socket = |
BluetoothSocketBlueZ::CreateBluetoothSocket(ui_task_runner_, |
socket_thread_); |
@@ -314,8 +316,8 @@ void BluetoothAdapterBlueZ::CreateL2capService( |
const CreateServiceCallback& callback, |
const CreateServiceErrorCallback& error_callback) { |
DCHECK(!dbus_is_shutdown_); |
- VLOG(1) << object_path_.value() |
- << ": Creating L2CAP service: " << uuid.canonical_value(); |
+ BLUETOOTH_LOG(EVENT) << object_path_.value() << ": Creating L2CAP service: " |
+ << uuid.canonical_value(); |
scoped_refptr<BluetoothSocketBlueZ> socket = |
BluetoothSocketBlueZ::CreateBluetoothSocket(ui_task_runner_, |
socket_thread_); |
@@ -327,7 +329,7 @@ void BluetoothAdapterBlueZ::RegisterAudioSink( |
const BluetoothAudioSink::Options& options, |
const device::BluetoothAdapter::AcquiredCallback& callback, |
const BluetoothAudioSink::ErrorCallback& error_callback) { |
- VLOG(1) << "Registering audio sink"; |
+ BLUETOOTH_LOG(EVENT) << "Registering audio sink"; |
if (!this->IsPresent()) { |
error_callback.Run(BluetoothAudioSink::ERROR_INVALID_ADAPTER); |
return; |
@@ -450,8 +452,8 @@ void BluetoothAdapterBlueZ::DevicePropertyChanged( |
++iter) { |
if (iter->second->GetAddress() == device_bluez->GetAddress()) { |
std::string old_address = iter->first; |
- VLOG(1) << "Device changed address, old: " << old_address |
- << " new: " << device_bluez->GetAddress(); |
+ BLUETOOTH_LOG(EVENT) << "Device changed address, old: " << old_address |
+ << " new: " << device_bluez->GetAddress(); |
scoped_ptr<BluetoothDevice> scoped_device = |
devices_.take_and_erase(iter); |
ignore_result(scoped_device.release()); |
@@ -529,7 +531,7 @@ void BluetoothAdapterBlueZ::InputPropertyChanged( |
} |
void BluetoothAdapterBlueZ::Released() { |
- VLOG(1) << "Release"; |
+ BLUETOOTH_LOG(EVENT) << "Release"; |
if (!IsPresent()) |
return; |
DCHECK(agent_.get()); |
@@ -542,7 +544,7 @@ void BluetoothAdapterBlueZ::RequestPinCode(const dbus::ObjectPath& device_path, |
const PinCodeCallback& callback) { |
DCHECK(IsPresent()); |
DCHECK(agent_.get()); |
- VLOG(1) << device_path.value() << ": RequestPinCode"; |
+ BLUETOOTH_LOG(EVENT) << device_path.value() << ": RequestPinCode"; |
BluetoothPairingBlueZ* pairing = GetPairing(device_path); |
if (!pairing) { |
@@ -557,7 +559,8 @@ void BluetoothAdapterBlueZ::DisplayPinCode(const dbus::ObjectPath& device_path, |
const std::string& pincode) { |
DCHECK(IsPresent()); |
DCHECK(agent_.get()); |
- VLOG(1) << device_path.value() << ": DisplayPinCode: " << pincode; |
+ BLUETOOTH_LOG(EVENT) << device_path.value() |
+ << ": DisplayPinCode: " << pincode; |
BluetoothPairingBlueZ* pairing = GetPairing(device_path); |
if (!pairing) |
@@ -570,7 +573,7 @@ void BluetoothAdapterBlueZ::RequestPasskey(const dbus::ObjectPath& device_path, |
const PasskeyCallback& callback) { |
DCHECK(IsPresent()); |
DCHECK(agent_.get()); |
- VLOG(1) << device_path.value() << ": RequestPasskey"; |
+ BLUETOOTH_LOG(EVENT) << device_path.value() << ": RequestPasskey"; |
BluetoothPairingBlueZ* pairing = GetPairing(device_path); |
if (!pairing) { |
@@ -586,8 +589,8 @@ void BluetoothAdapterBlueZ::DisplayPasskey(const dbus::ObjectPath& device_path, |
uint16_t entered) { |
DCHECK(IsPresent()); |
DCHECK(agent_.get()); |
- VLOG(1) << device_path.value() << ": DisplayPasskey: " << passkey << " (" |
- << entered << " entered)"; |
+ BLUETOOTH_LOG(EVENT) << device_path.value() << ": DisplayPasskey: " << passkey |
+ << " (" << entered << " entered)"; |
BluetoothPairingBlueZ* pairing = GetPairing(device_path); |
if (!pairing) |
@@ -605,7 +608,8 @@ void BluetoothAdapterBlueZ::RequestConfirmation( |
const ConfirmationCallback& callback) { |
DCHECK(IsPresent()); |
DCHECK(agent_.get()); |
- VLOG(1) << device_path.value() << ": RequestConfirmation: " << passkey; |
+ BLUETOOTH_LOG(EVENT) << device_path.value() |
+ << ": RequestConfirmation: " << passkey; |
BluetoothPairingBlueZ* pairing = GetPairing(device_path); |
if (!pairing) { |
@@ -621,7 +625,7 @@ void BluetoothAdapterBlueZ::RequestAuthorization( |
const ConfirmationCallback& callback) { |
DCHECK(IsPresent()); |
DCHECK(agent_.get()); |
- VLOG(1) << device_path.value() << ": RequestAuthorization"; |
+ BLUETOOTH_LOG(EVENT) << device_path.value() << ": RequestAuthorization"; |
BluetoothPairingBlueZ* pairing = GetPairing(device_path); |
if (!pairing) { |
@@ -638,7 +642,7 @@ void BluetoothAdapterBlueZ::AuthorizeService( |
const ConfirmationCallback& callback) { |
DCHECK(IsPresent()); |
DCHECK(agent_.get()); |
- VLOG(1) << device_path.value() << ": AuthorizeService: " << uuid; |
+ BLUETOOTH_LOG(EVENT) << device_path.value() << ": AuthorizeService: " << uuid; |
BluetoothDeviceBlueZ* device_bluez = GetDeviceWithPath(device_path); |
if (!device_bluez) { |
@@ -665,11 +669,12 @@ void BluetoothAdapterBlueZ::AuthorizeService( |
void BluetoothAdapterBlueZ::Cancel() { |
DCHECK(IsPresent()); |
DCHECK(agent_.get()); |
- VLOG(1) << "Cancel"; |
+ BLUETOOTH_LOG(EVENT) << "Cancel"; |
} |
void BluetoothAdapterBlueZ::OnRegisterAgent() { |
- VLOG(1) << "Pairing agent registered, requesting to be made default"; |
+ BLUETOOTH_LOG(EVENT) << "Pairing agent registered, " |
+ << "requesting to be made default"; |
bluez::BluezDBusManager::Get() |
->GetBluetoothAgentManagerClient() |
@@ -693,7 +698,7 @@ void BluetoothAdapterBlueZ::OnRegisterAgentError( |
} |
void BluetoothAdapterBlueZ::OnRequestDefaultAgent() { |
- VLOG(1) << "Pairing agent now default"; |
+ BLUETOOTH_LOG(EVENT) << "Pairing agent now default"; |
} |
void BluetoothAdapterBlueZ::OnRequestDefaultAgentError( |
@@ -708,7 +713,8 @@ void BluetoothAdapterBlueZ::OnRegisterAudioSink( |
const device::BluetoothAudioSink::ErrorCallback& error_callback, |
scoped_refptr<BluetoothAudioSink> audio_sink) { |
if (!IsPresent()) { |
- VLOG(1) << "Failed to register audio sink, adapter not present"; |
+ BLUETOOTH_LOG(ERROR) << "Failed to register audio sink, " |
+ << "adapter not present"; |
error_callback.Run(BluetoothAudioSink::ERROR_INVALID_ADAPTER); |
return; |
} |
@@ -760,9 +766,9 @@ void BluetoothAdapterBlueZ::SetAdapter(const dbus::ObjectPath& object_path) { |
DCHECK(!dbus_is_shutdown_); |
object_path_ = object_path; |
- VLOG(1) << object_path_.value() << ": using adapter."; |
+ BLUETOOTH_LOG(EVENT) << object_path_.value() << ": using adapter."; |
- VLOG(1) << "Registering pairing agent"; |
+ BLUETOOTH_LOG(EVENT) << "Registering pairing agent"; |
bluez::BluezDBusManager::Get() |
->GetBluetoothAgentManagerClient() |
->RegisterAgent(dbus::ObjectPath(kAgentPath), |
@@ -830,7 +836,7 @@ void BluetoothAdapterBlueZ::SetDefaultAdapterName() { |
void BluetoothAdapterBlueZ::RemoveAdapter() { |
DCHECK(IsPresent()); |
- VLOG(1) << object_path_.value() << ": adapter removed."; |
+ BLUETOOTH_LOG(EVENT) << object_path_.value() << ": adapter removed."; |
bluez::BluetoothAdapterClient::Properties* properties = |
bluez::BluezDBusManager::Get() |
@@ -873,10 +879,10 @@ void BluetoothAdapterBlueZ::DiscoverableChanged(bool discoverable) { |
void BluetoothAdapterBlueZ::DiscoveringChanged(bool discovering) { |
// If the adapter stopped discovery due to a reason other than a request by |
// us, reset the count to 0. |
- VLOG(1) << "Discovering changed: " << discovering; |
+ BLUETOOTH_LOG(EVENT) << "Discovering changed: " << discovering; |
if (!discovering && !discovery_request_pending_ && |
num_discovery_sessions_ > 0) { |
- VLOG(1) << "Marking sessions as inactive."; |
+ BLUETOOTH_LOG(EVENT) << "Marking sessions as inactive."; |
num_discovery_sessions_ = 0; |
MarkDiscoverySessionsAsInactive(); |
} |
@@ -1029,7 +1035,7 @@ void BluetoothAdapterBlueZ::UseProfile( |
DCHECK(delegate); |
if (!IsPresent()) { |
- VLOG(2) << "Adapter not present, erroring out"; |
+ BLUETOOTH_LOG(ERROR) << "Adapter not present, erroring out"; |
error_callback.Run("Adapter not present"); |
return; |
} |
@@ -1060,15 +1066,16 @@ void BluetoothAdapterBlueZ::UseProfile( |
void BluetoothAdapterBlueZ::ReleaseProfile( |
const dbus::ObjectPath& device_path, |
BluetoothAdapterProfileBlueZ* profile) { |
- VLOG(2) << "Releasing Profile: " << profile->uuid().canonical_value() |
- << " from " << device_path.value(); |
+ BLUETOOTH_LOG(EVENT) << "Releasing Profile: " |
+ << profile->uuid().canonical_value() << " from " |
+ << device_path.value(); |
profile->RemoveDelegate( |
device_path, base::Bind(&BluetoothAdapterBlueZ::RemoveProfile, |
weak_ptr_factory_.GetWeakPtr(), profile->uuid())); |
} |
void BluetoothAdapterBlueZ::RemoveProfile(const BluetoothUUID& uuid) { |
- VLOG(2) << "Remove Profile: " << uuid.canonical_value(); |
+ BLUETOOTH_LOG(EVENT) << "Remove Profile: " << uuid.canonical_value(); |
if (profiles_.find(uuid) != profiles_.end()) { |
delete profiles_[uuid]; |
@@ -1113,9 +1120,9 @@ void BluetoothAdapterBlueZ::OnRegisterProfileError( |
const BluetoothUUID& uuid, |
const std::string& error_name, |
const std::string& error_message) { |
- VLOG(2) << object_path_.value() |
- << ": Failed to register profile: " << error_name << ": " |
- << error_message; |
+ BLUETOOTH_LOG(ERROR) << object_path_.value() |
+ << ": Failed to register profile: " << error_name << ": " |
+ << error_message; |
if (profile_queues_.find(uuid) == profile_queues_.end()) |
return; |
@@ -1166,13 +1173,14 @@ void BluetoothAdapterBlueZ::AddDiscoverySession( |
UMABluetoothDiscoverySessionOutcome::ADAPTER_NOT_PRESENT); |
return; |
} |
- VLOG(1) << __func__; |
+ BLUETOOTH_LOG(DEBUG) << __func__; |
if (discovery_request_pending_) { |
// The pending request is either to stop a previous session or to start a |
// new one. Either way, queue this one. |
DCHECK(num_discovery_sessions_ == 1 || num_discovery_sessions_ == 0); |
- VLOG(1) << "Pending request to start/stop device discovery. Queueing " |
- << "request to start a new discovery session."; |
+ BLUETOOTH_LOG(EVENT) |
+ << "Pending request to start/stop device discovery. " |
+ << "Queueing request to start a new discovery session."; |
discovery_request_queue_.push( |
std::make_tuple(discovery_filter, callback, error_callback)); |
return; |
@@ -1229,7 +1237,7 @@ void BluetoothAdapterBlueZ::RemoveDiscoverySession( |
return; |
} |
- VLOG(1) << __func__; |
+ BLUETOOTH_LOG(DEBUG) << __func__; |
// There are active sessions other than the one currently being removed. |
if (num_discovery_sessions_ > 1) { |
DCHECK(IsDiscovering()); |
@@ -1243,8 +1251,8 @@ void BluetoothAdapterBlueZ::RemoveDiscoverySession( |
// If there is a pending request to BlueZ, then queue this request. |
if (discovery_request_pending_) { |
- VLOG(1) << "Pending request to start/stop device discovery. Queueing " |
- << "request to stop discovery session."; |
+ BLUETOOTH_LOG(EVENT) << "Pending request to start/stop device discovery. " |
+ << "Queueing request to stop discovery session."; |
error_callback.Run( |
UMABluetoothDiscoverySessionOutcome::REMOVE_WITH_PENDING_REQUEST); |
return; |
@@ -1255,7 +1263,7 @@ void BluetoothAdapterBlueZ::RemoveDiscoverySession( |
// TODO(armansito): This should never happen once we have the |
// DiscoverySession API. Replace this case with an assert once it's |
// the deprecated methods have been removed. (See crbug.com/3445008). |
- VLOG(1) << "No active discovery sessions. Returning error."; |
+ BLUETOOTH_LOG(EVENT) << "No active discovery sessions. Returning error."; |
error_callback.Run( |
UMABluetoothDiscoverySessionOutcome::ACTIVE_SESSION_NOT_IN_ADAPTER); |
return; |
@@ -1347,7 +1355,7 @@ void BluetoothAdapterBlueZ::OnStartDiscovery( |
const base::Closure& callback, |
const DiscoverySessionErrorCallback& error_callback) { |
// Report success on the original request and increment the count. |
- VLOG(1) << __func__; |
+ BLUETOOTH_LOG(DEBUG) << __func__; |
DCHECK(discovery_request_pending_); |
DCHECK_EQ(num_discovery_sessions_, 0); |
discovery_request_pending_ = false; |
@@ -1381,7 +1389,8 @@ void BluetoothAdapterBlueZ::OnStartDiscoveryError( |
// changing to false and then back to true. In this case, report success. |
if (IsPresent() && error_name == bluetooth_device::kErrorInProgress && |
IsDiscovering()) { |
- VLOG(1) << "Discovery previously initiated. Reporting success."; |
+ BLUETOOTH_LOG(EVENT) |
+ << "Discovery previously initiated. Reporting success."; |
num_discovery_sessions_++; |
callback.Run(); |
} else { |
@@ -1394,7 +1403,7 @@ void BluetoothAdapterBlueZ::OnStartDiscoveryError( |
void BluetoothAdapterBlueZ::OnStopDiscovery(const base::Closure& callback) { |
// Report success on the original request and decrement the count. |
- VLOG(1) << __func__; |
+ BLUETOOTH_LOG(DEBUG) << __func__; |
DCHECK(discovery_request_pending_); |
DCHECK_EQ(num_discovery_sessions_, 1); |
discovery_request_pending_ = false; |
@@ -1462,7 +1471,7 @@ void BluetoothAdapterBlueZ::OnSetDiscoveryFilter( |
const base::Closure& callback, |
const DiscoverySessionErrorCallback& error_callback) { |
// Report success on the original request and increment the count. |
- VLOG(1) << __func__; |
+ BLUETOOTH_LOG(DEBUG) << __func__; |
if (IsPresent()) { |
callback.Run(); |
} else { |
@@ -1496,7 +1505,7 @@ void BluetoothAdapterBlueZ::OnSetDiscoveryFilterError( |
void BluetoothAdapterBlueZ::ProcessQueuedDiscoveryRequests() { |
while (!discovery_request_queue_.empty()) { |
- VLOG(1) << "Process queued discovery request."; |
+ BLUETOOTH_LOG(EVENT) << "Process queued discovery request."; |
DiscoveryParamTuple params = discovery_request_queue_.front(); |
discovery_request_queue_.pop(); |
AddDiscoverySession(std::get<0>(params), std::get<1>(params), |