From 0a5f5d3875c7e3ba6efd9eb937d126db52d1e0a4 Mon Sep 17 00:00:00 2001 From: "attinasi%netscape.com" Date: Fri, 28 Apr 2000 21:27:20 +0000 Subject: [PATCH] Put the PERF_METRICS timing code back into Viewer: it was removed when the WebShell changes were made a while ago. r=dcone --- webshell/tests/viewer/makefile.win | 1 + webshell/tests/viewer/nsWebBrowserChrome.cpp | 56 +++++++++++++++----- webshell/tests/viewer/nsWebBrowserChrome.h | 4 ++ 3 files changed, 48 insertions(+), 13 deletions(-) diff --git a/webshell/tests/viewer/makefile.win b/webshell/tests/viewer/makefile.win index 414425d84bd..526faceab45 100644 --- a/webshell/tests/viewer/makefile.win +++ b/webshell/tests/viewer/makefile.win @@ -93,6 +93,7 @@ LINCS= \ LLIBS= \ $(DIST)\lib\gkgfxwin.lib \ $(DIST)\lib\timer_s.lib \ + $(DIST)\lib\util.lib \ $(DIST)\lib\raptornativewidgets_s.lib \ $(DIST)\lib\raptorbasewidget_s.lib \ $(DIST)\lib\raptorwidget_s.lib \ diff --git a/webshell/tests/viewer/nsWebBrowserChrome.cpp b/webshell/tests/viewer/nsWebBrowserChrome.cpp index 36ab1c576f1..40ab5c6f470 100644 --- a/webshell/tests/viewer/nsWebBrowserChrome.cpp +++ b/webshell/tests/viewer/nsWebBrowserChrome.cpp @@ -41,7 +41,8 @@ //*** nsWebBrowserChrome: Object Management //***************************************************************************** -nsWebBrowserChrome::nsWebBrowserChrome() : mBrowserWindow(nsnull) +nsWebBrowserChrome::nsWebBrowserChrome() : mBrowserWindow(nsnull), mTimerSet(PR_FALSE) + { NS_INIT_REFCNT(); } @@ -436,25 +437,54 @@ void nsWebBrowserChrome::OnLoadStart(nsIChannel* aChannel) if(mBrowserWindow->mThrobber) mBrowserWindow->mThrobber->Start(); - nsCOMPtr uri; - aChannel->GetURI(getter_AddRefs(uri)); - - if(mBrowserWindow->mStatus) - { - nsXPIDLCString uriString; + if (aChannel) { - uri->GetSpec(getter_Copies(uriString)); - - nsAutoString url; url.AssignWithConversion(uriString); - url.AppendWithConversion(": start"); - PRUint32 size; - mBrowserWindow->mStatus->SetText(url,size); + nsCOMPtr uri; + aChannel->GetURI(getter_AddRefs(uri)); + +#ifdef MOZ_PERF_METRICS + if (PR_FALSE == mTimerSet) { + char* url; + nsresult rv = NS_OK; + rv = uri->GetSpec(&url); + if (NS_SUCCEEDED(rv)) { + MOZ_TIMER_LOG(("*** Timing layout processes on url: '%s', WebBrowserChrome: %p\n", url, this)); + delete [] url; + } + MOZ_TIMER_DEBUGLOG(("Reset and start: nsWebBrowserChrome::OnLoadStart(), this=%p\n", this)); + MOZ_TIMER_RESET(mTotalTime); + MOZ_TIMER_START(mTotalTime); + mTimerSet = PR_TRUE; } +#endif + + if(mBrowserWindow->mStatus) + { + nsXPIDLCString uriString; + + uri->GetSpec(getter_Copies(uriString)); + + nsAutoString url; url.AssignWithConversion(uriString); + url.AppendWithConversion(": start"); + PRUint32 size; + mBrowserWindow->mStatus->SetText(url,size); + } + } // if (aChannel) } void nsWebBrowserChrome::OnLoadFinished(nsIChannel* aChannel, PRInt32 aProgressStatusFlags) { +#ifdef MOZ_PERF_METRICS + if ( (aProgressStatusFlags & nsIWebProgress::flag_win_stop) && mTimerSet ) { + MOZ_TIMER_DEBUGLOG(("Stop: nsWebShell::OnEndDocumentLoad(), this=%p\n", this)); + MOZ_TIMER_STOP(mTotalTime); + MOZ_TIMER_LOG(("Total (Layout + Page Load) Time (webBrowserChrome=%p): ", this)); + MOZ_TIMER_PRINT(mTotalTime); + mTimerSet = PR_FALSE; + } +#endif + nsXPIDLCString uriString; if(aChannel) { diff --git a/webshell/tests/viewer/nsWebBrowserChrome.h b/webshell/tests/viewer/nsWebBrowserChrome.h index a5162ccca71..6f717f942fe 100644 --- a/webshell/tests/viewer/nsWebBrowserChrome.h +++ b/webshell/tests/viewer/nsWebBrowserChrome.h @@ -32,6 +32,7 @@ #include "nsIBaseWindow.h" #include "nsIInterfaceRequestor.h" #include "nsIWebProgressListener.h" +#include "nsTimer.h" class nsBrowserWindow; @@ -70,6 +71,9 @@ protected: protected: nsBrowserWindow* mBrowserWindow; + + PRBool mTimerSet; + MOZ_TIMER_DECLARE(mTotalTime) }; #endif /* nsWebBrowserChrome_h__ */