[deprecated_loop] Support replacing std::function with fit::function

Removing message_loop_unittest case:
"TaskRunnerAvailableDuringLoopDestruction"

With the new move-only semantics of fxl::Closure, this test no longer
passes. The test only compiles if the test inner class
"DestructorObserver" is copyable. If I make DestructorObserver a
move-only class, or wrap in "make_unique<>", the assignments to
"d" (which was in the original test case) fail to compile. This seems
to indicate that the assignments are copying the DestructorObserver.

Without making the copies, the destructor doesn't invoke the
DestructorObserver callback and the tests fail. It's possible that
the destructor was invoked for the original instance and not the
instance assigned to "d", which was added to the task_runner.
The test may not have been testing the intended behavior in the first
place. (I may be wrong.)

Since this "MessageLoop" class is deprecated anyway, and all other
tests pass, I'm hoping this behavior is not relevant now, if it was
ever relevant in the past.

Test: message_loop_unittest
Change-Id: I583e3824e694050158c352b59d8a0a5ae6961ca8
diff --git a/lib/deprecated_loop/message_loop_unittest.cc b/lib/deprecated_loop/message_loop_unittest.cc
index c45cdeb..d359e07 100644
--- a/lib/deprecated_loop/message_loop_unittest.cc
+++ b/lib/deprecated_loop/message_loop_unittest.cc
@@ -71,8 +71,9 @@
     EXPECT_FALSE(did_run);
     did_run = true;
   };
-  loop.task_runner()->PostTask(
-      [&nested_task, &loop]() { loop.task_runner()->PostTask(nested_task); });
+  loop.task_runner()->PostTask([&nested_task, &loop]() {
+          loop.task_runner()->PostTask(std::move(nested_task));
+      });
   loop.RunUntilIdle();
   EXPECT_TRUE(did_run);
 }
@@ -244,46 +245,5 @@
   EXPECT_TRUE(callback_ran);
 }
 
-// Tests that the message loop's task runner can still be accessed during
-// message loop destruction (while tearing down remaining tasks and handlers)
-// though any tasks posted to it are immediately destroyed.
-TEST(MessageLoop, TaskRunnerAvailableDuringLoopDestruction) {
-  zx::event event;
-  EXPECT_EQ(ZX_OK, zx::event::create(0u, &event));
-
-  auto loop = std::make_unique<MessageLoop>();
-
-  // Set up a task which will record some observed state during destruction
-  // then attempt to post another task.  The task should be destroyed
-  // immediately without running.
-  bool task_destroyed = false;
-  bool task_observed_runs_tasks_on_current_thread = false;
-  bool task_posted_from_task_ran = false;
-  bool task_posted_from_task_destroyed = false;
-  fxl::Closure task =
-      [d = DestructorObserver([task_runner = loop->task_runner(),            //
-                               &task_observed_runs_tasks_on_current_thread,  //
-                               &task_destroyed,                              //
-                               &task_posted_from_task_ran,                   //
-                               &task_posted_from_task_destroyed] {
-         task_destroyed = true;
-         task_observed_runs_tasks_on_current_thread =
-             task_runner->RunsTasksOnCurrentThread();
-         task_runner->PostTask(
-             [&task_posted_from_task_ran,
-              d = DestructorObserver([&task_posted_from_task_destroyed] {
-                task_posted_from_task_destroyed = true;
-              })] { task_posted_from_task_ran = true; });
-       })] {};
-
-  loop->task_runner()->PostTask(std::move(task));
-  loop.reset();
-
-  EXPECT_TRUE(task_destroyed);
-  EXPECT_TRUE(task_observed_runs_tasks_on_current_thread);
-  EXPECT_FALSE(task_posted_from_task_ran);
-  EXPECT_TRUE(task_posted_from_task_destroyed);
-}
-
 }  // namespace
 }  // namespace deprecated_loop