Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1978)

Unified Diff: device/bluetooth/bluetooth_polling_thread_win.h

Issue 11411130: Implemented BluetoothTaskManagerWin class. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Replace naked MessageLoop pointer with SequencedTaskRunner refcounted pointer Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..e43869b6baf2f5d12fcb02d61bb30a38ba646eba
--- /dev/null
+++ b/device/bluetooth/bluetooth_polling_thread_win.h
@@ -0,0 +1,49 @@
+// 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, 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 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_

Powered by Google App Engine
This is Rietveld 408576698