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_message_loop_(MessageLoop::current()), | |
15 ALLOW_THIS_IN_INITIALIZER_LIST(thread_(this)) { | |
16 DCHECK(ui_message_loop_); | |
17 DCHECK(ui_message_loop_->type() == MessageLoop::TYPE_UI); | |
bryeung
2012/12/10 19:51:28
why have you switched to checking the message loop
youngki
2012/12/17 17:17:23
I was following the existing patterns from other f
| |
18 } | |
19 | |
20 BluetoothTaskManagerWin::~BluetoothTaskManagerWin() { | |
21 } | |
22 | |
23 void BluetoothTaskManagerWin::AddObserver(Observer* observer) { | |
24 CHECK(observer); | |
25 observers_.AddObserver(observer); | |
26 } | |
27 | |
28 void BluetoothTaskManagerWin::RemoveObserver(Observer* observer) { | |
29 CHECK(observer); | |
30 observers_.RemoveObserver(observer); | |
31 } | |
32 | |
33 void BluetoothTaskManagerWin::StartThread() { | |
bryeung
2012/12/10 19:51:28
CHECKing for thread here would be good
youngki
2012/12/17 17:17:23
Done.
| |
34 if (!thread_.message_loop()) { | |
35 thread_.Start(); | |
bryeung
2012/12/10 19:51:28
can thread_.Start() be overridden so that it posts
youngki
2012/12/17 17:17:23
Thread::Start() is not virtual, but I added Blueto
| |
36 thread_.message_loop()->PostTask( | |
37 FROM_HERE, | |
38 base::Bind(&BluetoothPollingThreadWin::PollAdapter, | |
39 base::Unretained(&thread_))); | |
40 } | |
41 } | |
42 | |
43 void BluetoothTaskManagerWin::StopThread() { | |
bryeung
2012/12/10 19:51:28
CHECKing for thread here would be good
youngki
2012/12/17 17:17:23
Done.
| |
44 thread_.Cancel(); | |
45 } | |
46 | |
47 void BluetoothTaskManagerWin::OnAdapterStateChanged(const AdapterState* state) { | |
48 DCHECK_EQ(ui_message_loop_, MessageLoop::current()); | |
49 FOR_EACH_OBSERVER(BluetoothTaskManagerWin::Observer, observers_, | |
50 AdapterStateChanged(*state)); | |
51 } | |
52 | |
53 } // namespace device | |
OLD | NEW |