From 73bcd890982c4ff2d7f6ede600ae056b95dfef41 Mon Sep 17 00:00:00 2001 From: "sgehani%netscape.com" Date: Tue, 20 Nov 2001 03:33:11 +0000 Subject: [PATCH] Implemented resetTimer(). b=106551; r=dp; sr=sfraser git-svn-id: svn://10.0.0.236/trunk@108548 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/xpcom/ds/nsITimelineService.idl | 5 ++++ mozilla/xpcom/ds/nsTimelineService.cpp | 31 +++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/mozilla/xpcom/ds/nsITimelineService.idl b/mozilla/xpcom/ds/nsITimelineService.idl index 3da53e04e24..fbcba75a1ce 100644 --- a/mozilla/xpcom/ds/nsITimelineService.idl +++ b/mozilla/xpcom/ds/nsITimelineService.idl @@ -106,6 +106,8 @@ interface nsITimelineService : nsISupports void stopTimer(in string timerName); void markTimer(in string timerName); + + void resetTimer(in string timerName); }; %{C++ @@ -124,6 +126,7 @@ interface nsITimelineService : nsISupports PR_EXTERN(nsresult) NS_TimelineMark(const char *text, ...); PR_EXTERN(nsresult) NS_TimelineStartTimer(const char *timerName); PR_EXTERN(nsresult) NS_TimelineStopTimer(const char *timerName); +PR_EXTERN(nsresult) NS_TimelineResetTimer(const char *timerName); PR_EXTERN(nsresult) NS_TimelineMarkTimer(const char *timerName, const char *str=nsnull); PR_EXTERN(nsresult) NS_TimelineIndent(); PR_EXTERN(nsresult) NS_TimelineOutdent(); @@ -143,6 +146,7 @@ PR_EXTERN(nsresult) NS_TimelineLeave(const char *text); #define NS_TIMELINE_START_TIMER(timerName) NS_TimelineStartTimer(timerName) #define NS_TIMELINE_STOP_TIMER(timerName) NS_TimelineStopTimer(timerName) #define NS_TIMELINE_MARK_TIMER(timerName) NS_TimelineMarkTimer(timerName) +#define NS_TIMELINE_RESET_TIMER(timerName) NS_TimelineResetTimer(timerName) #define NS_TIMELINE_MARK_TIMER1(timerName, str) NS_TimelineMarkTimer(timerName, str) /* @@ -194,6 +198,7 @@ PR_EXTERN(nsresult) NS_TimelineLeave(const char *text); #define NS_TIMELINE_START_TIMER(timerName) #define NS_TIMELINE_STOP_TIMER(timerName) #define NS_TIMELINE_MARK_TIMER(timerName) +#define NS_TIMELINE_RESET_TIMER(timerName) #define NS_TIMELINE_MARK_TIMER1(timerName, str) #define NS_TIMELINE_ENTER(text) #define NS_TIMELINE_LEAVE(text) diff --git a/mozilla/xpcom/ds/nsTimelineService.cpp b/mozilla/xpcom/ds/nsTimelineService.cpp index 07889a424b9..53bc512469c 100644 --- a/mozilla/xpcom/ds/nsTimelineService.cpp +++ b/mozilla/xpcom/ds/nsTimelineService.cpp @@ -79,6 +79,7 @@ class nsTimelineServiceTimer { * measured. */ void stop(PRTime now); + void reset(); PRTime getAccum(); PRTime getAccum(PRTime now); @@ -122,6 +123,12 @@ void nsTimelineServiceTimer::stop(PRTime now) PR_Unlock(mLock); } +void nsTimelineServiceTimer::reset() +{ + mStart = 0; + mAccum = 0; +} + PRTime nsTimelineServiceTimer::getAccum() { PRTime accum; @@ -380,6 +387,24 @@ PR_IMPLEMENT(nsresult) NS_TimelineMarkTimer(const char *timerName, const char *s return NS_OK; } +PR_IMPLEMENT(nsresult) NS_TimelineResetTimer(const char *timerName) +{ + if (timers == NULL) { + return NS_ERROR_FAILURE; + } + + PR_Lock(timerLock); + nsTimelineServiceTimer *timer + = (nsTimelineServiceTimer *)PL_HashTableLookup(timers, timerName); + PR_Unlock(timerLock); + if (timer == NULL) { + return NS_ERROR_FAILURE; + } + + timer->reset(); + return NS_OK; +} + PR_IMPLEMENT(nsresult) NS_TimelineIndent() { indent++; // Could have threading issues here. @@ -445,6 +470,12 @@ NS_IMETHODIMP nsTimelineService::MarkTimer(const char *timerName) return NS_TimelineMarkTimer(timerName); } +/* void resetTimer (in string timerName); */ +NS_IMETHODIMP nsTimelineService::ResetTimer(const char *timerName) +{ + return NS_TimelineResetTimer(timerName); +} + /* void indent (); */ NS_IMETHODIMP nsTimelineService::Indent() {