Reporting for MediaRawData:
Option 1: Report it in nsDocument::DocAddSizeOfExcludingThis (nsINode) HTMLMediaElement -> MediaSource -> SourceBuffer -> TrackBufferManager -> MediaRawData Pro: this should work Con: It would be rather generic under mDOMElementNodesSize
njn suggested expanding the struct to specify HTMLMediaElement specific stuff
- Reporter: https://dxr.mozilla.org/mozilla-central/source/dom/base/nsDocument.cpp#12646
- TracksBufferManager: https://dxr.mozilla.org/mozilla-central/source/dom/media/mediasource/TrackBuffersManager.cpp#1631
- MediaData: https://dxr.mozilla.org/mozilla-central/source/dom/media/MediaData.h#370
Option 2: Unknown, MediaSource might be owned somewhere else https://dxr.mozilla.org/mozilla-central/source/dom/media/MediaDecoder.cpp#445
Async all the things:
- nsWindowMemoryReporter::CollectReports - This does the reporting of total sizes, passes a sizeof struct into other methods
- WindowPaths needs to be newed / refcounted
- Reporting of total sizes needs to be deferred
- CollectWindowReports returns a promise, ->then decrements pending count
- CollectWindowReports - This does the reporting of individual windows sizes, calls
aWindow->AddSizeOfIncludingThis(&windowSizes);
- AddSizeOf returns promise ->then does the reporting, increments totals
- nsGlobalWindow::AddSizeOfIncludingThis - calls
mDoc->DocAddSizeOfIncludingThis(aWindowSizes);
mDoc->DocAddSizeOfIncludingThis(aWindowSizes)
returns promise otherwise create already resolved happy promise- nsIDocument::DocAddSizeOfIncludingThis - we care about the subclass implementation
nsDocument::DocAddSizeOfExcludingThis(nsWindowSizes* aWindowSizes)
- Stub out other implementors to return a resolved promise
- nsDocument::DocAddSizeOfExcludingThis(nsWindowSizes* aWindowSizes) - calls nsINode::SizeOfExcludingThis. These need to take some sort of struct so that they can indicate if they're async
- Loop through nodes, each returns a promise, ->then will add to the tally
- Update all INodes to return resolved promise except HTMLMediaElement
- Return a Promise::All([array of promises])
- (...7...8...) HTMLMediaElement::SizeOfExcludingThis -> MediaSource::SizeOfIncludingThis -> ad nauseum
Pass in accumulator
struct AsyncSizeAccumulator
{
MallocSizeOf mSizeOf;
size_t mSize;
size_t mPendingRequests;
};
With promises this probably actually isn't necessary.
But we also need some sort of callback mechanism. Promises might be nice:
Promise MediaSource::DeferredSizeOfIncludingThis(...) {
Promise deferred = mSourceBuffers->DefferedSizeOfIncludingThis(...);
return deferred;
}
Promise TrackBuffersManager::DeferredSizeOfIncludingThis(...) {
Promise deferred = Dispatch(taskqueue, this, SizeOfExlcudingThisInternal);
return deferred;
}