2018-11-30 22:52:05 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2008-11-04 18:22:04 +03:00
|
|
|
|
|
|
|
#ifndef nsDNSPrefetch_h___
|
2008-12-05 23:53:24 +03:00
|
|
|
#define nsDNSPrefetch_h___
|
2008-11-04 18:22:04 +03:00
|
|
|
|
2018-10-31 23:39:03 +03:00
|
|
|
#include "nsIWeakReferenceUtils.h"
|
2008-11-04 18:22:04 +03:00
|
|
|
#include "nsString.h"
|
2011-05-23 08:29:42 +04:00
|
|
|
#include "mozilla/TimeStamp.h"
|
2012-06-06 07:18:25 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2017-02-15 12:48:15 +03:00
|
|
|
#include "mozilla/BasePrincipal.h"
|
2008-11-04 18:22:04 +03:00
|
|
|
|
|
|
|
#include "nsIDNSListener.h"
|
|
|
|
|
|
|
|
class nsIURI;
|
|
|
|
class nsIDNSService;
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class nsDNSPrefetch final : public nsIDNSListener {
|
2018-04-30 19:46:04 +03:00
|
|
|
~nsDNSPrefetch() = default;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2008-11-04 18:22:04 +03:00
|
|
|
public:
|
2013-07-19 06:24:13 +04:00
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
2008-11-04 18:22:04 +03:00
|
|
|
NS_DECL_NSIDNSLISTENER
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2017-02-15 12:48:15 +03:00
|
|
|
nsDNSPrefetch(nsIURI* aURI, mozilla::OriginAttributes& aOriginAttributes,
|
|
|
|
nsIDNSListener* aListener, bool storeTiming);
|
2011-05-23 08:29:42 +04:00
|
|
|
bool TimingsValid() const {
|
|
|
|
return !mStartTimestamp.IsNull() && !mEndTimestamp.IsNull();
|
|
|
|
}
|
|
|
|
// Only use the two timings if TimingsValid() returns true
|
|
|
|
const mozilla::TimeStamp& StartTimestamp() const { return mStartTimestamp; }
|
|
|
|
const mozilla::TimeStamp& EndTimestamp() const { return mEndTimestamp; }
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2008-11-04 18:22:04 +03:00
|
|
|
static nsresult Initialize(nsIDNSService* aDNSService);
|
|
|
|
static nsresult Shutdown();
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2008-11-04 18:22:04 +03:00
|
|
|
// Call one of the following methods to start the Prefetch.
|
2013-11-22 01:35:45 +04:00
|
|
|
nsresult PrefetchHigh(bool refreshDNS = false);
|
|
|
|
nsresult PrefetchMedium(bool refreshDNS = false);
|
|
|
|
nsresult PrefetchLow(bool refreshDNS = false);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2008-11-04 18:22:04 +03:00
|
|
|
private:
|
2011-05-23 08:29:42 +04:00
|
|
|
nsCString mHostname;
|
2018-09-22 23:54:11 +03:00
|
|
|
bool mIsHttps;
|
2017-02-15 12:48:15 +03:00
|
|
|
mozilla::OriginAttributes mOriginAttributes;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mStoreTiming;
|
2011-05-23 08:29:42 +04:00
|
|
|
mozilla::TimeStamp mStartTimestamp;
|
|
|
|
mozilla::TimeStamp mEndTimestamp;
|
2013-11-27 22:19:14 +04:00
|
|
|
nsWeakPtr mListener;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
nsresult Prefetch(uint16_t flags);
|
2008-11-04 18:22:04 +03:00
|
|
|
};
|
|
|
|
|
2017-07-06 15:00:35 +03:00
|
|
|
#endif
|