chromium/components/feed/core/v2/tasks/upload_actions_task.h

// Copyright 2020 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_FEED_CORE_V2_TASKS_UPLOAD_ACTIONS_TASK_H_
#define COMPONENTS_FEED_CORE_V2_TASKS_UPLOAD_ACTIONS_TASK_H_

#include <memory>
#include <optional>
#include <vector>

#include "base/functional/callback.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/raw_ref.h"
#include "base/memory/weak_ptr.h"
#include "components/feed/core/proto/v2/store.pb.h"
#include "components/feed/core/proto/v2/wire/feed_action.pb.h"
#include "components/feed/core/proto/v2/wire/upload_actions_request.pb.h"
#include "components/feed/core/proto/v2/wire/upload_actions_response.pb.h"
#include "components/feed/core/v2/enums.h"
#include "components/feed/core/v2/feed_network.h"
#include "components/feed/core/v2/feed_store.h"
#include "components/feed/core/v2/launch_reliability_logger.h"
#include "components/feed/core/v2/public/logging_parameters.h"
#include "components/feed/core/v2/types.h"
#include "components/offline_pages/task/task.h"

namespace feed {
class FeedStream;
class LaunchReliabilityLogger;

// Uploads user actions and returns a consistency token to be used for loading
// the stream later.
//
// Repeat while pending actions remain to be processed:
//   1. Gather as many actions as can fit in the request size limit. If we
//    encounter stale actions that should be erased, set those aside.
//   2. Increment upload_attempt_count for each action to be uploaded. Write
//    these actions back to the store and erase actions that should be erased.
//   3. Try to upload the batch of actions. If the upload is successful, get
//    the new consistency token and erase the uploaded actions from the store.
//
// If we have a new consistency token, it's the caller's responsibility to write
// it to storage.
class UploadActionsTask : public offline_pages::Task {};

}  // namespace feed

#endif  // COMPONENTS_FEED_CORE_V2_TASKS_UPLOAD_ACTIONS_TASK_H_