| OLD | NEW |
| (Empty) |
| 1 // Copyright 2017 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 #ifndef CONTENT_PUBLIC_TEST_REPEATED_NOTIFICATION_OBSERVER_H_ | |
| 6 #define CONTENT_PUBLIC_TEST_REPEATED_NOTIFICATION_OBSERVER_H_ | |
| 7 | |
| 8 #include "base/run_loop.h" | |
| 9 #include "content/public/browser/notification_observer.h" | |
| 10 #include "content/public/browser/notification_registrar.h" | |
| 11 | |
| 12 namespace content { | |
| 13 | |
| 14 // RepeatedNotificationObserver allows code to wait until specified number | |
| 15 // of notifications of particular type are posted. | |
| 16 class RepeatedNotificationObserver : public NotificationObserver { | |
| 17 public: | |
| 18 RepeatedNotificationObserver(int type, int count); | |
| 19 | |
| 20 // NotificationObserver: | |
| 21 void Observe(int type, | |
| 22 const NotificationSource& source, | |
| 23 const NotificationDetails& details) override; | |
| 24 | |
| 25 // Wait until |count| events of |type| (both specified in constructor) happen. | |
| 26 void Wait(); | |
| 27 | |
| 28 private: | |
| 29 int num_outstanding_; | |
| 30 NotificationRegistrar registrar_; | |
| 31 bool running_; | |
| 32 base::RunLoop run_loop_; | |
| 33 | |
| 34 DISALLOW_COPY_AND_ASSIGN(RepeatedNotificationObserver); | |
| 35 }; | |
| 36 | |
| 37 } // namespace content | |
| 38 | |
| 39 #endif // CONTENT_PUBLIC_TEST_REPEATED_NOTIFICATION_OBSERVER_H_ | |
| OLD | NEW |