toolkit/components/statusfilter/nsBrowserStatusFilter.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4
michael@0 5 #ifndef nsBrowserStatusFilter_h__
michael@0 6 #define nsBrowserStatusFilter_h__
michael@0 7
michael@0 8 #include "nsIWebProgressListener.h"
michael@0 9 #include "nsIWebProgressListener2.h"
michael@0 10 #include "nsIWebProgress.h"
michael@0 11 #include "nsWeakReference.h"
michael@0 12 #include "nsITimer.h"
michael@0 13 #include "nsCOMPtr.h"
michael@0 14 #include "nsString.h"
michael@0 15
michael@0 16 //-----------------------------------------------------------------------------
michael@0 17 // nsBrowserStatusFilter - a web progress listener implementation designed to
michael@0 18 // sit between nsDocLoader and nsBrowserStatusHandler to filter out and limit
michael@0 19 // the frequency of certain events to improve page load performance.
michael@0 20 //-----------------------------------------------------------------------------
michael@0 21
michael@0 22 class nsBrowserStatusFilter : public nsIWebProgress
michael@0 23 , public nsIWebProgressListener2
michael@0 24 , public nsSupportsWeakReference
michael@0 25 {
michael@0 26 public:
michael@0 27 nsBrowserStatusFilter();
michael@0 28 virtual ~nsBrowserStatusFilter();
michael@0 29
michael@0 30 NS_DECL_ISUPPORTS
michael@0 31 NS_DECL_NSIWEBPROGRESS
michael@0 32 NS_DECL_NSIWEBPROGRESSLISTENER
michael@0 33 NS_DECL_NSIWEBPROGRESSLISTENER2
michael@0 34
michael@0 35 private:
michael@0 36 nsresult StartDelayTimer();
michael@0 37 void ProcessTimeout();
michael@0 38 void MaybeSendProgress();
michael@0 39 void MaybeSendStatus();
michael@0 40 void ResetMembers();
michael@0 41 bool DelayInEffect() { return mDelayedStatus || mDelayedProgress; }
michael@0 42
michael@0 43 static void TimeoutHandler(nsITimer *aTimer, void *aClosure);
michael@0 44
michael@0 45 private:
michael@0 46 nsCOMPtr<nsIWebProgressListener> mListener;
michael@0 47 nsCOMPtr<nsITimer> mTimer;
michael@0 48
michael@0 49 // delayed values
michael@0 50 nsString mStatusMsg;
michael@0 51 int64_t mCurProgress;
michael@0 52 int64_t mMaxProgress;
michael@0 53
michael@0 54 nsString mCurrentStatusMsg;
michael@0 55 bool mStatusIsDirty;
michael@0 56 int32_t mCurrentPercentage;
michael@0 57
michael@0 58 // used to convert OnStart/OnStop notifications into progress notifications
michael@0 59 int32_t mTotalRequests;
michael@0 60 int32_t mFinishedRequests;
michael@0 61 bool mUseRealProgressFlag;
michael@0 62
michael@0 63 // indicates whether a timeout is pending
michael@0 64 bool mDelayedStatus;
michael@0 65 bool mDelayedProgress;
michael@0 66 };
michael@0 67
michael@0 68 #define NS_BROWSERSTATUSFILTER_CONTRACTID \
michael@0 69 "@mozilla.org/appshell/component/browser-status-filter;1"
michael@0 70 #define NS_BROWSERSTATUSFILTER_CID \
michael@0 71 { /* 6356aa16-7916-4215-a825-cbc2692ca87a */ \
michael@0 72 0x6356aa16, \
michael@0 73 0x7916, \
michael@0 74 0x4215, \
michael@0 75 {0xa8, 0x25, 0xcb, 0xc2, 0x69, 0x2c, 0xa8, 0x7a} \
michael@0 76 }
michael@0 77
michael@0 78 #endif // !nsBrowserStatusFilter_h__

mercurial