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

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

Issue 2404623002: bluetooth: Add DeviceChanged logging in Device service. (Closed)
Patch Set: Move devices map, simplify initialization Created 4 years, 1 month 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
« no previous file with comments | « device/bluetooth/adapter.cc ('k') | device/bluetooth/public/interfaces/adapter.mojom » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <utility> 5 #include <utility>
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "device/bluetooth/device.h" 8 #include "device/bluetooth/device.h"
9 #include "mojo/public/cpp/bindings/strong_binding.h" 9 #include "mojo/public/cpp/bindings/strong_binding.h"
10 10
11 namespace bluetooth { 11 namespace bluetooth {
12 12
13 Device::Device(const std::string& address, 13 Device::Device(const std::string& address,
14 scoped_refptr<device::BluetoothAdapter> adapter) 14 scoped_refptr<device::BluetoothAdapter> adapter)
15 : address_(address), adapter_(std::move(adapter)) {} 15 : address_(address), adapter_(std::move(adapter)) {}
16 16
17 Device::~Device() {} 17 Device::~Device() {}
18 18
19 // static 19 // static
20 mojom::DeviceInfoPtr Device::ConstructDeviceInfoStruct( 20 mojom::DeviceInfoPtr Device::ConstructDeviceInfoStruct(
21 const device::BluetoothDevice* device) { 21 const device::BluetoothDevice* device) {
22 mojom::DeviceInfoPtr device_info = mojom::DeviceInfo::New(); 22 mojom::DeviceInfoPtr device_info = mojom::DeviceInfo::New();
23 23
24 device_info->name = device->GetName(); 24 device_info->name = device->GetName();
25 device_info->name_for_display = 25 device_info->name_for_display =
26 base::UTF16ToUTF8(device->GetNameForDisplay()); 26 base::UTF16ToUTF8(device->GetNameForDisplay());
27 device_info->address = device->GetAddress(); 27 device_info->address = device->GetAddress();
28 28
29 if (device->GetInquiryRSSI()) {
30 device_info->rssi = mojom::RSSIWrapper::New();
31 device_info->rssi->value = device->GetInquiryRSSI().value();
32 }
33
29 return device_info; 34 return device_info;
30 } 35 }
31 36
32 void Device::GetInfo(const GetInfoCallback& callback) { 37 void Device::GetInfo(const GetInfoCallback& callback) {
33 device::BluetoothDevice* device = adapter_->GetDevice(address_); 38 device::BluetoothDevice* device = adapter_->GetDevice(address_);
34 if (device) { 39 if (device) {
35 mojom::DeviceInfoPtr device_info = ConstructDeviceInfoStruct(device); 40 mojom::DeviceInfoPtr device_info = ConstructDeviceInfoStruct(device);
36 callback.Run(std::move(device_info)); 41 callback.Run(std::move(device_info));
37 } else { 42 } else {
38 callback.Run(nullptr); 43 callback.Run(nullptr);
39 } 44 }
40 } 45 }
41 46
42 } // namespace bluetooth 47 } // namespace bluetooth
OLDNEW
« no previous file with comments | « device/bluetooth/adapter.cc ('k') | device/bluetooth/public/interfaces/adapter.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698