Commit c8a7001d authored by Martin Kreichgauer's avatar Martin Kreichgauer Committed by Commit Bot

device/bluetooth: log WinRT API calls to chrome://device-log

We have been debugging various FIDO caBLE related issues that often only
appear sporadically on a particular combination of (computer, OS
version, phone). In some of them, WinRT behaving in exciting and
unexpected ways was at least a contributing factor. The WinRT Bluetooth
code currently VLOGs, which makes it difficult to obtain logs in these
cases. Replace them with BLUETOOTH_LOG(), which can easily be collected
by end users after the fact.

These log statements can be converted to DVLOG once the WinRT Bluetooth
and FIDO caBLE stacks have sufficiently stabilized.

Change-Id: Id13f9e107167ecdc3e0230aee86ecf90219697d5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2021331
Commit-Queue: Martin Kreichgauer <martinkr@google.com>
Reviewed-by: default avatarGiovanni Ortuño Urquidi <ortuno@chromium.org>
Cr-Commit-Position: refs/heads/master@{#737149}
parent 7be4d650
This diff is collapsed.
......@@ -13,6 +13,7 @@
#include "base/threading/thread_task_runner_handle.h"
#include "base/win/post_async_results.h"
#include "base/win/winrt_storage_util.h"
#include "components/device_event_log/device_event_log.h"
#include "device/bluetooth/bluetooth_remote_gatt_service_winrt.h"
#include "device/bluetooth/event_utils_winrt.h"
......@@ -53,14 +54,15 @@ BluetoothRemoteGattDescriptorWinrt::Create(
GUID guid;
HRESULT hr = descriptor->get_Uuid(&guid);
if (FAILED(hr)) {
VLOG(2) << "Getting UUID failed: " << logging::SystemErrorCodeToString(hr);
BLUETOOTH_LOG(ERROR) << "Getting UUID failed: "
<< logging::SystemErrorCodeToString(hr);
return nullptr;
}
uint16_t attribute_handle;
hr = descriptor->get_AttributeHandle(&attribute_handle);
if (FAILED(hr)) {
VLOG(2) << "Getting AttributeHandle failed: "
BLUETOOTH_LOG(ERROR) << "Getting AttributeHandle failed: "
<< logging::SystemErrorCodeToString(hr);
return nullptr;
}
......@@ -112,7 +114,8 @@ void BluetoothRemoteGattDescriptorWinrt::ReadRemoteDescriptor(
HRESULT hr = descriptor_->ReadValueWithCacheModeAsync(
BluetoothCacheMode_Uncached, &read_value_op);
if (FAILED(hr)) {
VLOG(2) << "GattDescriptor::ReadValueWithCacheModeAsync failed: "
BLUETOOTH_LOG(ERROR)
<< "GattDescriptor::ReadValueWithCacheModeAsync failed: "
<< logging::SystemErrorCodeToString(hr);
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
......@@ -127,7 +130,7 @@ void BluetoothRemoteGattDescriptorWinrt::ReadRemoteDescriptor(
weak_ptr_factory_.GetWeakPtr()));
if (FAILED(hr)) {
VLOG(2) << "PostAsyncResults failed: "
BLUETOOTH_LOG(ERROR) << "PostAsyncResults failed: "
<< logging::SystemErrorCodeToString(hr);
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
......@@ -155,7 +158,7 @@ void BluetoothRemoteGattDescriptorWinrt::WriteRemoteDescriptor(
ComPtr<IGattDescriptor2> descriptor_2;
HRESULT hr = descriptor_.As(&descriptor_2);
if (FAILED(hr)) {
VLOG(2) << "As IGattDescriptor2 failed: "
BLUETOOTH_LOG(ERROR) << "As IGattDescriptor2 failed: "
<< logging::SystemErrorCodeToString(hr);
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
......@@ -167,7 +170,7 @@ void BluetoothRemoteGattDescriptorWinrt::WriteRemoteDescriptor(
ComPtr<IBuffer> buffer;
hr = base::win::CreateIBufferFromData(value.data(), value.size(), &buffer);
if (FAILED(hr)) {
VLOG(2) << "base::win::CreateIBufferFromData failed: "
BLUETOOTH_LOG(ERROR) << "base::win::CreateIBufferFromData failed: "
<< logging::SystemErrorCodeToString(hr);
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
......@@ -179,7 +182,7 @@ void BluetoothRemoteGattDescriptorWinrt::WriteRemoteDescriptor(
ComPtr<IAsyncOperation<GattWriteResult*>> write_value_op;
hr = descriptor_2->WriteValueWithResultAsync(buffer.Get(), &write_value_op);
if (FAILED(hr)) {
VLOG(2) << "GattDescriptor::WriteValueWithResultAsync failed: "
BLUETOOTH_LOG(ERROR) << "GattDescriptor::WriteValueWithResultAsync failed: "
<< logging::SystemErrorCodeToString(hr);
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
......@@ -195,7 +198,7 @@ void BluetoothRemoteGattDescriptorWinrt::WriteRemoteDescriptor(
weak_ptr_factory_.GetWeakPtr()));
if (FAILED(hr)) {
VLOG(2) << "PostAsyncResults failed: "
BLUETOOTH_LOG(ERROR) << "PostAsyncResults failed: "
<< logging::SystemErrorCodeToString(hr);
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
......@@ -251,6 +254,8 @@ void BluetoothRemoteGattDescriptorWinrt::OnReadValue(
auto pending_read_callbacks = std::move(pending_read_callbacks_);
if (!read_result) {
BLUETOOTH_LOG(ERROR)
<< "GattDescriptor::ReadValueWithCacheModeAsync returned no result";
std::move(pending_read_callbacks->error_callback)
.Run(BluetoothGattService::GATT_ERROR_FAILED);
return;
......@@ -259,7 +264,7 @@ void BluetoothRemoteGattDescriptorWinrt::OnReadValue(
GattCommunicationStatus status;
HRESULT hr = read_result->get_Status(&status);
if (FAILED(hr)) {
VLOG(2) << "Getting GATT Communication Status failed: "
BLUETOOTH_LOG(ERROR) << "Getting GATT Communication Status failed: "
<< logging::SystemErrorCodeToString(hr);
std::move(pending_read_callbacks->error_callback)
.Run(BluetoothGattService::GATT_ERROR_FAILED);
......@@ -267,11 +272,11 @@ void BluetoothRemoteGattDescriptorWinrt::OnReadValue(
}
if (status != GattCommunicationStatus_Success) {
VLOG(2) << "Unexpected GattCommunicationStatus: " << status;
BLUETOOTH_LOG(ERROR) << "Unexpected GattCommunicationStatus: " << status;
ComPtr<IGattReadResult2> read_result_2;
hr = read_result.As(&read_result_2);
if (FAILED(hr)) {
VLOG(2) << "As IGattReadResult2 failed: "
BLUETOOTH_LOG(ERROR) << "As IGattReadResult2 failed: "
<< logging::SystemErrorCodeToString(hr);
std::move(pending_read_callbacks->error_callback)
.Run(BluetoothGattService::GATT_ERROR_FAILED);
......@@ -287,7 +292,7 @@ void BluetoothRemoteGattDescriptorWinrt::OnReadValue(
ComPtr<IBuffer> value;
hr = read_result->get_Value(&value);
if (FAILED(hr)) {
VLOG(2) << "Getting Descriptor Value failed: "
BLUETOOTH_LOG(ERROR) << "Getting Descriptor Value failed: "
<< logging::SystemErrorCodeToString(hr);
std::move(pending_read_callbacks->error_callback)
.Run(BluetoothGattService::GATT_ERROR_FAILED);
......@@ -298,7 +303,7 @@ void BluetoothRemoteGattDescriptorWinrt::OnReadValue(
uint32_t length = 0;
hr = base::win::GetPointerToBufferData(value.Get(), &data, &length);
if (FAILED(hr)) {
VLOG(2) << "Getting Pointer To Buffer Data failed: "
BLUETOOTH_LOG(ERROR) << "Getting Pointer To Buffer Data failed: "
<< logging::SystemErrorCodeToString(hr);
std::move(pending_read_callbacks->error_callback)
.Run(BluetoothGattService::GATT_ERROR_FAILED);
......@@ -315,6 +320,8 @@ void BluetoothRemoteGattDescriptorWinrt::OnWriteValueWithResult(
auto pending_write_callbacks = std::move(pending_write_callbacks_);
if (!write_result) {
BLUETOOTH_LOG(ERROR)
<< "GattDescriptor::WriteValueWithResultAsync returned no result";
std::move(pending_write_callbacks->error_callback)
.Run(BluetoothGattService::GATT_ERROR_FAILED);
return;
......@@ -323,7 +330,7 @@ void BluetoothRemoteGattDescriptorWinrt::OnWriteValueWithResult(
GattCommunicationStatus status;
HRESULT hr = write_result->get_Status(&status);
if (FAILED(hr)) {
VLOG(2) << "Getting GATT Communication Status failed: "
BLUETOOTH_LOG(ERROR) << "Getting GATT Communication Status failed: "
<< logging::SystemErrorCodeToString(hr);
std::move(pending_write_callbacks->error_callback)
.Run(BluetoothGattService::GATT_ERROR_FAILED);
......@@ -331,7 +338,7 @@ void BluetoothRemoteGattDescriptorWinrt::OnWriteValueWithResult(
}
if (status != GattCommunicationStatus_Success) {
VLOG(2) << "Unexpected GattCommunicationStatus: " << status;
BLUETOOTH_LOG(ERROR) << "Unexpected GattCommunicationStatus: " << status;
std::move(pending_write_callbacks->error_callback)
.Run(BluetoothRemoteGattServiceWinrt::GetGattErrorCode(
write_result.Get()));
......
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