Bug 1571987 - Forward proxy check request to parent process r=dragana,bwc

Differential Revision: https://phabricator.services.mozilla.com/D41004

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Kershaw Chang 2019-08-24 05:37:00 +00:00
Родитель e6b2d42978
Коммит 5018d39958
7 изменённых файлов: 74 добавлений и 7 удалений

Просмотреть файл

@ -3,13 +3,14 @@
* You can obtain one at http://mozilla.org/MPL/2.0/. */
include protocol PNecko;
include protocol PSocketProcess;
namespace mozilla {
namespace net {
protocol PProxyConfigLookup
{
manager PNecko;
manager PNecko or PSocketProcess;
child:
async __delete__(bool aProxied);

Просмотреть файл

@ -32,6 +32,7 @@
#include "mozilla/net/NeckoChild.h"
#include "mozilla/net/ProxyConfigLookup.h"
#include "mozilla/net/ProxyConfigLookupChild.h"
#include "mozilla/net/SocketProcessChild.h"
#include "MediaManager.h"
#include "WebrtcGmpVideoCodec.h"
@ -103,6 +104,12 @@ void PeerConnectionMedia::InitLocalAddrs() {
}
}
static net::ProxyConfigLookupChild* CreateActor(PeerConnectionMedia* aSelf) {
RefPtr<PeerConnectionMedia> self = aSelf;
return new net::ProxyConfigLookupChild(
[self](bool aProxied) { self->ProxySettingReceived(aProxied); });
}
nsresult PeerConnectionMedia::InitProxy() {
// Allow mochitests to disable this, since mochitest configures a fake proxy
// that serves up content.
@ -113,16 +120,22 @@ nsresult PeerConnectionMedia::InitProxy() {
return NS_OK;
}
if (!XRE_IsParentProcess()) {
if (XRE_IsContentProcess()) {
if (NS_WARN_IF(!net::gNeckoChild)) {
return NS_ERROR_FAILURE;
}
RefPtr<PeerConnectionMedia> self = this;
net::ProxyConfigLookupChild* actor = new net::ProxyConfigLookupChild(
[self](bool aProxied) { self->ProxySettingReceived(aProxied); });
net::gNeckoChild->SendPProxyConfigLookupConstructor(CreateActor(this));
return NS_OK;
}
net::gNeckoChild->SendPProxyConfigLookupConstructor(actor);
if (XRE_IsSocketProcess()) {
net::SocketProcessChild* child = net::SocketProcessChild::GetSingleton();
if (!child) {
return NS_ERROR_FAILURE;
}
child->SendPProxyConfigLookupConstructor(CreateActor(this));
return NS_OK;
}

Просмотреть файл

@ -6,6 +6,7 @@
include protocol PDNSRequest;
include protocol PSocketProcessBridge;
include protocol PProfiler;
include protocol PProxyConfigLookup;
include protocol PWebrtcProxyChannel;
include MemoryReportTypes;
@ -28,6 +29,7 @@ namespace net {
protocol PSocketProcess
{
manages PDNSRequest;
manages PProxyConfigLookup;
manages PWebrtcProxyChannel;
parent:
@ -45,6 +47,7 @@ parent:
async PWebrtcProxyChannel(TabId tabId);
async PDNSRequest(nsCString hostName, OriginAttributes originAttributes,
uint32_t flags);
async PProxyConfigLookup();
child:
async PreferenceUpdate(Pref pref);

Просмотреть файл

@ -23,6 +23,7 @@
#endif
#ifdef MOZ_WEBRTC
# include "mozilla/net/ProxyConfigLookupChild.h"
# include "mozilla/net/WebrtcProxyChannelChild.h"
#endif
@ -228,5 +229,18 @@ bool SocketProcessChild::DeallocPDNSRequestChild(PDNSRequestChild* aChild) {
return true;
}
PProxyConfigLookupChild* SocketProcessChild::AllocPProxyConfigLookupChild() {
MOZ_CRASH("AllocPProxyConfigLookupChild should not be called");
return nullptr;
}
bool SocketProcessChild::DeallocPProxyConfigLookupChild(
PProxyConfigLookupChild* aActor) {
#ifdef MOZ_WEBRTC
delete static_cast<ProxyConfigLookupChild*>(aActor);
#endif
return true;
}
} // namespace net
} // namespace mozilla

Просмотреть файл

@ -36,7 +36,7 @@ class SocketProcessChild final : public PSocketProcessChild {
mozilla::ipc::IPCResult RecvRequestMemoryReport(
const uint32_t& generation, const bool& anonymize,
const bool& minimizeMemoryUsage,
const Maybe<ipc::FileDescriptor>& DMDFile);
const Maybe<mozilla::ipc::FileDescriptor>& DMDFile);
mozilla::ipc::IPCResult RecvSetOffline(const bool& aOffline);
mozilla::ipc::IPCResult RecvInitSocketProcessBridgeParent(
const ProcessId& aContentProcessId,
@ -52,6 +52,8 @@ class SocketProcessChild final : public PSocketProcessChild {
const nsCString& aHost, const OriginAttributes& aOriginAttributes,
const uint32_t& aFlags);
bool DeallocPDNSRequestChild(PDNSRequestChild*);
PProxyConfigLookupChild* AllocPProxyConfigLookupChild();
bool DeallocPProxyConfigLookupChild(PProxyConfigLookupChild* aActor);
void CleanUp();
void DestroySocketProcessBridgeParent(ProcessId aId);

Просмотреть файл

@ -12,6 +12,7 @@
#ifdef MOZ_WEBRTC
# include "mozilla/dom/ContentProcessManager.h"
# include "mozilla/dom/BrowserParent.h"
# include "mozilla/net/ProxyConfigLookupParent.h"
# include "mozilla/net/WebrtcProxyChannelParent.h"
#endif
@ -164,6 +165,35 @@ bool SocketProcessParent::DeallocPDNSRequestParent(PDNSRequestParent* aParent) {
return true;
}
PProxyConfigLookupParent* SocketProcessParent::AllocPProxyConfigLookupParent() {
#ifdef MOZ_WEBRTC
RefPtr<ProxyConfigLookupParent> actor = new ProxyConfigLookupParent();
return actor.forget().take();
#else
return nullptr;
#endif
}
mozilla::ipc::IPCResult SocketProcessParent::RecvPProxyConfigLookupConstructor(
PProxyConfigLookupParent* aActor) {
#ifdef MOZ_WEBRTC
ProxyConfigLookupParent* actor =
static_cast<ProxyConfigLookupParent*>(aActor);
actor->DoProxyLookup();
#endif
return IPC_OK();
}
bool SocketProcessParent::DeallocPProxyConfigLookupParent(
PProxyConfigLookupParent* aActor) {
#ifdef MOZ_WEBRTC
RefPtr<ProxyConfigLookupParent> actor =
dont_AddRef(static_cast<ProxyConfigLookupParent*>(aActor));
MOZ_ASSERT(actor);
#endif
return true;
}
// To ensure that IPDL is finished before SocketParent gets deleted.
class DeferredDeleteSocketProcessParent : public Runnable {
public:

Просмотреть файл

@ -64,6 +64,10 @@ class SocketProcessParent final
const OriginAttributes& aOriginAttributes,
const uint32_t& flags) override;
bool DeallocPDNSRequestParent(PDNSRequestParent*);
PProxyConfigLookupParent* AllocPProxyConfigLookupParent();
virtual mozilla::ipc::IPCResult RecvPProxyConfigLookupConstructor(
PProxyConfigLookupParent* aActor) override;
bool DeallocPProxyConfigLookupParent(PProxyConfigLookupParent* aActor);
void ActorDestroy(ActorDestroyReason aWhy) override;
bool SendRequestMemoryReport(const uint32_t& aGeneration,