2018-11-30 22:52:05 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
2015-08-06 00:25:39 +03:00
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#include "WebBrowserPersistResourcesChild.h"
|
|
|
|
|
|
|
|
#include "WebBrowserPersistDocumentChild.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
NS_IMPL_ISUPPORTS(WebBrowserPersistResourcesChild,
|
|
|
|
nsIWebBrowserPersistResourceVisitor)
|
|
|
|
|
|
|
|
WebBrowserPersistResourcesChild::WebBrowserPersistResourcesChild() {}
|
|
|
|
|
2016-11-22 15:56:19 +03:00
|
|
|
WebBrowserPersistResourcesChild::~WebBrowserPersistResourcesChild() = default;
|
2015-08-06 00:25:39 +03:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
WebBrowserPersistResourcesChild::VisitResource(
|
|
|
|
nsIWebBrowserPersistDocument* aDocument, const nsACString& aURI,
|
2018-11-09 17:48:11 +03:00
|
|
|
nsContentPolicyType aContentPolicyType) {
|
2015-08-06 00:25:39 +03:00
|
|
|
nsCString copiedURI(aURI); // Yay, XPIDL/IPDL mismatch.
|
2018-11-09 17:48:11 +03:00
|
|
|
SendVisitResource(copiedURI, aContentPolicyType);
|
2015-08-06 00:25:39 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
WebBrowserPersistResourcesChild::VisitDocument(
|
|
|
|
nsIWebBrowserPersistDocument* aDocument,
|
|
|
|
nsIWebBrowserPersistDocument* aSubDocument) {
|
|
|
|
auto* subActor = new WebBrowserPersistDocumentChild();
|
2015-09-21 15:54:00 +03:00
|
|
|
// 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
|
2019-04-10 01:39:01 +03:00
|
|
|
// ignored by the parent. In particular, the BrowserChild in which
|
2015-09-21 15:54:00 +03:00
|
|
|
// persistence started does not necessarily exist at this point;
|
|
|
|
// see bug 1203602.
|
|
|
|
if (!Manager()->Manager()->SendPWebBrowserPersistDocumentConstructor(
|
|
|
|
subActor, nullptr, 0)) {
|
2015-08-06 00:25:39 +03:00
|
|
|
// 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::EndVisit(
|
|
|
|
nsIWebBrowserPersistDocument* aDocument, nsresult aStatus) {
|
|
|
|
Send__delete__(this, aStatus);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace mozilla
|