This CL adds unit-tests for the SafeBrowsingBlockingPage class.
This required:
- creating a factory to create SafeBrowsingBlockingPage
  instances (so unit-tests can provide their own sub-classes).
- making the code posts tasks on the current message loop
  when there is no IO thread.  This should only happen in
  tests scenarios where we only have 1 thread.

BUG=6731
TEST=Run the unit-tests. In Chrome, navigate to pages flagged as malware (ex: ianfette.org) and make sure the safe browsing feature still works as expected.

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13088 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/safe_browsing/safe_browsing_service.cc b/chrome/browser/safe_browsing/safe_browsing_service.cc
index 47a19417..2f8f5ea 100644
--- a/chrome/browser/safe_browsing/safe_browsing_service.cc
+++ b/chrome/browser/safe_browsing/safe_browsing_service.cc
@@ -264,12 +264,14 @@
   if (!wc) {
     // The tab is gone and we did not have a chance at showing the interstitial.
     // Just act as "Don't Proceed" was chosen.
-    base::Thread* io_thread = g_browser_process->io_thread();
-    if (!io_thread)
-      return;
     std::vector<UnsafeResource> resources;
     resources.push_back(resource);
-    io_thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(
+    MessageLoop* message_loop;
+    if (g_browser_process->io_thread())
+      message_loop = g_browser_process->io_thread()->message_loop();
+    else  // For unit-tests, just post on the current thread.
+      message_loop = MessageLoop::current();
+    message_loop->PostTask(FROM_HERE, NewRunnableMethod(
         this, &SafeBrowsingService::OnBlockingPageDone, resources, false));
     return;
   }