chromium/components/autofill/core/browser/payments/wait_for_signal_or_timeout.h

// Copyright 2021 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_AUTOFILL_CORE_BROWSER_PAYMENTS_WAIT_FOR_SIGNAL_OR_TIMEOUT_H_
#define COMPONENTS_AUTOFILL_CORE_BROWSER_PAYMENTS_WAIT_FOR_SIGNAL_OR_TIMEOUT_H_

#include "base/functional/callback.h"
#include "base/memory/weak_ptr.h"
#include "base/sequence_checker.h"
#include "base/time/time.h"

// A WaitForSignalOrTimeout waits for Signal() or a time out and calls a
// callback when either of these happens for the first time.
//
// The WaitForSignalOrTimeout is Reset()-able and ensures that the callback will
// be called at most once (unless Reset() resets the state). The
// WaitForSignalOrTimeout can be destroyed at any time without negative
// side-effects. The callback won't be called in this case. If the Signal()
// arrives before a call for OnEventOrTimeOut(), the callback will be called
// immediately. If a second Signal() arrives, nothing happens. The
// WaitForSignalOrTimeout must be used on single task sequence.
//
// This class provides the bare minimum needed for a Payment task. If there are
// more use cases, feel free to spice it up and move it to base/.
class WaitForSignalOrTimeout {};

#endif  // COMPONENTS_AUTOFILL_CORE_BROWSER_PAYMENTS_WAIT_FOR_SIGNAL_OR_TIMEOUT_H_