1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/components/statusfilter/nsBrowserStatusFilter.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,78 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +#ifndef nsBrowserStatusFilter_h__ 1.9 +#define nsBrowserStatusFilter_h__ 1.10 + 1.11 +#include "nsIWebProgressListener.h" 1.12 +#include "nsIWebProgressListener2.h" 1.13 +#include "nsIWebProgress.h" 1.14 +#include "nsWeakReference.h" 1.15 +#include "nsITimer.h" 1.16 +#include "nsCOMPtr.h" 1.17 +#include "nsString.h" 1.18 + 1.19 +//----------------------------------------------------------------------------- 1.20 +// nsBrowserStatusFilter - a web progress listener implementation designed to 1.21 +// sit between nsDocLoader and nsBrowserStatusHandler to filter out and limit 1.22 +// the frequency of certain events to improve page load performance. 1.23 +//----------------------------------------------------------------------------- 1.24 + 1.25 +class nsBrowserStatusFilter : public nsIWebProgress 1.26 + , public nsIWebProgressListener2 1.27 + , public nsSupportsWeakReference 1.28 +{ 1.29 +public: 1.30 + nsBrowserStatusFilter(); 1.31 + virtual ~nsBrowserStatusFilter(); 1.32 + 1.33 + NS_DECL_ISUPPORTS 1.34 + NS_DECL_NSIWEBPROGRESS 1.35 + NS_DECL_NSIWEBPROGRESSLISTENER 1.36 + NS_DECL_NSIWEBPROGRESSLISTENER2 1.37 + 1.38 +private: 1.39 + nsresult StartDelayTimer(); 1.40 + void ProcessTimeout(); 1.41 + void MaybeSendProgress(); 1.42 + void MaybeSendStatus(); 1.43 + void ResetMembers(); 1.44 + bool DelayInEffect() { return mDelayedStatus || mDelayedProgress; } 1.45 + 1.46 + static void TimeoutHandler(nsITimer *aTimer, void *aClosure); 1.47 + 1.48 +private: 1.49 + nsCOMPtr<nsIWebProgressListener> mListener; 1.50 + nsCOMPtr<nsITimer> mTimer; 1.51 + 1.52 + // delayed values 1.53 + nsString mStatusMsg; 1.54 + int64_t mCurProgress; 1.55 + int64_t mMaxProgress; 1.56 + 1.57 + nsString mCurrentStatusMsg; 1.58 + bool mStatusIsDirty; 1.59 + int32_t mCurrentPercentage; 1.60 + 1.61 + // used to convert OnStart/OnStop notifications into progress notifications 1.62 + int32_t mTotalRequests; 1.63 + int32_t mFinishedRequests; 1.64 + bool mUseRealProgressFlag; 1.65 + 1.66 + // indicates whether a timeout is pending 1.67 + bool mDelayedStatus; 1.68 + bool mDelayedProgress; 1.69 +}; 1.70 + 1.71 +#define NS_BROWSERSTATUSFILTER_CONTRACTID \ 1.72 + "@mozilla.org/appshell/component/browser-status-filter;1" 1.73 +#define NS_BROWSERSTATUSFILTER_CID \ 1.74 +{ /* 6356aa16-7916-4215-a825-cbc2692ca87a */ \ 1.75 + 0x6356aa16, \ 1.76 + 0x7916, \ 1.77 + 0x4215, \ 1.78 + {0xa8, 0x25, 0xcb, 0xc2, 0x69, 0x2c, 0xa8, 0x7a} \ 1.79 +} 1.80 + 1.81 +#endif // !nsBrowserStatusFilter_h__