| Index: content/public/browser/notification_watcher.cc
|
| diff --git a/content/public/browser/notification_watcher.cc b/content/public/browser/notification_watcher.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..da3f69302ef7a14145ff05ac08c250b51722727d
|
| --- /dev/null
|
| +++ b/content/public/browser/notification_watcher.cc
|
| @@ -0,0 +1,37 @@
|
| +// 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.
|
| +
|
| +#include "content/public/browser/notification_watcher.h"
|
| +
|
| +#include "content/public/browser/notification_details.h"
|
| +#include "content/public/browser/notification_registrar.h"
|
| +#include "content/public/browser/notification_service.h"
|
| +#include "content/public/browser/notification_source.h"
|
| +
|
| +namespace content {
|
| +
|
| +NotificationWatcher::NotificationWatcher(int notification_type,
|
| + const ConditionTestCallback& callback)
|
| + : type_(notification_type),
|
| + callback_(callback) {
|
| +}
|
| +
|
| +void NotificationWatcher::Run() {
|
| + if (callback_.Run())
|
| + return;
|
| +
|
| + content::NotificationRegistrar registrar;
|
| + registrar.Add(this, type_, content::NotificationService::AllSources());
|
| + run_loop_.Run();
|
| +}
|
| +
|
| +void NotificationWatcher::Observe(
|
| + int type,
|
| + const content::NotificationSource& source,
|
| + const content::NotificationDetails& details) {
|
| + if (callback_.Run())
|
| + run_loop_.Quit();
|
| +}
|
| +
|
| +} // namespace content
|
|
|