Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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 "nsITimer.h"
13 #include "nsCOMPtr.h"
14 #include "nsString.h"
16 //-----------------------------------------------------------------------------
17 // nsBrowserStatusFilter - a web progress listener implementation designed to
18 // sit between nsDocLoader and nsBrowserStatusHandler to filter out and limit
19 // the frequency of certain events to improve page load performance.
20 //-----------------------------------------------------------------------------
22 class nsBrowserStatusFilter : public nsIWebProgress
23 , public nsIWebProgressListener2
24 , public nsSupportsWeakReference
25 {
26 public:
27 nsBrowserStatusFilter();
28 virtual ~nsBrowserStatusFilter();
30 NS_DECL_ISUPPORTS
31 NS_DECL_NSIWEBPROGRESS
32 NS_DECL_NSIWEBPROGRESSLISTENER
33 NS_DECL_NSIWEBPROGRESSLISTENER2
35 private:
36 nsresult StartDelayTimer();
37 void ProcessTimeout();
38 void MaybeSendProgress();
39 void MaybeSendStatus();
40 void ResetMembers();
41 bool DelayInEffect() { return mDelayedStatus || mDelayedProgress; }
43 static void TimeoutHandler(nsITimer *aTimer, void *aClosure);
45 private:
46 nsCOMPtr<nsIWebProgressListener> mListener;
47 nsCOMPtr<nsITimer> mTimer;
49 // delayed values
50 nsString mStatusMsg;
51 int64_t mCurProgress;
52 int64_t mMaxProgress;
54 nsString mCurrentStatusMsg;
55 bool mStatusIsDirty;
56 int32_t mCurrentPercentage;
58 // used to convert OnStart/OnStop notifications into progress notifications
59 int32_t mTotalRequests;
60 int32_t mFinishedRequests;
61 bool mUseRealProgressFlag;
63 // indicates whether a timeout is pending
64 bool mDelayedStatus;
65 bool mDelayedProgress;
66 };
68 #define NS_BROWSERSTATUSFILTER_CONTRACTID \
69 "@mozilla.org/appshell/component/browser-status-filter;1"
70 #define NS_BROWSERSTATUSFILTER_CID \
71 { /* 6356aa16-7916-4215-a825-cbc2692ca87a */ \
72 0x6356aa16, \
73 0x7916, \
74 0x4215, \
75 {0xa8, 0x25, 0xcb, 0xc2, 0x69, 0x2c, 0xa8, 0x7a} \
76 }
78 #endif // !nsBrowserStatusFilter_h__