netwerk/base/src/nsDNSPrefetch.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/netwerk/base/src/nsDNSPrefetch.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,51 @@
     1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef nsDNSPrefetch_h___
    1.10 +#define nsDNSPrefetch_h___
    1.11 +
    1.12 +#include "nsWeakReference.h"
    1.13 +#include "nsString.h"
    1.14 +#include "mozilla/TimeStamp.h"
    1.15 +#include "mozilla/Attributes.h"
    1.16 +
    1.17 +#include "nsIDNSListener.h"
    1.18 +
    1.19 +class nsIURI;
    1.20 +class nsIDNSService;
    1.21 +
    1.22 +class nsDNSPrefetch MOZ_FINAL : public nsIDNSListener
    1.23 +{
    1.24 +public:
    1.25 +    NS_DECL_THREADSAFE_ISUPPORTS
    1.26 +    NS_DECL_NSIDNSLISTENER
    1.27 +  
    1.28 +    nsDNSPrefetch(nsIURI *aURI, nsIDNSListener *aListener, bool storeTiming);
    1.29 +    bool TimingsValid() const {
    1.30 +        return !mStartTimestamp.IsNull() && !mEndTimestamp.IsNull();
    1.31 +    }
    1.32 +    // Only use the two timings if TimingsValid() returns true
    1.33 +    const mozilla::TimeStamp& StartTimestamp() const { return mStartTimestamp; }
    1.34 +    const mozilla::TimeStamp& EndTimestamp() const { return mEndTimestamp; }
    1.35 +
    1.36 +    static nsresult Initialize(nsIDNSService *aDNSService);
    1.37 +    static nsresult Shutdown();
    1.38 +
    1.39 +    // Call one of the following methods to start the Prefetch.
    1.40 +    nsresult PrefetchHigh(bool refreshDNS = false);
    1.41 +    nsresult PrefetchMedium(bool refreshDNS = false);
    1.42 +    nsresult PrefetchLow(bool refreshDNS = false);
    1.43 +  
    1.44 +private:
    1.45 +    nsCString mHostname;
    1.46 +    bool mStoreTiming;
    1.47 +    mozilla::TimeStamp mStartTimestamp;
    1.48 +    mozilla::TimeStamp mEndTimestamp;
    1.49 +    nsWeakPtr mListener;
    1.50 +
    1.51 +    nsresult Prefetch(uint16_t flags);
    1.52 +};
    1.53 +
    1.54 +#endif 

mercurial