chromium/chrome/browser/cart/fetch_discount_worker.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 CHROME_BROWSER_CART_FETCH_DISCOUNT_WORKER_H_
#define CHROME_BROWSER_CART_FETCH_DISCOUNT_WORKER_H_

#include <memory>

#include "base/memory/raw_ptr.h"
#include "base/memory/scoped_refptr.h"
#include "base/memory/weak_ptr.h"
#include "base/task/sequenced_task_runner.h"
#include "chrome/browser/cart/cart_discount_fetcher.h"
#include "chrome/browser/cart/cart_service.h"
#include "chrome/browser/commerce/coupons/coupon_service.h"
#include "components/signin/public/identity_manager/primary_account_access_token_fetcher.h"

namespace network {
class SharedURLLoaderFactory;
class PendingSharedURLLoaderFactory;
}  // namespace network

namespace signin {
class IdentityManager;
}  // namespace signin

namespace variations {
class VariationsClient;
}  // namespace variations

// Delegate class that enables FetchDiscountWorker to use discount-related
// functionalities from CartService.
class CartDiscountServiceDelegate {};

// This is used to fetch discounts for active Carts in cart_db. It starts
// to work after calling Start() and continue to work util Chrome is finished.
// The flow looks as follow:
//
//   UI Thread              | backend_task_runner_
//  ===========================================
// 1) Start                 |
// 2) PrepareToFetch (delay)|
// 3) ReadyToFetch          |
// 4)                       | FetchInBackground
// 5)                       | DoneFetchingInBackground
// 6) AfterDiscountFetched  |
// 7) OnUpdatingDiscounts   |
// 8) Start                 |

// TODO(meiliang): Add an API to allow ending the work earlier. e.g. when user
// has hidden the cart module.
class FetchDiscountWorker {};

#endif  // CHROME_BROWSER_CART_FETCH_DISCOUNT_WORKER_H_