1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "base/callback_helpers.h"
9 ScopedClosureRunner::ScopedClosureRunner() = default;
11 ScopedClosureRunner::ScopedClosureRunner(OnceClosure closure)
12 : closure_(std::move(closure)) {}
14 ScopedClosureRunner::ScopedClosureRunner(ScopedClosureRunner&& other)
15 : closure_(other.Release()) {}
17 ScopedClosureRunner& ScopedClosureRunner::operator=(
18 ScopedClosureRunner&& other) {
21 ReplaceClosure(other.Release());
26 ScopedClosureRunner::~ScopedClosureRunner() {
30 void ScopedClosureRunner::RunAndReset() {
32 std::move(closure_).Run();
35 void ScopedClosureRunner::ReplaceClosure(OnceClosure closure) {
36 closure_ = std::move(closure);
39 OnceClosure ScopedClosureRunner::Release() {
40 return std::move(closure_);