Index: content/public/test/notification_watcher.h |
diff --git a/content/public/test/notification_watcher.h b/content/public/test/notification_watcher.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..ccc44b67014cc9fa950b605606f39bce702b0233 |
--- /dev/null |
+++ b/content/public/test/notification_watcher.h |
@@ -0,0 +1,49 @@ |
+// Copyright 2013 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CONTENT_PUBLIC_BROWSER_NOTIFICATION_WATCHER_H_ |
bartfab (slow)
2013/03/07 12:17:23
This no longer matches the file path.
dconnelly
2013/03/07 14:45:19
Done.
|
+#define CONTENT_PUBLIC_BROWSER_NOTIFICATION_WATCHER_H_ |
+ |
+#include "base/basictypes.h" |
+#include "base/callback.h" |
+#include "base/compiler_specific.h" |
+#include "base/run_loop.h" |
+#include "content/public/browser/notification_observer.h" |
+ |
+namespace content { |
+ |
+class NotificationDetails; |
+class NotificationSource; |
+ |
+// Observes a specific notification type and quits the message loop once a |
+// condition holds. |
+class NotificationWatcher |
+ : public content::NotificationObserver { |
+ public: |
+ // Callback invoked on notifications. Should return true when the condition |
+ // that the caller is waiting for is satisfied. |
+ typedef base::Callback<bool(void)> ConditionTestCallback; |
+ |
+ explicit NotificationWatcher(int notification_type, |
+ const ConditionTestCallback& callback); |
+ virtual ~NotificationWatcher(); |
+ |
+ void Run(); |
+ |
+ // content::NotificationObserver: |
+ virtual void Observe(int type, |
+ const content::NotificationSource& source, |
+ const content::NotificationDetails& details) OVERRIDE; |
+ |
+ private: |
+ int type_; |
+ ConditionTestCallback callback_; |
+ base::RunLoop run_loop_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(NotificationWatcher); |
+}; |
+ |
+} // namespace content |
+ |
+#endif // CONTENT_PUBLIC_BROWSER_NOTIFICATION_WATCHER_H_ |