Skip to content

Commit

Permalink
Miscellaneous: change absl::optional to std::optional
Browse files Browse the repository at this point in the history
  • Loading branch information
uazo committed Aug 1, 2024
1 parent 71aab81 commit 5a5326f
Show file tree
Hide file tree
Showing 8 changed files with 171 additions and 171 deletions.
4 changes: 2 additions & 2 deletions build/patches/Add-a-proxy-configuration-page.patch
Original file line number Diff line number Diff line change
Expand Up @@ -977,7 +977,7 @@ new file mode 100644
+ }
+
+ if (const std::string* pacURL = config.FindString("pac_url")) {
+ absl::optional<bool> pacMandatory = config.FindBool("pac_mandatory");
+ std::optional<bool> pacMandatory = config.FindBool("pac_mandatory");
+ auto proxyConfig = net::ProxyConfig::CreateFromCustomPacURL(
+ GURL(*pacURL));
+ proxyConfig.set_pac_mandatory(pacMandatory.value_or(false));
Expand Down Expand Up @@ -1037,7 +1037,7 @@ new file mode 100644
+ if (bypass_rules == nullptr)
+ return;
+
+ absl::optional<bool> reverse_bypass = rules->FindBool("reverse_bypass");
+ std::optional<bool> reverse_bypass = rules->FindBool("reverse_bypass");
+
+ proxyConfig.proxy_rules().bypass_rules.ParseFromString(*bypass_rules);
+ proxyConfig.proxy_rules().reverse_bypass = reverse_bypass.value_or(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ diff --git a/content/browser/network/cross_origin_embedder_policy_reporter.cc b/
kType, context_url_, blink::mojom::ReportBody::New(std::move(list))));
}
+#if BUILDFLAG(ENABLE_REPORTING)
+ const absl::optional<std::string>& endpoint =
+ const std::optional<std::string>& endpoint =
+ report_only ? report_only_endpoint_ : endpoint_;
if (endpoint) {
base::Value::Dict body_to_pass;
Expand Down
34 changes: 17 additions & 17 deletions build/patches/Experimental-user-scripts-support.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5414,7 +5414,7 @@ new file mode 100755
+ MatchesPath(StripTrailingWildcard(other.path()));
+}
+
+absl::optional<URLPattern> URLPattern::CreateIntersection(
+std::optional<URLPattern> URLPattern::CreateIntersection(
+ const URLPattern& other) const {
+ // Easy case: Schemes don't overlap. Return nullopt.
+ int intersection_schemes = URLPattern::SCHEME_NONE;
Expand Down Expand Up @@ -5816,7 +5816,7 @@ new file mode 100755
+ // contains another, it will be handled correctly, but this method does not
+ // deal with cases like /*a* and /*b* (where technically the intersection
+ // is /*a*b*|/*b*a*); the intersection returned for that case will be empty.
+ absl::optional<URLPattern> CreateIntersection(const URLPattern& other) const;
+ std::optional<URLPattern> CreateIntersection(const URLPattern& other) const;
+
+ // Converts this URLPattern into an equivalent set of URLPatterns that don't
+ // use a wildcard in the scheme component. If this URLPattern doesn't use a
Expand Down Expand Up @@ -5984,7 +5984,7 @@ new file mode 100755
+ // they have with the other patterns.
+ for (const auto* pattern : unique_set1) {
+ for (const auto* pattern2 : unique_set2) {
+ absl::optional<URLPattern> intersection =
+ std::optional<URLPattern> intersection =
+ pattern->CreateIntersection(*pattern2);
+ if (intersection)
+ result.patterns_.insert(std::move(*intersection));
Expand Down Expand Up @@ -8280,7 +8280,7 @@ new file mode 100755
+ }
+
+void ScriptInjection::OnJsInjectionCompleted(
+ absl::optional<base::Value> results,
+ std::optional<base::Value> results,
+ base::TimeTicks start_time) {
+ DCHECK(!did_inject_js_);
+
Expand All @@ -8304,13 +8304,13 @@ new file mode 100755
+ run_location_, injected_stylesheets, num_injected_stylesheets);
+ blink::WebLocalFrame* web_frame = render_frame_->GetWebFrame();
+ // Default CSS origin is "author", but can be overridden to "user" by scripts.
+ absl::optional<CSSOrigin> css_origin = injector_->GetCssOrigin();
+ std::optional<CSSOrigin> css_origin = injector_->GetCssOrigin();
+ blink::WebCssOrigin blink_css_origin =
+ css_origin && *css_origin == CSS_ORIGIN_USER
+ ? blink::WebCssOrigin::kUser
+ : blink::WebCssOrigin::kAuthor;
+ blink::WebStyleSheetKey style_sheet_key;
+ if (const absl::optional<std::string>& injection_key =
+ if (const std::optional<std::string>& injection_key =
+ injector_->GetInjectionKey())
+ style_sheet_key = blink::WebString::FromASCII(*injection_key);
+ for (const blink::WebString& css : css_sources)
Expand Down Expand Up @@ -8414,7 +8414,7 @@ new file mode 100755
+
+ // Called when JS injection for the given frame has been completed or
+ // cancelled.
+ void OnJsInjectionCompleted(absl::optional<base::Value> results,
+ void OnJsInjectionCompleted(std::optional<base::Value> results,
+ base::TimeTicks start_time);
+
+ private:
Expand Down Expand Up @@ -8465,7 +8465,7 @@ new file mode 100755
+ bool log_activity_;
+
+ // Results storage.
+ absl::optional<base::Value> execution_result_;
+ std::optional<base::Value> execution_result_;
+
+ // The callback to run upon completing asynchronously.
+ CompletionCallback async_completion_callback_;
Expand Down Expand Up @@ -9052,10 +9052,10 @@ new file mode 100755
+ virtual bool IsUserGesture() const = 0;
+
+ // Returns the CSS origin of this injection.
+ virtual absl::optional<CSSOrigin> GetCssOrigin() const = 0;
+ virtual std::optional<CSSOrigin> GetCssOrigin() const = 0;
+
+ // Returns the key for this injection, if it's a CSS injection.
+ virtual const absl::optional<std::string> GetInjectionKey() const = 0;
+ virtual const std::optional<std::string> GetInjectionKey() const = 0;
+
+ // Returns true if the script expects results.
+ virtual bool ExpectsResults() const = 0;
Expand Down Expand Up @@ -9090,7 +9090,7 @@ new file mode 100755
+ // |render_frame| contains the render frame, or null if the frame was
+ // invalidated.
+ virtual void OnInjectionComplete(
+ absl::optional<base::Value> execution_result,
+ std::optional<base::Value> execution_result,
+ UserScript::RunLocation run_location,
+ content::RenderFrame* render_frame) = 0;
+
Expand Down Expand Up @@ -9355,11 +9355,11 @@ new file mode 100755
+ return false;
+}
+
+absl::optional<CSSOrigin> UserScriptInjector::GetCssOrigin() const {
+std::optional<CSSOrigin> UserScriptInjector::GetCssOrigin() const {
+ return absl::nullopt;
+}
+
+const absl::optional<std::string> UserScriptInjector::GetInjectionKey() const {
+const std::optional<std::string> UserScriptInjector::GetInjectionKey() const {
+ return absl::nullopt;
+}
+
Expand Down Expand Up @@ -9437,7 +9437,7 @@ new file mode 100755
+}
+
+void UserScriptInjector::OnInjectionComplete(
+ absl::optional<base::Value> execution_result,
+ std::optional<base::Value> execution_result,
+ UserScript::RunLocation run_location,
+ content::RenderFrame* render_frame) {}
+
Expand Down Expand Up @@ -9493,8 +9493,8 @@ new file mode 100755
+ // ScriptInjector implementation.
+ UserScript::InjectionType script_type() const override;
+ bool IsUserGesture() const override;
+ absl::optional<CSSOrigin> GetCssOrigin() const override;
+ const absl::optional<std::string> GetInjectionKey() const override;
+ std::optional<CSSOrigin> GetCssOrigin() const override;
+ const std::optional<std::string> GetInjectionKey() const override;
+ bool ExpectsResults() const override;
+ bool ShouldInjectJs(
+ UserScript::RunLocation run_location,
Expand All @@ -9510,7 +9510,7 @@ new file mode 100755
+ UserScript::RunLocation run_location,
+ std::set<std::string>* injected_stylesheets,
+ size_t* num_injected_stylesheets) const override;
+ void OnInjectionComplete(absl::optional<base::Value> execution_result,
+ void OnInjectionComplete(std::optional<base::Value> execution_result,
+ UserScript::RunLocation run_location,
+ content::RenderFrame* render_frame) override;
+ void OnWillNotInject(InjectFailureReason reason,
Expand Down
28 changes: 14 additions & 14 deletions build/patches/Eyeo-Adblock-for-Cromite.patch
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ diff --git a/chrome/browser/adblock/adblock_content_browser_client.cc b/chrome/b
const GURL& url,
+ const url::Origin& initiator_origin,
const net::SiteForCookies& site_for_cookies,
- const absl::optional<std::string>& user_agent,
- const std::optional<std::string>& user_agent,
+ const std::optional<std::string>& user_agent,
mojo::PendingRemote<network::mojom::WebSocketHandshakeClient>
handshake_client) {
Expand Down Expand Up @@ -378,7 +378,7 @@ diff --git a/chrome/browser/adblock/adblock_content_browser_client.cc b/chrome/b
const GURL& url,
+ const url::Origin& initiator_origin,
const net::SiteForCookies& site_for_cookies,
- const absl::optional<std::string>& user_agent,
- const std::optional<std::string>& user_agent,
+ const std::optional<std::string>& user_agent,
mojo::PendingRemote<network::mojom::WebSocketHandshakeClient>
handshake_client) {
Expand Down Expand Up @@ -413,7 +413,7 @@ diff --git a/chrome/browser/adblock/adblock_content_browser_client.cc b/chrome/b
const GURL& url,
+ const url::Origin& initiator_origin,
const net::SiteForCookies& site_for_cookies,
- const absl::optional<std::string>& user_agent,
- const std::optional<std::string>& user_agent,
+ const std::optional<std::string>& user_agent,
mojo::PendingRemote<network::mojom::WebSocketHandshakeClient>
handshake_client,
Expand Down Expand Up @@ -563,7 +563,7 @@ diff --git a/chrome/browser/adblock/adblock_content_browser_client.cc b/chrome/b
int render_process_id,
URLLoaderFactoryType type,
const url::Origin& request_initiator,
- absl::optional<int64_t> navigation_id,
- std::optional<int64_t> navigation_id,
+ const net::IsolationInfo& isolation_info,
+ std::optional<int64_t> navigation_id,
ukm::SourceIdObj ukm_source_id,
Expand Down Expand Up @@ -643,7 +643,7 @@ diff --git a/chrome/browser/adblock/adblock_content_browser_client.h b/chrome/br
const GURL& url,
+ const url::Origin& initiator_origin,
const net::SiteForCookies& site_for_cookies,
- const absl::optional<std::string>& user_agent,
- const std::optional<std::string>& user_agent,
+ const std::optional<std::string>& user_agent,
mojo::PendingRemote<network::mojom::WebSocketHandshakeClient>
handshake_client) override;
Expand All @@ -664,7 +664,7 @@ diff --git a/chrome/browser/adblock/adblock_content_browser_client.h b/chrome/br
int render_process_id,
URLLoaderFactoryType type,
const url::Origin& request_initiator,
- absl::optional<int64_t> navigation_id,
- std::optional<int64_t> navigation_id,
+ const net::IsolationInfo& isolation_info,
+ std::optional<int64_t> navigation_id,
ukm::SourceIdObj ukm_source_id,
Expand Down Expand Up @@ -699,7 +699,7 @@ diff --git a/chrome/browser/adblock/adblock_content_browser_client.h b/chrome/br
const GURL& url,
+ const url::Origin& initiator_origin,
const net::SiteForCookies& site_for_cookies,
- const absl::optional<std::string>& user_agent,
- const std::optional<std::string>& user_agent,
+ const std::optional<std::string>& user_agent,
mojo::PendingRemote<network::mojom::WebSocketHandshakeClient>
handshake_client);
Expand All @@ -710,7 +710,7 @@ diff --git a/chrome/browser/adblock/adblock_content_browser_client.h b/chrome/br
const GURL& url,
+ const url::Origin& initiator_origin,
const net::SiteForCookies& site_for_cookies,
- const absl::optional<std::string>& user_agent,
- const std::optional<std::string>& user_agent,
+ const std::optional<std::string>& user_agent,
mojo::PendingRemote<network::mojom::WebSocketHandshakeClient>
handshake_client,
Expand Down Expand Up @@ -854,7 +854,7 @@ diff --git a/chrome/browser/extensions/api/adblock_private/adblock_private_api.c
+AdblockPrivateSetPrivilegedFiltersEnabledFunction::~AdblockPrivateSetPrivilegedFiltersEnabledFunction() {}
+
+ExtensionFunction::ResponseAction AdblockPrivateSetPrivilegedFiltersEnabledFunction::Run() {
+ absl::optional<api::adblock_private::SetEnabled::Params> params =
+ std::optional<api::adblock_private::SetEnabled::Params> params =
+ api::adblock_private::SetEnabled::Params::Create(args());
+ EXTENSION_FUNCTION_VALIDATE(params);
+
Expand Down Expand Up @@ -4357,7 +4357,7 @@ diff --git a/components/adblock/core/converter/flatbuffer_converter.cc b/compone
diff --git a/components/adblock/core/converter/parser/metadata.cc b/components/adblock/core/converter/parser/metadata.cc
--- a/components/adblock/core/converter/parser/metadata.cc
+++ b/components/adblock/core/converter/parser/metadata.cc
@@ -58,13 +58,6 @@ absl::optional<Metadata> Metadata::FromStream(std::istream& filter_stream) {
@@ -58,13 +58,6 @@ std::optional<Metadata> Metadata::FromStream(std::istream& filter_stream) {
if (key == "homepage") {
homepage = value;
} else if (key == "redirect") {
Expand Down Expand Up @@ -4428,7 +4428,7 @@ diff --git a/components/adblock/core/converter/parser/url_filter.cc b/components
piece.remove_suffix(1);
}
if (piece.find('|') == base::StringPiece::npos) {
@@ -108,21 +112,21 @@ absl::optional<UrlFilter> UrlFilter::FromString(std::string filter_str) {
@@ -108,21 +112,21 @@ std::optional<UrlFilter> UrlFilter::FromString(std::string filter_str) {

if (options->Csp().has_value() && options->Csp().value().empty() &&
!is_allowing) {
Expand Down Expand Up @@ -4456,7 +4456,7 @@ diff --git a/components/adblock/core/converter/parser/url_filter.cc b/components
diff --git a/components/adblock/core/converter/parser/url_filter_options.cc b/components/adblock/core/converter/parser/url_filter_options.cc
--- a/components/adblock/core/converter/parser/url_filter_options.cc
+++ b/components/adblock/core/converter/parser/url_filter_options.cc
@@ -88,20 +88,14 @@ absl::optional<UrlFilterOptions> UrlFilterOptions::FromString(
@@ -88,20 +88,14 @@ std::optional<UrlFilterOptions> UrlFilterOptions::FromString(
}
domains = DomainOption::FromString(value, kDomainOrSitekeySeparator);
} else if (key == "sitekey") {
Expand All @@ -4483,7 +4483,7 @@ diff --git a/components/adblock/core/converter/parser/url_filter_options.cc b/co
} else {
ContentType content_type = ContentTypeFromString(key);
if (content_type != ContentType::Unknown) {
@@ -184,6 +178,7 @@ absl::optional<UrlFilterOptions::RewriteOption> UrlFilterOptions::ParseRewrite(
@@ -184,6 +178,7 @@ std::optional<UrlFilterOptions::RewriteOption> UrlFilterOptions::ParseRewrite(
// static
SiteKeys UrlFilterOptions::ParseSitekeys(const std::string& sitekey_value) {
SiteKeys sitekeys;
Expand Down Expand Up @@ -4663,7 +4663,7 @@ diff --git a/components/adblock/core/sitekey_storage_impl.cc b/components/adbloc
return;
@@ -53,6 +55,7 @@ void SitekeyStorageImpl::ProcessResponseHeaders(

absl::optional<std::pair<GURL, SiteKey>>
std::optional<std::pair<GURL, SiteKey>>
SitekeyStorageImpl::FindSiteKeyForAnyUrl(const std::vector<GURL>& urls) const {
+ if ((true)) return {};
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
Expand Down
6 changes: 3 additions & 3 deletions build/patches/Internal-firewall.patch
Original file line number Diff line number Diff line change
Expand Up @@ -548,13 +548,13 @@ new file mode 100644
+ return it->second.allowed;
+}
+
+absl::optional<builders::EntryDecoder> FirewallService::GetEntry(
+std::optional<builders::EntryDecoder> FirewallService::GetEntry(
+ int32_t unique_id_hash_code) const {
+ const auto it = decode_map_.find(unique_id_hash_code);
+ if (it == decode_map_.end())
+ return absl::nullopt;
+
+ return absl::optional<builders::EntryDecoder>(it->second);
+ return std::optional<builders::EntryDecoder>(it->second);
+}
+
+}
Expand Down Expand Up @@ -608,7 +608,7 @@ new file mode 100644
+ ~FirewallService();
+
+ bool IsAllowed(int32_t unique_id_hash_code);
+ absl::optional<builders::EntryDecoder> GetEntry(int32_t unique_id_hash_code) const;
+ std::optional<builders::EntryDecoder> GetEntry(int32_t unique_id_hash_code) const;
+
+ private:
+ raw_ptr<PrefService> pref_service_;
Expand Down
Loading

0 comments on commit 5a5326f

Please sign in to comment.