/src/mozilla-central/netwerk/base/nsDNSPrefetch.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
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/. */ |
5 | | |
6 | | #ifndef nsDNSPrefetch_h___ |
7 | | #define nsDNSPrefetch_h___ |
8 | | |
9 | | #include "nsWeakReference.h" |
10 | | #include "nsString.h" |
11 | | #include "mozilla/TimeStamp.h" |
12 | | #include "mozilla/Attributes.h" |
13 | | #include "mozilla/BasePrincipal.h" |
14 | | |
15 | | #include "nsIDNSListener.h" |
16 | | |
17 | | class nsIURI; |
18 | | class nsIDNSService; |
19 | | |
20 | | class nsDNSPrefetch final : public nsIDNSListener |
21 | | { |
22 | 0 | ~nsDNSPrefetch() = default; |
23 | | |
24 | | public: |
25 | | NS_DECL_THREADSAFE_ISUPPORTS |
26 | | NS_DECL_NSIDNSLISTENER |
27 | | |
28 | | nsDNSPrefetch(nsIURI *aURI, mozilla::OriginAttributes& aOriginAttributes, |
29 | | nsIDNSListener *aListener, bool storeTiming); |
30 | 0 | bool TimingsValid() const { |
31 | 0 | return !mStartTimestamp.IsNull() && !mEndTimestamp.IsNull(); |
32 | 0 | } |
33 | | // Only use the two timings if TimingsValid() returns true |
34 | 0 | const mozilla::TimeStamp& StartTimestamp() const { return mStartTimestamp; } |
35 | 0 | const mozilla::TimeStamp& EndTimestamp() const { return mEndTimestamp; } |
36 | | |
37 | | static nsresult Initialize(nsIDNSService *aDNSService); |
38 | | static nsresult Shutdown(); |
39 | | |
40 | | // Call one of the following methods to start the Prefetch. |
41 | | nsresult PrefetchHigh(bool refreshDNS = false); |
42 | | nsresult PrefetchMedium(bool refreshDNS = false); |
43 | | nsresult PrefetchLow(bool refreshDNS = false); |
44 | | |
45 | | private: |
46 | | nsCString mHostname; |
47 | | bool mIsHttps; |
48 | | mozilla::OriginAttributes mOriginAttributes; |
49 | | bool mStoreTiming; |
50 | | mozilla::TimeStamp mStartTimestamp; |
51 | | mozilla::TimeStamp mEndTimestamp; |
52 | | nsWeakPtr mListener; |
53 | | |
54 | | nsresult Prefetch(uint16_t flags); |
55 | | }; |
56 | | |
57 | | #endif |