Bug 1337893 - Part 1: Updating idl and ipdl files of DNS to make them originAttributes aware. r=valentin
authorTim Huang <tihuang@mozilla.com>
Wed, 15 Feb 2017 11:53:37 +0800
changeset 346139 b8ee0c21d462cfeb8a549785dd7c0cd0bbdbf3b4
parent 346138 c1e2141e8efe46a3245b15b044d39b977393de16
child 346140 7405ef5589cc1f141c22bc2de596c010be4d6c17
push id31459
push usercbook@mozilla.com
push dateTue, 07 Mar 2017 14:05:14 +0000
treeherdermozilla-central@1fb56ba248d5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvalentin
bugs1337893
milestone54.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1337893 - Part 1: Updating idl and ipdl files of DNS to make them originAttributes aware. r=valentin MozReview-Commit-ID: 8ev5AU1GKo5
netwerk/dns/PDNSRequest.ipdl
netwerk/dns/nsIDNSService.idl
netwerk/ipc/PNecko.ipdl
--- a/netwerk/dns/PDNSRequest.ipdl
+++ b/netwerk/dns/PDNSRequest.ipdl
@@ -6,30 +6,33 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 include protocol PNecko;
 
 include PDNSRequestParams;
 
 include "mozilla/net/NeckoMessageUtils.h";
 
+using mozilla::OriginAttributes from "mozilla/ipc/BackgroundUtils.h";
+
 namespace mozilla {
 namespace net {
 
 async protocol PDNSRequest
 {
   manager PNecko;
 
 parent:
   // constructor in PNecko takes AsyncResolve args that initialize request
 
   // Pass args here rather than storing them in the parent; they are only
   // needed if the request is to be canceled.
-  async CancelDNSRequest(nsCString hostName, uint32_t flags,
-                         nsCString networkInterface, nsresult reason);
+  async CancelDNSRequest(nsCString hostName, OriginAttributes originAttributes,
+                         uint32_t flags, nsCString networkInterface,
+                         nsresult reason);
   async __delete__();
 
 child:
   async LookupCompleted(DNSRequestResponse reply);
 
 };
 
 } //namespace net
--- a/netwerk/dns/nsIDNSService.idl
+++ b/netwerk/dns/nsIDNSService.idl
@@ -1,27 +1,32 @@
 /* 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"
 
+%{ C++
+#include "mozilla/BasePrincipal.h"
+%}
+
 interface nsICancelable;
 interface nsIEventTarget;
 interface nsIDNSRecord;
 interface nsIDNSListener;
 
 %{C++
 #include "nsTArrayForwardDeclare.h"
 namespace mozilla { namespace net {
     struct DNSCacheEntries;
 } }
 %}
 
 [ptr] native EntriesArray(nsTArray<mozilla::net::DNSCacheEntries>);
+[ref] native OriginAttributes(const mozilla::OriginAttributes);
 
 /**
  * nsIDNSService
  */
 [scriptable, uuid(de5642c6-61fc-4fcf-9a47-03226b0d4e21)]
 interface nsIDNSService : nsISupports
 {
     /**
@@ -34,84 +39,143 @@ interface nsIDNSService : nsISupports
      * @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).
+     * @param aOriginAttributes
+     *        the originAttribute for this resolving, the DNS cache will be
+     *        separated according to this originAttributes. This attribute is
+     *        optional to avoid breaking add-ons.
      *
      * @return An object that can be used to cancel the host lookup.
      */
+    [implicit_jscontext, optional_argc]
     nsICancelable asyncResolve(in AUTF8String       aHostName,
                                in unsigned long     aFlags,
                                in nsIDNSListener    aListener,
-                               in nsIEventTarget    aListenerTarget);
+                               in nsIEventTarget    aListenerTarget,
+                    [optional] in jsval aOriginAttributes);
+
+    [notxpcom]
+    nsresult asyncResolveNative(in AUTF8String       aHostName,
+                                in unsigned long     aFlags,
+                                in nsIDNSListener    aListener,
+                                in nsIEventTarget    aListenerTarget,
+                                in OriginAttributes  aOriginAttributes,
+                                out nsICancelable    aResult);
 
     /**
      * 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
+     * @param aOriginAttributes
+     *        the originAttribute for this resolving. This attribute is optional
+     *        to avoid breaking add-ons.
      *
      * @return An object that can be used to cancel the host lookup.
      */
+    [implicit_jscontext, optional_argc]
     void cancelAsyncResolve(in AUTF8String       aHostName,
                             in unsigned long     aFlags,
                             in nsIDNSListener    aListener,
-                            in nsresult          aReason);
+                            in nsresult          aReason,
+                 [optional] in jsval             aOriginAttributes);
+
+    [notxpcom]
+    nsresult cancelAsyncResolveNative(in AUTF8String       aHostName,
+                                      in unsigned long     aFlags,
+                                      in nsIDNSListener    aListener,
+                                      in nsresult          aReason,
+                                      in OriginAttributes  aOriginAttributes);
 
     /**
      * called to synchronously resolve a hostname.  warning this method may
      * block the calling thread for a long period of time.  it is extremely
      * unwise to call this function on the UI thread of an application.
      *
      * @param aHostName
      *        the hostname or IP-address-literal to resolve.
      * @param aFlags
      *        a bitwise OR of the RESOLVE_ prefixed constants defined below.
+     * @param aOriginAttributes
+     *        the originAttribute for this resolving, the DNS cache will be
+     *        separated according to this originAttributes. This attribute is
+     *        optional to avoid breaking add-ons.
      *
      * @return DNS record corresponding to the given hostname.
      * @throws NS_ERROR_UNKNOWN_HOST if host could not be resolved.
      */
+    [implicit_jscontext, optional_argc]
     nsIDNSRecord resolve(in AUTF8String   aHostName,
-                         in unsigned long aFlags);
+                         in unsigned long aFlags,
+              [optional] in jsval         aOriginAttributes);
+
+    [notxpcom]
+    nsresult resolveNative(in AUTF8String       aHostName,
+                           in unsigned long     aFlags,
+                           in OriginAttributes  aOriginAttributes,
+                           out nsIDNSRecord     aResult);
 
     /**
      * kicks off an asynchronous host lookup.
      *
      * This function is identical to asyncResolve except an additional
      * parameter aNetwortInterface. If parameter aNetworkInterface is an empty
      * string function will return the same result as asyncResolve.
      * Setting aNetworkInterface value make only sense for gonk,because it
      * an per networking interface query is possible.
      */
+    [implicit_jscontext, optional_argc]
     nsICancelable asyncResolveExtended(in AUTF8String       aHostName,
                                        in unsigned long     aFlags,
                                        in AUTF8String       aNetworkInterface,
                                        in nsIDNSListener    aListener,
-                                       in nsIEventTarget    aListenerTarget);
+                                       in nsIEventTarget    aListenerTarget,
+                            [optional] in jsval             aOriginAttributes);
+
+    [notxpcom]
+    nsresult asyncResolveExtendedNative(in AUTF8String       aHostName,
+                                        in unsigned long     aFlags,
+                                        in AUTF8String       aNetworkInterface,
+                                        in nsIDNSListener    aListener,
+                                        in nsIEventTarget    aListenerTarget,
+                                        in OriginAttributes  aOriginAttributes,
+                                        out nsICancelable    aResult);
 
     /**
      * Attempts to cancel a previously requested async DNS lookup
      * This is an extended versin with a additional parameter aNetworkInterface
      */
+    [implicit_jscontext, optional_argc]
     void cancelAsyncResolveExtended(in AUTF8String       aHostName,
                                     in unsigned long     aFlags,
                                     in AUTF8String       aNetworkInterface,
                                     in nsIDNSListener    aListener,
-                                    in nsresult          aReason);
+                                    in nsresult          aReason,
+                         [optional] in jsval             aOriginAttributes);
+
+    [notxpcom]
+    nsresult cancelAsyncResolveExtendedNative(in AUTF8String       aHostName,
+                                              in unsigned long     aFlags,
+                                              in AUTF8String       aNetworkInterface,
+                                              in nsIDNSListener    aListener,
+                                              in nsresult          aReason,
+                                              in OriginAttributes  aOriginAttributes);
 
     /**
      * The method takes a pointer to an nsTArray
      * and fills it with cache entry data
      * Called by the networking dashboard
      */
     [noscript] void getDNSCacheEntries(in EntriesArray args);
 
--- a/netwerk/ipc/PNecko.ipdl
+++ b/netwerk/ipc/PNecko.ipdl
@@ -71,31 +71,34 @@ parent:
   async PFTPChannel(PBrowserOrId browser, SerializedLoadContext loadContext,
                     FTPChannelCreationArgs args);
 
   async PWebSocket(PBrowserOrId browser, SerializedLoadContext loadContext,
                    uint32_t aSerialID);
   async PTCPServerSocket(uint16_t localPort, uint16_t backlog, bool useArrayBuffers);
   async PUDPSocket(Principal principal, nsCString filter);
 
-  async PDNSRequest(nsCString hostName, uint32_t flags, nsCString networkInterface);
+  async PDNSRequest(nsCString hostName, OriginAttributes originAttributes,
+                    uint32_t flags, nsCString networkInterface);
 
   async PWebSocketEventListener(uint64_t aInnerWindowID);
 
   /* Predictor Methods */
   async PredPredict(OptionalURIParams targetURI, OptionalURIParams sourceURI,
                     uint32_t reason, OriginAttributes originAttributes,
                     bool hasVerifier);
   async PredLearn(URIParams targetURI, OptionalURIParams sourceURI,
                   uint32_t reason, OriginAttributes originAttributes);
   async PredReset();
 
   async SpeculativeConnect(URIParams uri, Principal principal, bool anonymous);
-  async HTMLDNSPrefetch(nsString hostname, uint16_t flags);
-  async CancelHTMLDNSPrefetch(nsString hostname, uint16_t flags, nsresult reason);
+  async HTMLDNSPrefetch(nsString hostname, OriginAttributes originAttributes,
+                        uint16_t flags);
+  async CancelHTMLDNSPrefetch(nsString hostname, OriginAttributes originAttributes,
+                              uint16_t flags, nsresult reason);
 
   /**
    * channelId is used to establish a connection between redirect channels in
    * the parent and the child when we're redirecting to a data: URI.
    */
   async PDataChannel(uint32_t channelId);
 
   async PRtspController();