Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3074)

Unified Diff: device/bluetooth/adapter.cc

Issue 2401193002: bluetooth: Add Device service for chrome://bluetooth-internals. (Closed)
Patch Set: Fully qualify mojom import Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « device/bluetooth/adapter.h ('k') | device/bluetooth/device.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/bluetooth/adapter.cc
diff --git a/device/bluetooth/adapter.cc b/device/bluetooth/adapter.cc
index 2352f23b38c9e38db2b432cbd680c092263804fd..564315ed988b52ee09d4d5b6474340cbe334527d 100644
--- a/device/bluetooth/adapter.cc
+++ b/device/bluetooth/adapter.cc
@@ -6,10 +6,8 @@
#include <utility>
#include <vector>
-#include "base/memory/ptr_util.h"
-#include "base/strings/utf_string_conversions.h"
#include "device/bluetooth/adapter.h"
-#include "mojo/public/cpp/bindings/string.h"
+#include "device/bluetooth/device.h"
#include "mojo/public/cpp/bindings/strong_binding.h"
namespace bluetooth {
@@ -36,11 +34,20 @@ void Adapter::GetInfo(const GetInfoCallback& callback) {
callback.Run(std::move(adapter_info));
}
+void Adapter::GetDevice(const std::string& address,
+ const GetDeviceCallback& callback) {
+ mojom::DevicePtr device_ptr;
+ mojo::MakeStrongBinding(base::MakeUnique<Device>(address, adapter_),
+ mojo::GetProxy(&device_ptr));
+ callback.Run(std::move(device_ptr));
+}
+
void Adapter::GetDevices(const GetDevicesCallback& callback) {
std::vector<mojom::DeviceInfoPtr> devices;
for (const device::BluetoothDevice* device : adapter_->GetDevices()) {
- mojom::DeviceInfoPtr device_info = ConstructDeviceInfoStruct(device);
+ mojom::DeviceInfoPtr device_info =
+ Device::ConstructDeviceInfoStruct(device);
devices.push_back(std::move(device_info));
}
@@ -54,7 +61,7 @@ void Adapter::SetClient(mojom::AdapterClientPtr client) {
void Adapter::DeviceAdded(device::BluetoothAdapter* adapter,
device::BluetoothDevice* device) {
if (client_) {
- auto device_info = ConstructDeviceInfoStruct(device);
+ auto device_info = Device::ConstructDeviceInfoStruct(device);
client_->DeviceAdded(std::move(device_info));
}
}
@@ -62,23 +69,9 @@ void Adapter::DeviceAdded(device::BluetoothAdapter* adapter,
void Adapter::DeviceRemoved(device::BluetoothAdapter* adapter,
device::BluetoothDevice* device) {
if (client_) {
- auto device_info = ConstructDeviceInfoStruct(device);
+ auto device_info = Device::ConstructDeviceInfoStruct(device);
client_->DeviceRemoved(std::move(device_info));
}
}
-// static
-mojom::DeviceInfoPtr Adapter::ConstructDeviceInfoStruct(
- const device::BluetoothDevice* device) {
- mojom::DeviceInfoPtr device_info = mojom::DeviceInfo::New();
-
- device_info->name = device->GetName();
- device_info->name_for_display =
- base::UTF16ToUTF8(device->GetNameForDisplay());
- device_info->id = device->GetIdentifier();
- device_info->address = device->GetAddress();
-
- return device_info;
-}
-
} // namespace bluetooth
« no previous file with comments | « device/bluetooth/adapter.h ('k') | device/bluetooth/device.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698