ProxyConfigLookupChild.cpp (1471B)
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #include "ProxyConfigLookupChild.h" 8 9 #include "mozilla/net/SocketProcessChild.h" 10 #include "nsProxyInfo.h" 11 12 namespace mozilla { 13 namespace net { 14 15 // static 16 bool ProxyConfigLookupChild::Create( 17 nsIURI* aURI, uint32_t aProxyResolveFlags, 18 std::function<void(nsIProxyInfo*, nsresult)>&& aCallback) { 19 SocketProcessChild* socketChild = SocketProcessChild::GetSingleton(); 20 if (!socketChild) { 21 return false; 22 } 23 24 RefPtr<ProxyConfigLookupChild> child = 25 new ProxyConfigLookupChild(std::move(aCallback)); 26 return socketChild->SendPProxyConfigLookupConstructor(child, aURI, 27 aProxyResolveFlags); 28 } 29 30 ProxyConfigLookupChild::ProxyConfigLookupChild( 31 std::function<void(nsIProxyInfo*, nsresult)>&& aCallback) 32 : mCallback(std::move(aCallback)) {} 33 34 mozilla::ipc::IPCResult ProxyConfigLookupChild::Recv__delete__( 35 nsTArray<ProxyInfoCloneArgs>&& aProxyInfo, const nsresult& aResult) { 36 nsCOMPtr<nsIProxyInfo> proxyInfo = 37 nsProxyInfo::DeserializeProxyInfo(aProxyInfo); 38 mCallback(proxyInfo, aResult); 39 return IPC_OK(); 40 } 41 42 } // namespace net 43 } // namespace mozilla