diff options
author | youngki@chromium.org <youngki@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-21 22:27:05 +0000 |
---|---|---|
committer | youngki@chromium.org <youngki@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-21 22:27:05 +0000 |
commit | d7ba4375ff5397e48cace373c094de118228c6eb (patch) | |
tree | 819360053382a21a7f58f96123cc72ffd6d99272 /device/bluetooth/bluetooth_device_win.cc | |
parent | 71b05e336fad0c76397a041bcb681fb84c6decb2 (diff) | |
download | chromium_src-d7ba4375ff5397e48cace373c094de118228c6eb.zip chromium_src-d7ba4375ff5397e48cace373c094de118228c6eb.tar.gz chromium_src-d7ba4375ff5397e48cace373c094de118228c6eb.tar.bz2 |
Implemented Device/Service discovery with incremented timeout values.
BluetoothTaskManagerWin::StartDiscovery() calls BluetoothTaskManagerWin::DiscoverDevices() with timeout = 1. DiscoverDevices() then issues a device inquiry for timeout period, then posts another DiscoverDevices() with timeout+1. DiscoverDevices() stops posting itself when StopDiscovery() is called, or timeout reaches maximum (48).
BUG=135470,168361
Review URL: https://chromiumcodereview.appspot.com/12041035
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@183869 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'device/bluetooth/bluetooth_device_win.cc')
-rw-r--r-- | device/bluetooth/bluetooth_device_win.cc | 65 |
1 files changed, 63 insertions, 2 deletions
diff --git a/device/bluetooth/bluetooth_device_win.cc b/device/bluetooth/bluetooth_device_win.cc index 14fe785..a083f09 100644 --- a/device/bluetooth/bluetooth_device_win.cc +++ b/device/bluetooth/bluetooth_device_win.cc @@ -7,20 +7,58 @@ #include "device/bluetooth/bluetooth_device_win.h" #include <string> + #include "base/basictypes.h" +#include "base/hash.h" #include "base/logging.h" +#include "base/memory/scoped_vector.h" +#include "base/stringprintf.h" #include "device/bluetooth/bluetooth_out_of_band_pairing_data.h" +#include "device/bluetooth/bluetooth_service_record_win.h" + +namespace { + +const int kSdpBytesBufferSize = 1024; + +} // namespace namespace device { -BluetoothDeviceWin::BluetoothDeviceWin() : BluetoothDevice() { +BluetoothDeviceWin::BluetoothDeviceWin( + const BluetoothTaskManagerWin::DeviceState& state) + : BluetoothDevice(), device_fingerprint_(ComputeDeviceFingerprint(state)) { + name_ = state.name; + address_ = state.address; + bluetooth_class_ = state.bluetooth_class; + connected_ = state.connected; + bonded_ = state.authenticated; + + for (ScopedVector<BluetoothTaskManagerWin::ServiceRecordState>::const_iterator + iter = state.service_record_states.begin(); + iter != state.service_record_states.end(); + ++iter) { + uint8 sdp_bytes_buffer[kSdpBytesBufferSize]; + std::copy((*iter)->sdp_bytes.begin(), + (*iter)->sdp_bytes.end(), + sdp_bytes_buffer); + BluetoothServiceRecord* service_record = new BluetoothServiceRecordWin( + (*iter)->name, + (*iter)->address, + (*iter)->sdp_bytes.size(), + sdp_bytes_buffer); + service_record_list_.push_back(service_record); + service_uuids_.push_back(service_record->uuid()); + } } BluetoothDeviceWin::~BluetoothDeviceWin() { } +void BluetoothDeviceWin::SetVisible(bool visible) { + visible_ = visible; +} + bool BluetoothDeviceWin::IsPaired() const { - NOTIMPLEMENTED(); return false; } @@ -118,4 +156,27 @@ void BluetoothDeviceWin::ClearOutOfBandPairingData( NOTIMPLEMENTED(); } +// static +uint32 BluetoothDeviceWin::ComputeDeviceFingerprint( + const BluetoothTaskManagerWin::DeviceState& state) { + std::string device_string = base::StringPrintf("%s%s%u%s%s%s", + state.name.c_str(), + state.address.c_str(), + state.bluetooth_class, + state.visible ? "true" : "false", + state.connected ? "true" : "false", + state.authenticated ? "true" : "false"); + for (ScopedVector<BluetoothTaskManagerWin::ServiceRecordState>::const_iterator + iter = state.service_record_states.begin(); + iter != state.service_record_states.end(); + ++iter) { + base::StringAppendF(&device_string, + "%s%s%d", + (*iter)->name.c_str(), + (*iter)->address.c_str(), + (*iter)->sdp_bytes.size()); + } + return base::Hash(device_string); +} + } // namespace device |