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

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

Issue 12929003: Implemented BluetoothAdapterMac::AddDevices(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changed the format type to unsigned long. Created 7 years, 9 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
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,
46 (*iter)->address, 45 (*iter)->address,
47 (*iter)->sdp_bytes.size(), 46 (*iter)->sdp_bytes.size(),
48 sdp_bytes_buffer); 47 sdp_bytes_buffer);
49 service_record_list_.push_back(service_record); 48 service_record_list_.push_back(service_record);
50 service_uuids_.push_back(service_record->uuid()); 49 service_uuids_.push_back(service_record->uuid());
51 } 50 }
52 } 51 }
53 52
54 BluetoothDeviceWin::~BluetoothDeviceWin() { 53 BluetoothDeviceWin::~BluetoothDeviceWin() {
55 } 54 }
56 55
57 void BluetoothDeviceWin::SetVisible(bool visible) {
58 visible_ = visible;
59 }
60
61 bool BluetoothDeviceWin::IsPaired() const { 56 bool BluetoothDeviceWin::IsPaired() const {
62 return false; 57 return false;
63 } 58 }
64 59
65 const BluetoothDevice::ServiceList& BluetoothDeviceWin::GetServices() const { 60 const BluetoothDevice::ServiceList& BluetoothDeviceWin::GetServices() const {
66 return service_uuids_; 61 return service_uuids_;
67 } 62 }
68 63
69 void BluetoothDeviceWin::GetServiceRecords( 64 void BluetoothDeviceWin::GetServiceRecords(
70 const ServiceRecordsCallback& callback, 65 const ServiceRecordsCallback& callback,
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 base::StringAppendF(&device_string, 181 base::StringAppendF(&device_string,
187 "%s%s%d", 182 "%s%s%d",
188 (*iter)->name.c_str(), 183 (*iter)->name.c_str(),
189 (*iter)->address.c_str(), 184 (*iter)->address.c_str(),
190 (*iter)->sdp_bytes.size()); 185 (*iter)->sdp_bytes.size());
191 } 186 }
192 return base::Hash(device_string); 187 return base::Hash(device_string);
193 } 188 }
194 189
195 } // namespace device 190 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698