Index: device/bluetooth/bluetooth_task_manager_win.h |
diff --git a/device/bluetooth/bluetooth_task_manager_win.h b/device/bluetooth/bluetooth_task_manager_win.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..85d0a684000f9b5ca01d03fcab522cc9f5396ebd |
--- /dev/null |
+++ b/device/bluetooth/bluetooth_task_manager_win.h |
@@ -0,0 +1,71 @@ |
+// 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_TASK_MANAGER_WIN_H_ |
+#define DEVICE_BLUETOOTH_BLUETOOTH_TASK_MANAGER_WIN_H_ |
+ |
+#include <string> |
+#include "base/memory/ref_counted.h" |
+#include "base/observer_list.h" |
+#include "device/bluetooth/bluetooth_polling_thread_win.h" |
+ |
+class MessageLoop; |
+ |
+namespace device { |
+ |
+// Manages the blocking Bluetooth tasks with a dedicated thread. It owns and |
+// runs a thread to perform blocking Bluetooth tasks and informs its observers |
+// of bluetooth adapter state changes and any other bluetooth device inquiry |
+// result. |
+// All the code in this class runs in the UI thread. |
bryeung
2012/12/10 19:51:28
This deserves a more thorough comment about why we
youngki
2012/12/17 17:17:23
I put some more comments to explain the message pa
|
+class BluetoothTaskManagerWin |
+ : public base::RefCountedThreadSafe<BluetoothTaskManagerWin> { |
+ public: |
+ struct AdapterState { |
+ std::string name; |
+ std::string address; |
+ bool powered; |
+ }; |
+ |
+ class Observer { |
+ public: |
+ virtual ~Observer() {} |
+ |
+ virtual void AdapterStateChanged(const AdapterState& state) {} |
+ }; |
+ |
+ BluetoothTaskManagerWin(); |
+ |
+ void AddObserver(Observer* observer); |
+ void RemoveObserver(Observer* observer); |
+ |
+ void StartThread(); |
+ void StopThread(); |
+ |
+ MessageLoop* message_loop() const { return ui_message_loop_; } |
+ |
+ private: |
+ friend class base::RefCountedThreadSafe<BluetoothTaskManagerWin>; |
+ friend class BluetoothPollingThreadWin; |
bryeung
2012/12/10 19:51:28
why is this necessary?
youngki
2012/12/17 17:17:23
This is necessary so that BluetoothPollingThreadWi
|
+ |
+ virtual ~BluetoothTaskManagerWin(); |
+ |
+ // Notify all Observers of updated AdapterState. Should only be called on the |
+ // UI thread. |
+ void OnAdapterStateChanged(const AdapterState* state); |
+ |
+ // Main message loop reference. |
+ MessageLoop* const ui_message_loop_; |
+ |
+ BluetoothPollingThreadWin thread_; |
+ |
+ // List of observers interested in event notifications. |
+ ObserverList<Observer> observers_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(BluetoothTaskManagerWin); |
+}; |
+ |
+} // namespace device |
+ |
+#endif // DEVICE_BLUETOOTH_BLUETOOTH_TASK_MANAGER_WIN_H_ |