Chromium Code Reviews| Index: content/public/browser/notification_watcher.h |
| diff --git a/content/public/browser/notification_watcher.h b/content/public/browser/notification_watcher.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..6d7ae1f75d243874cc58a68b1221fe2a779438ad |
| --- /dev/null |
| +++ b/content/public/browser/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_ |
| +#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/common/content_export.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 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.
|
| + : 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); |
| + |
| + 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_ |