mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Update include/base headers for C++11/14 (see issue #3140)
See the issue for update guidelines.
This commit is contained in:
43
libcef_dll/base/cef_callback_helpers.cc
Normal file
43
libcef_dll/base/cef_callback_helpers.cc
Normal file
@ -0,0 +1,43 @@
|
||||
// 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 "include/base/cef_callback_helpers.h"
|
||||
|
||||
namespace base {
|
||||
|
||||
ScopedClosureRunner::ScopedClosureRunner() = default;
|
||||
|
||||
ScopedClosureRunner::ScopedClosureRunner(OnceClosure closure)
|
||||
: closure_(std::move(closure)) {}
|
||||
|
||||
ScopedClosureRunner::ScopedClosureRunner(ScopedClosureRunner&& other)
|
||||
: closure_(other.Release()) {}
|
||||
|
||||
ScopedClosureRunner& ScopedClosureRunner::operator=(
|
||||
ScopedClosureRunner&& other) {
|
||||
if (this != &other) {
|
||||
RunAndReset();
|
||||
ReplaceClosure(other.Release());
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
ScopedClosureRunner::~ScopedClosureRunner() {
|
||||
RunAndReset();
|
||||
}
|
||||
|
||||
void ScopedClosureRunner::RunAndReset() {
|
||||
if (closure_)
|
||||
std::move(closure_).Run();
|
||||
}
|
||||
|
||||
void ScopedClosureRunner::ReplaceClosure(OnceClosure closure) {
|
||||
closure_ = std::move(closure);
|
||||
}
|
||||
|
||||
OnceClosure ScopedClosureRunner::Release() {
|
||||
return std::move(closure_);
|
||||
}
|
||||
|
||||
} // namespace base
|
Reference in New Issue
Block a user