Bug 1003046 - ContentChild::RecvPBrowserConstructor should not call SendGetProcessAttributes(), r=fabrice,khuey

This commit is contained in:
Olli Pettay 2014-06-04 00:15:27 +03:00
parent fe508a07fc
commit cb55b3b096
6 changed files with 55 additions and 18 deletions

View File

@ -548,6 +548,7 @@ ContentChild::Init(MessageLoop* aIOLoop,
GetCPOWManager();
SendGetProcessAttributes(&mID, &mIsForApp, &mIsForBrowser);
InitProcessAttributes();
return true;
@ -556,8 +557,6 @@ ContentChild::Init(MessageLoop* aIOLoop,
void
ContentChild::InitProcessAttributes()
{
SendGetProcessAttributes(&mID, &mIsForApp, &mIsForBrowser);
#ifdef MOZ_NUWA_PROCESS
if (IsNuwaProcess()) {
SetProcessName(NS_LITERAL_STRING("(Nuwa)"), false);
@ -925,7 +924,10 @@ ContentChild::DeallocPJavaScriptChild(PJavaScriptChild *child)
PBrowserChild*
ContentChild::AllocPBrowserChild(const IPCTabContext& aContext,
const uint32_t& aChromeFlags)
const uint32_t& aChromeFlags,
const uint64_t& aId,
const bool& aIsForApp,
const bool& aIsForBrowser)
{
// We'll happily accept any kind of IPCTabContext here; we don't need to
// check that it's of a certain type for security purposes, because we
@ -946,9 +948,12 @@ ContentChild::AllocPBrowserChild(const IPCTabContext& aContext,
}
bool
ContentChild::RecvPBrowserConstructor(PBrowserChild* actor,
const IPCTabContext& context,
const uint32_t& chromeFlags)
ContentChild::RecvPBrowserConstructor(PBrowserChild* aActor,
const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const uint64_t& aID,
const bool& aIsForApp,
const bool& aIsForBrowser)
{
// This runs after AllocPBrowserChild() returns and the IPC machinery for this
// PBrowserChild has been set up.
@ -956,7 +961,7 @@ ContentChild::RecvPBrowserConstructor(PBrowserChild* actor,
nsCOMPtr<nsIObserverService> os = services::GetObserverService();
if (os) {
nsITabChild* tc =
static_cast<nsITabChild*>(static_cast<TabChild*>(actor));
static_cast<nsITabChild*>(static_cast<TabChild*>(aActor));
os->NotifyObservers(tc, "tab-child-created", nullptr);
}
@ -970,6 +975,9 @@ ContentChild::RecvPBrowserConstructor(PBrowserChild* actor,
// Redo InitProcessAttributes() when the app or browser is really
// launching so the attributes will be correct.
mID = aID;
mIsForApp = aIsForApp;
mIsForBrowser = aIsForBrowser;
InitProcessAttributes();
}

View File

@ -104,8 +104,11 @@ public:
AllocPBackgroundChild(Transport* aTransport, ProcessId aOtherProcess)
MOZ_OVERRIDE;
virtual PBrowserChild* AllocPBrowserChild(const IPCTabContext &aContext,
const uint32_t &chromeFlags);
virtual PBrowserChild* AllocPBrowserChild(const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const uint64_t& aID,
const bool& aIsForApp,
const bool& aIsForBrowser);
virtual bool DeallocPBrowserChild(PBrowserChild*);
virtual PDeviceStorageRequestChild* AllocPDeviceStorageRequestChild(const DeviceStorageParams&);
@ -305,9 +308,12 @@ public:
DeallocPFileDescriptorSetChild(PFileDescriptorSetChild*) MOZ_OVERRIDE;
protected:
virtual bool RecvPBrowserConstructor(PBrowserChild* actor,
const IPCTabContext& context,
const uint32_t& chromeFlags) MOZ_OVERRIDE;
virtual bool RecvPBrowserConstructor(PBrowserChild* aCctor,
const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const uint64_t& aID,
const bool& aIsForApp,
const bool& aIsForBrowser) MOZ_OVERRIDE;
private:
virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE;

View File

@ -800,7 +800,10 @@ ContentParent::CreateBrowserOrApp(const TabContext& aContext,
// DeallocPBrowserParent() releases this ref.
tp.forget().take(),
aContext.AsIPCTabContext(),
chromeFlags);
chromeFlags,
cp->ChildID(),
cp->IsForApp(),
cp->IsForBrowser());
return static_cast<TabParent*>(browser);
}
return nullptr;
@ -898,7 +901,10 @@ ContentParent::CreateBrowserOrApp(const TabContext& aContext,
// DeallocPBrowserParent() releases this ref.
nsRefPtr<TabParent>(tp).forget().take(),
aContext.AsIPCTabContext(),
chromeFlags);
chromeFlags,
p->ChildID(),
p->IsForApp(),
p->IsForBrowser());
p->MaybeTakeCPUWakeLock(aFrameElement);
@ -2416,7 +2422,10 @@ ContentParent::DeallocPJavaScriptParent(PJavaScriptParent *parent)
PBrowserParent*
ContentParent::AllocPBrowserParent(const IPCTabContext& aContext,
const uint32_t &aChromeFlags)
const uint32_t& aChromeFlags,
const uint64_t& aId,
const bool& aIsForApp,
const bool& aIsForBrowser)
{
unused << aChromeFlags;

View File

@ -152,6 +152,10 @@ public:
bool IsAlive();
bool IsForApp();
bool IsForBrowser()
{
return mIsForBrowser;
}
#ifdef MOZ_NUWA_PROCESS
bool IsNuwaProcess();
#endif
@ -360,7 +364,10 @@ private:
virtual bool DeallocPJavaScriptParent(mozilla::jsipc::PJavaScriptParent*) MOZ_OVERRIDE;
virtual PBrowserParent* AllocPBrowserParent(const IPCTabContext& aContext,
const uint32_t& aChromeFlags) MOZ_OVERRIDE;
const uint32_t& aChromeFlags,
const uint64_t& aId,
const bool& aIsForApp,
const bool& aIsForBrowser) MOZ_OVERRIDE;
virtual bool DeallocPBrowserParent(PBrowserParent* frame) MOZ_OVERRIDE;
virtual PDeviceStorageRequestParent*

View File

@ -323,7 +323,10 @@ both:
// privileges by requesting a PBrowser corresponding to a highly-privileged
// app; the child can only request privileges for an app which the child has
// access to (in the form of a TabChild).
async PBrowser(IPCTabContext context, uint32_t chromeFlags);
//
// Keep the last 3 attributes in sync with GetProcessAttributes!
async PBrowser(IPCTabContext context, uint32_t chromeFlags,
uint64_t id, bool isForApp, bool isForBrowser);
async PBlob(BlobConstructorParams params);
@ -432,6 +435,8 @@ parent:
* isForBrowser|, we're loading <browser> for an app. When
* |isForBrowser|, we're loading <browser>. When |!isForApp &&
* !isForBrowser|, we're probably loading <xul:browser remote>.
*
* Keep the return values in sync with PBrowser()!
*/
sync GetProcessAttributes()
returns (uint64_t id, bool isForApp, bool isForBrowser);

View File

@ -1257,10 +1257,12 @@ TabChild::BrowserFrameProvideWindow(nsIDOMWindow* aOpener,
context.openerChild() = this;
context.isBrowserElement() = IsBrowserElement();
ContentChild* cc = static_cast<ContentChild*>(Manager());
unused << Manager()->SendPBrowserConstructor(
// We release this ref in DeallocPBrowserChild
nsRefPtr<TabChild>(newChild).forget().take(),
IPCTabContext(context, mScrolling), /* chromeFlags */ 0);
IPCTabContext(context, mScrolling), /* chromeFlags */ 0,
cc->GetID(), cc->IsForApp(), cc->IsForBrowser());
nsAutoCString spec;
if (aURI) {