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

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

Issue 2828403002: Revert of Revert "Revert of Reland: Switch WindowedNotificationObserver to use base::RunLoop.... (Closed)
Patch Set: 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 base::RunLoop run_loop; 197 scoped_refptr<content::MessageLoopRunner> runner(
198 quit_closure_ = run_loop.QuitClosure(); 198 new content::MessageLoopRunner);
199 quit_closure_ = runner->QuitClosure();
199 200
200 std::unique_ptr<base::CallbackList<void()>::Subscription> subscription; 201 std::unique_ptr<base::CallbackList<void()>::Subscription> subscription;
201 if (notification_set) { 202 if (notification_set) {
202 subscription = notification_set->callback_list().Add(base::Bind( 203 subscription = notification_set->callback_list().Add(base::Bind(
203 &ExtensionTestNotificationObserver::MaybeQuit, base::Unretained(this))); 204 &ExtensionTestNotificationObserver::MaybeQuit, base::Unretained(this)));
204 } 205 }
205 run_loop.Run(); 206 runner->Run();
206 207
207 condition_.Reset(); 208 condition_.Reset();
208 quit_closure_.Reset(); 209 quit_closure_.Reset();
209 } 210 }
210 211
211 void ExtensionTestNotificationObserver::MaybeQuit() { 212 void ExtensionTestNotificationObserver::MaybeQuit() {
212 if (condition_.Run()) 213 if (condition_.Run())
213 quit_closure_.Run(); 214 quit_closure_.Run();
214 } 215 }
215 216
216 } // namespace extensions 217 } // 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