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 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_POLLING_THREAD_WIN_H_ |
| 6 #define DEVICE_BLUETOOTH_BLUETOOTH_POLLING_THREAD_WIN_H_ |
| 7 |
| 8 #include "base/synchronization/cancellation_flag.h" |
| 9 #include "base/threading/thread.h" |
| 10 |
| 11 namespace device { |
| 12 |
| 13 class BluetoothTaskManagerWin; |
| 14 |
| 15 // A thread dedicated to perform blocking bluetooth APIs on Windows. |
| 16 // Other than constructor, destructor, StartPolling(), and Cancel(), all else in |
| 17 // this class should run on its own thread. |
| 18 // The constructor, destructor, StartPolling(), and Cancel() MUST be run from |
| 19 // the |task_manager_|'s message loop. |
| 20 class BluetoothPollingThreadWin : public base::Thread { |
| 21 public: |
| 22 BluetoothPollingThreadWin(BluetoothTaskManagerWin* task_manager); |
| 23 virtual ~BluetoothPollingThreadWin(); |
| 24 |
| 25 void StartPolling(); |
| 26 void Cancel(); |
| 27 |
| 28 private: |
| 29 friend class BluetoothTaskManagerWin; |
| 30 |
| 31 // Called periodically to get the latest state of the Bluetooth Adapter from |
| 32 // the Windows APIs. Posts another call to PollAdapter unless |
| 33 // |cancellation_flag_| is set. |
| 34 void PollAdapter(); |
| 35 |
| 36 static const int kPollIntervalMs; |
| 37 |
| 38 // The task manager owning this thread. It is guaranteed to outlive this |
| 39 // object. |
| 40 BluetoothTaskManagerWin* task_manager_; |
| 41 |
| 42 base::CancellationFlag cancellation_flag_; |
| 43 |
| 44 DISALLOW_COPY_AND_ASSIGN(BluetoothPollingThreadWin); |
| 45 }; |
| 46 |
| 47 } // namespace device |
| 48 |
| 49 #endif // DEVICE_BLUETOOTH_BLUETOOTH_POLLING_THREAD_WIN_H_ |
OLD | NEW |