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

Unified Diff: device/bluetooth/bluetooth_task_manager_win.h

Issue 11411130: Implemented BluetoothTaskManagerWin class. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Added BluetoothTaskManagerWin class Created 8 years, 1 month 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_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_

Powered by Google App Engine
This is Rietveld 408576698