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 6df506a9da624091f1022c832177959b653ff929..ffefddab83a56bd08e0bcd174676f5c620e428d1 100644 |
--- a/chrome/browser/extensions/test_extension_prefs.cc |
+++ b/chrome/browser/extensions/test_extension_prefs.cc |
@@ -11,6 +11,7 @@ |
#include "base/message_loop.h" |
#include "base/message_loop_proxy.h" |
#include "base/synchronization/waitable_event.h" |
+#include "base/threading/sequenced_worker_pool.h" |
#include "base/values.h" |
#include "chrome/browser/extensions/extension_pref_store.h" |
#include "chrome/browser/extensions/extension_pref_value_map.h" |
@@ -54,9 +55,10 @@ class MockExtensionPrefs : public ExtensionPrefs { |
} // namespace |
-TestExtensionPrefs::TestExtensionPrefs() |
- : pref_service_(NULL), |
- extensions_disabled_(false) { |
+TestExtensionPrefs::TestExtensionPrefs( |
+ base::SequencedWorkerPool* blocking_pool) : pref_service_(NULL), |
+ extensions_disabled_(false) { |
+ blocking_pool_ = blocking_pool; |
EXPECT_TRUE(temp_dir_.CreateUniqueTempDir()); |
preferences_file_ = temp_dir_.path().AppendASCII("Preferences"); |
extensions_dir_ = temp_dir_.path().AppendASCII("Extensions"); |
@@ -65,36 +67,21 @@ TestExtensionPrefs::TestExtensionPrefs() |
RecreateExtensionPrefs(); |
} |
-TestExtensionPrefs::~TestExtensionPrefs() {} |
+TestExtensionPrefs::~TestExtensionPrefs() { |
+} |
void TestExtensionPrefs::RecreateExtensionPrefs() { |
// We persist and reload the PrefService's PrefStores because this process |
// deletes all empty dictionaries. The ExtensionPrefs implementation |
// needs to be able to handle this situation. |
if (pref_service_.get()) { |
- // 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_-> CommitPendingWrite(); |
- EXPECT_TRUE(BrowserThread::PostTask( |
- BrowserThread::FILE, |
- FROM_HERE, |
- base::Bind(&base::WaitableEvent::Signal, |
- base::Unretained(&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(); |
+ pref_service_->CommitPendingWrite(); |
+ blocking_pool_->FlushForTesting(); |
akalin
2012/10/18 23:52:24
i think you can replace the FlushForTesting call w
zel
2012/10/19 01:20:32
Done.
|
} |
extension_pref_value_map_.reset(new ExtensionPrefValueMap); |
PrefServiceMockBuilder builder; |
- builder.WithUserFilePrefs(preferences_file_); |
+ builder.WithUserFilePrefs(preferences_file_, blocking_pool_.get()); |
builder.WithExtensionPrefs( |
new ExtensionPrefStore(extension_pref_value_map_.get(), false)); |
pref_service_.reset(builder.Create()); |