Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "device/bluetooth/bluetooth_classic_win_fake.h" | 5 #include "device/bluetooth/bluetooth_classic_win_fake.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 | 8 |
| 9 namespace device { | 9 namespace device { |
| 10 namespace win { | 10 namespace win { |
| 11 | 11 |
| 12 BluetoothClassicWrapperFake::BluetoothClassicWrapperFake() {} | 12 BluetoothClassicWrapperFake::BluetoothClassicWrapperFake() {} |
| 13 BluetoothClassicWrapperFake::~BluetoothClassicWrapperFake() {} | 13 BluetoothClassicWrapperFake::~BluetoothClassicWrapperFake() {} |
| 14 | 14 |
| 15 HBLUETOOTH_RADIO_FIND BluetoothClassicWrapperFake::FindFirstRadio( | 15 HBLUETOOTH_RADIO_FIND BluetoothClassicWrapperFake::FindFirstRadio( |
| 16 const BLUETOOTH_FIND_RADIO_PARAMS* params, | 16 const BLUETOOTH_FIND_RADIO_PARAMS* params, |
| 17 HANDLE* out_handle) { | 17 HANDLE* out_handle) { |
| 18 NOTIMPLEMENTED(); | 18 if (simulated_radios_.get() != nullptr) { |
|
scheib
2016/02/07 01:45:19
Just:
if (simulated_radios_) {
gogerald1
2016/02/08 17:00:04
Done.
| |
| 19 *out_handle = (PVOID)simulated_radios_.get(); | |
| 20 return *out_handle; | |
| 21 } | |
| 19 return NULL; | 22 return NULL; |
| 20 } | 23 } |
| 21 | 24 |
| 22 DWORD BluetoothClassicWrapperFake::GetRadioInfo( | 25 DWORD BluetoothClassicWrapperFake::GetRadioInfo( |
| 23 HANDLE handle, | 26 HANDLE handle, |
| 24 PBLUETOOTH_RADIO_INFO out_radio_info) { | 27 PBLUETOOTH_RADIO_INFO out_radio_info) { |
| 25 NOTIMPLEMENTED(); | 28 if (simulated_radios_.get() != nullptr) { |
|
scheib
2016/02/07 01:45:18
Just:
if (simulated_radios_) {
gogerald1
2016/02/08 17:00:05
Done.
| |
| 29 *out_radio_info = simulated_radios_->radio_info; | |
| 30 } | |
| 26 return ERROR_SUCCESS; | 31 return ERROR_SUCCESS; |
|
scheib
2016/02/07 01:45:18
Return success even if there were no radios?
gogerald1
2016/02/08 17:00:04
Done. Move error record from next CL to this CL.
| |
| 27 } | 32 } |
| 28 | 33 |
| 29 BOOL BluetoothClassicWrapperFake::FindRadioClose(HBLUETOOTH_RADIO_FIND handle) { | 34 BOOL BluetoothClassicWrapperFake::FindRadioClose(HBLUETOOTH_RADIO_FIND handle) { |
| 30 NOTIMPLEMENTED(); | |
| 31 return TRUE; | 35 return TRUE; |
| 32 } | 36 } |
| 33 | 37 |
| 34 BOOL BluetoothClassicWrapperFake::IsConnectable(HANDLE handle) { | 38 BOOL BluetoothClassicWrapperFake::IsConnectable(HANDLE handle) { |
| 35 NOTIMPLEMENTED(); | 39 if (simulated_radios_.get() != nullptr) { |
|
scheib
2016/02/07 01:45:18
Just:
if (simulated_radios_) {
gogerald1
2016/02/08 17:00:04
Done.
| |
| 40 return simulated_radios_->is_connectable; | |
| 41 } | |
| 36 return TRUE; | 42 return TRUE; |
|
scheib
2016/02/07 01:45:19
If no radios it seems that FALSE should be returne
gogerald1
2016/02/08 17:00:05
Done.
| |
| 37 } | 43 } |
| 38 | 44 |
| 39 HBLUETOOTH_DEVICE_FIND BluetoothClassicWrapperFake::FindFirstDevice( | 45 HBLUETOOTH_DEVICE_FIND BluetoothClassicWrapperFake::FindFirstDevice( |
| 40 const BLUETOOTH_DEVICE_SEARCH_PARAMS* params, | 46 const BLUETOOTH_DEVICE_SEARCH_PARAMS* params, |
| 41 BLUETOOTH_DEVICE_INFO* out_device_info) { | 47 BLUETOOTH_DEVICE_INFO* out_device_info) { |
| 42 NOTIMPLEMENTED(); | |
| 43 return NULL; | 48 return NULL; |
| 44 } | 49 } |
| 45 | 50 |
| 46 BOOL BluetoothClassicWrapperFake::FindNextDevice( | 51 BOOL BluetoothClassicWrapperFake::FindNextDevice( |
| 47 HBLUETOOTH_DEVICE_FIND handle, | 52 HBLUETOOTH_DEVICE_FIND handle, |
| 48 BLUETOOTH_DEVICE_INFO* out_device_info) { | 53 BLUETOOTH_DEVICE_INFO* out_device_info) { |
| 49 NOTIMPLEMENTED(); | 54 NOTIMPLEMENTED(); |
| 50 return TRUE; | 55 return TRUE; |
| 51 } | 56 } |
| 52 | 57 |
| 53 BOOL BluetoothClassicWrapperFake::FindDeviceClose( | 58 BOOL BluetoothClassicWrapperFake::FindDeviceClose( |
| 54 HBLUETOOTH_DEVICE_FIND handle) { | 59 HBLUETOOTH_DEVICE_FIND handle) { |
| 55 NOTIMPLEMENTED(); | 60 NOTIMPLEMENTED(); |
| 56 return TRUE; | 61 return TRUE; |
| 57 } | 62 } |
| 58 | 63 |
| 59 BOOL BluetoothClassicWrapperFake::EnableDiscovery(HANDLE handle, | 64 BOOL BluetoothClassicWrapperFake::EnableDiscovery(HANDLE handle, |
| 60 BOOL is_enable) { | 65 BOOL is_enable) { |
| 61 NOTIMPLEMENTED(); | |
| 62 return TRUE; | 66 return TRUE; |
| 63 } | 67 } |
| 64 | 68 |
| 65 BOOL BluetoothClassicWrapperFake::EnableIncomingConnections(HANDLE handle, | 69 BOOL BluetoothClassicWrapperFake::EnableIncomingConnections(HANDLE handle, |
| 66 BOOL is_enable) { | 70 BOOL is_enable) { |
| 67 NOTIMPLEMENTED(); | |
| 68 return TRUE; | 71 return TRUE; |
| 69 } | 72 } |
| 73 | |
| 74 BluetoothRadio* BluetoothClassicWrapperFake::SimulateARadio( | |
| 75 base::string16 name, | |
| 76 BLUETOOTH_ADDRESS address) { | |
| 77 BluetoothRadio* radio = new BluetoothRadio(); | |
| 78 radio->is_connectable = true; // set it connectable by default. | |
| 79 size_t length = | |
| 80 ((name.size() > BLUETOOTH_MAX_NAME_SIZE) ? BLUETOOTH_MAX_NAME_SIZE | |
| 81 : name.size()); | |
| 82 for (size_t i = 0; i < length; i++) { | |
|
scheib
2016/02/07 01:45:19
There is very likely a src/base utility for this,
gogerald1
2016/02/08 17:00:04
It looks this function is used to write formatted
| |
| 83 radio->radio_info.szName[i] = name.at(i); | |
| 84 } | |
| 85 radio->radio_info.address = address; | |
| 86 simulated_radios_.reset(radio); | |
| 87 return radio; | |
| 88 } | |
| 70 } // namespace device | 89 } // namespace device |
| 71 } // namespace win | 90 } // namespace win |
| OLD | NEW |