Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(191)

Side by Side Diff: content/public/test/repeated_notification_observer.cc

Issue 2798143004: Fix for URL opening code (Closed)
Patch Set: Simplified PRE_test checking Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2017 The Chromium Authors. All rights reserved.
sky 2017/06/08 19:17:49 no (c)
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/repeated_notification_observer.h"
6
7 #include "base/macros.h"
8 #include "content/public/browser/browser_thread.h"
9 #include "content/public/browser/notification_service.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11
12 namespace content {
13
14 RepeatedNotificationObserver::RepeatedNotificationObserver(int type, int count)
15 : num_outstanding_(count), running_(false) {
16 registrar_.Add(this, type, NotificationService::AllSources());
17 }
18
19 void RepeatedNotificationObserver::Observe(int type,
20 const NotificationSource& source,
21 const NotificationDetails& details) {
22 ASSERT_GT(num_outstanding_, 0);
23 if (!--num_outstanding_ && running_) {
24 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
sky 2017/06/08 19:17:49 Can't you call run_loop_.Quit (or QuitWhenIdle())
25 run_loop_.QuitClosure());
26 }
27 }
28
29 void RepeatedNotificationObserver::Wait() {
30 if (num_outstanding_ <= 0)
31 return;
32
33 running_ = true;
sky 2017/06/08 19:17:49 base::AutoReset.
eugenebng 2017/06/09 13:16:22 Done.
34 run_loop_.Run();
35 running_ = false;
36 }
37
38 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698