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

Side by Side Diff: media/audio/key_press_monitor.h

Issue 21183002: Adding key press detection in the browser process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 4 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) 2013 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 MEDIA_AUDIO_KEY_PRESS_MONITOR_H_
6 #define MEDIA_AUDIO_KEY_PRESS_MONITOR_H_
7
8 #include "base/basictypes.h"
9 #include "base/observer_list.h"
10 #include "base/synchronization/lock.h"
11
12 namespace media {
13
14 // This class monitors the system-wide key presses and notifies the listeners.
15 // All methods can be called on any thread.
16 // TODO(jiayl): this is only a stub now. Need to implement the event monitoring.
17 class KeyPressMonitor {
18 public:
19 // The implementation has to be thread safe.
20 class KeyPressListener {
21 public:
22 // This can be called on any thread.
23 virtual void OnKeyPressed() = 0;
24 protected:
25 virtual ~KeyPressListener() {}
26 };
27
28 KeyPressMonitor();
29 ~KeyPressMonitor();
30
31 // Adds |listener| to receive event notifications. A listener should not be
32 // added more than once.
33 // The callers should make sure |listener| is valid and call
34 // RemoveKeyPressListener before |listener| is destroyed.
35 void AddKeyPressListener(KeyPressListener* listener);
36 // Removes |listener| from receiving event notifications. Does nothing if
37 // |listener| has not been added or has already been removed.
38 void RemoveKeyPressListener(KeyPressListener* listener);
39
40 private:
41 // Raw pointers of the listeners.
42 typedef ObserverList<KeyPressListener> ListenerList;
DaleCurtis 2013/08/02 01:01:17 Typedef seems a bit overkill. AudioInputControlle
jiayl 2013/08/02 20:32:20 Done.
43 ListenerList listeners_;
44 base::Lock listeners_lock_;
45
46 DISALLOW_COPY_AND_ASSIGN(KeyPressMonitor);
47 };
48
49 } // namespace media
50
51 #endif // MEDIA_AUDIO_KEY_PRESS_MONITOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698