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