bug 1224022 use pointers instead of copies of string literals in AudioNode memory reporting r?padenot draft
authorKarl Tomlinson <karlt+@karlt.net>
Mon, 04 Jul 2016 16:24:47 +1200
changeset 383467 020bc4aafa02a3241c8ddebd320655bfa39a9feb
parent 383466 cce2431572b3d148458b46a3cffdd6efcbb4cd79
child 383468 0e8a7d058a0e97c8990c2c5244ebc8f83b694031
push id22037
push userktomlinson@mozilla.com
push dateMon, 04 Jul 2016 08:58:23 +0000
reviewerspadenot
bugs1224022
milestone50.0a1
bug 1224022 use pointers instead of copies of string literals in AudioNode memory reporting r?padenot MozReview-Commit-ID: 2shrkrBYsFM
dom/media/MediaStreamGraph.cpp
dom/media/MediaStreamGraph.h
dom/media/webaudio/AudioNode.h
--- 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();