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..cef49c1fb9ad066f0112a7f74fb78c9c0e5b4345 |
--- /dev/null |
+++ b/device/bluetooth/bluetooth_polling_thread_win.h |
@@ -0,0 +1,51 @@ |
+// 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 BluetoothPollingThreadWinTest; |
+class BluetoothTaskManagerWin; |
+ |
+// A thread dedicated to perform blocking bluetooth APIs on Windows. |
+// Other than constructor, destructor, StartPolling(), and Cancel(), all else in |
+// this class should run on its own thread. |
+// The constructor, destructor, StartPolling(), and Cancel() MUST be run from |
+// the |task_manager_|'s message loop. |
+class BluetoothPollingThreadWin : public base::Thread { |
+ public: |
+ BluetoothPollingThreadWin(BluetoothTaskManagerWin* task_manager); |
+ virtual ~BluetoothPollingThreadWin(); |
+ |
+ void StartPolling(); |
+ void Cancel(); |
+ |
+ private: |
+ friend class BluetoothPollingThreadWinTest; |
+ 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_ |