| Index: content/public/test/repeated_notification_observer.cc | 
| diff --git a/content/public/test/repeated_notification_observer.cc b/content/public/test/repeated_notification_observer.cc | 
| new file mode 100644 | 
| index 0000000000000000000000000000000000000000..f9e6a99904806bb90d4b3fea9efdf9c5e6eb1361 | 
| --- /dev/null | 
| +++ b/content/public/test/repeated_notification_observer.cc | 
| @@ -0,0 +1,38 @@ | 
| +// Copyright (c) 2017 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/repeated_notification_observer.h" | 
| + | 
| +#include "base/macros.h" | 
| +#include "content/public/browser/browser_thread.h" | 
| +#include "content/public/browser/notification_service.h" | 
| +#include "testing/gtest/include/gtest/gtest.h" | 
| + | 
| +namespace content { | 
| + | 
| +RepeatedNotificationObserver::RepeatedNotificationObserver(int type, int count) | 
| +    : num_outstanding_(count), running_(false) { | 
| +  registrar_.Add(this, type, NotificationService::AllSources()); | 
| +} | 
| + | 
| +void RepeatedNotificationObserver::Observe(int type, | 
| +                                           const NotificationSource& source, | 
| +                                           const NotificationDetails& details) { | 
| +  ASSERT_GT(num_outstanding_, 0); | 
| +  if (!--num_outstanding_ && running_) { | 
| +    BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 
| +                            run_loop_.QuitClosure()); | 
| +  } | 
| +} | 
| + | 
| +void RepeatedNotificationObserver::Wait() { | 
| +  if (num_outstanding_ <= 0) | 
| +    return; | 
| + | 
| +  running_ = true; | 
| +  run_loop_.Run(); | 
| +  running_ = false; | 
| +} | 
| + | 
| +}  // namespace content | 
|  |