ImportantFileWriter: check return value of PostTask
when writing to the disk, so we can be sure it doesn't lose data.

Also fix tests that misused things.

TEST=none
BUG=none

Review URL: http://codereview.chromium.org/6627060

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@77695 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/profiles/profile_manager_unittest.cc b/chrome/browser/profiles/profile_manager_unittest.cc
index 57bba48..81c99bba 100644
--- a/chrome/browser/profiles/profile_manager_unittest.cc
+++ b/chrome/browser/profiles/profile_manager_unittest.cc
@@ -20,7 +20,9 @@
 
 class ProfileManagerTest : public testing::Test {
  protected:
-  ProfileManagerTest() : ui_thread_(BrowserThread::UI, &message_loop_) {
+  ProfileManagerTest()
+      : ui_thread_(BrowserThread::UI, &message_loop_),
+        file_thread_(BrowserThread::FILE, &message_loop_) {
   }
 
   virtual void SetUp() {
@@ -40,6 +42,7 @@
 
   MessageLoopForUI message_loop_;
   BrowserThread ui_thread_;
+  BrowserThread file_thread_;
 
   // the path to temporary directory used to contain the test operations
   FilePath test_dir_;
@@ -140,8 +143,13 @@
   EXPECT_TRUE(profile1->GetBookmarkModel());
   EXPECT_TRUE(profile2->GetBookmarkModel());
   EXPECT_TRUE(profile2->GetHistoryService(Profile::EXPLICIT_ACCESS));
+
+  // Make sure any pending tasks run before we destroy the profiles.
+  message_loop_.RunAllPending();
+
   profile1.reset();
   profile2.reset();
+
   // Make sure history cleans up correctly.
   message_loop_.RunAllPending();
 }