// Copyright 2022 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef BASE_THREADING_SEQUENCE_BOUND_INTERNAL_H_ #define BASE_THREADING_SEQUENCE_BOUND_INTERNAL_H_ #include #include #include #include "base/compiler_specific.h" #include "base/functional/bind.h" #include "base/functional/callback.h" #include "base/functional/callback_helpers.h" #include "base/location.h" #include "base/memory/aligned_memory.h" #include "base/memory/raw_ptr.h" #include "base/task/sequenced_task_runner.h" namespace base::sequence_bound_internal { struct CrossThreadTraits { template using CrossThreadTask = OnceCallback; template static inline auto BindOnce(Functor&& functor, Args&&... args) { return ::base::BindOnce(std::forward(functor), std::forward(args)...); } template static inline auto Unretained(T ptr) { return ::base::Unretained(ptr); } static inline bool PostTask(SequencedTaskRunner& task_runner, const Location& location, OnceClosure&& task) { return task_runner.PostTask(location, std::move(task)); } static inline bool PostTaskAndReply(SequencedTaskRunner& task_runner, const Location& location, OnceClosure&& task, OnceClosure&& reply) { return task_runner.PostTaskAndReply(location, std::move(task), std::move(reply)); } template static inline bool PostTaskAndReplyWithResult( SequencedTaskRunner& task_runner, const Location& location, OnceCallback&& task, OnceCallback&& reply) { return task_runner.PostTaskAndReplyWithResult(location, std::move(task), std::move(reply)); } // Accept RepeatingCallback here since it's convertible to a OnceCallback. template