#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 {
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 , std::string >>)>
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 ,
std::string >>)>
cb) { … }
void CallFinalizeOnSequence(
base::WeakPtr<FileUploadJob::Delegate> delegate,
std::string_view session_token,
base::OnceCallback<void(StatusOr<std::string >)> cb) { … }
}
FileUploadJob::Delegate::Delegate() = default;
FileUploadJob::Delegate::~Delegate() = default;
base::WeakPtr<FileUploadJob::Delegate> FileUploadJob::Delegate::GetWeakPtr() { … }
FileUploadJob::Manager* FileUploadJob::Manager::GetInstance() { … }
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 { … }
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::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 , std::string >>
result) { … }
void FileUploadJob::NextStep(const ScopedReservation& scoped_reservation,
base::OnceClosure done_cb) { … }
void FileUploadJob::DoneNextStep(
base::ScopedClosureRunner done,
StatusOr<std::pair<int64_t , std::string >>
result) { … }
void FileUploadJob::Finalize(base::OnceClosure done_cb) { … }
void FileUploadJob::DoneFinalize(
base::ScopedClosureRunner done,
StatusOr<std::string > result) { … }
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() { … }
}