From 1a96551a279242efef41468357e38d3091e884bc Mon Sep 17 00:00:00 2001 From: Anton Bikineev Date: Sat, 15 May 2021 22:35:36 +0000 Subject: components: Replace base::Optional and friends with absl counterparts This replaces: - base::Optional -> absl::optional - include "base/optional.h" -> include "third_party/abseil-cpp/absl/types/optional.h" - base::nullopt -> absl::nullopt - base::make_optional -> absl::make_optional Bug: 1202909 Change-Id: If697b7bf69b199c1796f873eedca3359cdb48c64 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2897151 Commit-Queue: Anton Bikineev Owners-Override: Anton Bikineev Reviewed-by: Peter Kasting Cr-Commit-Position: refs/heads/master@{#883296} NOKEYCHECK=True GitOrigin-RevId: 1156b5f891de178171e71b9221a96bef1ced3d3b --- patch_reader.cc | 56 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) (limited to 'patch_reader.cc') diff --git a/patch_reader.cc b/patch_reader.cc index 3ec17e4..99951da 100644 --- a/patch_reader.cc +++ b/patch_reader.cc @@ -78,42 +78,42 @@ bool EquivalenceSource::Initialize(BufferSource* source) { patch::ParseBuffer(source, ©_count_); } -base::Optional EquivalenceSource::GetNext() { +absl::optional EquivalenceSource::GetNext() { if (src_skip_.empty() || dst_skip_.empty() || copy_count_.empty()) - return base::nullopt; + return absl::nullopt; Equivalence equivalence = {}; uint32_t length = 0; if (!patch::ParseVarUInt(©_count_, &length)) - return base::nullopt; + return absl::nullopt; equivalence.length = base::strict_cast(length); int32_t src_offset_diff = 0; // Intentionally signed. if (!patch::ParseVarInt(&src_skip_, &src_offset_diff)) - return base::nullopt; + return absl::nullopt; base::CheckedNumeric src_offset = previous_src_offset_ + src_offset_diff; if (!src_offset.IsValid()) - return base::nullopt; + return absl::nullopt; equivalence.src_offset = src_offset.ValueOrDie(); previous_src_offset_ = src_offset + equivalence.length; if (!previous_src_offset_.IsValid()) - return base::nullopt; + return absl::nullopt; uint32_t dst_offset_diff = 0; // Intentionally unsigned. if (!patch::ParseVarUInt(&dst_skip_, &dst_offset_diff)) - return base::nullopt; + return absl::nullopt; base::CheckedNumeric dst_offset = previous_dst_offset_ + dst_offset_diff; if (!dst_offset.IsValid()) - return base::nullopt; + return absl::nullopt; equivalence.dst_offset = dst_offset.ValueOrDie(); previous_dst_offset_ = equivalence.dst_offset + equivalence.length; if (!previous_dst_offset_.IsValid()) - return base::nullopt; + return absl::nullopt; // Caveat: |equivalence| is assumed to be safe only once the // ValidateEquivalencesAndExtraData() method has returned true. Prior to this @@ -131,10 +131,10 @@ bool ExtraDataSource::Initialize(BufferSource* source) { return patch::ParseBuffer(source, &extra_data_); } -base::Optional ExtraDataSource::GetNext(offset_t size) { +absl::optional ExtraDataSource::GetNext(offset_t size) { ConstBufferView buffer; if (!extra_data_.GetRegion(size, &buffer)) - return base::nullopt; + return absl::nullopt; // |buffer| is assumed to always be safe/valid. return buffer; } @@ -150,32 +150,32 @@ bool RawDeltaSource::Initialize(BufferSource* source) { patch::ParseBuffer(source, &raw_delta_diff_); } -base::Optional RawDeltaSource::GetNext() { +absl::optional RawDeltaSource::GetNext() { if (raw_delta_skip_.empty() || raw_delta_diff_.empty()) - return base::nullopt; + return absl::nullopt; RawDeltaUnit raw_delta = {}; uint32_t copy_offset_diff = 0; if (!patch::ParseVarUInt(&raw_delta_skip_, ©_offset_diff)) - return base::nullopt; + return absl::nullopt; base::CheckedNumeric copy_offset = copy_offset_diff + copy_offset_compensation_; if (!copy_offset.IsValid()) - return base::nullopt; + return absl::nullopt; raw_delta.copy_offset = copy_offset.ValueOrDie(); if (!raw_delta_diff_.GetValue(&raw_delta.diff)) - return base::nullopt; + return absl::nullopt; // A 0 value for a delta.diff is considered invalid since it has no meaning. if (!raw_delta.diff) - return base::nullopt; + return absl::nullopt; // We keep track of the compensation needed for next offset, taking into // account delta encoding and bias of -1. copy_offset_compensation_ = copy_offset + 1; if (!copy_offset_compensation_.IsValid()) - return base::nullopt; + return absl::nullopt; // |raw_delta| is assumed to always be safe/valid. return raw_delta; } @@ -191,12 +191,12 @@ bool ReferenceDeltaSource::Initialize(BufferSource* source) { return patch::ParseBuffer(source, &source_); } -base::Optional ReferenceDeltaSource::GetNext() { +absl::optional ReferenceDeltaSource::GetNext() { if (source_.empty()) - return base::nullopt; + return absl::nullopt; int32_t ref_delta = 0; if (!patch::ParseVarInt(&source_, &ref_delta)) - return base::nullopt; + return absl::nullopt; // |ref_delta| is assumed to always be safe/valid. return ref_delta; } @@ -211,22 +211,22 @@ bool TargetSource::Initialize(BufferSource* source) { return patch::ParseBuffer(source, &extra_targets_); } -base::Optional TargetSource::GetNext() { +absl::optional TargetSource::GetNext() { if (extra_targets_.empty()) - return base::nullopt; + return absl::nullopt; uint32_t target_diff = 0; if (!patch::ParseVarUInt(&extra_targets_, &target_diff)) - return base::nullopt; + return absl::nullopt; base::CheckedNumeric target = target_diff + target_compensation_; if (!target.IsValid()) - return base::nullopt; + return absl::nullopt; // We keep track of the compensation needed for next target, taking into // account delta encoding and bias of -1. target_compensation_ = target + 1; if (!target_compensation_.IsValid()) - return base::nullopt; + return absl::nullopt; // Caveat: |target| will be a valid offset_t, but it's up to the caller to // check whether it's a valid offset for an image. return offset_t(target.ValueOrDie()); @@ -312,12 +312,12 @@ bool PatchElementReader::ValidateEquivalencesAndExtraData() { /******** EnsemblePatchReader ********/ -base::Optional EnsemblePatchReader::Create( +absl::optional EnsemblePatchReader::Create( ConstBufferView buffer) { BufferSource source(buffer); EnsemblePatchReader patch; if (!patch.Initialize(&source)) - return base::nullopt; + return absl::nullopt; return patch; } -- cgit v1.2.3