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 #include "content/public/test/notification_watcher.h" | |
| 6 | |
| 7 #include "content/public/browser/notification_details.h" | |
| 8 #include "content/public/browser/notification_registrar.h" | |
| 9 #include "content/public/browser/notification_service.h" | |
| 10 #include "content/public/browser/notification_source.h" | |
| 11 | |
| 12 namespace content { | |
| 13 | |
| 14 NotificationWatcher::NotificationWatcher(int notification_type, | |
| 15 const ConditionTestCallback& callback) | |
| 16 : type_(notification_type), | |
| 17 callback_(callback) { | |
| 18 } | |
| 19 | |
| 20 NotificationWatcher::~NotificationWatcher() { | |
| 21 } | |
| 22 | |
| 23 void NotificationWatcher::Run() { | |
|
sky
2013/03/07 20:47:14
This class is effectively the same thing as Window
| |
| 24 if (callback_.Run()) | |
| 25 return; | |
| 26 | |
| 27 content::NotificationRegistrar registrar; | |
| 28 registrar.Add(this, type_, content::NotificationService::AllSources()); | |
| 29 run_loop_.Run(); | |
| 30 } | |
| 31 | |
| 32 void NotificationWatcher::Observe( | |
| 33 int type, | |
| 34 const content::NotificationSource& source, | |
| 35 const content::NotificationDetails& details) { | |
| 36 if (callback_.Run()) | |
| 37 run_loop_.Quit(); | |
| 38 } | |
| 39 | |
| 40 } // namespace content | |
| OLD | NEW |