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

Unified Diff: chrome/browser/extensions/test_extension_prefs.cc

Issue 8274012: Wait for URLBlacklist update tasks on automation tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added BrowserThread::WaitForPendingTasksOn, removed SignalingTask Created 9 years, 2 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/browser/extensions/test_extension_prefs.cc
diff --git a/chrome/browser/extensions/test_extension_prefs.cc b/chrome/browser/extensions/test_extension_prefs.cc
index a8eb4445174542d689f2a17d951ee1f88d61d215..6f72d56bb755031d69ff8a2a5687ff5dba771556 100644
--- a/chrome/browser/extensions/test_extension_prefs.cc
+++ b/chrome/browser/extensions/test_extension_prefs.cc
@@ -9,7 +9,6 @@
#include "base/message_loop.h"
#include "base/message_loop_proxy.h"
#include "base/values.h"
-#include "base/synchronization/waitable_event.h"
#include "chrome/browser/extensions/extension_pref_store.h"
#include "chrome/browser/extensions/extension_pref_value_map.h"
#include "chrome/browser/extensions/extension_prefs.h"
@@ -19,7 +18,6 @@
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_constants.h"
#include "chrome/common/json_pref_store.h"
-#include "chrome/test/base/signaling_task.h"
#include "content/browser/browser_thread.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -69,18 +67,12 @@ void TestExtensionPrefs::RecreateExtensionPrefs() {
// The PrefService writes its persistent file on the file thread, so we
// need to wait for any pending I/O to complete before creating a new
// PrefService.
- base::WaitableEvent io_finished(false, false);
pref_service_->SavePersistentPrefs();
- EXPECT_TRUE(BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
- new SignalingTask(&io_finished)));
-
- // If the FILE thread is in fact the current thread (possible in testing
- // scenarios), we have to ensure the task has a chance to run. If the FILE
- // thread is a different thread, the test must ensure that thread is running
- // (otherwise the Wait below will hang).
- MessageLoop::current()->RunAllPending();
-
- io_finished.Wait();
+ if (!BrowserThread::WaitForPendingTasksOn(BrowserThread::DB)) {
+ // If the FILE thread is in fact the current thread (possible in testing
+ // scenarios), we have to ensure the task is executed before proceeding.
+ MessageLoop::current()->RunAllPending();
+ }
}
extension_pref_value_map_.reset(new ExtensionPrefValueMap);

Powered by Google App Engine
This is Rietveld 408576698