michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef nsDNSPrefetch_h___ michael@0: #define nsDNSPrefetch_h___ michael@0: michael@0: #include "nsWeakReference.h" michael@0: #include "nsString.h" michael@0: #include "mozilla/TimeStamp.h" michael@0: #include "mozilla/Attributes.h" michael@0: michael@0: #include "nsIDNSListener.h" michael@0: michael@0: class nsIURI; michael@0: class nsIDNSService; michael@0: michael@0: class nsDNSPrefetch MOZ_FINAL : public nsIDNSListener michael@0: { michael@0: public: michael@0: NS_DECL_THREADSAFE_ISUPPORTS michael@0: NS_DECL_NSIDNSLISTENER michael@0: michael@0: nsDNSPrefetch(nsIURI *aURI, nsIDNSListener *aListener, bool storeTiming); michael@0: bool TimingsValid() const { michael@0: return !mStartTimestamp.IsNull() && !mEndTimestamp.IsNull(); michael@0: } michael@0: // Only use the two timings if TimingsValid() returns true michael@0: const mozilla::TimeStamp& StartTimestamp() const { return mStartTimestamp; } michael@0: const mozilla::TimeStamp& EndTimestamp() const { return mEndTimestamp; } michael@0: michael@0: static nsresult Initialize(nsIDNSService *aDNSService); michael@0: static nsresult Shutdown(); michael@0: michael@0: // Call one of the following methods to start the Prefetch. michael@0: nsresult PrefetchHigh(bool refreshDNS = false); michael@0: nsresult PrefetchMedium(bool refreshDNS = false); michael@0: nsresult PrefetchLow(bool refreshDNS = false); michael@0: michael@0: private: michael@0: nsCString mHostname; michael@0: bool mStoreTiming; michael@0: mozilla::TimeStamp mStartTimestamp; michael@0: mozilla::TimeStamp mEndTimestamp; michael@0: nsWeakPtr mListener; michael@0: michael@0: nsresult Prefetch(uint16_t flags); michael@0: }; michael@0: michael@0: #endif