#include "chrome/browser/policy/messaging_layer/util/upload_response_parser.h"
#include <cstddef>
#include <cstdint>
#include <optional>
#include <string>
#include <utility>
#include "base/base64.h"
#include "base/feature_list.h"
#include "base/metrics/histogram_functions.h"
#include "base/strings/strcat.h"
#include "base/strings/string_number_conversions.h"
#include "base/token.h"
#include "base/types/expected.h"
#include "base/types/expected_macros.h"
#include "base/uuid.h"
#include "base/values.h"
#include "chrome/browser/policy/messaging_layer/upload/record_upload_request_builder.h"
#include "components/reporting/proto/synced/configuration_file.pb.h"
#include "components/reporting/util/encrypted_reporting_json_keys.h"
#include "components/reporting/util/reporting_errors.h"
#include "components/reporting/util/status.h"
#include "components/reporting/util/status_macros.h"
#include "components/reporting/util/statusor.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
namespace reporting {
namespace {
std::optional<Priority> GetPriorityProtoFromSequenceInformationValue(
const base::Value::Dict& sequence_information) { … }
StatusOr<std::tuple<int64_t, int64_t>> ParseSequencingIdAndGenerationId(
const std::string* sequencing_id,
const std::string* generation_id) { … }
StatusOr<Destination> GetDestinationProto(
const std::string& destination_string) { … }
StatusOr<ConfigFile> GetConfigurationProtoFromDict(
const base::Value::Dict& file) { … }
}
UploadResponseParser::UploadResponseParser(bool is_generation_guid_required,
base::Value::Dict response)
: … { … }
UploadResponseParser::UploadResponseParser(UploadResponseParser&& other) =
default;
UploadResponseParser& UploadResponseParser::operator=(
UploadResponseParser&& other) = default;
UploadResponseParser::~UploadResponseParser() = default;
StatusOr<SequenceInformation>
UploadResponseParser::last_successfully_uploaded_record_sequence_info() const { … }
StatusOr<SignedEncryptionInfo> UploadResponseParser::encryption_settings()
const { … }
StatusOr<ConfigFile> UploadResponseParser::config_file() const { … }
StatusOr<EncryptedRecord>
UploadResponseParser::gap_record_for_permanent_failure() const { … }
bool UploadResponseParser::force_confirm_flag() const { … }
bool UploadResponseParser::enable_upload_size_adjustment() const { … }
#if BUILDFLAG(IS_CHROMEOS)
bool GenerationGuidIsValid(bool is_generation_guid_required,
const std::string& generation_guid) {
if (generation_guid.empty() && !is_generation_guid_required) {
return true;
}
return base::Uuid::ParseCaseInsensitive(generation_guid).is_valid();
}
bool IsMissingGenerationGuid(bool is_generation_guid_required,
const std::string* generation_guid) {
if (!is_generation_guid_required) {
return false;
}
return !generation_guid || generation_guid->empty();
}
#endif
bool IsMissingSequenceInformation(bool is_generation_guid_required,
const std::string* sequencing_id,
const std::string* generation_id,
const std::optional<Priority> priority_result,
const std::string* generation_guid) { … }
StatusOr<SequenceInformation>
UploadResponseParser::SequenceInformationValueToProto(
bool is_generation_guid_required,
const base::Value::Dict& sequence_information_dict) { … }
StatusOr<EncryptedRecord>
UploadResponseParser::HandleFailedUploadedSequenceInformation(
bool is_generation_guid_required,
const SequenceInformation& highest_sequence_information,
const base::Value::Dict& sequence_information_dict) { … }
}