2008-11-04 07:22:04 -08:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-05-21 04:12:37 -07: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 07:22:04 -08:00
|
|
|
|
|
|
|
#ifndef nsDNSPrefetch_h___
|
2008-12-05 12:53:24 -08:00
|
|
|
#define nsDNSPrefetch_h___
|
2008-11-04 07:22:04 -08:00
|
|
|
|
2013-11-27 10:19:14 -08:00
|
|
|
#include "nsWeakReference.h"
|
2008-11-04 07:22:04 -08:00
|
|
|
#include "nsString.h"
|
2011-05-22 21:29:42 -07:00
|
|
|
#include "mozilla/TimeStamp.h"
|
2012-06-05 20:18:25 -07:00
|
|
|
#include "mozilla/Attributes.h"
|
2008-11-04 07:22:04 -08:00
|
|
|
|
|
|
|
#include "nsIDNSListener.h"
|
|
|
|
|
|
|
|
class nsIURI;
|
|
|
|
class nsIDNSService;
|
|
|
|
|
2012-06-05 20:18:25 -07:00
|
|
|
class nsDNSPrefetch MOZ_FINAL : public nsIDNSListener
|
2008-11-04 07:22:04 -08:00
|
|
|
{
|
2014-06-24 09:36:44 -07:00
|
|
|
~nsDNSPrefetch() {}
|
|
|
|
|
2008-11-04 07:22:04 -08:00
|
|
|
public:
|
2013-07-18 19:24:13 -07:00
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
2008-11-04 07:22:04 -08:00
|
|
|
NS_DECL_NSIDNSLISTENER
|
|
|
|
|
2013-11-27 10:19:14 -08:00
|
|
|
nsDNSPrefetch(nsIURI *aURI, nsIDNSListener *aListener, bool storeTiming);
|
2011-05-22 21:29:42 -07: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; }
|
2008-11-04 07:22:04 -08:00
|
|
|
|
|
|
|
static nsresult Initialize(nsIDNSService *aDNSService);
|
|
|
|
static nsresult Shutdown();
|
|
|
|
|
|
|
|
// Call one of the following methods to start the Prefetch.
|
2013-11-21 13:35:45 -08:00
|
|
|
nsresult PrefetchHigh(bool refreshDNS = false);
|
|
|
|
nsresult PrefetchMedium(bool refreshDNS = false);
|
|
|
|
nsresult PrefetchLow(bool refreshDNS = false);
|
2008-11-04 07:22:04 -08:00
|
|
|
|
|
|
|
private:
|
2011-05-22 21:29:42 -07:00
|
|
|
nsCString mHostname;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mStoreTiming;
|
2011-05-22 21:29:42 -07:00
|
|
|
mozilla::TimeStamp mStartTimestamp;
|
|
|
|
mozilla::TimeStamp mEndTimestamp;
|
2013-11-27 10:19:14 -08:00
|
|
|
nsWeakPtr mListener;
|
2011-05-22 21:29:42 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
nsresult Prefetch(uint16_t flags);
|
2008-11-04 07:22:04 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|