author B2G Bumper Bot <>
Mon, 22 Feb 2016 03:50:56 -0800
changeset 325570 eb40b8a7a68c57c380ae8b42fcacdcaaff159e0a
parent 263771 ac4464790ec4896a5188fa50cfc69ae0ffeddc08
child 394258 a98c0d18ca5e674181625cbe6c07c5c85853c0f2
permissions -rw-r--r--
Bumping manifests a=b2g-bump

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* 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 */

#ifndef nsDNSPrefetch_h___
#define nsDNSPrefetch_h___

#include "nsWeakReference.h"
#include "nsString.h"
#include "mozilla/TimeStamp.h"
#include "mozilla/Attributes.h"

#include "nsIDNSListener.h"

class nsIURI;
class nsIDNSService;

class nsDNSPrefetch final : public nsIDNSListener
    ~nsDNSPrefetch() {}

    nsDNSPrefetch(nsIURI *aURI, nsIDNSListener *aListener, bool storeTiming);
    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; }

    static nsresult Initialize(nsIDNSService *aDNSService);
    static nsresult Shutdown();

    // Call one of the following methods to start the Prefetch.
    nsresult PrefetchHigh(bool refreshDNS = false);
    nsresult PrefetchMedium(bool refreshDNS = false);
    nsresult PrefetchLow(bool refreshDNS = false);
    nsCString mHostname;
    bool mStoreTiming;
    mozilla::TimeStamp mStartTimestamp;
    mozilla::TimeStamp mEndTimestamp;
    nsWeakPtr mListener;

    nsresult Prefetch(uint16_t flags);