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_TEST_NOTIFICATION_WATCHER_H_ | |
6 #define CONTENT_PUBLIC_TEST_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/public/browser/notification_observer.h" | |
13 | |
14 namespace content { | |
15 | |
16 class NotificationDetails; | |
17 class NotificationSource; | |
18 | |
19 // Observes a specific notification type and quits the message loop once a | |
20 // condition holds. | |
21 class NotificationWatcher | |
22 : public content::NotificationObserver { | |
23 public: | |
24 // Callback invoked on notifications. Should return true when the condition | |
25 // that the caller is waiting for is satisfied. | |
26 typedef base::Callback<bool(void)> ConditionTestCallback; | |
27 | |
28 explicit NotificationWatcher(int notification_type, | |
29 const ConditionTestCallback& callback); | |
30 virtual ~NotificationWatcher(); | |
31 | |
32 void Run(); | |
sky
2013/03/08 00:38:37
This needs better documentation. I would never exp
| |
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_; | |
sky
2013/03/08 00:38:37
const
| |
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_TEST_NOTIFICATION_WATCHER_H_ | |
OLD | NEW |