0
Files
src/base/callback_helpers.cc
Chris Watkins bb7211cd37 Run clang-tidy modernize-use-equals-{delete,default} on //base
See the bugs and cxx post for justification and details:
https://groups.google.com/a/chromium.org/forum/#!topic/cxx/RkOHzIK6Tq8

This change was done using clang-tidy as described here:
https://chromium.googlesource.com/chromium/src/+/lkcr/docs/clang_tidy.md

In some cases the the tool leaves behind a string of commas where it
replaced a member initializer list
(https://bugs.llvm.org/show_bug.cgi?id=35051). They were cleaned up with:
  git diff --name-only | \
    xargs sed -E -i 's/(^\s*|\)\s*):[ ,]*= default/\1 = default/'

BUG=778959,778957

Change-Id: I95a3f3dae4796e4a7beb77793a6101f433a2c649
Reviewed-on: https://chromium-review.googlesource.com/789718
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Commit-Queue: Chris Watkins <watk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#520033}
2017-11-29 07:16:38 +00:00

41 lines
1004 B
C++

// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/callback_helpers.h"
namespace base {
ScopedClosureRunner::ScopedClosureRunner() = default;
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());
return *this;
}
void ScopedClosureRunner::RunAndReset() {
std::move(closure_).Run();
}
void ScopedClosureRunner::ReplaceClosure(OnceClosure closure) {
closure_ = std::move(closure);
}
OnceClosure ScopedClosureRunner::Release() {
return std::move(closure_);
}
} // namespace base