Bug 842679 - Part 1: Fire tab-child-created observer message in ContentChild. r=cjones, a=tef+
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -549,41 +549,66 @@ static void FirstIdle(void)
sFirstIdleTask = nullptr;
ContentChild::GetSingleton()->SendFirstIdle();
}
PBrowserChild*
ContentChild::AllocPBrowser(const IPCTabContext& aContext,
const uint32_t& aChromeFlags)
{
+ // 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
+ // believe whatever the parent process tells us.
+
+ nsRefPtr<TabChild> child = TabChild::Create(TabContext(aContext), aChromeFlags);
+
+ // The ref here is released in DeallocPBrowser.
+ return child.forget().get();
+}
+
+bool
+ContentChild::RecvPBrowserConstructor(PBrowserChild* actor,
+ const IPCTabContext& context,
+ const uint32_t& chromeFlags)
+{
+ // This runs after AllocPBrowser() returns and the IPC machinery for this
+ // PBrowserChild has been set up.
+ //
+ // We have to NotifyObservers("tab-child-created") before we
+ // TemporarilyLockProcessPriority because the NotifyObservers call may cause
+ // us to initialize the ProcessPriorityManager, and
+ // TemporarilyLockProcessPriority only works after the
+ // ProcessPriorityManager has been initialized.
+
+ nsCOMPtr<nsIObserverService> os = services::GetObserverService();
+ if (os) {
+ nsITabChild* tc =
+ static_cast<nsITabChild*>(static_cast<TabChild*>(actor));
+ os->NotifyObservers(tc, "tab-child-created", nullptr);
+ }
+
static bool hasRunOnce = false;
if (!hasRunOnce) {
hasRunOnce = true;
MOZ_ASSERT(!sFirstIdleTask);
sFirstIdleTask = NewRunnableFunction(FirstIdle);
MessageLoop::current()->PostIdleTask(FROM_HERE, sFirstIdleTask);
// We are either a brand-new process loading its first PBrowser, or we
// are the preallocated process transforming into a particular
// app/browser. Either way, our parent has already set our process
// priority, and we want to leave it there for a few seconds while we
// start up.
TemporarilyLockProcessPriority();
}
- // 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
- // believe whatever the parent process tells us.
+ return true;
+}
- nsRefPtr<TabChild> child = TabChild::Create(TabContext(aContext), aChromeFlags);
-
- // The ref here is released below.
- return child.forget().get();
-}
bool
ContentChild::DeallocPBrowser(PBrowserChild* iframe)
{
TabChild* child = static_cast<TabChild*>(iframe);
NS_RELEASE(child);
return true;
}
--- a/dom/ipc/ContentChild.h
+++ b/dom/ipc/ContentChild.h
@@ -207,16 +207,21 @@ public:
bool IsForApp() { return mIsForApp; }
bool IsForBrowser() { return mIsForBrowser; }
bool GetParamsForBlob(nsDOMFileBase* aBlob,
BlobConstructorParams* aOutParams);
BlobChild* GetOrCreateActorForBlob(nsIDOMBlob* aBlob);
+protected:
+ virtual bool RecvPBrowserConstructor(PBrowserChild* actor,
+ const IPCTabContext& context,
+ const uint32_t& chromeFlags);
+
private:
virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE;
virtual void ProcessingError(Result what) MOZ_OVERRIDE;
/**
* Exit *now*. Do not shut down XPCOM, do not pass Go, do not run
* static destructors, do not collect $200.