chromium/chrome/browser/policy/messaging_layer/upload/file_upload_job.cc

// 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.

#include "chrome/browser/policy/messaging_layer/upload/file_upload_job.h"

#include <memory>
#include <string>
#include <string_view>
#include <tuple>
#include <utility>

#include "base/functional/bind.h"
#include "base/functional/callback_forward.h"
#include "base/functional/callback_helpers.h"
#include "base/location.h"
#include "base/memory/ptr_util.h"
#include "base/memory/weak_ptr.h"
#include "base/metrics/histogram_functions.h"
#include "base/no_destructor.h"
#include "base/sequence_checker.h"
#include "base/strings/strcat.h"
#include "base/strings/string_number_conversions.h"
#include "base/task/bind_post_task.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/task_traits.h"
#include "base/task/thread_pool.h"
#include "base/types/expected.h"
#include "chrome/browser/policy/messaging_layer/proto/synced/log_upload_event.pb.h"
#include "chrome/browser/policy/messaging_layer/public/report_client.h"
#include "components/reporting/proto/synced/record.pb.h"
#include "components/reporting/proto/synced/record_constants.pb.h"
#include "components/reporting/proto/synced/upload_tracker.pb.h"
#include "components/reporting/resources/resource_manager.h"
#include "components/reporting/storage/storage_module_interface.h"
#include "components/reporting/util/reporting_errors.h"
#include "components/reporting/util/status.h"

namespace reporting {

namespace {

// These three helpers call `Initiate`, `NextStep` and `Finalize` in
// delegate on respective task runner and make sure to call `cb` even if
// `delegate` is invalidated.
void CallInitiateOnSequence(
    base::WeakPtr<FileUploadJob::Delegate> delegate,
    std::string_view origin_path,
    std::string_view upload_parameters,
    base::OnceCallback<void(
        StatusOr<std::pair<int64_t /*total*/, std::string /*session_token*/>>)>
        cb) {}

void CallNextStepOnSequence(
    base::WeakPtr<FileUploadJob::Delegate> delegate,
    int64_t total,
    int64_t uploaded,
    std::string_view session_token,
    ScopedReservation scoped_reservation,
    base::OnceCallback<void(StatusOr<std::pair<int64_t /*uploaded*/,
                                               std::string /*session_token*/>>)>
        cb) {}

void CallFinalizeOnSequence(
    base::WeakPtr<FileUploadJob::Delegate> delegate,
    std::string_view session_token,
    base::OnceCallback<void(StatusOr<std::string /*access_parameters*/>)> cb) {}
}  // namespace

// Delegate base class implementation.

FileUploadJob::Delegate::Delegate() = default;
FileUploadJob::Delegate::~Delegate() = default;

base::WeakPtr<FileUploadJob::Delegate> FileUploadJob::Delegate::GetWeakPtr() {}

// Manager implementation.

// static
FileUploadJob::Manager* FileUploadJob::Manager::GetInstance() {}

// static
std::unique_ptr<FileUploadJob::Manager>&
FileUploadJob::Manager::instance_ref() {}

FileUploadJob::Manager::Manager()
    :{}

FileUploadJob::Manager::~Manager() = default;

void FileUploadJob::Manager::Register(
    Priority priority,
    Record record_copy,
    ::ash::reporting::LogUploadEvent log_upload_event,
    Delegate::SmartPtr delegate,
    base::OnceCallback<void(StatusOr<FileUploadJob*>)> result_cb) {}

scoped_refptr<base::SequencedTaskRunner>
FileUploadJob::Manager::sequenced_task_runner() const {}

// EventHelper implementation.

FileUploadJob::EventHelper::EventHelper(
    base::WeakPtr<FileUploadJob> job,
    Priority priority,
    Record record_copy,
    ::ash::reporting::LogUploadEvent log_upload_event)
    :{}

FileUploadJob::EventHelper::~EventHelper() {}

void FileUploadJob::EventHelper::Run(
    const ScopedReservation& scoped_reservation,
    base::OnceCallback<void(Status)> done_cb) {}

void FileUploadJob::EventHelper::Complete(Status status) {}

void FileUploadJob::EventHelper::RepostAndComplete() {}

void FileUploadJob::EventHelper::PostRetry() const {}

// FileUploadJob implementation.

FileUploadJob::FileUploadJob(const UploadSettings& settings,
                             const UploadTracker& tracker,
                             Delegate::SmartPtr delegate)
    :{}

FileUploadJob::~FileUploadJob() = default;

base::ScopedClosureRunner FileUploadJob::CompletionCb(
    base::OnceClosure done_cb) {}

void FileUploadJob::Initiate(base::OnceClosure done_cb) {}

void FileUploadJob::DoneInitiate(
    base::ScopedClosureRunner done,
    StatusOr<std::pair<int64_t /*total*/, std::string /*session_token*/>>
        result) {}

void FileUploadJob::NextStep(const ScopedReservation& scoped_reservation,
                             base::OnceClosure done_cb) {}

void FileUploadJob::DoneNextStep(
    base::ScopedClosureRunner done,
    StatusOr<std::pair<int64_t /*uploaded*/, std::string /*session_token*/>>
        result) {}

void FileUploadJob::Finalize(base::OnceClosure done_cb) {}

void FileUploadJob::DoneFinalize(
    base::ScopedClosureRunner done,
    StatusOr<std::string /*access_parameters*/> result) {}

// static
void FileUploadJob::AddRecordToStorage(
    Priority priority,
    Record record_copy,
    base::OnceCallback<void(Status)> done_cb) {}

void FileUploadJob::SetEventHelperForTest(
    std::unique_ptr<FileUploadJob::EventHelper> event_helper) {}

FileUploadJob::EventHelper* FileUploadJob::event_helper() const {}

const UploadSettings& FileUploadJob::settings() const {}

const UploadTracker& FileUploadJob::tracker() const {}

base::WeakPtr<FileUploadJob> FileUploadJob::GetWeakPtr() {}
}  // namespace reporting