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

Side by Side 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 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_POLLING_THREAD_WIN_H_
6 #define DEVICE_BLUETOOTH_BLUETOOTH_POLLING_THREAD_WIN_H_
7
8 #include "base/memory/scoped_ptr.h"
9 #include "base/threading/thread.h"
10
11 namespace device {
12
13 // A thread dedicated to perform blocking bluetooth APIs on Windows.
14 class BluetoothPollingThreadWin : public base::Thread {
15 public:
16 struct Properties {
17 std::string name;
18 std::string address;
19 bool powered;
20 };
21
22 class Observer {
23 public:
24 virtual ~Observer() {}
25
26 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.
27 };
28
29 BluetoothPollingThreadWin();
30 virtual ~BluetoothPollingThreadWin();
31
32 void AddObserver(Observer* observer);
33 void RemoveObserver(Observer* observer);
34
35 void Init();
36
37 private:
38 // Finds the bluetooth adapter and creates a handle for it. Then it returns
39 // the handle to the main thread.
40 void FindAdapterHandleAndReply(
41 base::WeakPtr<BluetoothPollingThreadWin> weak_ptr) const;
42
43 // Callback to be run on the main thread with the valid adapter_handle.
44 void OnAdapterHandleAvailable(HANDLE adapter_handle);
45
46 // Populates bluetooth adapter properties using adapter_handle_.
47 void GetAdapterProperties(Properties* properties) const;
48
49 static const int kPollIntervalMs;
50
51 HANDLE adapter_handle_;
52
53 // List of observers interested in event notifications from us.
54 ObserverList<Observer> observers_;
55
56 // NOTE: This should remain the last member so it'll be destroyed and
57 // invalidate its weak pointers before any other members are destroyed.
58 base::WeakPtrFactory<BluetoothPollingThreadWin> weak_ptr_factory_;
59
60 DISALLOW_COPY_AND_ASSIGN(BluetoothPollingThreadWin);
61 };
62
63 } // namespace device
64
65 #endif // DEVICE_BLUETOOTH_BLUETOOTH_POLLING_THREAD_WIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698