| Index: device/bluetooth/bluetooth_task_manager_win.cc
|
| diff --git a/device/bluetooth/bluetooth_task_manager_win.cc b/device/bluetooth/bluetooth_task_manager_win.cc
|
| index 144682f61c66578a91b5c69eb8c841413399cd71..ddb051e9d0cd1282d659aa6fc165daa50f0dc723 100644
|
| --- a/device/bluetooth/bluetooth_task_manager_win.cc
|
| +++ b/device/bluetooth/bluetooth_task_manager_win.cc
|
| @@ -13,22 +13,14 @@
|
| #include "base/stringprintf.h"
|
| #include "base/sys_string_conversions.h"
|
| #include "base/threading/sequenced_worker_pool.h"
|
| -#include "base/threading/thread_restrictions.h"
|
| #include "base/win/scoped_handle.h"
|
| -#include "device/bluetooth/bluetooth_includes_win.h"
|
| +#include "device/bluetooth/bluetooth_init_win.h"
|
|
|
| namespace {
|
|
|
| const int kNumThreadsInWorkerPool = 3;
|
| const char kBluetoothThreadName[] = "BluetoothPollingThreadWin";
|
|
|
| -// A frame-based exception handler filter function for a handler for exceptions
|
| -// generated by the Visual C++ delay loader helper function.
|
| -int FilterVisualCPPExceptions(DWORD exception_code) {
|
| - return HRESULT_FACILITY(exception_code) == FACILITY_VISUALCPP ?
|
| - EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH;
|
| -} // namespace
|
| -
|
| // Populates bluetooth adapter state using adapter_handle.
|
| void GetAdapterState(HANDLE adapter_handle,
|
| device::BluetoothTaskManagerWin::AdapterState* state) {
|
| @@ -61,28 +53,6 @@ namespace device {
|
| // static
|
| const int BluetoothTaskManagerWin::kPollIntervalMs = 500;
|
|
|
| -// static
|
| -bool BluetoothTaskManagerWin::HasBluetoothStack() {
|
| - static enum {
|
| - HBS_UNKNOWN,
|
| - HBS_YES,
|
| - HBS_NO,
|
| - } has_bluetooth_stack = HBS_UNKNOWN;
|
| -
|
| - if (has_bluetooth_stack == HBS_UNKNOWN) {
|
| - base::ThreadRestrictions::AssertIOAllowed();
|
| - HRESULT hr = E_FAIL;
|
| - __try {
|
| - hr = __HrLoadAllImportsForDll("bthprops.cpl");
|
| - } __except(FilterVisualCPPExceptions(::GetExceptionCode())) {
|
| - hr = E_FAIL;
|
| - }
|
| - has_bluetooth_stack = SUCCEEDED(hr) ? HBS_YES : HBS_NO;
|
| - }
|
| -
|
| - return has_bluetooth_stack == HBS_YES;
|
| -}
|
| -
|
| BluetoothTaskManagerWin::BluetoothTaskManagerWin(
|
| scoped_refptr<base::SequencedTaskRunner> ui_task_runner)
|
| : ui_task_runner_(ui_task_runner),
|
| @@ -128,8 +98,18 @@ void BluetoothTaskManagerWin::StartPolling() {
|
| DCHECK(bluetooth_task_runner_->RunsTasksOnCurrentThread());
|
|
|
| // TODO(youngki): Handle this check where BluetoothAdapter is initialized.
|
| - if (HasBluetoothStack()) {
|
| + if (device::bluetooth_init_win::HasBluetoothStack()) {
|
| PollAdapter();
|
| + } else {
|
| + // IF the bluetooth stack is not available, we still send an empty state
|
| + // to BluetoothAdapter so that it is marked initialized, but the adapter
|
| + // will not be present.
|
| + AdapterState* state = new AdapterState();
|
| + ui_task_runner_->PostTask(
|
| + FROM_HERE,
|
| + base::Bind(&BluetoothTaskManagerWin::OnAdapterStateChanged,
|
| + this,
|
| + base::Owned(state)));
|
| }
|
| }
|
|
|
| @@ -215,4 +195,4 @@ void BluetoothTaskManagerWin::SetPowered(
|
| }
|
| }
|
|
|
| -} // namespace device
|
| +} // namespace device
|
|
|