Convert base::ScopedClosureRunner to use OnceCallback

After this CL, ScopedClosureRunner uses base::OnceClosure as its internal
callback object. That implies it gets able to take base::OnceClosure in
addition to base::Closure, and ScopedClosureRunner::Release returns
base::OnceClosure instead of base::Closure.

Bug: 714018
Change-Id: I031ef7b70bc9673ea7781e292719e26ddc74b1a7
Reviewed-on: https://chromium-review.googlesource.com/597090
Reviewed-by: Daniel Cheng <[email protected]>
Reviewed-by: Alexander Alekseev <[email protected]>
Reviewed-by: Kazuhiro Inaba <[email protected]>
Reviewed-by: Zijie He <[email protected]>
Reviewed-by: Gabriel Charette <[email protected]>
Reviewed-by: Peter Beverloo <[email protected]>
Commit-Queue: Taiju Tsuiki <[email protected]>
Cr-Commit-Position: refs/heads/master@{#492538}
diff --git a/base/callback_helpers.cc b/base/callback_helpers.cc
index 838e6c8d..1f87a6c 100644
--- a/base/callback_helpers.cc
+++ b/base/callback_helpers.cc
@@ -4,18 +4,16 @@
 
 #include "base/callback_helpers.h"
 
-#include "base/callback.h"
-
 namespace base {
 
 ScopedClosureRunner::ScopedClosureRunner() {}
 
-ScopedClosureRunner::ScopedClosureRunner(const Closure& closure)
-    : closure_(closure) {}
+ScopedClosureRunner::ScopedClosureRunner(OnceClosure closure)
+    : closure_(std::move(closure)) {}
 
 ScopedClosureRunner::~ScopedClosureRunner() {
   if (!closure_.is_null())
-    closure_.Run();
+    std::move(closure_).Run();
 }
 
 ScopedClosureRunner::ScopedClosureRunner(ScopedClosureRunner&& other)
@@ -28,19 +26,15 @@
 }
 
 void ScopedClosureRunner::RunAndReset() {
-  Closure old_closure = Release();
-  if (!old_closure.is_null())
-    old_closure.Run();
+  std::move(closure_).Run();
 }
 
-void ScopedClosureRunner::ReplaceClosure(const Closure& closure) {
-  closure_ = closure;
+void ScopedClosureRunner::ReplaceClosure(OnceClosure closure) {
+  closure_ = std::move(closure);
 }
 
-Closure ScopedClosureRunner::Release() {
-  Closure result = closure_;
-  closure_.Reset();
-  return result;
+OnceClosure ScopedClosureRunner::Release() {
+  return std::move(closure_);
 }
 
 }  // namespace base