[M94 Dev][Tizen] Fix for errors for generating ninja files
[platform/framework/web/chromium-efl.git] / base / callback_helpers.cc
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.
4
5 #include "base/callback_helpers.h"
6
7 namespace base {
8
9 ScopedClosureRunner::ScopedClosureRunner() = default;
10
11 ScopedClosureRunner::ScopedClosureRunner(OnceClosure closure)
12     : closure_(std::move(closure)) {}
13
14 ScopedClosureRunner::ScopedClosureRunner(ScopedClosureRunner&& other)
15     : closure_(other.Release()) {}
16
17 ScopedClosureRunner& ScopedClosureRunner::operator=(
18     ScopedClosureRunner&& other) {
19   if (this != &other) {
20     RunAndReset();
21     ReplaceClosure(other.Release());
22   }
23   return *this;
24 }
25
26 ScopedClosureRunner::~ScopedClosureRunner() {
27   RunAndReset();
28 }
29
30 void ScopedClosureRunner::RunAndReset() {
31   if (closure_)
32     std::move(closure_).Run();
33 }
34
35 void ScopedClosureRunner::ReplaceClosure(OnceClosure closure) {
36   closure_ = std::move(closure);
37 }
38
39 OnceClosure ScopedClosureRunner::Release() {
40   return std::move(closure_);
41 }
42
43 }  // namespace base