Bug 1311275 - use protocol service directly instead of NS_GetFileFromURLSpec; r=mayhemer
authorLiang-Heng Chen <xeonchen@mozilla.com>
Wed, 19 Oct 2016 20:34:00 +0200
changeset 319827 ee15d36745a84ba995d4e349eca3a10690c571ec
parent 319826 ea39ecf49414c920b402938cd1ddef62dbb18c01
child 319828 042d532e3d9e553c89062ba169940602558755ff
push id20748
push userphilringnalda@gmail.com
push dateFri, 28 Oct 2016 03:39:55 +0000
treeherderfx-team@715360440695 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmayhemer
bugs1311275
milestone52.0a1
Bug 1311275 - use protocol service directly instead of NS_GetFileFromURLSpec; r=mayhemer MozReview-Commit-ID: 26ElbTXr6fI
netwerk/socket/nsSOCKSIOLayer.cpp
--- a/netwerk/socket/nsSOCKSIOLayer.cpp
+++ b/netwerk/socket/nsSOCKSIOLayer.cpp
@@ -14,19 +14,18 @@
 #include "nsIDNSRecord.h"
 #include "nsISOCKSSocketInfo.h"
 #include "nsISocketProvider.h"
 #include "nsSOCKSIOLayer.h"
 #include "nsNetCID.h"
 #include "nsIDNSListener.h"
 #include "nsICancelable.h"
 #include "nsThreadUtils.h"
-#include "nsIURL.h"
 #include "nsIFile.h"
-#include "nsNetUtil.h"
+#include "nsIFileProtocolHandler.h"
 #include "mozilla/Logging.h"
 #include "mozilla/net/DNS.h"
 #include "mozilla/Unused.h"
 
 using mozilla::LogLevel;
 using namespace mozilla::net;
 
 static PRDescIdentity nsSOCKSIOLayerIdentity;
@@ -128,19 +127,31 @@ private:
 
     nsresult SetDomainSocketPath(const nsACString& aDomainSocketPath,
                              NetAddr* aProxyAddr)
     {
 #ifdef XP_UNIX
         nsresult rv;
         MOZ_ASSERT(aProxyAddr);
 
+        nsCOMPtr<nsIProtocolHandler> protocolHandler(
+            do_GetService(NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "file", &rv));
+        if (NS_WARN_IF(NS_FAILED(rv))) {
+            return rv;
+        }
+
+        nsCOMPtr<nsIFileProtocolHandler> fileHandler(
+            do_QueryInterface(protocolHandler, &rv));
+        if (NS_WARN_IF(NS_FAILED(rv))) {
+            return rv;
+        }
+
         nsCOMPtr<nsIFile> socketFile;
-        rv = NS_GetFileFromURLSpec(aDomainSocketPath,
-                                   getter_AddRefs(socketFile));
+        rv = fileHandler->GetFileFromURLSpec(aDomainSocketPath,
+                                             getter_AddRefs(socketFile));
         if (NS_WARN_IF(NS_FAILED(rv))) {
             return rv;
         }
 
         nsAutoCString path;
         if (NS_WARN_IF(NS_FAILED(rv = socketFile->GetNativePath(path)))) {
             return rv;
         }