зеркало из https://github.com/mozilla/pjs.git
Bug 667474 - Do a naive computation of windows' size in the DOM Memory Reporter. r=jst
This commit is contained in:
Родитель
7c4deac451
Коммит
a74928257d
|
@ -36,6 +36,7 @@
|
|||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsDOMMemoryReporter.h"
|
||||
#include "nsGlobalWindow.h"
|
||||
|
||||
|
||||
nsDOMMemoryReporter::nsDOMMemoryReporter()
|
||||
|
@ -80,9 +81,23 @@ nsDOMMemoryReporter::GetDescription(char** aDescription)
|
|||
*aDescription = strdup("Memory used by the DOM.");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static
|
||||
PLDHashOperator
|
||||
GetWindowsMemoryUsage(const PRUint64& aId, nsGlobalWindow*& aWindow,
|
||||
void* aClosure)
|
||||
{
|
||||
*(PRInt64*)aClosure += aWindow->SizeOf();
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMMemoryReporter::GetMemoryUsed(PRInt64* aMemoryUsed) {
|
||||
*aMemoryUsed = 0;
|
||||
|
||||
nsGlobalWindow::WindowByIdTable* windows = nsGlobalWindow::GetWindowsTable();
|
||||
windows->Enumerate(GetWindowsMemoryUsage, aMemoryUsed);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -287,6 +287,7 @@ public:
|
|||
|
||||
typedef mozilla::TimeStamp TimeStamp;
|
||||
typedef mozilla::TimeDuration TimeDuration;
|
||||
typedef nsDataHashtable<nsUint64HashKey, nsGlobalWindow*> WindowByIdTable;
|
||||
|
||||
// public methods
|
||||
nsPIDOMWindow* GetPrivateParent();
|
||||
|
@ -539,6 +540,14 @@ public:
|
|||
|
||||
static bool HasPerformanceSupport();
|
||||
|
||||
static WindowByIdTable* GetWindowsTable() {
|
||||
return sWindowsById;
|
||||
}
|
||||
|
||||
PRInt64 SizeOf() const {
|
||||
return sizeof(*this);
|
||||
}
|
||||
|
||||
private:
|
||||
// Enable updates for the accelerometer.
|
||||
void EnableDeviceMotionUpdates();
|
||||
|
@ -960,7 +969,6 @@ protected:
|
|||
friend class PostMessageEvent;
|
||||
static nsIDOMStorageList* sGlobalStorageList;
|
||||
|
||||
typedef nsDataHashtable<nsUint64HashKey, nsGlobalWindow*> WindowByIdTable;
|
||||
static WindowByIdTable* sWindowsById;
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче