Bug 890570 - PRemoteOpenFile Constructor doesn't need PBrowser r=jduell

This commit is contained in:
David Zbarsky 2013-08-21 02:49:43 -04:00
parent 1109d8cbb4
commit a9365e5d20
6 changed files with 34 additions and 32 deletions

View File

@ -189,7 +189,7 @@ NeckoChild::DeallocPTCPServerSocketChild(PTCPServerSocketChild* child)
}
PRemoteOpenFileChild*
NeckoChild::AllocPRemoteOpenFileChild(const URIParams&, PBrowserChild*)
NeckoChild::AllocPRemoteOpenFileChild(const URIParams&)
{
// We don't allocate here: instead we always use IPDL constructor that takes
// an existing RemoteOpenFileChild

View File

@ -47,8 +47,7 @@ protected:
const uint16_t& aBacklog,
const nsString& aBinaryType);
virtual bool DeallocPTCPServerSocketChild(PTCPServerSocketChild*);
virtual PRemoteOpenFileChild* AllocPRemoteOpenFileChild(const URIParams&,
PBrowserChild*);
virtual PRemoteOpenFileChild* AllocPRemoteOpenFileChild(const URIParams&);
virtual bool DeallocPRemoteOpenFileChild(PRemoteOpenFileChild*);
};

View File

@ -385,8 +385,7 @@ NeckoParent::DeallocPTCPServerSocketParent(PTCPServerSocketParent* actor)
}
PRemoteOpenFileParent*
NeckoParent::AllocPRemoteOpenFileParent(const URIParams& aURI,
PBrowserParent* aBrowser)
NeckoParent::AllocPRemoteOpenFileParent(const URIParams& aURI)
{
nsCOMPtr<nsIURI> uri = DeserializeURI(aURI);
nsCOMPtr<nsIFileURL> fileURL = do_QueryInterface(uri);
@ -396,30 +395,37 @@ NeckoParent::AllocPRemoteOpenFileParent(const URIParams& aURI,
// security checks
if (UsingNeckoIPCSecurity()) {
if (!aBrowser) {
printf_stderr("NeckoParent::AllocPRemoteOpenFile: "
"FATAL error: missing TabParent: KILLING CHILD PROCESS\n");
return nullptr;
}
nsRefPtr<TabParent> tabParent = static_cast<TabParent*>(aBrowser);
uint32_t appId = tabParent->OwnOrContainingAppId();
nsCOMPtr<nsIAppsService> appsService =
do_GetService(APPS_SERVICE_CONTRACTID);
if (!appsService) {
return nullptr;
}
nsCOMPtr<mozIDOMApplication> domApp;
nsresult rv = appsService->GetAppByLocalId(appId, getter_AddRefs(domApp));
if (!domApp) {
return nullptr;
}
nsCOMPtr<mozIApplication> mozApp = do_QueryInterface(domApp);
if (!mozApp) {
return nullptr;
}
bool haveValidBrowser = false;
bool hasManage = false;
rv = mozApp->HasPermission("webapps-manage", &hasManage);
if (NS_FAILED(rv)) {
nsCOMPtr<mozIApplication> mozApp;
for (uint32_t i = 0; i < Manager()->ManagedPBrowserParent().Length(); i++) {
nsRefPtr<TabParent> tabParent =
static_cast<TabParent*>(Manager()->ManagedPBrowserParent()[i]);
uint32_t appId = tabParent->OwnOrContainingAppId();
nsCOMPtr<mozIDOMApplication> domApp;
nsresult rv = appsService->GetAppByLocalId(appId, getter_AddRefs(domApp));
if (!domApp) {
continue;
}
mozApp = do_QueryInterface(domApp);
if (!mozApp) {
continue;
}
hasManage = false;
rv = mozApp->HasPermission("webapps-manage", &hasManage);
if (NS_FAILED(rv)) {
continue;
}
haveValidBrowser = true;
break;
}
if (!haveValidBrowser) {
return nullptr;
}
@ -462,7 +468,7 @@ NeckoParent::AllocPRemoteOpenFileParent(const URIParams& aURI,
} else {
// regular packaged apps can only access their own application.zip file
nsAutoString basePath;
rv = mozApp->GetBasePath(basePath);
nsresult rv = mozApp->GetBasePath(basePath);
if (NS_FAILED(rv)) {
return nullptr;
}
@ -491,8 +497,7 @@ NeckoParent::AllocPRemoteOpenFileParent(const URIParams& aURI,
bool
NeckoParent::RecvPRemoteOpenFileConstructor(PRemoteOpenFileParent* aActor,
const URIParams& aFileURI,
PBrowserParent* aBrowser)
const URIParams& aFileURI)
{
return static_cast<RemoteOpenFileParent*>(aActor)->OpenSendCloseDelete();
}

View File

@ -88,12 +88,10 @@ protected:
virtual bool DeallocPWebSocketParent(PWebSocketParent*);
virtual PTCPSocketParent* AllocPTCPSocketParent();
virtual PRemoteOpenFileParent* AllocPRemoteOpenFileParent(const URIParams& aFileURI,
PBrowserParent* aBrowser)
virtual PRemoteOpenFileParent* AllocPRemoteOpenFileParent(const URIParams& aFileURI)
MOZ_OVERRIDE;
virtual bool RecvPRemoteOpenFileConstructor(PRemoteOpenFileParent* aActor,
const URIParams& aFileURI,
PBrowserParent* aBrowser)
const URIParams& aFileURI)
MOZ_OVERRIDE;
virtual bool DeallocPRemoteOpenFileParent(PRemoteOpenFileParent* aActor)
MOZ_OVERRIDE;

View File

@ -54,7 +54,7 @@ parent:
PWebSocket(PBrowser browser, SerializedLoadContext loadContext);
PTCPServerSocket(uint16_t localPort, uint16_t backlog, nsString binaryType);
PRemoteOpenFile(URIParams fileuri, nullable PBrowser browser);
PRemoteOpenFile(URIParams fileuri);
HTMLDNSPrefetch(nsString hostname, uint16_t flags);
CancelHTMLDNSPrefetch(nsString hostname, uint16_t flags, nsresult reason);

View File

@ -184,7 +184,7 @@ RemoteOpenFileChild::AsyncRemoteFileOpen(int32_t aFlags,
URIParams uri;
SerializeURI(mURI, uri);
gNeckoChild->SendPRemoteOpenFileConstructor(this, uri, mTabChild);
gNeckoChild->SendPRemoteOpenFileConstructor(this, uri);
// The chrome process now has a logical ref to us until it calls Send__delete.
AddIPDLReference();