Open Bug 1408793 Opened 7 years ago Updated 2 years ago

Encapsulate SetStringBuffer() and AsAString().Assign() in DOMString::SetString


(Core :: DOM: Bindings (WebIDL), enhancement, P3)




Tracking Status
firefox58 --- affected


(Reporter: n.nethercote, Unassigned)


DOMString has functions SetOwnedString() and SetOwnedAtom(). It should probably also have SetOwnedEphemeralString(), which would encapsulate the SetEphemeralStringBuffer() and AsAString().Assign() combination.
What is EphemeralString?
Priority: -- → P3
So the idea would be to have a SetEphemeralString, which does what the code in XMLHttpRequestStringBuffer::GetAsString is doing right now, yes?

I really hate the naming on these functions, by the way; I am open to ideas on how to change them.  The basic point is that we have some Set* calls that are passed a thing that is guaranteed to outlive the DOMString (and hence the DOMString does not need to keep it alive), and others are passed a thing that is _not_ guaranteed to live long enough, so the DOMString needs to copy or addref or something.
Could we use the word Dependent there, like we use with DependentString?
I guess SetStringBuffer would be SetDependentStringBuffer and SetEphemeralStringBuffer would be just
SetStringBuffer? And should SetOwnedString be SetDependentString.
SetOwnedString has a bit weird behavior, and I can blame myself about that.

I think the cases when DOMString may not own the string data, should be clearly named so.
Component: DOM → DOM: Core & HTML

OK, a bunch of the naming stuff got sorted out in bug 1407858. Resummarizing accordingly.

One complication: the one consumer I know of here wants to do a fallible assignment to the nsString, because it can have large chunks of data.

Component: DOM: Core & HTML → DOM: Bindings (WebIDL)
Summary: Encapsulate SetEphemeralStringBuffer() and AsAString().Assign() → Encapsulate SetStringBuffer() and AsAString().Assign() in DOMString::SetString
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.