Backout 38abb03271de (bug 698326) due to xpcshell tests failure

This commit is contained in:
Marco Bonardo 2011-11-11 20:12:12 +01:00
parent 3ca204c2dd
commit 710987a799
5 changed files with 13 additions and 104 deletions

View File

@ -160,9 +160,9 @@
#define NS_TYPEAHEADFIND_CID \
{ 0xe7f70966, 0x9a37, 0x48d7, { 0x8a, 0xeb, 0x35, 0x99, 0x8f, 0x31, 0x09, 0x0e} }
// {5edc87c2-6960-44e5-8431-bdfbb56f6aff}
// {42ef1d52-3351-4973-98f8-d18f089bccfa}
#define NS_URLCLASSIFIERPREFIXSET_CID \
{ 0x5edc87c2, 0x6960, 0x44e5, { 0x84, 0x31, 0xbd, 0xfb, 0xb5, 0x6f, 0x6a, 0xff} }
{ 0x42ef1d52, 0x3351, 0x4973, { 0x98, 0xf8, 0xd1, 0x8f, 0x08, 0x9b, 0xcc, 0xfa} }
// {5eb7c3c1-ec1f-4007-87cc-eefb37d68ce6}
#define NS_URLCLASSIFIERDBSERVICE_CID \

View File

@ -41,7 +41,7 @@
interface nsIArray;
[scriptable, uuid(5edc87c2-6960-44e5-8431-bdfbb56f6aff)]
[scriptable, uuid(42ef1d52-3351-4973-98f8-d18f089bccfa)]
interface nsIUrlClassifierPrefixSet : nsISupports
{
void setPrefixes([const, array, size_is(aLength)] in unsigned long aPrefixes,
@ -51,7 +51,7 @@ interface nsIUrlClassifierPrefixSet : nsISupports
boolean contains(in unsigned long aPrefix);
boolean probe(in unsigned long aPrefix, in unsigned long aKey,
inout boolean aReady);
PRUint32 sizeOfIncludingThis(in boolean aCountMe);
PRUint32 estimateSize();
PRUint32 getKey();
boolean isEmpty();
void loadFromFile(in nsIFile aFile);

View File

@ -3653,7 +3653,7 @@ nsUrlClassifierDBServiceWorker::LoadPrefixSet(nsCOMPtr<nsIFile> & aFile)
#ifdef DEBUG
PRUint32 size = 0;
rv = mPrefixSet->SizeOfIncludingThis(true, &size);
rv = mPrefixSet->EstimateSize(&size);
LOG(("SB tree done, size = %d bytes\n", size));
NS_ENSURE_SUCCESS(rv, rv);
#endif

View File

@ -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;
}

View File

@ -45,19 +45,16 @@
#include "nsID.h"
#include "nsIFile.h"
#include "nsIUrlClassifierPrefixSet.h"
#include "nsIMemoryReporter.h"
#include "nsToolkitCompsCID.h"
#include "mozilla/Mutex.h"
#include "mozilla/CondVar.h"
#include "mozilla/FileUtils.h"
class nsPrefixSetReporter;
class nsUrlClassifierPrefixSet : public nsIUrlClassifierPrefixSet
{
public:
nsUrlClassifierPrefixSet();
virtual ~nsUrlClassifierPrefixSet();
virtual ~nsUrlClassifierPrefixSet() {};
// Can send an empty Array to clean the tree
NS_IMETHOD SetPrefixes(const PRUint32* aArray, PRUint32 aLength);
@ -72,7 +69,7 @@ public:
NS_IMETHOD Probe(PRUint32 aPrefix, PRUint32 aKey, bool* aReady, bool* aFound);
// Return the estimated size of the set on disk and in memory,
// in bytes
NS_IMETHOD SizeOfIncludingThis(bool aCountMe, PRUint32* aSize);
NS_IMETHOD EstimateSize(PRUint32* aSize);
NS_IMETHOD IsEmpty(bool * aEmpty);
NS_IMETHOD LoadFromFile(nsIFile* aFile);
NS_IMETHOD StoreToFile(nsIFile* aFile);
@ -88,7 +85,6 @@ protected:
mozilla::Mutex mPrefixSetLock;
mozilla::CondVar mSetIsReady;
nsRefPtr<nsPrefixSetReporter> mReporter;
PRUint32 BinSearch(PRUint32 start, PRUint32 end, PRUint32 target);
nsresult LoadFromFd(mozilla::AutoFDClose & fileFd);
@ -107,7 +103,6 @@ protected:
nsTArray<PRUint32> mIndexStarts;
// array containing deltas from indices.
nsTArray<PRUint16> mDeltas;
};
#endif