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

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: Use Observer pattern 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_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..d68f16c30ff6511347c06cf955a3001138b86104
--- /dev/null
+++ b/device/bluetooth/bluetooth_polling_thread_win.h
@@ -0,0 +1,65 @@
+// 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/memory/scoped_ptr.h"
+#include "base/threading/thread.h"
+
+namespace device {
+
+// A thread dedicated to perform blocking bluetooth APIs on Windows.
+class BluetoothPollingThreadWin : public base::Thread {
+ public:
+ struct Properties {
+ std::string name;
+ std::string address;
+ bool powered;
+ };
+
+ class Observer {
+ public:
+ virtual ~Observer() {}
+
+ virtual void AdapterPropertyChanged(const Properties& properties) {}
bryeung 2012/11/23 13:32:22 Please document that this will always be called on
youngki 2012/11/23 18:26:38 Done.
+ };
+
+ BluetoothPollingThreadWin();
+ virtual ~BluetoothPollingThreadWin();
+
+ void AddObserver(Observer* observer);
+ void RemoveObserver(Observer* observer);
+
+ void Init();
+
+ private:
+ // Finds the bluetooth adapter and creates a handle for it. Then it returns
+ // the handle to the main thread.
+ void FindAdapterHandleAndReply(
+ base::WeakPtr<BluetoothPollingThreadWin> weak_ptr) const;
+
+ // Callback to be run on the main thread with the valid adapter_handle.
+ void OnAdapterHandleAvailable(HANDLE adapter_handle);
+
+ // Populates bluetooth adapter properties using adapter_handle_.
+ void GetAdapterProperties(Properties* properties) const;
+
+ static const int kPollIntervalMs;
+
+ HANDLE adapter_handle_;
+
+ // List of observers interested in event notifications from us.
+ ObserverList<Observer> observers_;
+
+ // NOTE: This should remain the last member so it'll be destroyed and
+ // invalidate its weak pointers before any other members are destroyed.
+ base::WeakPtrFactory<BluetoothPollingThreadWin> weak_ptr_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(BluetoothPollingThreadWin);
+};
+
+} // namespace device
+
+#endif // DEVICE_BLUETOOTH_BLUETOOTH_POLLING_THREAD_WIN_H_

Powered by Google App Engine
This is Rietveld 408576698