New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 889590 link

Starred by 5 users

Issue metadata

Status: Assigned
Owner:
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux , Android , Windows , iOS , Chrome , Mac , Fuchsia
Pri: 3
Type: Feature



Sign in to add a comment

Create a `url::Origin::CreateFromStringPiece` function

Project Member Reported by palmer@chromium.org, Sep 26

Issue description

People 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?
 

Comment 1 Deleted

As part of fixing this bug (if we do), search the codebase for `Create(GURL` patterns and fix them where appropriate.
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?
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? 

 
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.)

Comment 6 Deleted

Sign in to add a comment