Backed out changeset a1d51e3fea63 (bug 935838) for B2G test_udpsocket.html timeouts.
authorRyan VanderMeulen <ryanvm@gmail.com>
Mon, 09 Mar 2015 16:35:06 -0400
changeset 249274 468eb0cd72c52c83854867f9eb741be717be4fb9
parent 249273 0f36303520aa31ce4e13a2d0711a6c69a57a1a6f
child 249275 1d8fe559384eabc16426c9e9502129c0ac177752
push id971
push userjbruaroey@mozilla.com
push dateTue, 10 Mar 2015 17:33:09 +0000
bugs935838
milestone39.0a1
backs outa1d51e3fea63060a607372b24870d00a9596327c
Backed out changeset a1d51e3fea63 (bug 935838) for B2G test_udpsocket.html timeouts. CLOSED TREE
dom/network/UDPSocket.cpp
dom/network/UDPSocketChild.cpp
dom/network/UDPSocketParent.cpp
dom/network/UDPSocketParent.h
dom/network/interfaces/nsIUDPSocketChild.idl
dom/push/PushService.jsm
media/mtransport/nr_socket_prsock.cpp
netwerk/base/nsIUDPSocket.idl
netwerk/base/nsUDPSocket.cpp
netwerk/base/nsUDPSocket.h
netwerk/ipc/NeckoChild.cpp
netwerk/ipc/NeckoChild.h
netwerk/ipc/NeckoParent.cpp
netwerk/ipc/NeckoParent.h
netwerk/ipc/PNecko.ipdl
netwerk/test/TestUDPSocket.cpp
netwerk/test/unit/test_udp_multicast.js
netwerk/test/unit/test_udpsocket.js
toolkit/devtools/discovery/discovery.js
toolkit/modules/secondscreen/SimpleServiceDiscovery.jsm
--- a/dom/network/UDPSocket.cpp
+++ b/dom/network/UDPSocket.cpp
@@ -382,38 +382,26 @@ UDPSocket::InitLocal(const nsAString& aL
   nsresult rv;
 
   nsCOMPtr<nsIUDPSocket> sock =
       do_CreateInstance("@mozilla.org/network/udp-socket;1", &rv);
   if (NS_FAILED(rv)) {
     return rv;
   }
 
-  nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(GetOwner(), &rv);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-
-  nsCOMPtr<nsIPrincipal> principal = global->PrincipalOrNull();
-  if (!principal) {
-    return NS_ERROR_FAILURE;
-  }
-
   if (aLocalAddress.IsEmpty()) {
-    rv = sock->Init(aLocalPort, /* loopback = */ false, principal,
-                    mAddressReuse, /* optionalArgc = */ 1);
+    rv = sock->Init(aLocalPort, /* loopback = */ false, mAddressReuse, /* optionalArgc = */ 1);
   } else {
     PRNetAddr prAddr;
     PR_InitializeNetAddr(PR_IpAddrAny, aLocalPort, &prAddr);
     PR_StringToNetAddr(NS_ConvertUTF16toUTF8(aLocalAddress).BeginReading(), &prAddr);
 
     mozilla::net::NetAddr addr;
     PRNetAddrToNetAddr(&prAddr, &addr);
-    rv = sock->InitWithAddress(&addr, principal, mAddressReuse,
-                               /* optionalArgc = */ 1);
+    rv = sock->InitWithAddress(&addr, mAddressReuse, /* optionalArgc = */ 1);
   }
   if (NS_FAILED(rv)) {
     return rv;
   }
 
   rv = sock->SetMulticastLoopback(mLoopback);
   if (NS_FAILED(rv)) {
     return rv;
@@ -465,29 +453,17 @@ UDPSocket::InitRemote(const nsAString& a
   nsresult rv;
 
   nsCOMPtr<nsIUDPSocketChild> sock =
     do_CreateInstance("@mozilla.org/udp-socket-child;1", &rv);
   if (NS_FAILED(rv)) {
     return rv;
   }
 
-  nsCOMPtr<nsIGlobalObject> obj = do_QueryInterface(GetOwner(), &rv);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-
-  nsCOMPtr<nsIPrincipal> principal = obj->PrincipalOrNull();
-  if (!principal) {
-    return NS_ERROR_FAILURE;
-  }
-
-  rv = sock->Bind(this, principal,
-                  NS_ConvertUTF16toUTF8(aLocalAddress), aLocalPort,
-                  mAddressReuse, mLoopback);
+  rv = sock->Bind(this, NS_ConvertUTF16toUTF8(aLocalAddress), aLocalPort, mAddressReuse, mLoopback);
   if (NS_FAILED(rv)) {
     return rv;
   }
 
   mSocketChild = sock;
 
   return NS_OK;
 }
--- a/dom/network/UDPSocketChild.cpp
+++ b/dom/network/UDPSocketChild.cpp
@@ -1,17 +1,16 @@
 /* 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 "UDPSocketChild.h"
 #include "mozilla/unused.h"
 #include "mozilla/ipc/InputStreamUtils.h"
 #include "mozilla/net/NeckoChild.h"
-#include "mozilla/dom/PermissionMessageUtils.h"
 
 using mozilla::net::gNeckoChild;
 
 namespace mozilla {
 namespace dom {
 
 NS_IMPL_ISUPPORTS(UDPSocketChildBase, nsIUDPSocketChild)
 
@@ -59,29 +58,27 @@ UDPSocketChild::UDPSocketChild()
 UDPSocketChild::~UDPSocketChild()
 {
 }
 
 // nsIUDPSocketChild Methods
 
 NS_IMETHODIMP
 UDPSocketChild::Bind(nsIUDPSocketInternal* aSocket,
-                     nsIPrincipal* aPrincipal,
                      const nsACString& aHost,
                      uint16_t aPort,
                      bool aAddressReuse,
                      bool aLoopback)
 {
   NS_ENSURE_ARG(aSocket);
 
   mSocket = aSocket;
   AddIPDLReference();
 
-  gNeckoChild->SendPUDPSocketConstructor(this, IPC::Principal(aPrincipal),
-                                         mFilterName);
+  gNeckoChild->SendPUDPSocketConstructor(this, mFilterName);
 
   SendBind(UDPAddressInfo(nsCString(aHost), aPort), aAddressReuse, aLoopback);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 UDPSocketChild::Close()
 {
--- a/dom/network/UDPSocketParent.cpp
+++ b/dom/network/UDPSocketParent.cpp
@@ -13,18 +13,16 @@
 #include "mozilla/unused.h"
 #include "mozilla/ipc/InputStreamUtils.h"
 #include "mozilla/net/DNS.h"
 #include "mozilla/net/NeckoCommon.h"
 #include "mozilla/net/PNeckoParent.h"
 #include "nsNetUtil.h"
 #include "mozilla/dom/ContentParent.h"
 #include "mozilla/dom/TabParent.h"
-#include "nsIPermissionManager.h"
-#include "nsIScriptSecurityManager.h"
 
 namespace mozilla {
 namespace dom {
 
 NS_IMPL_ISUPPORTS(UDPSocketParent, nsIUDPSocketListener)
 
 UDPSocketParent::UDPSocketParent()
   : mIPCOpen(true)
@@ -62,56 +60,29 @@ UDPSocketParent::OfflineNotification(nsI
   }
 
   return NS_OK;
 }
 
 uint32_t
 UDPSocketParent::GetAppId()
 {
-  if (!mPrincipal) {
-    return nsIScriptSecurityManager::UNKNOWN_APP_ID;
+  uint32_t appId = nsIScriptSecurityManager::UNKNOWN_APP_ID;
+  const PContentParent *content = Manager()->Manager();
+  const InfallibleTArray<PBrowserParent*>& browsers = content->ManagedPBrowserParent();
+  if (browsers.Length() > 0) {
+    TabParent *tab = TabParent::GetFrom(browsers[0]);
+    appId = tab->OwnAppId();
   }
-
-  uint32_t appId = nsIScriptSecurityManager::UNKNOWN_APP_ID;
-  nsresult rv = mPrincipal->GetAppId(&appId);
-  if (NS_FAILED(rv)) {
-    appId = nsIScriptSecurityManager::UNKNOWN_APP_ID;
-  }
-
   return appId;
 }
 
 bool
-UDPSocketParent::Init(const IPC::Principal& aPrincipal,
-                      const nsACString& aFilter)
+UDPSocketParent::Init(const nsACString& aFilter)
 {
-  mPrincipal = aPrincipal;
-  if (net::UsingNeckoIPCSecurity() &&
-      mPrincipal &&
-      !ContentParent::IgnoreIPCPrincipal()) {
-    if (!AssertAppPrincipal(Manager()->Manager(), mPrincipal)) {
-      return false;
-    }
-
-    nsCOMPtr<nsIPermissionManager> permMgr =
-      services::GetPermissionManager();
-    if (!permMgr) {
-      NS_WARNING("No PermissionManager available!");
-      return false;
-    }
-
-    uint32_t permission = nsIPermissionManager::DENY_ACTION;
-    permMgr->TestExactPermissionFromPrincipal(mPrincipal, "udp-socket",
-                                              &permission);
-    if (permission != nsIPermissionManager::ALLOW_ACTION) {
-      return false;
-    }
-  }
-
   if (!aFilter.IsEmpty()) {
     nsAutoCString contractId(NS_NETWORK_UDP_SOCKET_FILTER_HANDLER_PREFIX);
     contractId.Append(aFilter);
     nsCOMPtr<nsIUDPSocketFilterHandler> filterHandler =
       do_GetService(contractId.get());
     if (filterHandler) {
       nsresult rv = filterHandler->NewFilter(getter_AddRefs(mFilter));
       if (NS_FAILED(rv)) {
@@ -131,19 +102,20 @@ UDPSocketParent::Init(const IPC::Princip
 // PUDPSocketParent methods
 
 bool
 UDPSocketParent::RecvBind(const UDPAddressInfo& aAddressInfo,
                           const bool& aAddressReuse, const bool& aLoopback)
 {
   // We don't have browser actors in xpcshell, and hence can't run automated
   // tests without this loophole.
-  if (net::UsingNeckoIPCSecurity() && !mFilter) {
+  if (net::UsingNeckoIPCSecurity() && !mFilter &&
+      !AssertAppProcessPermission(Manager()->Manager(), "udp-socket")) {
     FireInternalError(__LINE__);
-    return true;
+    return false;
   }
 
   if (NS_FAILED(BindInternal(aAddressInfo.addr(), aAddressInfo.port(), aAddressReuse, aLoopback))) {
     FireInternalError(__LINE__);
     return true;
   }
 
   nsCOMPtr<nsINetAddr> localAddr;
@@ -175,30 +147,28 @@ UDPSocketParent::BindInternal(const nsCS
   nsCOMPtr<nsIUDPSocket> sock =
       do_CreateInstance("@mozilla.org/network/udp-socket;1", &rv);
 
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   if (aHost.IsEmpty()) {
-    rv = sock->Init(aPort, false, mPrincipal, aAddressReuse,
-                    /* optional_argc = */ 1);
+    rv = sock->Init(aPort, false, aAddressReuse, /* optional_argc = */ 1);
   } else {
     PRNetAddr prAddr;
     PR_InitializeNetAddr(PR_IpAddrAny, aPort, &prAddr);
     PRStatus status = PR_StringToNetAddr(aHost.BeginReading(), &prAddr);
     if (status != PR_SUCCESS) {
       return NS_ERROR_FAILURE;
     }
 
     mozilla::net::NetAddr addr;
     PRNetAddrToNetAddr(&prAddr, &addr);
-    rv = sock->InitWithAddress(&addr, mPrincipal, aAddressReuse,
-                               /* optional_argc = */ 1);
+    rv = sock->InitWithAddress(&addr, aAddressReuse, /* optional_argc = */ 1);
   }
 
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   rv = sock->SetMulticastLoopback(aLoopback);
   if (NS_WARN_IF(NS_FAILED(rv))) {
--- a/dom/network/UDPSocketParent.h
+++ b/dom/network/UDPSocketParent.h
@@ -7,32 +7,31 @@
 #ifndef mozilla_dom_UDPSocketParent_h__
 #define mozilla_dom_UDPSocketParent_h__
 
 #include "mozilla/net/PUDPSocketParent.h"
 #include "nsCOMPtr.h"
 #include "nsIUDPSocket.h"
 #include "nsIUDPSocketFilter.h"
 #include "mozilla/net/OfflineObserver.h"
-#include "mozilla/dom/PermissionMessageUtils.h"
 
 namespace mozilla {
 namespace dom {
 
 class UDPSocketParent : public mozilla::net::PUDPSocketParent
                       , public nsIUDPSocketListener
                       , public mozilla::net::DisconnectableParent
 {
 public:
   NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSIUDPSOCKETLISTENER
 
   UDPSocketParent();
 
-  bool Init(const IPC::Principal& aPrincipal, const nsACString& aFilter);
+  bool Init(const nsACString& aFilter);
 
   virtual bool RecvBind(const UDPAddressInfo& aAddressInfo,
                         const bool& aAddressReuse, const bool& aLoopback) MOZ_OVERRIDE;
 
   virtual bool RecvOutgoingData(const UDPData& aData, const UDPSocketAddr& aAddr) MOZ_OVERRIDE;
 
   virtual bool RecvClose() MOZ_OVERRIDE;
   virtual bool RecvRequestDelete() MOZ_OVERRIDE;
@@ -53,15 +52,14 @@ private:
                         const bool& aAddressReuse, const bool& aLoopback);
 
   void FireInternalError(uint32_t aLineNo);
 
   bool mIPCOpen;
   nsCOMPtr<nsIUDPSocket> mSocket;
   nsCOMPtr<nsIUDPSocketFilter> mFilter;
   nsRefPtr<mozilla::net::OfflineObserver> mObserver;
-  nsCOMPtr<nsIPrincipal> mPrincipal;
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif // !defined(mozilla_dom_UDPSocketParent_h__)
--- a/dom/network/interfaces/nsIUDPSocketChild.idl
+++ b/dom/network/interfaces/nsIUDPSocketChild.idl
@@ -2,38 +2,36 @@
  * 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"
 #include "nsINetAddr.idl"
 
 interface nsIUDPSocketInternal;
 interface nsIInputStream;
-interface nsIPrincipal;
 
 %{ C++
 namespace mozilla {
 namespace net {
 union NetAddr;
 }
 }
 %}
 native NetAddr(mozilla::net::NetAddr);
 [ptr] native NetAddrPtr(mozilla::net::NetAddr);
 
-[scriptable, uuid(d24536f1-dc03-4ef4-a347-647625def206)]
+[scriptable, uuid(36ec5264-6a58-4cf2-ad9a-185292e0d1d1)]
 interface nsIUDPSocketChild : nsISupports
 {
   readonly attribute unsigned short localPort;
   readonly attribute AUTF8String localAddress;
   attribute AUTF8String filterName;
 
   // Tell the chrome process to bind the UDP socket to a given local host and port
-  void bind(in nsIUDPSocketInternal socket, in nsIPrincipal principal,
-            in AUTF8String host, in unsigned short port,
+  void bind(in nsIUDPSocketInternal socket, in AUTF8String host, in unsigned short port,
             in bool addressReuse, in bool loopback);
 
   // Tell the chrome process to perform equivalent operations to all following methods
   void send(in AUTF8String host, in unsigned short port,
             [const, array, size_is(byteLength)] in uint8_t bytes,
             in unsigned long byteLength);
   // Send without DNS query
   void sendWithAddr(in nsINetAddr addr,
--- a/dom/push/PushService.jsm
+++ b/dom/push/PushService.jsm
@@ -1679,17 +1679,17 @@ this.PushService = {
 
     if (!prefs.get("udp.wakeupEnabled")) {
       debug("UDP support disabled");
       return;
     }
 
     this._udpServer = Cc["@mozilla.org/network/udp-socket;1"]
                         .createInstance(Ci.nsIUDPSocket);
-    this._udpServer.init(-1, false, Services.scriptSecurityManager.getSystemPrincipal());
+    this._udpServer.init(-1, false);
     this._udpServer.asyncListen(this);
     debug("listenForUDPWakeup listening on " + this._udpServer.port);
 
     return this._udpServer.port;
   },
 
   /**
    * Called by UDP Server Socket. As soon as a ping is recieved via UDP,
--- a/media/mtransport/nr_socket_prsock.cpp
+++ b/media/mtransport/nr_socket_prsock.cpp
@@ -1073,17 +1073,17 @@ void NrSocketIpc::create_m(const nsACStr
   nsRefPtr<NrSocketIpcProxy> proxy(new NrSocketIpcProxy);
   rv = proxy->Init(this);
   if (NS_FAILED(rv)) {
     err_ = true;
     mon.NotifyAll();
     return;
   }
 
-  if (NS_FAILED(socket_child_->Bind(proxy, nullptr, host, port,
+  if (NS_FAILED(socket_child_->Bind(proxy, host, port,
                                     /* reuse = */ false,
                                     /* loopback = */ false))) {
     err_ = true;
     MOZ_ASSERT(false, "Failed to create UDP socket");
     mon.NotifyAll();
     return;
   }
 }
--- a/netwerk/base/nsIUDPSocket.idl
+++ b/netwerk/base/nsIUDPSocket.idl
@@ -6,17 +6,16 @@
 #include "nsISupports.idl"
 
 interface nsINetAddr;
 interface nsIUDPSocketListener;
 interface nsIUDPMessage;
 interface nsISocketTransport;
 interface nsIOutputStream;
 interface nsIInputStream;
-interface nsIPrincipal;
 
 %{ C++
 #include "nsTArrayForwardDeclare.h"
 namespace mozilla {
 namespace net {
 union NetAddr;
 }
 }
@@ -25,60 +24,51 @@ native NetAddr(mozilla::net::NetAddr);
 [ptr] native NetAddrPtr(mozilla::net::NetAddr);
 [ref] native Uint8TArrayRef(FallibleTArray<uint8_t>);
 
 /**
  * nsIUDPSocket
  *
  * An interface to a UDP socket that can accept incoming connections.
  */
-[scriptable, uuid(e0377f7b-34a9-4d0f-8191-7e0cba77a52f)]
+[scriptable, uuid(8f28299c-f2ac-468a-8223-190335006bbc)]
 interface nsIUDPSocket : nsISupports
 {
     /**
      * init
      *
      * This method initializes a UDP socket.
      *
      * @param aPort
      *        The port of the UDP socket.  Pass -1 to indicate no preference,
      *        and a port will be selected automatically.
      * @param aLoopbackOnly
      *        If true, the UDP socket will only respond to connections on the
      *        local loopback interface.  Otherwise, it will accept connections
      *        from any interface.  To specify a particular network interface,
      *        use initWithAddress.
-     * @param aPrincipal
-     *        The principal connected to this socket.
      * @param aAddressReuse
      *        If true, the socket is allowed to be bound to an address that is
      *        already in use. Default is true.
      */
-    [optional_argc] void init(in long aPort,
-                              in boolean aLoopbackOnly,
-                              in nsIPrincipal aPrincipal,
-                              [optional] in boolean aAddressReuse);
+    [optional_argc] void init(in long aPort, in boolean aLoopbackOnly, [optional] in boolean aAddressReuse);
 
     /**
      * initWithAddress
      *
      * This method initializes a UDP socket, and binds it to a particular
      * local address (and hence a particular local network interface).
      *
      * @param aAddr
      *        The address to which this UDP socket should be bound.
-     * @param aPrincipal
-     *        The principal connected to this socket.
      * @param aAddressReuse
      *        If true, the socket is allowed to be bound to an address that is
      *        already in use. Default is true.
      */
-    [noscript, optional_argc] void initWithAddress([const] in NetAddrPtr aAddr,
-                                                   in nsIPrincipal aPrincipal,
-                                                   [optional] in boolean aAddressReuse);
+    [noscript, optional_argc] void initWithAddress([const] in NetAddrPtr aAddr, [optional] in boolean aAddressReuse);
 
     /**
      * close
      *
      * This method closes a UDP socket.  This does not affect already
      * connected client sockets (i.e., the nsISocketTransport instances
      * created from this UDP socket).  This will cause the onStopListening
      * event to asynchronously fire with a status of NS_BINDING_ABORTED.
--- a/netwerk/base/nsUDPSocket.cpp
+++ b/netwerk/base/nsUDPSocket.cpp
@@ -9,34 +9,29 @@
 #include "mozilla/HoldDropJSObjects.h"
 
 #include "nsSocketTransport2.h"
 #include "nsUDPSocket.h"
 #include "nsProxyRelease.h"
 #include "nsAutoPtr.h"
 #include "nsError.h"
 #include "nsNetCID.h"
-#include "nsNetUtil.h"
 #include "prnetdb.h"
 #include "prio.h"
 #include "nsNetAddr.h"
 #include "nsNetSegmentUtils.h"
 #include "NetworkActivityMonitor.h"
 #include "nsStreamUtils.h"
 #include "nsIPipe.h"
 #include "prerror.h"
 #include "nsThreadUtils.h"
 #include "nsIDNSRecord.h"
 #include "nsIDNSService.h"
 #include "nsICancelable.h"
 
-#ifdef MOZ_WIDGET_GONK
-#include "NetStatistics.h"
-#endif
-
 using namespace mozilla::net;
 using namespace mozilla;
 
 static NS_DEFINE_CID(kSocketTransportServiceCID, NS_SOCKETTRANSPORTSERVICE_CID);
 static const uint32_t UDP_PACKET_CHUNK_SIZE = 1400;
 
 //-----------------------------------------------------------------------------
 
@@ -254,18 +249,16 @@ nsUDPMessage::GetDataAsTArray()
 
 //-----------------------------------------------------------------------------
 // nsUDPSocket
 //-----------------------------------------------------------------------------
 
 nsUDPSocket::nsUDPSocket()
   : mLock("nsUDPSocket.mLock")
   , mFD(nullptr)
-  , mAppId(NECKO_UNKNOWN_APP_ID)
-  , mIsInBrowserElement(false)
   , mAttached(false)
   , mByteReadCount(0)
   , mByteWriteCount(0)
 {
   mAddr.raw.family = PR_AF_UNSPEC;
   // we want to be able to access the STS directly, and it may not have been
   // constructed yet.  the STS constructor sets gSocketTransportService.
   if (!gSocketTransportService)
@@ -288,17 +281,16 @@ nsUDPSocket::~nsUDPSocket()
 
   MOZ_COUNT_DTOR(nsUDPSocket);
 }
 
 void
 nsUDPSocket::AddOutputBytes(uint64_t aBytes)
 {
   mByteWriteCount += aBytes;
-  SaveNetworkStats(false);
 }
 
 void
 nsUDPSocket::OnMsgClose()
 {
   SOCKET_LOG(("nsUDPSocket::OnMsgClose [this=%p]\n", this));
 
   if (NS_FAILED(mCondition))
@@ -476,17 +468,16 @@ nsUDPSocket::OnSocketReady(PRFileDesc *f
   count = PR_RecvFrom(mFD, buff, sizeof(buff), 0, &prClientAddr, PR_INTERVAL_NO_WAIT);
 
   if (count < 1) {
     NS_WARNING("error of recvfrom on UDP socket");
     mCondition = NS_ERROR_UNEXPECTED;
     return;
   }
   mByteReadCount += count;
-  SaveNetworkStats(false);
 
   FallibleTArray<uint8_t> data;
   if(!data.AppendElements(buff, count)){
     mCondition = NS_ERROR_UNEXPECTED;
     return;
   }
 
   nsCOMPtr<nsIAsyncInputStream> pipeIn;
@@ -524,17 +515,16 @@ nsUDPSocket::OnSocketDetached(PRFileDesc
     mCondition = NS_ERROR_ABORT;
 
   if (mFD)
   {
     NS_ASSERTION(mFD == fd, "wrong file descriptor");
     PR_Close(mFD);
     mFD = nullptr;
   }
-  SaveNetworkStats(true);
 
   if (mListener)
   {
     // need to atomically clear mListener.  see our Close() method.
     nsCOMPtr<nsIUDPSocketListener> listener;
     {
       MutexAutoLock lock(mLock);
       mListener.swap(listener);
@@ -561,75 +551,52 @@ nsUDPSocket::IsLocal(bool *aIsLocal)
 NS_IMPL_ISUPPORTS(nsUDPSocket, nsIUDPSocket)
 
 
 //-----------------------------------------------------------------------------
 // nsSocket::nsISocket
 //-----------------------------------------------------------------------------
 
 NS_IMETHODIMP
-nsUDPSocket::Init(int32_t aPort, bool aLoopbackOnly, nsIPrincipal *aPrincipal,
-                  bool aAddressReuse, uint8_t aOptionalArgc)
+nsUDPSocket::Init(int32_t aPort, bool aLoopbackOnly, bool aAddressReuse, uint8_t aOptionalArgc)
 {
   NetAddr addr;
 
   if (aPort < 0)
     aPort = 0;
 
   addr.raw.family = AF_INET;
   addr.inet.port = htons(aPort);
 
   if (aLoopbackOnly)
     addr.inet.ip = htonl(INADDR_LOOPBACK);
   else
     addr.inet.ip = htonl(INADDR_ANY);
 
-  return InitWithAddress(&addr, aPrincipal, aAddressReuse, aOptionalArgc);
+  return InitWithAddress(&addr, aAddressReuse, aOptionalArgc);
 }
 
 NS_IMETHODIMP
-nsUDPSocket::InitWithAddress(const NetAddr *aAddr, nsIPrincipal *aPrincipal,
-                             bool aAddressReuse, uint8_t aOptionalArgc)
+nsUDPSocket::InitWithAddress(const NetAddr *aAddr, bool aAddressReuse, uint8_t aOptionalArgc)
 {
   NS_ENSURE_TRUE(mFD == nullptr, NS_ERROR_ALREADY_INITIALIZED);
 
   bool addressReuse = (aOptionalArgc == 1) ? aAddressReuse : true;
 
   //
   // configure listening socket...
   //
 
   mFD = PR_OpenUDPSocket(aAddr->raw.family);
   if (!mFD)
   {
     NS_WARNING("unable to create UDP socket");
     return NS_ERROR_FAILURE;
   }
 
-  if (aPrincipal) {
-    nsresult rv = aPrincipal->GetAppId(&mAppId);
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-
-    rv = aPrincipal->GetIsInBrowserElement(&mIsInBrowserElement);
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-  }
-
-#ifdef MOZ_WIDGET_GONK
-  if (mAppId != NECKO_UNKNOWN_APP_ID) {
-    nsCOMPtr<nsINetworkInterface> activeNetwork;
-    GetActiveNetworkInterface(activeNetwork);
-    mActiveNetwork =
-      new nsMainThreadPtrHolder<nsINetworkInterface>(activeNetwork);
-  }
-#endif
-
   uint16_t port;
   if (NS_FAILED(net::GetPort(aAddr, &port))) {
     NS_WARNING("invalid bind address");
     goto fail;
   }
 
   PRSocketOptionData opt;
 
@@ -686,17 +653,16 @@ nsUDPSocket::Close()
     // has been set.  otherwise, we should just close the socket here...
     if (!mListener)
     {
       if (mFD)
       {
         PR_Close(mFD);
         mFD = nullptr;
       }
-      SaveNetworkStats(true);
       return NS_OK;
     }
   }
   return PostEvent(this, &nsUDPSocket::OnMsgClose);
 }
 
 NS_IMETHODIMP
 nsUDPSocket::GetPort(int32_t *aResult)
@@ -722,44 +688,16 @@ nsUDPSocket::GetLocalAddr(nsINetAddr * *
 NS_IMETHODIMP
 nsUDPSocket::GetAddress(NetAddr *aResult)
 {
   // no need to enter the lock here
   memcpy(aResult, &mAddr, sizeof(mAddr));
   return NS_OK;
 }
 
-void
-nsUDPSocket::SaveNetworkStats(bool aEnforce)
-{
-#ifdef MOZ_WIDGET_GONK
-  if (!mActiveNetwork || mAppId == NECKO_UNKNOWN_APP_ID) {
-    return;
-  }
-
-  if (mByteReadCount == 0 && mByteWriteCount == 0) {
-    return;
-  }
-
-  uint64_t total = mByteReadCount + mByteWriteCount;
-  if (aEnforce || total > NETWORK_STATS_THRESHOLD) {
-    // Create the event to save the network statistics.
-    // the event is then dispathed to the main thread.
-    nsRefPtr<nsRunnable> event =
-      new SaveNetworkStatsEvent(mAppId, mIsInBrowserElement, mActiveNetwork,
-                                mByteReadCount, mByteWriteCount, false);
-    NS_DispatchToMainThread(event);
-
-    // Reset the counters after saving.
-    mByteReadCount = 0;
-    mByteWriteCount = 0;
-  }
-#endif
-}
-
 namespace {
 //-----------------------------------------------------------------------------
 // SocketListenerProxy
 //-----------------------------------------------------------------------------
 class SocketListenerProxy MOZ_FINAL : public nsIUDPSocketListener
 {
   ~SocketListenerProxy() {}
 
--- a/netwerk/base/nsUDPSocket.h
+++ b/netwerk/base/nsUDPSocket.h
@@ -7,20 +7,16 @@
 #define nsUDPSocket_h__
 
 #include "nsIUDPSocket.h"
 #include "mozilla/Mutex.h"
 #include "nsIOutputStream.h"
 #include "nsAutoPtr.h"
 #include "nsCycleCollectionParticipant.h"
 
-#ifdef MOZ_WIDGET_GONK
-#include "nsINetworkManager.h"
-#endif
-
 //-----------------------------------------------------------------------------
 
 class nsUDPSocket MOZ_FINAL : public nsASocketHandler
                             , public nsIUDPSocket
 {
 public:
   NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSIUDPSOCKET
@@ -49,35 +45,28 @@ private:
   friend class SetSocketOptionRunnable;
   nsresult SetSocketOption(const PRSocketOptionData& aOpt);
   nsresult JoinMulticastInternal(const PRNetAddr& aAddr,
                                  const PRNetAddr& aIface);
   nsresult LeaveMulticastInternal(const PRNetAddr& aAddr,
                                   const PRNetAddr& aIface);
   nsresult SetMulticastInterfaceInternal(const PRNetAddr& aIface);
 
-  void SaveNetworkStats(bool aEnforce);
-
   // lock protects access to mListener;
   // so mListener is not cleared while being used/locked.
   mozilla::Mutex                       mLock;
   PRFileDesc                           *mFD;
   mozilla::net::NetAddr                mAddr;
-  uint32_t                             mAppId;
-  bool                                 mIsInBrowserElement;
   nsCOMPtr<nsIUDPSocketListener>       mListener;
   nsCOMPtr<nsIEventTarget>             mListenerTarget;
   bool                                 mAttached;
   nsRefPtr<nsSocketTransportService>   mSts;
 
   uint64_t   mByteReadCount;
   uint64_t   mByteWriteCount;
-#ifdef MOZ_WIDGET_GONK
-  nsMainThreadPtrHandle<nsINetworkInterface> mActiveNetwork;
-#endif
 };
 
 //-----------------------------------------------------------------------------
 
 class nsUDPMessage : public nsIUDPMessage
 {
 public:
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
--- a/netwerk/ipc/NeckoChild.cpp
+++ b/netwerk/ipc/NeckoChild.cpp
@@ -232,18 +232,17 @@ bool
 NeckoChild::DeallocPTCPServerSocketChild(PTCPServerSocketChild* child)
 {
   TCPServerSocketChild* p = static_cast<TCPServerSocketChild*>(child);
   p->ReleaseIPDLReference();
   return true;
 }
 
 PUDPSocketChild*
-NeckoChild::AllocPUDPSocketChild(const Principal& aPrincipal,
-                                 const nsCString& aFilter)
+NeckoChild::AllocPUDPSocketChild(const nsCString& aFilter)
 {
   NS_NOTREACHED("AllocPUDPSocket should not be called");
   return nullptr;
 }
 
 bool
 NeckoChild::DeallocPUDPSocketChild(PUDPSocketChild* child)
 {
--- a/netwerk/ipc/NeckoChild.h
+++ b/netwerk/ipc/NeckoChild.h
@@ -46,18 +46,17 @@ protected:
   virtual PTCPSocketChild* AllocPTCPSocketChild(const nsString& host,
                                                 const uint16_t& port) MOZ_OVERRIDE;
   virtual bool DeallocPTCPSocketChild(PTCPSocketChild*) MOZ_OVERRIDE;
   virtual PTCPServerSocketChild*
     AllocPTCPServerSocketChild(const uint16_t& aLocalPort,
                                const uint16_t& aBacklog,
                                const nsString& aBinaryType) MOZ_OVERRIDE;
   virtual bool DeallocPTCPServerSocketChild(PTCPServerSocketChild*) MOZ_OVERRIDE;
-  virtual PUDPSocketChild* AllocPUDPSocketChild(const Principal& aPrincipal,
-                                                const nsCString& aFilter) MOZ_OVERRIDE;
+  virtual PUDPSocketChild* AllocPUDPSocketChild(const nsCString& aFilter) MOZ_OVERRIDE;
   virtual bool DeallocPUDPSocketChild(PUDPSocketChild*) MOZ_OVERRIDE;
   virtual PDNSRequestChild* AllocPDNSRequestChild(const nsCString& aHost,
                                                   const uint32_t& aFlags,
                                                   const nsCString& aNetworkInterface) MOZ_OVERRIDE;
   virtual bool DeallocPDNSRequestChild(PDNSRequestChild*) MOZ_OVERRIDE;
   virtual PRemoteOpenFileChild*
     AllocPRemoteOpenFileChild(const SerializedLoadContext& aSerialized,
                               const URIParams&,
--- a/netwerk/ipc/NeckoParent.cpp
+++ b/netwerk/ipc/NeckoParent.cpp
@@ -450,30 +450,28 @@ bool
 NeckoParent::DeallocPTCPServerSocketParent(PTCPServerSocketParent* actor)
 {
   TCPServerSocketParent* p = static_cast<TCPServerSocketParent*>(actor);
    p->ReleaseIPDLReference();
   return true;
 }
 
 PUDPSocketParent*
-NeckoParent::AllocPUDPSocketParent(const Principal& /* unused */,
-                                   const nsCString& /* unused */)
+NeckoParent::AllocPUDPSocketParent(const nsCString& /* unused */)
 {
   nsRefPtr<UDPSocketParent> p = new UDPSocketParent();
 
   return p.forget().take();
 }
 
 bool
 NeckoParent::RecvPUDPSocketConstructor(PUDPSocketParent* aActor,
-                                       const Principal& aPrincipal,
                                        const nsCString& aFilter)
 {
-  return static_cast<UDPSocketParent*>(aActor)->Init(aPrincipal, aFilter);
+  return static_cast<UDPSocketParent*>(aActor)->Init(aFilter);
 }
 
 bool
 NeckoParent::DeallocPUDPSocketParent(PUDPSocketParent* actor)
 {
   UDPSocketParent* p = static_cast<UDPSocketParent*>(actor);
   p->Release();
   return true;
--- a/netwerk/ipc/NeckoParent.h
+++ b/netwerk/ipc/NeckoParent.h
@@ -144,21 +144,18 @@ protected:
     AllocPTCPServerSocketParent(const uint16_t& aLocalPort,
                                 const uint16_t& aBacklog,
                                 const nsString& aBinaryType) MOZ_OVERRIDE;
   virtual bool RecvPTCPServerSocketConstructor(PTCPServerSocketParent*,
                                                const uint16_t& aLocalPort,
                                                const uint16_t& aBacklog,
                                                const nsString& aBinaryType) MOZ_OVERRIDE;
   virtual bool DeallocPTCPServerSocketParent(PTCPServerSocketParent*) MOZ_OVERRIDE;
-  virtual PUDPSocketParent* AllocPUDPSocketParent(const Principal& aPrincipal,
-                                                  const nsCString& aFilter) MOZ_OVERRIDE;
-  virtual bool RecvPUDPSocketConstructor(PUDPSocketParent*,
-                                         const Principal& aPrincipal,
-                                         const nsCString& aFilter) MOZ_OVERRIDE;
+  virtual PUDPSocketParent* AllocPUDPSocketParent(const nsCString& aFilter) MOZ_OVERRIDE;
+  virtual bool RecvPUDPSocketConstructor(PUDPSocketParent*, const nsCString& aFilter) MOZ_OVERRIDE;
   virtual bool DeallocPUDPSocketParent(PUDPSocketParent*) MOZ_OVERRIDE;
   virtual PDNSRequestParent* AllocPDNSRequestParent(const nsCString& aHost,
                                                     const uint32_t& aFlags,
                                                     const nsCString& aNetworkInterface) MOZ_OVERRIDE;
   virtual bool RecvPDNSRequestConstructor(PDNSRequestParent* actor,
                                           const nsCString& hostName,
                                           const uint32_t& flags,
                                           const nsCString& aNetworkInterface) MOZ_OVERRIDE;
--- a/netwerk/ipc/PNecko.ipdl
+++ b/netwerk/ipc/PNecko.ipdl
@@ -25,17 +25,16 @@ include protocol PRtspController;
 include protocol PRtspChannel;
 include URIParams;
 include InputStreamParams;
 include NeckoChannelParams;
 include PBrowserOrId;
 
 using class IPC::SerializedLoadContext from "SerializedLoadContext.h";
 using mozilla::dom::TabId from "mozilla/dom/ipc/IdType.h";
-using class IPC::Principal from "mozilla/dom/PermissionMessageUtils.h";
 
 namespace mozilla {
 namespace net {
 
 //-------------------------------------------------------------------
 prio(normal upto urgent) sync protocol PNecko
 {
   manager PContent;
@@ -61,17 +60,17 @@ parent:
                SerializedLoadContext loadContext,
                HttpChannelCreationArgs args);
   PWyciwygChannel();
   PFTPChannel(PBrowserOrId browser, SerializedLoadContext loadContext,
               FTPChannelCreationArgs args);
 
   PWebSocket(PBrowserOrId browser, SerializedLoadContext loadContext);
   PTCPServerSocket(uint16_t localPort, uint16_t backlog, nsString binaryType);
-  PUDPSocket(Principal principal, nsCString filter);
+  PUDPSocket(nsCString filter);
 
   PDNSRequest(nsCString hostName, uint32_t flags, nsCString networkInterface);
 
   PRemoteOpenFile(SerializedLoadContext loadContext,
                   URIParams fileuri,
                   OptionalURIParams appuri);
 
   HTMLDNSPrefetch(nsString hostname, uint16_t flags);
--- a/netwerk/test/TestUDPSocket.cpp
+++ b/netwerk/test/TestUDPSocket.cpp
@@ -6,17 +6,16 @@
 #include "TestHarness.h"
 #include "nsIUDPSocket.h"
 #include "nsISocketTransportService.h"
 #include "nsISocketTransport.h"
 #include "nsIOutputStream.h"
 #include "nsIInputStream.h"
 #include "nsINetAddr.h"
 #include "nsITimer.h"
-#include "nsNetUtil.h"
 #include "mozilla/net/DNS.h"
 #include "prerror.h"
 
 #define REQUEST  0x68656c6f
 #define RESPONSE 0x6f6c6568
 #define MULTICAST_TIMEOUT 2000
 
 #define EXPECT_SUCCESS(rv, ...) \
@@ -268,34 +267,26 @@ main(int32_t argc, char *argv[])
   server = do_CreateInstance("@mozilla.org/network/udp-socket;1", &rv);
   NS_ENSURE_SUCCESS(rv, -1);
   client = do_CreateInstance("@mozilla.org/network/udp-socket;1", &rv);
   NS_ENSURE_SUCCESS(rv, -1);
 
   // Create UDPServerListener to process UDP packets
   nsRefPtr<UDPServerListener> serverListener = new UDPServerListener();
 
-  nsCOMPtr<nsIScriptSecurityManager> secman =
-    do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
-  NS_ENSURE_SUCCESS(rv, -1);
-
-  nsCOMPtr<nsIPrincipal> systemPrincipal;
-  rv = secman->GetSystemPrincipal(getter_AddRefs(systemPrincipal));
-  NS_ENSURE_SUCCESS(rv, -1);
-
   // Bind server socket to 0.0.0.0
-  rv = server->Init(0, false, systemPrincipal, true, 0);
+  rv = server->Init(0, false, true, 0);
   NS_ENSURE_SUCCESS(rv, -1);
   int32_t serverPort;
   server->GetPort(&serverPort);
   server->AsyncListen(serverListener);
 
   // Bind clinet on arbitrary port
   nsRefPtr<UDPClientListener> clientListener = new UDPClientListener();
-  client->Init(0, false, systemPrincipal, true, 0);
+  client->Init(0, false, true, 0);
   client->AsyncListen(clientListener);
 
   // Write data to server
   uint32_t count;
   const uint32_t data = REQUEST;
 
   phase = TEST_OUTPUT_STREAM;
   rv = client->Send(NS_LITERAL_CSTRING("127.0.0.1"), serverPort, (uint8_t*)&data, sizeof(uint32_t), &count);
--- a/netwerk/test/unit/test_udp_multicast.js
+++ b/netwerk/test/unit/test_udp_multicast.js
@@ -1,17 +1,16 @@
 // Bug 960397: UDP multicast options
 
 const { Constructor: CC } = Components;
 
 const UDPSocket = CC("@mozilla.org/network/udp-socket;1",
                      "nsIUDPSocket",
                      "init");
 const { Promise: promise } = Cu.import("resource://gre/modules/Promise.jsm", {});
-Cu.import("resource://gre/modules/Services.jsm");
 
 const ADDRESS_TEST1 = "224.0.0.200";
 const ADDRESS_TEST2 = "224.0.0.201";
 const ADDRESS_TEST3 = "224.0.0.202";
 const ADDRESS_TEST4 = "224.0.0.203";
 
 const TIMEOUT = 2000;
 
@@ -28,18 +27,17 @@ function run_test() {
 
 function setup() {
   gConverter = Cc["@mozilla.org/intl/scriptableunicodeconverter"].
                createInstance(Ci.nsIScriptableUnicodeConverter);
   gConverter.charset = "utf8";
 }
 
 function createSocketAndJoin(addr) {
-  let socket = new UDPSocket(-1, false,
-                     Services.scriptSecurityManager.getSystemPrincipal());
+  let socket = new UDPSocket(-1, false);
   socket.joinMulticast(addr);
   return socket;
 }
 
 function sendPing(socket, addr) {
   let ping = "ping";
   let rawPing = gConverter.convertToByteArray(ping);
 
--- a/netwerk/test/unit/test_udpsocket.js
+++ b/netwerk/test/unit/test_udpsocket.js
@@ -1,24 +1,22 @@
 /* -*- Mode: Javasript; indent-tab-mode: nil; js-indent-level: 2 -*- */
 /* 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/. */
 "use strict";
 
-Cu.import("resource://gre/modules/Services.jsm");
-
 const HELLO_WORLD = "Hello World";
 
 add_test(function test_udp_message_raw_data() {
   do_print("test for nsIUDPMessage.rawData");
 
   let socket = Cc["@mozilla.org/network/udp-socket;1"].createInstance(Ci.nsIUDPSocket);
 
-  socket.init(-1, true, Services.scriptSecurityManager.getSystemPrincipal());
+  socket.init(-1, true);
   do_print("Port assigned : " + socket.port);
   socket.asyncListen({
     QueryInterface : XPCOMUtils.generateQI([Ci.nsIUDPSocketListener]),
     onPacketReceived : function(aSocket, aMessage){
       let recv_data = String.fromCharCode.apply(null, aMessage.rawData);
       do_check_eq(recv_data, HELLO_WORLD);
       do_check_eq(recv_data, aMessage.data);
       socket.close();
@@ -35,17 +33,17 @@ add_test(function test_udp_message_raw_d
   do_check_eq(written, HELLO_WORLD.length);
 });
 
 add_test(function test_udp_send_stream() {
   do_print("test for nsIUDPSocket.sendBinaryStream");
 
   let socket = Cc["@mozilla.org/network/udp-socket;1"].createInstance(Ci.nsIUDPSocket);
 
-  socket.init(-1, true, Services.scriptSecurityManager.getSystemPrincipal());
+  socket.init(-1, true);
   socket.asyncListen({
     QueryInterface : XPCOMUtils.generateQI([Ci.nsIUDPSocketListener]),
     onPacketReceived : function(aSocket, aMessage){
       let recv_data = String.fromCharCode.apply(null, aMessage.rawData);
       do_check_eq(recv_data, HELLO_WORLD);
       socket.close();
       run_next_test();
     },
--- a/toolkit/devtools/discovery/discovery.js
+++ b/toolkit/devtools/discovery/discovery.js
@@ -73,17 +73,17 @@ function log(msg) {
 /**
  * Each Transport instance owns a single UDPSocket.
  * @param port integer
  *        The port to listen on for incoming UDP multicast packets.
  */
 function Transport(port) {
   EventEmitter.decorate(this);
   try {
-    this.socket = new UDPSocket(port, false, Services.scriptSecurityManager.getSystemPrincipal());
+    this.socket = new UDPSocket(port, false);
     this.socket.joinMulticast(ADDRESS);
     this.socket.asyncListen(this);
   } catch(e) {
     log("Failed to start new socket: " + e);
   }
 }
 
 Transport.prototype = {
--- a/toolkit/modules/secondscreen/SimpleServiceDiscovery.jsm
+++ b/toolkit/modules/secondscreen/SimpleServiceDiscovery.jsm
@@ -139,17 +139,17 @@ var SimpleServiceDiscovery = {
 
     // Look for any fixed IP devices. Some routers might be configured to block
     // UDP broadcasts, so this is a way to skip discovery.
     this._searchFixedDevices();
 
     // Perform a UDP broadcast to search for SSDP devices
     let socket = Cc["@mozilla.org/network/udp-socket;1"].createInstance(Ci.nsIUDPSocket);
     try {
-      socket.init(SSDP_PORT, false, Services.scriptSecurityManager.getSystemPrincipal());
+      socket.init(SSDP_PORT, false);
       socket.joinMulticast(SSDP_ADDRESS);
       socket.asyncListen(this);
     } catch (e) {
       // We were unable to create the broadcast socket. Just return, but don't
       // kill the interval timer. This might work next time.
       log("failed to start socket: " + e);
       return;
     }