Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef nsDNSPrefetch_h___ |
michael@0 | 7 | #define nsDNSPrefetch_h___ |
michael@0 | 8 | |
michael@0 | 9 | #include "nsWeakReference.h" |
michael@0 | 10 | #include "nsString.h" |
michael@0 | 11 | #include "mozilla/TimeStamp.h" |
michael@0 | 12 | #include "mozilla/Attributes.h" |
michael@0 | 13 | |
michael@0 | 14 | #include "nsIDNSListener.h" |
michael@0 | 15 | |
michael@0 | 16 | class nsIURI; |
michael@0 | 17 | class nsIDNSService; |
michael@0 | 18 | |
michael@0 | 19 | class nsDNSPrefetch MOZ_FINAL : public nsIDNSListener |
michael@0 | 20 | { |
michael@0 | 21 | public: |
michael@0 | 22 | NS_DECL_THREADSAFE_ISUPPORTS |
michael@0 | 23 | NS_DECL_NSIDNSLISTENER |
michael@0 | 24 | |
michael@0 | 25 | nsDNSPrefetch(nsIURI *aURI, nsIDNSListener *aListener, bool storeTiming); |
michael@0 | 26 | bool TimingsValid() const { |
michael@0 | 27 | return !mStartTimestamp.IsNull() && !mEndTimestamp.IsNull(); |
michael@0 | 28 | } |
michael@0 | 29 | // Only use the two timings if TimingsValid() returns true |
michael@0 | 30 | const mozilla::TimeStamp& StartTimestamp() const { return mStartTimestamp; } |
michael@0 | 31 | const mozilla::TimeStamp& EndTimestamp() const { return mEndTimestamp; } |
michael@0 | 32 | |
michael@0 | 33 | static nsresult Initialize(nsIDNSService *aDNSService); |
michael@0 | 34 | static nsresult Shutdown(); |
michael@0 | 35 | |
michael@0 | 36 | // Call one of the following methods to start the Prefetch. |
michael@0 | 37 | nsresult PrefetchHigh(bool refreshDNS = false); |
michael@0 | 38 | nsresult PrefetchMedium(bool refreshDNS = false); |
michael@0 | 39 | nsresult PrefetchLow(bool refreshDNS = false); |
michael@0 | 40 | |
michael@0 | 41 | private: |
michael@0 | 42 | nsCString mHostname; |
michael@0 | 43 | bool mStoreTiming; |
michael@0 | 44 | mozilla::TimeStamp mStartTimestamp; |
michael@0 | 45 | mozilla::TimeStamp mEndTimestamp; |
michael@0 | 46 | nsWeakPtr mListener; |
michael@0 | 47 | |
michael@0 | 48 | nsresult Prefetch(uint16_t flags); |
michael@0 | 49 | }; |
michael@0 | 50 | |
michael@0 | 51 | #endif |