Bug 653627 - Don't use char** in nsIMemoryReporter. r=khuey, sr=bz.

This commit is contained in:
Nicholas Nethercote 2011-07-08 12:45:16 +10:00
Родитель 87e308ca2d
Коммит 14e0e78adc
10 изменённых файлов: 69 добавлений и 78 удалений

Просмотреть файл

@ -54,31 +54,31 @@ nsDOMMemoryReporter::Init()
}
NS_IMETHODIMP
nsDOMMemoryReporter::GetProcess(char** aProcess)
nsDOMMemoryReporter::GetProcess(nsACString &aProcess)
{
// "" means the main process.
*aProcess = strdup("");
aProcess.Truncate();
return NS_OK;
}
NS_IMETHODIMP
nsDOMMemoryReporter::GetPath(char** aMemoryPath)
nsDOMMemoryReporter::GetPath(nsACString &aMemoryPath)
{
*aMemoryPath = strdup("explicit/dom");
aMemoryPath.AssignLiteral("explicit/dom");
return NS_OK;
}
NS_IMETHODIMP
nsDOMMemoryReporter::GetKind(int* aKind)
nsDOMMemoryReporter::GetKind(PRInt32* aKind)
{
*aKind = KIND_HEAP;
return NS_OK;
}
NS_IMETHODIMP
nsDOMMemoryReporter::GetDescription(char** aDescription)
nsDOMMemoryReporter::GetDescription(nsACString &aDescription)
{
*aDescription = strdup("Memory used by the DOM.");
aDescription.AssignLiteral("Memory used by the DOM.");
return NS_OK;
}

Просмотреть файл

@ -44,16 +44,10 @@
class nsDOMMemoryReporter: public nsIMemoryReporter {
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIMEMORYREPORTER
static void Init();
NS_IMETHOD GetProcess(char** aProcess);
NS_IMETHOD GetPath(char** aMemoryPath);
NS_IMETHOD GetKind(int* aKnd);
NS_IMETHOD GetDescription(char** aDescription);
NS_IMETHOD GetUnits(PRInt32* aUnits);
NS_IMETHOD GetAmount(PRInt64* aAmount);
private:
// Protect ctor, use Init() instead.
nsDOMMemoryReporter();

Просмотреть файл

@ -363,11 +363,11 @@ ContentChild::RecvPMemoryReportRequestConstructor(PMemoryReportRequestChild* chi
PRInt32 units;
PRInt64 amount;
nsCString desc;
r->GetPath(getter_Copies(path));
r->GetPath(path);
r->GetKind(&kind);
r->GetUnits(&units);
r->GetAmount(&amount);
r->GetDescription(getter_Copies(desc));
r->GetDescription(desc);
MemoryReport memreport(process, path, kind, units, amount, desc);
reports.AppendElement(memreport);

Просмотреть файл

@ -600,13 +600,13 @@ public:
NS_DECL_ISUPPORTS
NS_IMETHOD GetProcess(char **process) {
*process = strdup("");
NS_IMETHOD GetProcess(nsACString &process) {
process.Truncate();
return NS_OK;
}
NS_IMETHOD GetPath(char **memoryPath) {
*memoryPath = strdup(SurfaceMemoryReporterPathForType(mType));
NS_IMETHOD GetPath(nsACString &path) {
path.Assign(SurfaceMemoryReporterPathForType(mType));
return NS_OK;
}
@ -625,8 +625,8 @@ public:
return NS_OK;
}
NS_IMETHOD GetDescription(char **desc) {
*desc = strdup("Memory used by gfx surface of the given type.");
NS_IMETHOD GetDescription(nsACString &desc) {
desc.AssignLiteral("Memory used by gfx surface of the given type.");
return NS_OK;
}

Просмотреть файл

@ -40,6 +40,7 @@
#include <math.h>
#include "nsString.h"
#include "nsIMemoryReporter.h"
#include "mozilla/ipc/SharedMemory.h"

Просмотреть файл

@ -158,30 +158,30 @@ public:
NS_DECL_ISUPPORTS
NS_IMETHOD GetProcess(char **process)
NS_IMETHOD GetProcess(nsACString &process)
{
*process = strdup("");
process.Truncate();
return NS_OK;
}
NS_IMETHOD GetPath(char **memoryPath)
NS_IMETHOD GetPath(nsACString &path)
{
if (mType == ChromeUsedRaw) {
*memoryPath = strdup("explicit/images/chrome/used/raw");
path.AssignLiteral("explicit/images/chrome/used/raw");
} else if (mType == ChromeUsedUncompressed) {
*memoryPath = strdup("explicit/images/chrome/used/uncompressed");
path.AssignLiteral("explicit/images/chrome/used/uncompressed");
} else if (mType == ChromeUnusedRaw) {
*memoryPath = strdup("explicit/images/chrome/unused/raw");
path.AssignLiteral("explicit/images/chrome/unused/raw");
} else if (mType == ChromeUnusedUncompressed) {
*memoryPath = strdup("explicit/images/chrome/unused/uncompressed");
path.AssignLiteral("explicit/images/chrome/unused/uncompressed");
} else if (mType == ContentUsedRaw) {
*memoryPath = strdup("explicit/images/content/used/raw");
path.AssignLiteral("explicit/images/content/used/raw");
} else if (mType == ContentUsedUncompressed) {
*memoryPath = strdup("explicit/images/content/used/uncompressed");
path.AssignLiteral("explicit/images/content/used/uncompressed");
} else if (mType == ContentUnusedRaw) {
*memoryPath = strdup("explicit/images/content/unused/raw");
path.AssignLiteral("explicit/images/content/unused/raw");
} else if (mType == ContentUnusedUncompressed) {
*memoryPath = strdup("explicit/images/content/unused/uncompressed");
path.AssignLiteral("explicit/images/content/unused/uncompressed");
}
return NS_OK;
}
@ -249,24 +249,24 @@ public:
return NS_OK;
}
NS_IMETHOD GetDescription(char **desc)
NS_IMETHOD GetDescription(nsACString &desc)
{
if (mType == ChromeUsedRaw) {
*desc = strdup("Memory used by in-use chrome images (compressed data).");
desc.AssignLiteral("Memory used by in-use chrome images (compressed data).");
} else if (mType == ChromeUsedUncompressed) {
*desc = strdup("Memory used by in-use chrome images (uncompressed data).");
desc.AssignLiteral("Memory used by in-use chrome images (uncompressed data).");
} else if (mType == ChromeUnusedRaw) {
*desc = strdup("Memory used by not in-use chrome images (compressed data).");
desc.AssignLiteral("Memory used by not in-use chrome images (compressed data).");
} else if (mType == ChromeUnusedUncompressed) {
*desc = strdup("Memory used by not in-use chrome images (uncompressed data).");
desc.AssignLiteral("Memory used by not in-use chrome images (uncompressed data).");
} else if (mType == ContentUsedRaw) {
*desc = strdup("Memory used by in-use content images (compressed data).");
desc.AssignLiteral("Memory used by in-use content images (compressed data).");
} else if (mType == ContentUsedUncompressed) {
*desc = strdup("Memory used by in-use content images (uncompressed data).");
desc.AssignLiteral("Memory used by in-use content images (uncompressed data).");
} else if (mType == ContentUnusedRaw) {
*desc = strdup("Memory used by not in-use content images (compressed data).");
desc.AssignLiteral("Memory used by not in-use content images (compressed data).");
} else if (mType == ContentUnusedUncompressed) {
*desc = strdup("Memory used by not in-use content images (uncompressed data).");
desc.AssignLiteral("Memory used by not in-use content images (uncompressed data).");
}
return NS_OK;
}

Просмотреть файл

@ -348,17 +348,15 @@ public:
}
NS_IMETHOD GetProcess(char **process)
NS_IMETHOD GetProcess(nsACString &process)
{
*process = strdup("");
process.Truncate();
return NS_OK;
}
NS_IMETHOD GetPath(char **memoryPath)
NS_IMETHOD GetPath(nsACString &path)
{
nsCString path;
path.AppendLiteral("explicit/storage/sqlite/");
path.AssignLiteral("explicit/storage/sqlite/");
path.Append(mDBConn.getFilename());
if (mType == Cache_Used) {
@ -370,8 +368,6 @@ public:
else if (mType == Stmt_Used) {
path.AppendLiteral("/stmt-used");
}
*memoryPath = ::ToNewCString(path);
return NS_OK;
}
@ -406,17 +402,17 @@ public:
return convertResultCode(rc);
}
NS_IMETHOD GetDescription(char **desc)
NS_IMETHOD GetDescription(nsACString &desc)
{
if (mType == Cache_Used) {
*desc = ::strdup("Memory (approximate) used by all pager caches.");
desc.AssignLiteral("Memory (approximate) used by all pager caches.");
}
else if (mType == Schema_Used) {
*desc = ::strdup("Memory (approximate) used to store the schema "
"for all databases associated with the connection");
desc.AssignLiteral("Memory (approximate) used to store the schema "
"for all databases associated with the connection");
}
else if (mType == Stmt_Used) {
*desc = ::strdup("Memory (approximate) used by all prepared statements");
desc.AssignLiteral("Memory (approximate) used by all prepared statements");
}
return NS_OK;
}

Просмотреть файл

@ -50,7 +50,7 @@ interface nsISimpleEnumerator;
* be accessed without triggering this computation. (Compare and contrast
* this with nsIMemoryMultiReporter.)
*/
[scriptable, uuid(37d18434-9819-4ce1-922f-15d8b63da066)]
[scriptable, uuid(b2c39f65-1799-4b92-a806-ab3cf6af3cfa)]
interface nsIMemoryReporter : nsISupports
{
/*
@ -60,7 +60,7 @@ interface nsIMemoryReporter : nsISupports
* from a child process is copied into the main process, the copy has its
* 'process' field set appropriately.
*/
readonly attribute string process;
readonly attribute ACString process;
/*
* The path that this memory usage should be reported under. Paths are
@ -94,7 +94,7 @@ interface nsIMemoryReporter : nsISupports
* - All other paths represent cross-cutting values and may overlap with any
* other reporter.
*/
readonly attribute string path;
readonly attribute AUTF8String path;
/*
* There are three categories of memory reporters:
@ -149,7 +149,7 @@ interface nsIMemoryReporter : nsISupports
/*
* A human-readable description of this memory usage report.
*/
readonly attribute string description;
readonly attribute AUTF8String description;
};
[scriptable, function, uuid(5b15f3fa-ba15-443c-8337-7770f5f0ce5d)]
@ -247,16 +247,16 @@ interface nsIMemoryReporterManager : nsISupports
/*
* Note that this defaults 'process' to "", which is usually what's desired.
*/
#define NS_MEMORY_REPORTER_IMPLEMENT(_classname, _path, _kind, _units, _usageFunction, _desc) \
#define NS_MEMORY_REPORTER_IMPLEMENT(_classname, _path, _kind, _units, _amountFunction, _desc) \
class MemoryReporter_##_classname : public nsIMemoryReporter { \
public: \
NS_DECL_ISUPPORTS \
NS_IMETHOD GetProcess(char **process) { *process = strdup(""); return NS_OK; } \
NS_IMETHOD GetPath(char **memoryPath) { *memoryPath = strdup(_path); return NS_OK; } \
NS_IMETHOD GetProcess(nsACString &process) { process.Truncate(); return NS_OK; } \
NS_IMETHOD GetPath(nsACString &memoryPath) { memoryPath.Assign(_path); return NS_OK; } \
NS_IMETHOD GetKind(int *kind) { *kind = _kind; return NS_OK; } \
NS_IMETHOD GetUnits(int *units) { *units = _units; return NS_OK; } \
NS_IMETHOD GetAmount(PRInt64 *amount) { *amount = _usageFunction(); return NS_OK; } \
NS_IMETHOD GetDescription(char **desc) { *desc = strdup(_desc); return NS_OK; } \
NS_IMETHOD GetAmount(PRInt64 *amount) { *amount = _amountFunction(); return NS_OK; } \
NS_IMETHOD GetDescription(nsACString &desc) { desc.Assign(_desc); return NS_OK; } \
}; \
NS_IMPL_ISUPPORTS1(MemoryReporter_##_classname, nsIMemoryReporter)

Просмотреть файл

@ -603,7 +603,7 @@ nsMemoryReporterManager::GetExplicit(PRInt64 *aExplicit)
if (kind == nsIMemoryReporter::KIND_MAPPED) {
nsCString path;
rv = r->GetPath(getter_Copies(path));
rv = r->GetPath(path);
NS_ENSURE_SUCCESS(rv, rv);
PRInt64 amount;
@ -618,7 +618,7 @@ nsMemoryReporterManager::GetExplicit(PRInt64 *aExplicit)
}
} else {
nsCString path;
rv = r->GetPath(getter_Copies(path));
rv = r->GetPath(path);
NS_ENSURE_SUCCESS(rv, rv);
if (path.Equals("heap-used")) {
@ -674,12 +674,12 @@ nsMemoryReporterManager::GetExplicit(PRInt64 *aExplicit)
NS_IMPL_ISUPPORTS1(nsMemoryReporter, nsIMemoryReporter)
nsMemoryReporter::nsMemoryReporter(nsCString& process,
nsCString& path,
nsMemoryReporter::nsMemoryReporter(nsACString& process,
nsACString& path,
PRInt32 kind,
PRInt32 units,
PRInt64 amount,
nsCString& desc)
nsACString& desc)
: mProcess(process)
, mPath(path)
, mKind(kind)
@ -693,15 +693,15 @@ nsMemoryReporter::~nsMemoryReporter()
{
}
NS_IMETHODIMP nsMemoryReporter::GetProcess(char **aProcess)
NS_IMETHODIMP nsMemoryReporter::GetProcess(nsACString &aProcess)
{
*aProcess = strdup(mProcess.get());
aProcess.Assign(mProcess);
return NS_OK;
}
NS_IMETHODIMP nsMemoryReporter::GetPath(char **aPath)
NS_IMETHODIMP nsMemoryReporter::GetPath(nsACString &aPath)
{
*aPath = strdup(mPath.get());
aPath.Assign(mPath);
return NS_OK;
}
@ -723,9 +723,9 @@ NS_IMETHODIMP nsMemoryReporter::GetAmount(PRInt64 *aAmount)
return NS_OK;
}
NS_IMETHODIMP nsMemoryReporter::GetDescription(char **aDescription)
NS_IMETHODIMP nsMemoryReporter::GetDescription(nsACString &aDescription)
{
*aDescription = strdup(mDesc.get());
aDescription.Assign(mDesc);
return NS_OK;
}

Просмотреть файл

@ -11,12 +11,12 @@ public:
NS_DECL_ISUPPORTS
NS_DECL_NSIMEMORYREPORTER
nsMemoryReporter(nsCString& process,
nsCString& path,
nsMemoryReporter(nsACString& process,
nsACString& path,
PRInt32 kind,
PRInt32 units,
PRInt64 amount,
nsCString& desc);
nsACString& desc);
~nsMemoryReporter();