Index: device/bluetooth/bluetooth_polling_thread_win.h |
diff --git a/device/bluetooth/bluetooth_polling_thread_win.h b/device/bluetooth/bluetooth_polling_thread_win.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..c853dc3be6ea99986445c2c0990792efd5ab8a75 |
--- /dev/null |
+++ b/device/bluetooth/bluetooth_polling_thread_win.h |
@@ -0,0 +1,46 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef DEVICE_BLUETOOTH_BLUETOOTH_POLLING_THREAD_WIN_H_ |
+#define DEVICE_BLUETOOTH_BLUETOOTH_POLLING_THREAD_WIN_H_ |
+ |
+#include "base/synchronization/cancellation_flag.h" |
+#include "base/threading/thread.h" |
+ |
+namespace device { |
+ |
+class BluetoothTaskManagerWin; |
+ |
+// A thread dedicated to perform blocking bluetooth APIs on Windows. |
+// Other than constructor, destructor, and Cancel(), all else in this class |
+// should run on its own thread. |
bryeung
2012/12/10 19:51:28
would be nice to specify here (and on the methods
youngki
2012/12/17 17:17:23
Done.
|
+class BluetoothPollingThreadWin : public base::Thread { |
+ public: |
+ BluetoothPollingThreadWin(BluetoothTaskManagerWin* task_manager); |
+ virtual ~BluetoothPollingThreadWin(); |
+ |
+ void Cancel(); |
+ |
+ private: |
+ friend class BluetoothTaskManagerWin; |
+ |
+ // Called periodically to get the latest state of the Bluetooth Adapter from |
+ // the Windows APIs. Posts another call to PollAdapter unless |
+ // |cancellation_flag_| is set. |
+ void PollAdapter(); |
+ |
+ static const int kPollIntervalMs; |
+ |
+ // The task manager owning this thread. It is guaranteed to outlive this |
+ // object. |
+ BluetoothTaskManagerWin* task_manager_; |
+ |
+ base::CancellationFlag cancellation_flag_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(BluetoothPollingThreadWin); |
+}; |
+ |
+} // namespace device |
+ |
+#endif // DEVICE_BLUETOOTH_BLUETOOTH_POLLING_THREAD_WIN_H_ |