| OLD | NEW |
| 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 Loading... |
| 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 |
| OLD | NEW |