Backed out 2 changesets (bug 799142) because of memory leaks

Backed out changeset a0cf0252cee4 (bug 799142)
Backed out changeset 7b1bb476bd8d (bug 799142)
This commit is contained in:
Ehsan Akhgari 2013-03-04 15:48:04 -05:00
Родитель 7ce7d0e0d8
Коммит afd997bcb5
2 изменённых файлов: 2 добавлений и 33 удалений

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

@ -11,7 +11,6 @@
#include "nsIThread.h"
#include "nsTimerImpl.h"
#include "nsThreadUtils.h"
#include "nsTArray.h"
@ -50,11 +49,6 @@ public:
void DoBeforeSleep();
void DoAfterSleep();
bool IsOnTimerThread() const
{
return mThread == NS_GetCurrentThread();
}
private:
~TimerThread();

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

@ -90,13 +90,6 @@ private:
class nsTimerEvent : public nsRunnable {
public:
nsTimerEvent() {
MOZ_ASSERT(gThread->IsOnTimerThread(),
"nsTimer must always be allocated on the timer thread");
PR_ATOMIC_INCREMENT(&sAllocatorUsers);
}
NS_IMETHOD Run();
nsTimerEvent(nsTimerImpl *timer, int32_t generation)
@ -111,14 +104,12 @@ public:
static void Init();
static void Shutdown();
static void DeleteAllocatorIfNeeded();
static void* operator new(size_t size) CPP_THROW_NEW {
return sAllocator->Alloc(size);
}
void operator delete(void* p) {
sAllocator->Free(p, sizeof(nsTimerEvent));
DeleteAllocatorIfNeeded();
}
private:
@ -128,23 +119,15 @@ private:
NS_WARNING("leaking reference to nsTimerImpl");
#endif
MOZ_COUNT_DTOR(nsTimerEvent);
MOZ_ASSERT(!sCanDeleteAllocator || sAllocatorUsers > 0,
"This will result in us attempting to deallocate the nsTimerEvent allocator twice");
PR_ATOMIC_DECREMENT(&sAllocatorUsers);
}
nsTimerImpl *mTimer;
int32_t mGeneration;
static TimerEventAllocator* sAllocator;
static int32_t sAllocatorUsers;
static bool sCanDeleteAllocator;
};
TimerEventAllocator* nsTimerEvent::sAllocator = nullptr;
int32_t nsTimerEvent::sAllocatorUsers = 0;
bool nsTimerEvent::sCanDeleteAllocator = false;
NS_IMPL_THREADSAFE_QUERY_INTERFACE1(nsTimerImpl, nsITimer)
NS_IMPL_THREADSAFE_ADDREF(nsTimerImpl)
@ -558,16 +541,8 @@ void nsTimerEvent::Init()
void nsTimerEvent::Shutdown()
{
sCanDeleteAllocator = true;
DeleteAllocatorIfNeeded();
}
void nsTimerEvent::DeleteAllocatorIfNeeded()
{
if (sCanDeleteAllocator && sAllocatorUsers == 0) {
delete sAllocator;
sAllocator = nullptr;
}
delete sAllocator;
sAllocator = nullptr;
}
NS_IMETHODIMP nsTimerEvent::Run()