Fix a variety of small issues with ScopedClosureRunner.

* Explicit deletion of copy constructors not necessary when move
  constructors are given.
* No way to check if the runner had a closure inside.
* RunAndReset() crashed if called with no closure inside.
* operator=() failed to run the outgoing closure.

Bug: none
Change-Id: I8c92dfaca95619fe6661af10c018a75dae7e25ff
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2537787
Commit-Queue: Peter Kasting <[email protected]>
Reviewed-by: Avi Drissman <[email protected]>
Reviewed-by: danakj <[email protected]>
Auto-Submit: Peter Kasting <[email protected]>
Cr-Commit-Position: refs/heads/master@{#827526}
diff --git a/base/callback_helpers.cc b/base/callback_helpers.cc
index 9086731..d779869 100644
--- a/base/callback_helpers.cc
+++ b/base/callback_helpers.cc
@@ -11,22 +11,25 @@
 ScopedClosureRunner::ScopedClosureRunner(OnceClosure closure)
     : closure_(std::move(closure)) {}
 
-ScopedClosureRunner::~ScopedClosureRunner() {
-  if (!closure_.is_null())
-    std::move(closure_).Run();
-}
-
 ScopedClosureRunner::ScopedClosureRunner(ScopedClosureRunner&& other)
     : closure_(other.Release()) {}
 
 ScopedClosureRunner& ScopedClosureRunner::operator=(
     ScopedClosureRunner&& other) {
-  ReplaceClosure(other.Release());
+  if (this != &other) {
+    RunAndReset();
+    ReplaceClosure(other.Release());
+  }
   return *this;
 }
 
+ScopedClosureRunner::~ScopedClosureRunner() {
+  RunAndReset();
+}
+
 void ScopedClosureRunner::RunAndReset() {
-  std::move(closure_).Run();
+  if (closure_)
+    std::move(closure_).Run();
 }
 
 void ScopedClosureRunner::ReplaceClosure(OnceClosure closure) {