blink: Make SecurityOrigin's tuple constructor directly populate members
Right now, blink::SecurityOrigin's Create(scheme, host, port) method smushes (that's the technical term, right?) the arguments together with some URL glue substrings like "://", feeds the result into KURL, and feeds the resulting KURL into the SecurityOrigin(KURL) constructor. Even though this mostly works, it's kind of complex, and it's different than how the corresponding url::Origin(url::SchemeHostPort) constructor works. The difference is that url::Origin(url::SchemeHostPort) imposes a precondition that its input be valid, so that the resulting origin is never opaque. This lets url::Origin(url::SchemeHostPort) just take the given scheme, host, and port and store them in Origin's fields. The immediate motivation for this change is that I'm working on a concurrent CL that will fix up SecurityOrigin's handling of URLs with port 0 (crbug.com/1136678). There are a bunch of parameterized tests that take input structs containing a scheme, a host, and a port, and they need to support arguments like {"file", "", 0} which should yield the non-opaque tuple origin ("file", "", 0) with serialization "file://", as well as arguments like {"http", "davids.website", 0} which should yield the non-opaque tuple origin ("http", "davids.website", 0). In the latter case, the current implementation omits the 0 from the string it passes to the KURL constructor, and gives back SecurityOrigin(KURL("https://davids.website")), which means there's no way to construct these test cases for the URL "https://davids.website:0", in a manner yielding an origin distinguishable from one constructed with the default port. Instead of the implemented fix, I considered just making the method unconditionally add the port to the string it passes to the KURL constructor. But this doesn't work for the {file, "", 0} case, because "file://:0" is an invalid URL. Bug: 1136678 Change-Id: Ifa5deadfd3a5a79fc6e00a2af1291c2063434203 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2464363Reviewed-by:Arthur Sonzogni <arthursonzogni@chromium.org> Reviewed-by:
Mike West <mkwst@chromium.org> Reviewed-by:
Łukasz Anforowicz <lukasza@chromium.org> Commit-Queue: David Van Cleve <davidvc@chromium.org> Cr-Commit-Position: refs/heads/master@{#819941}
Showing
Please register or sign in to comment