1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #ifndef nsBrowserStatusFilter_h__
6 #define nsBrowserStatusFilter_h__
8 #include "nsIWebProgressListener.h"
9 #include "nsIWebProgressListener2.h"
10 #include "nsIWebProgress.h"
11 #include "nsWeakReference.h"
12 #include "nsCycleCollectionParticipant.h"
17 //-----------------------------------------------------------------------------
18 // nsBrowserStatusFilter - a web progress listener implementation designed to
19 // sit between nsDocLoader and nsBrowserStatusHandler to filter out and limit
20 // the frequency of certain events to improve page load performance.
21 //-----------------------------------------------------------------------------
23 class nsBrowserStatusFilter
: public nsIWebProgress
,
24 public nsIWebProgressListener2
,
25 public nsSupportsWeakReference
{
27 nsBrowserStatusFilter();
29 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
30 NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsBrowserStatusFilter
,
32 NS_DECL_NSIWEBPROGRESS
33 NS_DECL_NSIWEBPROGRESSLISTENER
34 NS_DECL_NSIWEBPROGRESSLISTENER2
37 virtual ~nsBrowserStatusFilter();
40 nsresult
StartDelayTimer();
41 void CallDelayedProgressListeners();
42 void MaybeSendProgress();
43 void MaybeSendStatus();
45 bool DelayInEffect() { return mDelayedStatus
|| mDelayedProgress
; }
47 static void TimeoutHandler(nsITimer
* aTimer
, void* aClosure
);
50 nsCOMPtr
<nsIWebProgressListener
> mListener
;
51 nsCOMPtr
<nsIEventTarget
> mTarget
;
52 nsCOMPtr
<nsITimer
> mTimer
;
59 nsString mCurrentStatusMsg
;
60 int32_t mCurrentPercentage
;
62 bool mIsLoadingDocument
;
64 // indicates whether a timeout is pending
66 bool mDelayedProgress
;
69 #define NS_BROWSERSTATUSFILTER_CONTRACTID \
70 "@mozilla.org/appshell/component/browser-status-filter;1"
71 #define NS_BROWSERSTATUSFILTER_CID \
72 { /* 6356aa16-7916-4215-a825-cbc2692ca87a */ \
73 0x6356aa16, 0x7916, 0x4215, { \
74 0xa8, 0x25, 0xcb, 0xc2, 0x69, 0x2c, 0xa8, 0x7a \
78 #endif // !nsBrowserStatusFilter_h__