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

Unified Diff: device/bluetooth/le_device.cc

Issue 2401193002: bluetooth: Add Device service for chrome://bluetooth-internals. (Closed)
Patch Set: Add log function comment 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
Index: device/bluetooth/le_device.cc
diff --git a/device/bluetooth/le_device.cc b/device/bluetooth/le_device.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c7a08949a3e2f74321eb5a28ded45d1ff820e86e
--- /dev/null
+++ b/device/bluetooth/le_device.cc
@@ -0,0 +1,42 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <utility>
+
+#include "base/memory/ptr_util.h"
+#include "base/strings/utf_string_conversions.h"
+#include "device/bluetooth/le_device.h"
+#include "mojo/public/cpp/bindings/strong_binding.h"
+
+namespace bluetooth {
+
+LEDevice::LEDevice(const std::string& address,
+ const scoped_refptr<device::BluetoothAdapter>& adapter)
+ : address_(address), adapter_(adapter) {}
+
+LEDevice::~LEDevice() {}
+
+// static
+mojom::LEDeviceInfoPtr LEDevice::ConstructLEDeviceInfoStruct(
+ const device::BluetoothDevice* device) {
+ mojom::LEDeviceInfoPtr device_info = mojom::LEDeviceInfo::New();
+
+ device_info->name = device->GetName();
+ device_info->id = device->GetIdentifier();
+ device_info->address = device->GetAddress();
+
+ return device_info;
+}
+
+void LEDevice::GetInfo(const GetInfoCallback& callback) {
+ device::BluetoothDevice* device = adapter_->GetDevice(address_);
+ if (device) {
+ mojom::LEDeviceInfoPtr device_info = ConstructLEDeviceInfoStruct(device);
+ callback.Run(std::move(device_info));
+ } else {
+ callback.Run(nullptr);
+ }
+}
+
+} // namespace bluetooth

Powered by Google App Engine
This is Rietveld 408576698