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

Side by Side 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: Reverted DEPS Created 7 years, 11 months 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_TASK_MANAGER_WIN_H_
6 #define DEVICE_BLUETOOTH_BLUETOOTH_TASK_MANAGER_WIN_H_
7
8 #include <string>
brettw 2013/01/09 20:06:04 Blank line after this.
youngki 2013/01/09 22:20:14 Done.
9 #include "base/memory/ref_counted.h"
10 #include "base/observer_list.h"
11
12 class MessageLoop;
13
14 namespace base {
15
16 class SequencedTaskRunner;
17 class SequencedWorkerPool;
18
19 } // namespace base
20
21 namespace device {
22
23 // Manages the blocking Bluetooth tasks using |SequencedWorkerPool|. It runs
24 // bluetooth tasks using |SequencedWorkerPool| and informs its observers of
25 // bluetooth adapter state changes and any other bluetooth device inquiry
26 // result.
27 //
28 // It delegates the blocking Windows API calls to |bluetooth_task_runner_|'s
29 // message loop, and receives responses via methods like OnAdapterStateChanged
30 // posted to UI thread.
31 class BluetoothTaskManagerWin
32 : public base::RefCountedThreadSafe<BluetoothTaskManagerWin> {
33 public:
34 struct AdapterState {
35 std::string name;
36 std::string address;
37 bool powered;
38 };
39
40 class Observer {
41 public:
42 virtual ~Observer() {}
43
44 virtual void AdapterStateChanged(const AdapterState& state) {}
45 };
46
47 BluetoothTaskManagerWin();
48
49 void AddObserver(Observer* observer);
50 void RemoveObserver(Observer* observer);
51
52 void Initialize();
53 void Shutdown();
54
55 private:
56 friend class base::RefCountedThreadSafe<BluetoothTaskManagerWin>;
57 friend class BluetoothTaskManagerWinTest;
58
59 static const int kPollIntervalMs;
60
61 virtual ~BluetoothTaskManagerWin();
62
63 // Notify all Observers of updated AdapterState. Should only be called on the
64 // UI thread.
65 void OnAdapterStateChanged(const AdapterState* state);
66
67 // Called on BluetoothTaskRunner.
68 void StartPolling();
69 void PollAdapter();
70
71 // UI task runner reference.
72 const scoped_refptr<base::SequencedTaskRunner> ui_task_runner_;
73
74 const scoped_refptr<base::SequencedWorkerPool> worker_pool_;
75 const scoped_refptr<base::SequencedTaskRunner> bluetooth_task_runner_;
76
77 // List of observers interested in event notifications.
78 ObserverList<Observer> observers_;
79
80 DISALLOW_COPY_AND_ASSIGN(BluetoothTaskManagerWin);
81 };
82
83 } // namespace device
84
85 #endif // DEVICE_BLUETOOTH_BLUETOOTH_TASK_MANAGER_WIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698