The lone remaining startup cache-related uses of nsAutoArrayPtr are both
in TestStartupCache.cpp, for use with nsIStartupCache::GetBuffer. The
uses can't use StartupCache::GetBuffer because StartupCache::GetBuffer
isn't visible outside of libxul, and TestStartupCache is a normal C++
unit test.
The Right Thing is to convert TestStartupCache to a gtest so we can see
libxul internal symbols and then delete nsIStartupCache entirely.
That's a bit complicated, as TestStartupCache doesn't fit nicely into
gtest's framework. The simpler solution is to add a UniquePtr overload
in the interface that hides the XPCOM outparam management details.
The only uses of this class use a template argument with a size of
|char| (uint8_t and char), and the class isn't designed to accomodate
template arguments of larger size (e.g. the implementation of Forget()
neglects to divide by sizeof(T) for allocating a return buffer). Let's
enforce this with a static_assert. This change makes the class safer to
use and also makes future changes simpler to reason about.
Similar to the previous change to NewObjectInputStreamFromBuffer, we
want to make the ownership transfer out of NewBufferFromStorageStream
more obvious. Doing this also lets us get rid of some uses of
nsAutoArrayPtr, which is less idiomatic than UniquePtr.
Because NewObjectInputStreamFromBuffer takes a raw pointer as input, the
typical coding pattern to use it is:
nsAutoArrayPtr<char> buf;
// assign something to buf
nsresult rv = NewObjectInputStreamFromBuffer(buf, ...);
if (NS_FAILED(rv)) {
...
return rv;
}
buf.forget();
Which is clumsy, error-prone, and obscures the ownership transfer of the
pointer into the stream returned by NewObjectInputStreamFromBuffer.
Let's address all of these concerns by changing the argument to a
UniquePtr<char[]>.
TestWriteObject() in TestStartupCache.cpp uses this odd pattern of
acquiring a raw pointer from the startup cache, and then stashing that
raw pointer into an nsAutoArrayPtr. We can do better by using the
getter_Transfers idiom and thereby always using the smart pointer.
Element location is rewritten with this patch in order to make it
compatible for use with promises. This makes consuming the API nicer
in the wider context of Marionette, since it no longer takes callbacks
and no longer has to be wrapped in external promises to be compatible
with the new dispatching technique.
MozReview-Commit-ID: DjZOXPqkZ5j
This reverts some of the changes made in bug 823483 patch 3 because it
turns out we don't want all of that behavior change.
MozReview-Commit-ID: Lbpi762qsbM
This patch convers the APZ:TransformEnd notification from a MessageManager message
to an observer notification so that it is more general and works on other platforms.
MozReview-Commit-ID: 8SSir828Ch7