// Copyright 2015 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef COMPONENTS_SYNC_BASE_BIND_TO_TASK_RUNNER_H_
#define COMPONENTS_SYNC_BASE_BIND_TO_TASK_RUNNER_H_

#include <utility>

#include "base/functional/callback.h"
#include "base/location.h"
#include "base/task/bind_post_task.h"
#include "base/task/sequenced_task_runner.h"

// Helpers for using base::BindPostTask() with the TaskRunner for the current
// sequence, ie. base::SequencedTaskRunner::GetCurrentDefault().
namespace syncer {

template <typename T>
base::OnceCallback<T> BindToCurrentSequence(
    base::OnceCallback<T> callback,
    const base::Location& location = FROM_HERE) {
  return base::BindPostTaskToCurrentDefault(std::move(callback), location);
}

template <typename T>
base::RepeatingCallback<T> BindToCurrentSequence(
    base::RepeatingCallback<T> callback,
    const base::Location& location = FROM_HERE) {
  return base::BindPostTaskToCurrentDefault(std::move(callback), location);
}

}  // namespace syncer

#endif  // COMPONENTS_SYNC_BASE_BIND_TO_TASK_RUNNER_H_