// Copyright 2018 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. #ifndef BASE_THREADING_SEQUENCE_BOUND_H_ #define BASE_THREADING_SEQUENCE_BOUND_H_ #include #include #include #include #include "base/bind.h" #include "base/callback.h" #include "base/callback_helpers.h" #include "base/compiler_specific.h" #include "base/location.h" #include "base/memory/aligned_memory.h" #include "base/memory/ptr_util.h" #include "base/memory/scoped_refptr.h" #include "base/run_loop.h" #include "base/sequence_checker.h" #include "base/sequenced_task_runner.h" #include "base/threading/sequenced_task_runner_handle.h" namespace base { namespace internal { struct DefaultCrossThreadBindTraits { 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); } template static inline bool PostTask(SequencedTaskRunner& task_runner, const Location& location, CrossThreadTask&& 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