chromium/chrome/browser/ui/views/web_apps/isolated_web_apps/callback_delayer.h

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

#ifndef CHROME_BROWSER_UI_VIEWS_WEB_APPS_ISOLATED_WEB_APPS_CALLBACK_DELAYER_H_
#define CHROME_BROWSER_UI_VIEWS_WEB_APPS_ISOLATED_WEB_APPS_CALLBACK_DELAYER_H_

#include <memory>

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

namespace web_app {

class Stopwatch;

// Buffers the execution of a callback until a minimum amount of time has
// passed, pausing the timer at a configurable percentage if the incoming
// callback hasn't been invoked. A progress update callback will be invoked at
// 60hz while the timer is running.
//
// Usage example:
//  CallbackDelayer delayer(base::Seconds(3), 0.8,
//                          base::BindOnce(&UpdateProgressBar, ...));
//  long_task->Run(delayer.StartDelayingCallback(
//      base::BindOnce(&OnLongTaskComplete, ...)));
class CallbackDelayer {};

}  // namespace web_app

#endif  // CHROME_BROWSER_UI_VIEWS_WEB_APPS_ISOLATED_WEB_APPS_CALLBACK_DELAYER_H_