Rename {absl => std}::optional in //components/
#cleanup
Automated patch. This is a no-op. Please avoid, to assign unrelated
bugs to this, as much as possible.
Context:
https://groups.google.com/a/chromium.org/g/cxx/c/nBD_1LaanTc/m/ghh-ZZhWAwAJ?utm_medium=email
As of https://crrev.com/1204351, absl::optional is now a type alias
for std::optional. We should migrate toward it.
Script:
```
function replace {
echo "Replacing $1 by $2"
git grep -l "$1" \
| cut -f1 -d: \
| grep \
-e "^components/" \
| grep \
-e "\.h" \
-e "\.cc" \
-e "\.mm" \
| grep -v \
-e "components/cast_streaming/browser/public/receiver_config.*" \
-e "components/power_metrics/*" \
-e "components/zucchini/patch_reader.*" \
| sort \
| uniq \
| xargs sed -i "s/$1/$2/g"
}
replace "absl::make_optional" "std::make_optional"
replace "absl::optional" "std::optional"
replace "absl::nullopt" "std::nullopt"
replace "absl::in_place" "std::in_place"
replace "absl::in_place_t" "std::in_place_t"
replace "\"third_party\/abseil-cpp\/absl\/types\/optional.h\"" "<optional>"
echo "Formatting:"
echo "IncludeBlocks: Regroup" >> ".clang-format"
echo "IncludeIsMainRegex: \"(_(android|apple|chromeos|freebsd|fuchsia|fuzzer|ios|linux|mac|nacl|openbsd|posix|stubs?|win))?(_(unit|browser|perf)?tests?)?$\"" >> ".clang-format"
git cl format
git restore ".clang-format"
git cl format
```
Bug: chromium:1500249
Change-Id: I34b45aba082a627d94fd9d3f9f994a60c64b40b1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5200092
Auto-Submit: Arthur Sonzogni <[email protected]>
Reviewed-by: danakj <[email protected]>
Commit-Queue: danakj <[email protected]>
Owners-Override: danakj <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1252820}
diff --git a/components/browsing_topics/annotator_impl.h b/components/browsing_topics/annotator_impl.h
index 4689819..7ff624e 100644
--- a/components/browsing_topics/annotator_impl.h
+++ b/components/browsing_topics/annotator_impl.h
@@ -5,6 +5,7 @@
#ifndef COMPONENTS_BROWSING_TOPICS_ANNOTATOR_IMPL_H_
#define COMPONENTS_BROWSING_TOPICS_ANNOTATOR_IMPL_H_
+#include <optional>
#include <string>
#include <unordered_map>
#include <vector>
@@ -17,7 +18,6 @@
#include "base/task/sequenced_task_runner.h"
#include "components/browsing_topics/annotator.h"
#include "components/optimization_guide/core/bert_model_handler.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace optimization_guide {
class OptimizationGuideModelProvider;
@@ -55,14 +55,14 @@
AnnotatorImpl(
optimization_guide::OptimizationGuideModelProvider* model_provider,
scoped_refptr<base::SequencedTaskRunner> background_task_runner,
- const absl::optional<optimization_guide::proto::Any>& model_metadata);
+ const std::optional<optimization_guide::proto::Any>& model_metadata);
~AnnotatorImpl() override;
// Annotator:
void BatchAnnotate(BatchAnnotationCallback callback,
const std::vector<std::string>& inputs) override;
void NotifyWhenModelAvailable(base::OnceClosure callback) override;
- absl::optional<optimization_guide::ModelInfo> GetBrowsingTopicsModelInfo()
+ std::optional<optimization_guide::ModelInfo> GetBrowsingTopicsModelInfo()
const override;
//////////////////////////////////////////////////////////////////////////////
@@ -76,7 +76,7 @@
override;
// Extracts the scored categories from the output of the model.
- absl::optional<std::vector<int32_t>> ExtractCategoriesFromModelOutput(
+ std::optional<std::vector<int32_t>> ExtractCategoriesFromModelOutput(
const std::vector<tflite::task::core::Category>& model_output) const;
protected:
@@ -89,7 +89,7 @@
void OnOverrideListLoadAttemptDone(
BatchAnnotationCallback callback,
const std::vector<std::string>& inputs,
- absl::optional<std::unordered_map<std::string, std::vector<int32_t>>>
+ std::optional<std::unordered_map<std::string, std::vector<int32_t>>>
override_list);
// Starts a batch annotation once the override list is loaded, if provided.
@@ -115,20 +115,20 @@
void PostprocessCategoriesToBatchAnnotationResult(
base::OnceClosure single_input_done_signal,
Annotation* annotation,
- const absl::optional<std::vector<tflite::task::core::Category>>& output);
+ const std::optional<std::vector<tflite::task::core::Category>>& output);
// Used to read the override list file on a background thread.
scoped_refptr<base::SequencedTaskRunner> background_task_runner_;
// Set whenever a valid override list file is passed along with the model file
// update. Used on the UI thread.
- absl::optional<base::FilePath> override_list_file_path_;
+ std::optional<base::FilePath> override_list_file_path_;
// Set whenever an override list file is available and the model file is
// loaded into memory. Reset whenever the model file is unloaded.
// Used on the UI thread. Lookups in this mapping should have |PreprocessHost|
// applied first.
- absl::optional<std::unordered_map<std::string, std::vector<int32_t>>>
+ std::optional<std::unordered_map<std::string, std::vector<int32_t>>>
override_list_;
// The version of topics model provided by the server in the model metadata