netwerk/dns/nsIDNSService.idl
author Kyle Machulis <kyle@nonpolynomial.com>
Wed, 10 Oct 2012 22:48:40 -0700
changeset 113348 e47353b30f18e46b660158753be885b2526410c5
parent 112200 02a62c14ec3b5d72cd014422b7427c2e9b2e5012
child 121093 45907821616dcd910a2b07f9363c5cf985d16322
permissions -rw-r--r--
Bug 796176 - Patch 1: UnixSocket changes to get connect/listen running main thread, connect status to consumers. r=cjones, a=blocking-basecamp

/* 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/. */

#include "nsISupports.idl"

interface nsICancelable;
interface nsIEventTarget;
interface nsIDNSRecord;
interface nsIDNSListener;

/**
 * nsIDNSService
 */
[scriptable, uuid(F6E05CC3-8A13-463D-877F-D59B20B59724)]
interface nsIDNSService : nsISupports
{
    /**
     * kicks off an asynchronous host lookup.
     *
     * @param aHostName
     *        the hostname or IP-address-literal to resolve.
     * @param aFlags
     *        a bitwise OR of the RESOLVE_ prefixed constants defined below.
     * @param aListener
     *        the listener to be notified when the result is available.
     * @param aListenerTarget
     *        optional parameter (may be null).  if non-null, this parameter
     *        specifies the nsIEventTarget of the thread on which the
     *        listener's onLookupComplete should be called.  however, if this
     *        parameter is null, then onLookupComplete will be called on an
     *        unspecified thread (possibly recursively).
     *
     * @return An object that can be used to cancel the host lookup.
     */
    nsICancelable asyncResolve(in AUTF8String       aHostName,
                               in unsigned long     aFlags,
                               in nsIDNSListener    aListener,
                               in nsIEventTarget    aListenerTarget);

    /**
     * Attempts to cancel a previously requested async DNS lookup
     *
     * @param aHostName
     *        the hostname or IP-address-literal to resolve.
     * @param aFlags
     *        a bitwise OR of the RESOLVE_ prefixed constants defined below.
     * @param aListener
     *        the original listener which was to be notified about the host lookup
     *        result - used to match request information to requestor.
     * @param aReason
     *        nsresult reason for the cancellation
     *
     * @return An object that can be used to cancel the host lookup.
     */
    void cancelAsyncResolve(in AUTF8String       aHostName,
                            in unsigned long     aFlags,
                            in nsIDNSListener    aListener,
                            in nsresult          aReason);
    
    /**
     * Called to synchronously resolve a hostname.  This method will fail
     * if called from the main thread.
     *
     * @param aHostName
     *        the hostname or IP-address-literal to resolve.
     * @param aFlags
     *        a bitwise OR of the RESOLVE_ prefixed constants defined below.
     *
     * @return DNS record corresponding to the given hostname.
     * @throws NS_ERROR_UNKNOWN_HOST if host could not be resolved.
     */
    nsIDNSRecord resolve(in AUTF8String   aHostName,
                         in unsigned long aFlags);

    /**
     * @return the hostname of the operating system.
     */
    readonly attribute AUTF8String myHostName;

    /*************************************************************************
     * Listed below are the various flags that may be OR'd together to form
     * the aFlags parameter passed to asyncResolve() and resolve().
     */

    /**
     * if set, this flag suppresses the internal DNS lookup cache.
     */
    const unsigned long RESOLVE_BYPASS_CACHE = (1 << 0);

    /**
     * if set, the canonical name of the specified host will be queried.
     */
    const unsigned long RESOLVE_CANONICAL_NAME = (1 << 1);

    /**
     * if set, the query is given lower priority. Medium takes precedence
     * if both are used.
     */
    const unsigned long RESOLVE_PRIORITY_MEDIUM = (1 << 2);
    const unsigned long RESOLVE_PRIORITY_LOW    = (1 << 3);

    /**
     * if set, indicates request is speculative. Speculative requests 
     * return errors if prefetching is disabled by configuration.
     */
    const unsigned long RESOLVE_SPECULATE = (1 << 4);

    /**
     * If set, only IPv4 addresses will be returned from resolve/asyncResolve.
     */
    const unsigned long RESOLVE_DISABLE_IPV6 = (1 << 5);

    /**
     * If set, only literals and cached entries will be returned from resolve/
     * asyncResolve.
     */
    const unsigned long RESOLVE_OFFLINE = (1 << 6);
};