| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "device/bluetooth/bluetooth_device_win.h" | 5 #include "device/bluetooth/bluetooth_device_win.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/hash.h" | 10 #include "base/hash.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 } // namespace | 23 } // namespace |
| 24 | 24 |
| 25 namespace device { | 25 namespace device { |
| 26 | 26 |
| 27 BluetoothDeviceWin::BluetoothDeviceWin( | 27 BluetoothDeviceWin::BluetoothDeviceWin( |
| 28 const BluetoothTaskManagerWin::DeviceState& state) | 28 const BluetoothTaskManagerWin::DeviceState& state) |
| 29 : BluetoothDevice(), device_fingerprint_(ComputeDeviceFingerprint(state)) { | 29 : BluetoothDevice(), device_fingerprint_(ComputeDeviceFingerprint(state)) { |
| 30 name_ = state.name; | 30 name_ = state.name; |
| 31 address_ = state.address; | 31 address_ = state.address; |
| 32 bluetooth_class_ = state.bluetooth_class; | 32 bluetooth_class_ = state.bluetooth_class; |
| 33 visible_ = state.visible; |
| 33 connected_ = state.connected; | 34 connected_ = state.connected; |
| 34 bonded_ = state.authenticated; | 35 paired_ = state.authenticated; |
| 35 | 36 |
| 36 for (ScopedVector<BluetoothTaskManagerWin::ServiceRecordState>::const_iterator | 37 for (ScopedVector<BluetoothTaskManagerWin::ServiceRecordState>::const_iterator |
| 37 iter = state.service_record_states.begin(); | 38 iter = state.service_record_states.begin(); |
| 38 iter != state.service_record_states.end(); | 39 iter != state.service_record_states.end(); |
| 39 ++iter) { | 40 ++iter) { |
| 40 uint8 sdp_bytes_buffer[kSdpBytesBufferSize]; | 41 uint8 sdp_bytes_buffer[kSdpBytesBufferSize]; |
| 41 std::copy((*iter)->sdp_bytes.begin(), | 42 std::copy((*iter)->sdp_bytes.begin(), |
| 42 (*iter)->sdp_bytes.end(), | 43 (*iter)->sdp_bytes.end(), |
| 43 sdp_bytes_buffer); | 44 sdp_bytes_buffer); |
| 44 BluetoothServiceRecord* service_record = new BluetoothServiceRecordWin( | 45 BluetoothServiceRecord* service_record = new BluetoothServiceRecordWin( |
| 45 (*iter)->name, | 46 (*iter)->name, |
| 46 (*iter)->address, | 47 (*iter)->address, |
| 47 (*iter)->sdp_bytes.size(), | 48 (*iter)->sdp_bytes.size(), |
| 48 sdp_bytes_buffer); | 49 sdp_bytes_buffer); |
| 49 service_record_list_.push_back(service_record); | 50 service_record_list_.push_back(service_record); |
| 50 service_uuids_.push_back(service_record->uuid()); | 51 service_uuids_.push_back(service_record->uuid()); |
| 51 } | 52 } |
| 52 } | 53 } |
| 53 | 54 |
| 54 BluetoothDeviceWin::~BluetoothDeviceWin() { | 55 BluetoothDeviceWin::~BluetoothDeviceWin() { |
| 55 } | 56 } |
| 56 | 57 |
| 57 void BluetoothDeviceWin::SetVisible(bool visible) { | 58 void BluetoothDeviceWin::SetVisible(bool visible) { |
| 58 visible_ = visible; | 59 visible_ = visible; |
| 59 } | 60 } |
| 60 | 61 |
| 62 uint32 BluetoothDeviceWin::GetBluetoothClass() const { |
| 63 return bluetooth_class_; |
| 64 } |
| 65 |
| 66 std::string BluetoothDeviceWin::GetDeviceName() const { |
| 67 return name_; |
| 68 } |
| 69 |
| 70 std::string BluetoothDeviceWin::GetAddress() const { |
| 71 return address_; |
| 72 } |
| 73 |
| 61 bool BluetoothDeviceWin::IsPaired() const { | 74 bool BluetoothDeviceWin::IsPaired() const { |
| 75 return paired_; |
| 76 } |
| 77 |
| 78 bool BluetoothDeviceWin::IsConnected() const { |
| 79 return connected_; |
| 80 } |
| 81 |
| 82 bool BluetoothDeviceWin::IsConnectable() const { |
| 62 return false; | 83 return false; |
| 63 } | 84 } |
| 64 | 85 |
| 65 const BluetoothDevice::ServiceList& BluetoothDeviceWin::GetServices() const { | 86 bool BluetoothDeviceWin::IsConnecting() const { |
| 87 return false; |
| 88 } |
| 89 |
| 90 BluetoothDevice::ServiceList BluetoothDeviceWin::GetServices() const { |
| 66 return service_uuids_; | 91 return service_uuids_; |
| 67 } | 92 } |
| 68 | 93 |
| 69 void BluetoothDeviceWin::GetServiceRecords( | 94 void BluetoothDeviceWin::GetServiceRecords( |
| 70 const ServiceRecordsCallback& callback, | 95 const ServiceRecordsCallback& callback, |
| 71 const ErrorCallback& error_callback) { | 96 const ErrorCallback& error_callback) { |
| 72 callback.Run(service_record_list_); | 97 callback.Run(service_record_list_); |
| 73 } | 98 } |
| 74 | 99 |
| 75 void BluetoothDeviceWin::ProvidesServiceWithName( | 100 void BluetoothDeviceWin::ProvidesServiceWithName( |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 base::StringAppendF(&device_string, | 211 base::StringAppendF(&device_string, |
| 187 "%s%s%d", | 212 "%s%s%d", |
| 188 (*iter)->name.c_str(), | 213 (*iter)->name.c_str(), |
| 189 (*iter)->address.c_str(), | 214 (*iter)->address.c_str(), |
| 190 (*iter)->sdp_bytes.size()); | 215 (*iter)->sdp_bytes.size()); |
| 191 } | 216 } |
| 192 return base::Hash(device_string); | 217 return base::Hash(device_string); |
| 193 } | 218 } |
| 194 | 219 |
| 195 } // namespace device | 220 } // namespace device |
| OLD | NEW |