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

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

Issue 2798143004: Fix for URL opening code (Closed)
Patch Set: Fixed class name usage. 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
« no previous file with comments | « content/public/test/repeated_notification_observer.h ('k') | content/test/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 #include "content/public/test/repeated_notification_observer.h"
6
7 #include "base/auto_reset.h"
8 #include "base/macros.h"
9 #include "content/public/browser/browser_thread.h"
10 #include "content/public/browser/notification_service.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12
13 namespace content {
14
15 RepeatedNotificationObserver::RepeatedNotificationObserver(int type, int count)
16 : num_outstanding_(count), running_(false) {
17 registrar_.Add(this, type, NotificationService::AllSources());
18 }
19
20 void RepeatedNotificationObserver::Observe(int type,
21 const NotificationSource& source,
22 const NotificationDetails& details) {
23 ASSERT_GT(num_outstanding_, 0);
24 if (!--num_outstanding_ && running_)
25 run_loop_.QuitWhenIdle();
26 }
27
28 void RepeatedNotificationObserver::Wait() {
29 if (num_outstanding_ <= 0)
30 return;
31
32 {
33 DCHECK(!running_);
34 base::AutoReset<bool> auto_reset(&running_, true);
35 run_loop_.Run();
36 }
37 }
38
39 } // namespace content
OLDNEW
« no previous file with comments | « content/public/test/repeated_notification_observer.h ('k') | content/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698