Commit 9eb5b72b authored by danakj's avatar danakj Committed by Commit Bot

Move bind_helpers.h contents to callback_helpers.h

Followups will change includes and remove the header.

R=dcheng@chromium.org
TBR=davidben@chromium.org,dalecurtis@chromium.org

Change-Id: Idd1de7bd21102b389676eda7cabdadf866b94903
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2521248
Auto-Submit: danakj <danakj@chromium.org>
Reviewed-by: default avatarDale Curtis <dalecurtis@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Commit-Queue: Dale Curtis <dalecurtis@chromium.org>
Commit-Queue: danakj <danakj@chromium.org>
Cr-Commit-Position: refs/heads/master@{#825160}
parent 0db08480
...@@ -5,65 +5,6 @@ ...@@ -5,65 +5,6 @@
#ifndef BASE_BIND_HELPERS_H_ #ifndef BASE_BIND_HELPERS_H_
#define BASE_BIND_HELPERS_H_ #define BASE_BIND_HELPERS_H_
#include <stddef.h> #include "base/callback_helpers.h"
#include <type_traits>
#include <utility>
#include "base/bind.h"
#include "base/callback.h"
#include "base/memory/weak_ptr.h"
#include "build/build_config.h"
// This defines a set of simple functions and utilities that people want when
// using {Once,Repeating}Callback<> and Bind{Once,Repeating}().
namespace base {
// Creates a null callback.
class BASE_EXPORT NullCallback {
public:
template <typename R, typename... Args>
operator RepeatingCallback<R(Args...)>() const {
return RepeatingCallback<R(Args...)>();
}
template <typename R, typename... Args>
operator OnceCallback<R(Args...)>() const {
return OnceCallback<R(Args...)>();
}
};
// Creates a callback that does nothing when called.
class BASE_EXPORT DoNothing {
public:
template <typename... Args>
operator RepeatingCallback<void(Args...)>() const {
return Repeatedly<Args...>();
}
template <typename... Args>
operator OnceCallback<void(Args...)>() const {
return Once<Args...>();
}
// Explicit way of specifying a specific callback type when the compiler can't
// deduce it.
template <typename... Args>
static RepeatingCallback<void(Args...)> Repeatedly() {
return BindRepeating([](Args... args) {});
}
template <typename... Args>
static OnceCallback<void(Args...)> Once() {
return BindOnce([](Args... args) {});
}
};
// Useful for creating a Closure that will delete a pointer when invoked. Only
// use this when necessary. In most cases MessageLoop::DeleteSoon() is a better
// fit.
template <typename T>
void DeletePointer(T* obj) {
delete obj;
}
} // namespace base
#endif // BASE_BIND_HELPERS_H_ #endif // BASE_BIND_HELPERS_H_
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/callback.h" #include "base/callback.h"
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "base/memory/ptr_util.h"
namespace base { namespace base {
...@@ -137,6 +136,50 @@ class BASE_EXPORT ScopedClosureRunner { ...@@ -137,6 +136,50 @@ class BASE_EXPORT ScopedClosureRunner {
OnceClosure closure_; OnceClosure closure_;
}; };
// Creates a null callback.
class BASE_EXPORT NullCallback {
public:
template <typename R, typename... Args>
operator RepeatingCallback<R(Args...)>() const {
return RepeatingCallback<R(Args...)>();
}
template <typename R, typename... Args>
operator OnceCallback<R(Args...)>() const {
return OnceCallback<R(Args...)>();
}
};
// Creates a callback that does nothing when called.
class BASE_EXPORT DoNothing {
public:
template <typename... Args>
operator RepeatingCallback<void(Args...)>() const {
return Repeatedly<Args...>();
}
template <typename... Args>
operator OnceCallback<void(Args...)>() const {
return Once<Args...>();
}
// Explicit way of specifying a specific callback type when the compiler can't
// deduce it.
template <typename... Args>
static RepeatingCallback<void(Args...)> Repeatedly() {
return BindRepeating([](Args... args) {});
}
template <typename... Args>
static OnceCallback<void(Args...)> Once() {
return BindOnce([](Args... args) {});
}
};
// Useful for creating a Closure that will delete a pointer when invoked. Only
// use this when necessary. In most cases MessageLoop::DeleteSoon() is a better
// fit.
template <typename T>
void DeletePointer(T* obj) {
delete obj;
}
} // namespace base } // namespace base
#endif // BASE_CALLBACK_HELPERS_H_ #endif // BASE_CALLBACK_HELPERS_H_
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "base/callback_helpers.h" #include "base/callback_helpers.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_macros.h"
#include "base/threading/sequenced_task_runner_handle.h" #include "base/threading/sequenced_task_runner_handle.h"
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "base/callback_helpers.h" #include "base/callback_helpers.h"
#include "base/location.h" #include "base/location.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "build/chromeos_buildflags.h" #include "build/chromeos_buildflags.h"
#include "gpu/config/gpu_driver_bug_workarounds.h" #include "gpu/config/gpu_driver_bug_workarounds.h"
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "base/file_version_info.h" #include "base/file_version_info.h"
#include "base/location.h" #include "base/location.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "base/metrics/field_trial.h" #include "base/metrics/field_trial.h"
#include "base/metrics/histogram_functions.h" #include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_macros.h"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment