NS_IMETHODIMP WebBrowserPersistResourcesChild::VisitDocument(nsIWebBrowserPersistDocument* aDocument, nsIWebBrowserPersistDocument* aSubDocument) { auto* subActor = new WebBrowserPersistDocumentChild(); dom::PBrowserChild* grandManager = Manager()->Manager(); // As a consequence of how PWebBrowserPersistDocumentConstructor can be // sent by both the parent and the child, we must pass the outerWindowID // argument here. We pass 0, though note that this argument is actually // just ignored when passed up to the parent from the child. if (!grandManager->SendPWebBrowserPersistDocumentConstructor(subActor, 0)) { // NOTE: subActor is freed at this point. return NS_ERROR_FAILURE; } // ...but here, IPC won't free subActor until after this returns // to the event loop. // The order of these two messages will be preserved, because // they're the same toplevel protocol and priority. // // With this ordering, it's always the transition out of START // state that causes a document's parent actor to be exposed to // XPCOM (for both parent->child and child->parent construction), // which simplifies the lifetime management. SendVisitDocument(subActor); subActor->Start(aSubDocument); return NS_OK; }
NS_IMETHODIMP WebBrowserPersistResourcesChild::VisitDocument( nsIWebBrowserPersistDocument* aDocument, nsIWebBrowserPersistDocument* aSubDocument) { auto* subActor = new WebBrowserPersistDocumentChild(); // As a consequence of how PWebBrowserPersistDocumentConstructor // can be sent by both the parent and the child, we must pass the // aBrowser and outerWindowID arguments here, but the values are // ignored by the parent. In particular, the TabChild in which // persistence started does not necessarily exist at this point; // see bug 1203602. if (!Manager()->Manager()->SendPWebBrowserPersistDocumentConstructor( subActor, nullptr, 0)) { // NOTE: subActor is freed at this point. return NS_ERROR_FAILURE; } // ...but here, IPC won't free subActor until after this returns // to the event loop. // The order of these two messages will be preserved, because // they're the same toplevel protocol and priority. // // With this ordering, it's always the transition out of START // state that causes a document's parent actor to be exposed to // XPCOM (for both parent->child and child->parent construction), // which simplifies the lifetime management. SendVisitDocument(subActor); subActor->Start(aSubDocument); return NS_OK; }