Mark GURL-producing methods as nodiscard
Change-Id: I84d1f59eb01ad15ca4837d7718c46a445fd2e5ab Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5953898 Commit-Queue: Charlie Harrison <csharrison@chromium.org> Reviewed-by: Charlie Harrison <csharrison@chromium.org> Auto-Submit: Chris Fredrickson <cfredric@chromium.org> Cr-Commit-Position: refs/heads/main@{#1373697}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
8fc5c858cb
commit
57ab027d53
14
url/gurl.h
14
url/gurl.h
@ -159,8 +159,8 @@ class COMPONENT_EXPORT(URL) GURL {
|
|||||||
//
|
//
|
||||||
// It is an error to resolve a URL relative to an invalid URL. The result
|
// It is an error to resolve a URL relative to an invalid URL. The result
|
||||||
// will be the empty URL.
|
// will be the empty URL.
|
||||||
GURL Resolve(std::string_view relative) const;
|
[[nodiscard]] GURL Resolve(std::string_view relative) const;
|
||||||
GURL Resolve(std::u16string_view relative) const;
|
[[nodiscard]] GURL Resolve(std::u16string_view relative) const;
|
||||||
|
|
||||||
// Creates a new GURL by replacing the current URL's components with the
|
// Creates a new GURL by replacing the current URL's components with the
|
||||||
// supplied versions. See the Replacements class in url_canon.h for more.
|
// supplied versions. See the Replacements class in url_canon.h for more.
|
||||||
@ -185,7 +185,7 @@ class COMPONENT_EXPORT(URL) GURL {
|
|||||||
//
|
//
|
||||||
// It is an error to get an empty path on an invalid URL. The result
|
// It is an error to get an empty path on an invalid URL. The result
|
||||||
// will be the empty URL.
|
// will be the empty URL.
|
||||||
GURL GetWithEmptyPath() const;
|
[[nodiscard]] GURL GetWithEmptyPath() const;
|
||||||
|
|
||||||
// A helper function to return a GURL without the filename, query values, and
|
// A helper function to return a GURL without the filename, query values, and
|
||||||
// fragment. For example,
|
// fragment. For example,
|
||||||
@ -194,7 +194,7 @@ class COMPONENT_EXPORT(URL) GURL {
|
|||||||
// GURL("https://www.foo.com/bar/").GetWithoutFilename().spec()
|
// GURL("https://www.foo.com/bar/").GetWithoutFilename().spec()
|
||||||
// will return "https://www.foo.com/bar/". If the GURL is invalid or missing a
|
// will return "https://www.foo.com/bar/". If the GURL is invalid or missing a
|
||||||
// scheme, authority or path, it will return an empty, invalid GURL.
|
// scheme, authority or path, it will return an empty, invalid GURL.
|
||||||
GURL GetWithoutFilename() const;
|
[[nodiscard]] GURL GetWithoutFilename() const;
|
||||||
|
|
||||||
// A helper function to return a GURL without the Ref (also named Fragment
|
// A helper function to return a GURL without the Ref (also named Fragment
|
||||||
// Identifier). For example,
|
// Identifier). For example,
|
||||||
@ -202,7 +202,7 @@ class COMPONENT_EXPORT(URL) GURL {
|
|||||||
// will return "https://www.foo.com/index.html".
|
// will return "https://www.foo.com/index.html".
|
||||||
// If the GURL is invalid or missing a
|
// If the GURL is invalid or missing a
|
||||||
// scheme, authority or path, it will return an empty, invalid GURL.
|
// scheme, authority or path, it will return an empty, invalid GURL.
|
||||||
GURL GetWithoutRef() const;
|
[[nodiscard]] GURL GetWithoutRef() const;
|
||||||
|
|
||||||
// A helper function to return a GURL containing just the scheme, host,
|
// A helper function to return a GURL containing just the scheme, host,
|
||||||
// and port from a URL. Equivalent to clearing any username and password,
|
// and port from a URL. Equivalent to clearing any username and password,
|
||||||
@ -219,13 +219,13 @@ class COMPONENT_EXPORT(URL) GURL {
|
|||||||
// conversions will likely return a wrong result for about:blank and/or
|
// conversions will likely return a wrong result for about:blank and/or
|
||||||
// in the presence of iframe.sandbox attribute. Prefer to get origins directly
|
// in the presence of iframe.sandbox attribute. Prefer to get origins directly
|
||||||
// from the source (e.g. RenderFrameHost::GetLastCommittedOrigin).
|
// from the source (e.g. RenderFrameHost::GetLastCommittedOrigin).
|
||||||
GURL DeprecatedGetOriginAsURL() const;
|
[[nodiscard]] GURL DeprecatedGetOriginAsURL() const;
|
||||||
|
|
||||||
// A helper function to return a GURL stripped from the elements that are not
|
// A helper function to return a GURL stripped from the elements that are not
|
||||||
// supposed to be sent as HTTP referrer: username, password and ref fragment.
|
// supposed to be sent as HTTP referrer: username, password and ref fragment.
|
||||||
// For invalid URLs or URLs that no valid referrers, an empty URL will be
|
// For invalid URLs or URLs that no valid referrers, an empty URL will be
|
||||||
// returned.
|
// returned.
|
||||||
GURL GetAsReferrer() const;
|
[[nodiscard]] GURL GetAsReferrer() const;
|
||||||
|
|
||||||
// Returns true if the scheme for the current URL is a known "standard-format"
|
// Returns true if the scheme for the current URL is a known "standard-format"
|
||||||
// scheme. A standard-format scheme adheres to what RFC 3986 calls "generic
|
// scheme. A standard-format scheme adheres to what RFC 3986 calls "generic
|
||||||
|
@ -81,13 +81,13 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
|||||||
CheckIdempotency(url_from_string_piece_part);
|
CheckIdempotency(url_from_string_piece_part);
|
||||||
CheckReplaceComponentsPreservesSpec(url_from_string_piece_part);
|
CheckReplaceComponentsPreservesSpec(url_from_string_piece_part);
|
||||||
|
|
||||||
url_from_string_piece_part.Resolve(relative_string);
|
std::ignore = url_from_string_piece_part.Resolve(relative_string);
|
||||||
|
|
||||||
if (relative_size % sizeof(char16_t) == 0) {
|
if (relative_size % sizeof(char16_t) == 0) {
|
||||||
std::u16string relative_string16(
|
std::u16string relative_string16(
|
||||||
reinterpret_cast<const char16_t*>(data + size_t_bytes),
|
reinterpret_cast<const char16_t*>(data + size_t_bytes),
|
||||||
relative_size / sizeof(char16_t));
|
relative_size / sizeof(char16_t));
|
||||||
url_from_string_piece_part.Resolve(relative_string16);
|
std::ignore = url_from_string_piece_part.Resolve(relative_string16);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
Reference in New Issue
Block a user