Bug 1526591 - Remove devtools.inspector.shapesHighlighter.enabled pref. r=rcaliman
[gecko.git] / netwerk / base / nsDNSPrefetch.h
blob698adb9275cd73dd1e7a8e72cbb7a1f6b207ceca
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef nsDNSPrefetch_h___
7 #define nsDNSPrefetch_h___
9 #include "nsIWeakReferenceUtils.h"
10 #include "nsString.h"
11 #include "mozilla/TimeStamp.h"
12 #include "mozilla/Attributes.h"
13 #include "mozilla/BasePrincipal.h"
15 #include "nsIDNSListener.h"
17 class nsIURI;
18 class nsIDNSService;
20 class nsDNSPrefetch final : public nsIDNSListener {
21 ~nsDNSPrefetch() = default;
23 public:
24 NS_DECL_THREADSAFE_ISUPPORTS
25 NS_DECL_NSIDNSLISTENER
27 nsDNSPrefetch(nsIURI* aURI, mozilla::OriginAttributes& aOriginAttributes,
28 nsIDNSListener* aListener, bool storeTiming);
29 bool TimingsValid() const {
30 return !mStartTimestamp.IsNull() && !mEndTimestamp.IsNull();
32 // Only use the two timings if TimingsValid() returns true
33 const mozilla::TimeStamp& StartTimestamp() const { return mStartTimestamp; }
34 const mozilla::TimeStamp& EndTimestamp() const { return mEndTimestamp; }
36 static nsresult Initialize(nsIDNSService* aDNSService);
37 static nsresult Shutdown();
39 // Call one of the following methods to start the Prefetch.
40 nsresult PrefetchHigh(bool refreshDNS = false);
41 nsresult PrefetchMedium(bool refreshDNS = false);
42 nsresult PrefetchLow(bool refreshDNS = false);
44 private:
45 nsCString mHostname;
46 bool mIsHttps;
47 mozilla::OriginAttributes mOriginAttributes;
48 bool mStoreTiming;
49 mozilla::TimeStamp mStartTimestamp;
50 mozilla::TimeStamp mEndTimestamp;
51 nsWeakPtr mListener;
53 nsresult Prefetch(uint16_t flags);
56 #endif