mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-20 00:35:44 +00:00
Bug 1493563 - Part 8: Report the memorty usage of the Content Blocking log; r=baku
Differential Revision: https://phabricator.services.mozilla.com/D6598
This commit is contained in:
parent
76e8de4967
commit
e97e383129
@ -14,6 +14,7 @@
|
||||
#include "nsHashKeys.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsWindowSizes.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
@ -29,6 +30,7 @@ class ContentBlockingLog final
|
||||
// Each element is a tuple of (type, blocked, repeatCount). The type values
|
||||
// come from the blocking types defined in nsIWebProgressListener.
|
||||
typedef nsTArray<LogEntry> OriginLog;
|
||||
typedef nsClassHashtable<nsStringHashKey, OriginLog> OriginLogHashTable;
|
||||
|
||||
struct StringWriteFunc : public JSONWriteFunc
|
||||
{
|
||||
@ -111,8 +113,24 @@ public:
|
||||
return buffer;
|
||||
}
|
||||
|
||||
void AddSizeOfExcludingThis(nsWindowSizes& aSizes) const
|
||||
{
|
||||
aSizes.mDOMOtherSize += mLog.ShallowSizeOfExcludingThis(aSizes.mState.mMallocSizeOf);
|
||||
|
||||
// Now add the sizes of each origin log queue.
|
||||
// The const_cast is needed because the nsTHashtable::Iterator interface is
|
||||
// not const-safe. :-(
|
||||
for (auto iter = const_cast<OriginLogHashTable&>(mLog).Iter();
|
||||
!iter.Done(); iter.Next()) {
|
||||
if (iter.UserData()) {
|
||||
aSizes.mDOMOtherSize +=
|
||||
iter.UserData()->ShallowSizeOfIncludingThis(aSizes.mState.mMallocSizeOf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
nsClassHashtable<nsStringHashKey, OriginLog> mLog;
|
||||
OriginLogHashTable mLog;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
@ -11789,6 +11789,8 @@ nsIDocument::DocAddSizeOfExcludingThis(nsWindowSizes& aSizes) const
|
||||
mql->SizeOfExcludingThis(aSizes.mState.mMallocSizeOf);
|
||||
}
|
||||
|
||||
mContentBlockingLog.AddSizeOfExcludingThis(aSizes);
|
||||
|
||||
// Measurement of the following members may be added later if DMD finds it
|
||||
// is worthwhile:
|
||||
// - many!
|
||||
|
Loading…
Reference in New Issue
Block a user