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

Side by Side Diff: device/bluetooth/device.cc

Issue 2401193002: bluetooth: Add Device service for chrome://bluetooth-internals. (Closed)
Patch Set: Mojom changes, JS formatting 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include <utility>
6
7 #include "base/memory/ptr_util.h"
8 #include "base/strings/utf_string_conversions.h"
9 #include "device/bluetooth/device.h"
10 #include "mojo/public/cpp/bindings/strong_binding.h"
11
12 namespace bluetooth {
13
14 Device::Device(const std::string& address,
15 scoped_refptr<device::BluetoothAdapter> adapter)
16 : address_(address), adapter_(adapter) {}
17
18 Device::~Device() {}
19
20 // static
21 mojom::DeviceInfoPtr Device::ConstructDeviceInfoStruct(
22 const device::BluetoothDevice* device) {
23 mojom::DeviceInfoPtr device_info = mojom::DeviceInfo::New();
24
25 device_info->name = device->GetName();
26 device_info->address = device->GetAddress();
27
28 return device_info;
29 }
30
31 void Device::GetInfo(const GetInfoCallback& callback) {
32 device::BluetoothDevice* device = adapter_->GetDevice(address_);
33 if (device) {
34 mojom::DeviceInfoPtr device_info = ConstructDeviceInfoStruct(device);
35 callback.Run(std::move(device_info));
36 } else {
37 callback.Run(nullptr);
38 }
39 }
40
41 } // namespace bluetooth
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698