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

Unified Diff: chrome/test/base/ui_test_utils.cc

Issue 573553004: Eliminate NOTIFICATION_HISTORY_LOADED notification (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: chrome/test/base/ui_test_utils.cc
diff --git a/chrome/test/base/ui_test_utils.cc b/chrome/test/base/ui_test_utils.cc
index 978835bd9958cd22f6f1da1cf3998e8e50da360d..0ec2bfcb8b0df310f17e7836e306aa7251635f7b 100644
--- a/chrome/test/base/ui_test_utils.cc
+++ b/chrome/test/base/ui_test_utils.cc
@@ -364,14 +364,6 @@ void WaitForTemplateURLServiceToLoad(TemplateURLService* service) {
ASSERT_TRUE(service->loaded());
}
-void WaitForHistoryToLoad(HistoryService* history_service) {
- content::WindowedNotificationObserver history_loaded_observer(
- chrome::NOTIFICATION_HISTORY_LOADED,
- content::NotificationService::AllSources());
- if (!history_service->BackendLoaded())
- history_loaded_observer.Wait();
-}
-
void DownloadURL(Browser* browser, const GURL& download_url) {
base::ScopedTempDir downloads_directory;
ASSERT_TRUE(downloads_directory.CreateUniqueTempDir());
@@ -581,4 +573,26 @@ void HistoryEnumerator::HistoryQueryComplete(
quit_task.Run();
}
+WaitHistoryLoadedObserver::WaitHistoryLoadedObserver(
+ content::MessageLoopRunner* runner)
+ : runner_(runner) {
+}
+
+WaitHistoryLoadedObserver::~WaitHistoryLoadedObserver() {
+}
+
+void WaitHistoryLoadedObserver::HistoryServiceLoaded(HistoryService* service) {
+ runner_->Quit();
+}
+
+void WaitForHistoryToLoad(HistoryService* history_service) {
+ if (!history_service->BackendLoaded()) {
+ scoped_refptr<content::MessageLoopRunner> runner =
+ new content::MessageLoopRunner;
+ WaitHistoryLoadedObserver observer(runner.get());
+ history_service->AddHistoryServiceObserver(&observer);
sdefresne 2014/10/20 13:15:42 Use ScopedObserver
nshaik 2014/10/29 08:43:39 Done.
+ runner->Run();
+ history_service->RemoveHistoryServiceObserver(&observer);
+ }
+}
} // namespace ui_test_utils

Powered by Google App Engine
This is Rietveld 408576698