OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 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 CONTENT_PUBLIC_BROWSER_NOTIFICATION_WATCHER_H_ | |
6 #define CONTENT_PUBLIC_BROWSER_NOTIFICATION_WATCHER_H_ | |
7 | |
8 #include "base/basictypes.h" | |
9 #include "base/callback.h" | |
10 #include "base/compiler_specific.h" | |
11 #include "base/run_loop.h" | |
12 #include "content/common/content_export.h" | |
13 #include "content/public/browser/notification_observer.h" | |
14 | |
15 namespace content { | |
16 | |
17 class NotificationDetails; | |
18 class NotificationSource; | |
19 | |
20 // Observes a specific notification type and quits the message loop once a | |
21 // condition holds. | |
22 class CONTENT_EXPORT NotificationWatcher | |
Mattias Nissler (ping if slow)
2013/03/01 10:37:21
There's already WindowedNotificationObserver in co
dconnelly
2013/03/06 10:02:59
Done.
| |
23 : public content::NotificationObserver { | |
24 public: | |
25 // Callback invoked on notifications. Should return true when the condition | |
26 // that the caller is waiting for is satisfied. | |
27 typedef base::Callback<bool(void)> ConditionTestCallback; | |
28 | |
29 explicit NotificationWatcher(int notification_type, | |
30 const ConditionTestCallback& callback); | |
31 | |
32 void Run(); | |
33 | |
34 // content::NotificationObserver: | |
35 virtual void Observe(int type, | |
36 const content::NotificationSource& source, | |
37 const content::NotificationDetails& details) OVERRIDE; | |
38 | |
39 private: | |
40 int type_; | |
41 ConditionTestCallback callback_; | |
42 base::RunLoop run_loop_; | |
43 | |
44 DISALLOW_COPY_AND_ASSIGN(NotificationWatcher); | |
45 }; | |
46 | |
47 } // namespace content | |
48 | |
49 #endif // CONTENT_PUBLIC_BROWSER_NOTIFICATION_WATCHER_H_ | |
OLD | NEW |