Create a `url::Origin::CreateFromStringPiece` function |
|
Issue descriptionPeople are having to do auto origin = url::Origin::Create(GURL(string)); That's a noisier-than-necessary call site. And perhaps we could avoid some copying or parsing as well?
,
Sep 26
As part of fixing this bug (if we do), search the codebase for `Create(GURL` patterns and fix them where appropriate.
,
Sep 26
Sounds like a good idea to me. My main suggestions: - drop "Piece" from the name, since that will (presumably) be an implementation detail - if you're feeling super fancy, I guess we could take a std::string&& overload too, but that wouldn't be kosher with the C++ style guide - I'd like to limit the possibilities here to creating a tuple origin (since presumably, they could just call url::Origin() otherwise. But perhaps there's a legitimate reason we'd need to create tuples from arbitrary strings?
,
Sep 26
FWIW, I've added a ToOrigin(string) helper in a few tests since those are places where initializing origins from character data is common. How often is this needed outside tests?
,
Sep 26
Answering my own question: 681 uses in tests, 65 uses in non-tests. (Just wondering if a test-only helper is desired, although we might as well have a standard way of doing the conversion when absolutely necessary.) |
|
►
Sign in to add a comment |
|
Comment 1 Deleted