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

Side by Side Diff: extensions/test/extension_test_notification_observer.cc

Issue 2740783003: Revert "Revert of Reland: Switch WindowedNotificationObserver to use base::RunLoop. (patchset #3 id… (Closed)
Patch Set: Fix comment. Created 3 years, 8 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/test_utils.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "extensions/test/extension_test_notification_observer.h" 5 #include "extensions/test/extension_test_notification_observer.h"
6 6
7 #include "content/public/browser/browser_context.h" 7 #include "content/public/browser/browser_context.h"
8 #include "content/public/browser/notification_details.h" 8 #include "content/public/browser/notification_details.h"
9 #include "content/public/browser/notification_registrar.h" 9 #include "content/public/browser/notification_registrar.h"
10 #include "content/public/browser/notification_service.h" 10 #include "content/public/browser/notification_service.h"
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 registry_observer_.RemoveAll(); 187 registry_observer_.RemoveAll();
188 } 188 }
189 189
190 void ExtensionTestNotificationObserver::WaitForCondition( 190 void ExtensionTestNotificationObserver::WaitForCondition(
191 const ConditionCallback& condition, 191 const ConditionCallback& condition,
192 NotificationSet* notification_set) { 192 NotificationSet* notification_set) {
193 if (condition.Run()) 193 if (condition.Run())
194 return; 194 return;
195 condition_ = condition; 195 condition_ = condition;
196 196
197 scoped_refptr<content::MessageLoopRunner> runner( 197 base::RunLoop run_loop;
198 new content::MessageLoopRunner); 198 quit_closure_ = run_loop.QuitClosure();
199 quit_closure_ = runner->QuitClosure();
200 199
201 std::unique_ptr<base::CallbackList<void()>::Subscription> subscription; 200 std::unique_ptr<base::CallbackList<void()>::Subscription> subscription;
202 if (notification_set) { 201 if (notification_set) {
203 subscription = notification_set->callback_list().Add(base::Bind( 202 subscription = notification_set->callback_list().Add(base::Bind(
204 &ExtensionTestNotificationObserver::MaybeQuit, base::Unretained(this))); 203 &ExtensionTestNotificationObserver::MaybeQuit, base::Unretained(this)));
205 } 204 }
206 runner->Run(); 205 run_loop.Run();
207 206
208 condition_.Reset(); 207 condition_.Reset();
209 quit_closure_.Reset(); 208 quit_closure_.Reset();
210 } 209 }
211 210
212 void ExtensionTestNotificationObserver::MaybeQuit() { 211 void ExtensionTestNotificationObserver::MaybeQuit() {
213 if (condition_.Run()) 212 if (condition_.Run())
214 quit_closure_.Run(); 213 quit_closure_.Run();
215 } 214 }
216 215
217 } // namespace extensions 216 } // namespace extensions
OLDNEW
« no previous file with comments | « content/public/test/test_utils.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698