Avoid leaks at shutdown when running purify

We'll risk a (rare) crash under purify, but avoid having a leak detected.

Note that this "leak" at shutdown is NBD, but this code at least shows
that the would be leak is "understood" and acceptable.

bug=6532
r=erikkay
Review URL: http://codereview.chromium.org/42083

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@11473 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/base/message_loop.cc b/base/message_loop.cc
index a57946b..3f216dc9 100644
--- a/base/message_loop.cc
+++ b/base/message_loop.cc
@@ -365,15 +365,21 @@
       AddToDelayedWorkQueue(pending_task);
     } else {
       // TODO(darin): Delete all tasks once it is safe to do so.
-      //delete task;
+      // Until it is totally safe, just do it when running purify.
+#ifdef PURIFY
+      delete task;
+#endif  // PURIFY
     }
   }
   did_work |= !deferred_non_nestable_work_queue_.empty();
   while (!deferred_non_nestable_work_queue_.empty()) {
-    // TODO(darin): Delete all tasks once it is safe to do so.
-    //Task* task = deferred_non_nestable_work_queue_.front().task;
+    Task* task = deferred_non_nestable_work_queue_.front().task;
     deferred_non_nestable_work_queue_.pop();
-    //delete task;
+    // TODO(darin): Delete all tasks once it is safe to do so.
+    // Until it is totaly safe, just delete them to keep purify happy.
+#ifdef PURIFY
+    delete task;
+#endif
   }
   did_work |= !delayed_work_queue_.empty();
   while (!delayed_work_queue_.empty()) {