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" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/memory/scoped_vector.h" | 12 #include "base/memory/scoped_vector.h" |
13 #include "base/stringprintf.h" | 13 #include "base/stringprintf.h" |
14 #include "device/bluetooth/bluetooth_out_of_band_pairing_data.h" | 14 #include "device/bluetooth/bluetooth_out_of_band_pairing_data.h" |
15 #include "device/bluetooth/bluetooth_service_record_win.h" | 15 #include "device/bluetooth/bluetooth_service_record_win.h" |
16 #include "device/bluetooth/bluetooth_socket_win.h" | 16 #include "device/bluetooth/bluetooth_socket_win.h" |
17 #include "device/bluetooth/bluetooth_task_manager_win.h" | 17 #include "device/bluetooth/bluetooth_task_manager_win.h" |
18 | 18 |
19 namespace { | 19 namespace { |
20 | 20 |
21 const int kSdpBytesBufferSize = 1024; | 21 const int kSdpBytesBufferSize = 1024; |
22 | 22 |
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(state.name, |
30 name_ = state.name; | 30 state.address, |
31 address_ = state.address; | 31 state.bluetooth_class, |
32 bluetooth_class_ = state.bluetooth_class; | 32 state.connected, |
33 connected_ = state.connected; | 33 state.authenticated), |
34 bonded_ = state.authenticated; | 34 device_fingerprint_(ComputeDeviceFingerprint(state)) { |
35 | |
36 for (ScopedVector<BluetoothTaskManagerWin::ServiceRecordState>::const_iterator | 35 for (ScopedVector<BluetoothTaskManagerWin::ServiceRecordState>::const_iterator |
37 iter = state.service_record_states.begin(); | 36 iter = state.service_record_states.begin(); |
38 iter != state.service_record_states.end(); | 37 iter != state.service_record_states.end(); |
39 ++iter) { | 38 ++iter) { |
40 uint8 sdp_bytes_buffer[kSdpBytesBufferSize]; | 39 uint8 sdp_bytes_buffer[kSdpBytesBufferSize]; |
41 std::copy((*iter)->sdp_bytes.begin(), | 40 std::copy((*iter)->sdp_bytes.begin(), |
42 (*iter)->sdp_bytes.end(), | 41 (*iter)->sdp_bytes.end(), |
43 sdp_bytes_buffer); | 42 sdp_bytes_buffer); |
44 BluetoothServiceRecord* service_record = new BluetoothServiceRecordWin( | 43 BluetoothServiceRecord* service_record = new BluetoothServiceRecordWin( |
45 (*iter)->name, | 44 (*iter)->name, |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 base::StringAppendF(&device_string, | 185 base::StringAppendF(&device_string, |
187 "%s%s%d", | 186 "%s%s%d", |
188 (*iter)->name.c_str(), | 187 (*iter)->name.c_str(), |
189 (*iter)->address.c_str(), | 188 (*iter)->address.c_str(), |
190 (*iter)->sdp_bytes.size()); | 189 (*iter)->sdp_bytes.size()); |
191 } | 190 } |
192 return base::Hash(device_string); | 191 return base::Hash(device_string); |
193 } | 192 } |
194 | 193 |
195 } // namespace device | 194 } // namespace device |
OLD | NEW |