bug 1242268 use pointers instead of copies of string literals in AudioNode memory reporting r?padenot
MozReview-Commit-ID: E85FGrmfOWI
--- a/dom/media/MediaStreamGraph.cpp
+++ b/dom/media/MediaStreamGraph.cpp
@@ -3484,18 +3484,18 @@ MediaStreamGraphImpl::CollectReports(nsI
rv = aHandleReport->Callback(EmptyCString(), _path, \
KIND_HEAP, UNITS_BYTES, _amount, \
NS_LITERAL_CSTRING(_desc), aData); \
NS_ENSURE_SUCCESS(rv, rv); \
} while (0)
for (size_t i = 0; i < mAudioStreamSizes.Length(); i++) {
const AudioNodeSizes& usage = mAudioStreamSizes[i];
- const char* const nodeType = usage.mNodeType.IsEmpty() ?
- "<unknown>" : usage.mNodeType.get();
+ const char* const nodeType =
+ usage.mNodeType ? usage.mNodeType : "<unknown>";
nsPrintfCString domNodePath("explicit/webaudio/audio-node/%s/dom-nodes",
nodeType);
REPORT(domNodePath, usage.mDomNode,
"Memory used by AudioNode DOM objects (Web Audio).");
nsPrintfCString enginePath("explicit/webaudio/audio-node/%s/engine-objects",
nodeType);
--- a/dom/media/MediaStreamGraph.h
+++ b/dom/media/MediaStreamGraph.h
@@ -431,17 +431,17 @@ public:
* Helper struct used to keep track of memory usage by AudioNodes.
*/
struct AudioNodeSizes
{
AudioNodeSizes() : mDomNode(0), mStream(0), mEngine(0), mNodeType() {}
size_t mDomNode;
size_t mStream;
size_t mEngine;
- nsCString mNodeType;
+ const char* mNodeType;
};
class MediaStreamGraphImpl;
class SourceMediaStream;
class ProcessedMediaStream;
class MediaInputPort;
class AudioNodeEngine;
class AudioNodeExternalInputStream;
--- a/dom/media/webaudio/AudioNode.h
+++ b/dom/media/webaudio/AudioNode.h
@@ -202,16 +202,18 @@ public:
// Do not call MarkInactive from a node destructor. If the destructor is
// called, then the node is already inactive.
// MarkInactive() may delete |this|.
void MarkInactive() { Context()->UnregisterActiveNode(this); }
virtual size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const;
virtual size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const;
+ // Returns a string from constant static storage identifying the dom node
+ // type.
virtual const char* NodeType() const = 0;
private:
virtual void LastRelease() override
{
// We are about to be deleted, disconnect the object from the graph before
// the derived type is destroyed.
DisconnectFromGraph();