Bug 1943650 - Command-line --help output misformatted after --dbus-service. r=emilio
[gecko.git] / toolkit / components / statusfilter / nsBrowserStatusFilter.h
blobb61aecaabd7c58c7f1d2d8fd4ee9d344be6a0b98
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"
13 #include "nsITimer.h"
14 #include "nsCOMPtr.h"
15 #include "nsString.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 {
26 public:
27 nsBrowserStatusFilter();
29 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
30 NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsBrowserStatusFilter,
31 nsIWebProgress)
32 NS_DECL_NSIWEBPROGRESS
33 NS_DECL_NSIWEBPROGRESSLISTENER
34 NS_DECL_NSIWEBPROGRESSLISTENER2
36 protected:
37 virtual ~nsBrowserStatusFilter();
39 private:
40 nsresult StartDelayTimer();
41 void CallDelayedProgressListeners();
42 void MaybeSendProgress();
43 void MaybeSendStatus();
44 void ResetMembers();
45 bool DelayInEffect() { return mDelayedStatus || mDelayedProgress; }
47 static void TimeoutHandler(nsITimer* aTimer, void* aClosure);
49 private:
50 nsCOMPtr<nsIWebProgressListener> mListener;
51 nsCOMPtr<nsIEventTarget> mTarget;
52 nsCOMPtr<nsITimer> mTimer;
54 // delayed values
55 nsString mStatusMsg;
56 int64_t mCurProgress;
57 int64_t mMaxProgress;
59 nsString mCurrentStatusMsg;
60 int32_t mCurrentPercentage;
61 bool mStatusIsDirty;
62 bool mIsLoadingDocument;
64 // indicates whether a timeout is pending
65 bool mDelayedStatus;
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 \
75 } \
78 #endif // !nsBrowserStatusFilter_h__