OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "device/bluetooth/bluetooth_task_manager_win.h" |
| 6 |
| 7 #include "base/bind.h" |
| 8 #include "base/message_loop.h" |
| 9 #include "device/bluetooth/bluetooth_polling_thread_win.h" |
| 10 |
| 11 namespace device { |
| 12 |
| 13 BluetoothTaskManagerWin::BluetoothTaskManagerWin() |
| 14 : ui_task_runner_(MessageLoop::current()->message_loop_proxy()), |
| 15 ALLOW_THIS_IN_INITIALIZER_LIST(thread_(this)) { |
| 16 } |
| 17 |
| 18 BluetoothTaskManagerWin::~BluetoothTaskManagerWin() { |
| 19 } |
| 20 |
| 21 void BluetoothTaskManagerWin::AddObserver(Observer* observer) { |
| 22 CHECK(observer); |
| 23 observers_.AddObserver(observer); |
| 24 } |
| 25 |
| 26 void BluetoothTaskManagerWin::RemoveObserver(Observer* observer) { |
| 27 CHECK(observer); |
| 28 observers_.RemoveObserver(observer); |
| 29 } |
| 30 |
| 31 void BluetoothTaskManagerWin::StartThread() { |
| 32 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); |
| 33 thread_.StartPolling(); |
| 34 } |
| 35 |
| 36 void BluetoothTaskManagerWin::StopThread() { |
| 37 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); |
| 38 thread_.Cancel(); |
| 39 } |
| 40 |
| 41 void BluetoothTaskManagerWin::OnAdapterStateChanged(const AdapterState* state) { |
| 42 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); |
| 43 FOR_EACH_OBSERVER(BluetoothTaskManagerWin::Observer, observers_, |
| 44 AdapterStateChanged(*state)); |
| 45 } |
| 46 |
| 47 } // namespace device |
OLD | NEW |