Remove uses of BodyAsStringCallbackDeprecated (components/, pt. 1) Updates multiple existing uses of the version of SimpleURLLoader::DownloadToStringOfUnboundedSizeUntilCrashAndDie that takes a BodyAsStringCallbackDeprecated to use the version that takes a BodyAsStringCallback. This primarily involves updating the callback function to accept a std::optional<std::string> instead of a std::unique_ptr<std::string>. This CL touches the first half of the components/ uses. Bug: 40258809 Change-Id: Ic45635114ec85257bd7506c510b8bfe0655c7eeb Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7169903 Commit-Queue: Andrew Williams <awillia@chromium.org> Reviewed-by: Maks Orlovich <morlovich@chromium.org> Owners-Override: Daniel Cheng <dcheng@chromium.org> Cr-Commit-Position: refs/heads/main@{#1549391} NOKEYCHECK=True GitOrigin-RevId: 460bab4c557005f9345d3ca8f029d80d2549efb7
diff --git a/net/net_metrics_log_uploader.cc b/net/net_metrics_log_uploader.cc index 182be8d..7581967 100644 --- a/net/net_metrics_log_uploader.cc +++ b/net/net_metrics_log_uploader.cc
@@ -4,7 +4,9 @@ #include "components/metrics/net/net_metrics_log_uploader.h" +#include <optional> #include <sstream> +#include <string> #include <string_view> #include "base/base64.h" @@ -592,7 +594,7 @@ // The callback is only invoked if |url_loader_| it was bound against is alive. void NetMetricsLogUploader::OnURLLoadComplete( - std::unique_ptr<std::string> response_body) { + std::optional<std::string> response_body) { int response_code = -1; if (url_loader_->ResponseInfo() && url_loader_->ResponseInfo()->headers) { response_code = url_loader_->ResponseInfo()->headers->response_code();
diff --git a/net/net_metrics_log_uploader.h b/net/net_metrics_log_uploader.h index 92b1697..1a13311 100644 --- a/net/net_metrics_log_uploader.h +++ b/net/net_metrics_log_uploader.h
@@ -6,6 +6,7 @@ #define COMPONENTS_METRICS_NET_NET_METRICS_LOG_UPLOADER_H_ #include <memory> +#include <optional> #include <string> #include <string_view> @@ -73,7 +74,7 @@ // the payload. void HTTPFallbackAborted(); - void OnURLLoadComplete(std::unique_ptr<std::string> response_body); + void OnURLLoadComplete(std::optional<std::string> response_body); // The URLLoader factory for loads done using the network stack. scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory_;