Backout 38abb03271de (bug 698326) due to xpcshell tests failure
This commit is contained in:
@@ -42,7 +42,6 @@
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsDebug.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsString.h"
|
||||
#include "nsUrlClassifierPrefixSet.h"
|
||||
#include "nsIUrlClassifierPrefixSet.h"
|
||||
#include "nsIRandomGenerator.h"
|
||||
@@ -68,78 +67,6 @@ static const PRLogModuleInfo *gUrlClassifierPrefixSetLog = nsnull;
|
||||
#define LOG_ENABLED() (false)
|
||||
#endif
|
||||
|
||||
class nsPrefixSetReporter : public nsIMemoryReporter
|
||||
{
|
||||
public:
|
||||
nsPrefixSetReporter(nsUrlClassifierPrefixSet * aParent, const nsACString & aName);
|
||||
virtual ~nsPrefixSetReporter() {};
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIMEMORYREPORTER
|
||||
|
||||
private:
|
||||
nsCString mPath;
|
||||
nsUrlClassifierPrefixSet * mParent;
|
||||
};
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS1(nsPrefixSetReporter, nsIMemoryReporter)
|
||||
|
||||
nsPrefixSetReporter::nsPrefixSetReporter(nsUrlClassifierPrefixSet * aParent,
|
||||
const nsACString & aName)
|
||||
: mParent(aParent)
|
||||
{
|
||||
mPath.Assign(NS_LITERAL_CSTRING("explicit/storage/prefixset"));
|
||||
if (!aName.IsEmpty()) {
|
||||
mPath.Append("/");
|
||||
mPath.Append(aName);
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPrefixSetReporter::GetProcess(nsACString & aProcess)
|
||||
{
|
||||
aProcess.Truncate();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPrefixSetReporter::GetPath(nsACString & aPath)
|
||||
{
|
||||
aPath.Assign(mPath);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPrefixSetReporter::GetKind(PRInt32 * aKind)
|
||||
{
|
||||
*aKind = nsIMemoryReporter::KIND_HEAP;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPrefixSetReporter::GetUnits(PRInt32 * aUnits)
|
||||
{
|
||||
*aUnits = nsIMemoryReporter::UNITS_BYTES;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPrefixSetReporter::GetAmount(PRInt64 * aAmount)
|
||||
{
|
||||
PRUint32 size;
|
||||
nsresult rv = mParent->SizeOfIncludingThis(true, &size);
|
||||
*aAmount = size;
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPrefixSetReporter::GetDescription(nsACString & aDescription)
|
||||
{
|
||||
aDescription.Assign(NS_LITERAL_CSTRING("Memory used by a PrefixSet for "
|
||||
"UrlClassifier, in bytes."));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS1(nsUrlClassifierPrefixSet, nsIUrlClassifierPrefixSet)
|
||||
|
||||
nsUrlClassifierPrefixSet::nsUrlClassifierPrefixSet()
|
||||
@@ -157,14 +84,6 @@ nsUrlClassifierPrefixSet::nsUrlClassifierPrefixSet()
|
||||
if (NS_FAILED(rv)) {
|
||||
LOG(("Failed to initialize PrefixSet"));
|
||||
}
|
||||
|
||||
mReporter = new nsPrefixSetReporter(this, NS_LITERAL_CSTRING("all"));
|
||||
NS_RegisterMemoryReporter(mReporter);
|
||||
}
|
||||
|
||||
nsUrlClassifierPrefixSet::~nsUrlClassifierPrefixSet()
|
||||
{
|
||||
NS_UnregisterMemoryReporter(mReporter);
|
||||
}
|
||||
|
||||
nsresult
|
||||
@@ -280,8 +199,6 @@ PRUint32 nsUrlClassifierPrefixSet::BinSearch(PRUint32 start,
|
||||
NS_IMETHODIMP
|
||||
nsUrlClassifierPrefixSet::Contains(PRUint32 aPrefix, bool * aFound)
|
||||
{
|
||||
mPrefixSetLock.AssertCurrentThreadOwns();
|
||||
|
||||
*aFound = false;
|
||||
|
||||
if (!mHasPrefixes) {
|
||||
@@ -327,18 +244,15 @@ nsUrlClassifierPrefixSet::Contains(PRUint32 aPrefix, bool * aFound)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsUrlClassifierPrefixSet::SizeOfIncludingThis(bool aCountMe, PRUint32 * aSize)
|
||||
nsUrlClassifierPrefixSet::EstimateSize(PRUint32 * aSize)
|
||||
{
|
||||
MutexAutoLock lock(mPrefixSetLock);
|
||||
if (aCountMe) {
|
||||
size_t usable = moz_malloc_usable_size(this);
|
||||
*aSize = (PRUint32)(usable ? usable : sizeof(*this));
|
||||
} else {
|
||||
*aSize = 0;
|
||||
*aSize = sizeof(bool);
|
||||
if (mHasPrefixes) {
|
||||
*aSize += sizeof(PRUint16) * mDeltas.Length();
|
||||
*aSize += sizeof(PRUint32) * mIndexPrefixes.Length();
|
||||
*aSize += sizeof(PRUint32) * mIndexStarts.Length();
|
||||
}
|
||||
*aSize += mDeltas.SizeOf();
|
||||
*aSize += mIndexPrefixes.SizeOf();
|
||||
*aSize += mIndexStarts.SizeOf();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user