Index: content/public/test/notification_watcher.cc |
diff --git a/content/public/test/notification_watcher.cc b/content/public/test/notification_watcher.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..419abc0180b1a34ead0008a50d245e83a61b049e |
--- /dev/null |
+++ b/content/public/test/notification_watcher.cc |
@@ -0,0 +1,40 @@ |
+// 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/test/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) { |
+} |
+ |
+NotificationWatcher::~NotificationWatcher() { |
+} |
+ |
+void NotificationWatcher::Run() { |
sky
2013/03/07 20:47:14
This class is effectively the same thing as Window
|
+ 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 |