1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "WebBrowserPersistResourcesChild.h"
9 #include "WebBrowserPersistDocumentChild.h"
10 #include "mozilla/dom/PContentChild.h"
14 NS_IMPL_ISUPPORTS(WebBrowserPersistResourcesChild
,
15 nsIWebBrowserPersistResourceVisitor
)
17 WebBrowserPersistResourcesChild::WebBrowserPersistResourcesChild() = default;
19 WebBrowserPersistResourcesChild::~WebBrowserPersistResourcesChild() = default;
22 WebBrowserPersistResourcesChild::VisitResource(
23 nsIWebBrowserPersistDocument
* aDocument
, const nsACString
& aURI
,
24 nsContentPolicyType aContentPolicyType
) {
25 nsCString
copiedURI(aURI
); // Yay, XPIDL/IPDL mismatch.
26 SendVisitResource(copiedURI
, aContentPolicyType
);
31 WebBrowserPersistResourcesChild::VisitDocument(
32 nsIWebBrowserPersistDocument
* aDocument
,
33 nsIWebBrowserPersistDocument
* aSubDocument
) {
34 RefPtr
<WebBrowserPersistDocumentChild
> subActor
=
35 new WebBrowserPersistDocumentChild();
36 // As a consequence of how PWebBrowserPersistDocumentConstructor
37 // can be sent by both the parent and the child, we must pass the
38 // aBrowser and outerWindowID arguments here, but the values are
39 // ignored by the parent. In particular, the BrowserChild in which
40 // persistence started does not necessarily exist at this point;
42 if (!Manager()->Manager()->SendPWebBrowserPersistDocumentConstructor(
43 subActor
, nullptr, nullptr)) {
44 return NS_ERROR_FAILURE
;
47 // The order of these two messages will be preserved, because
48 // they're the same toplevel protocol and priority.
50 // With this ordering, it's always the transition out of START
51 // state that causes a document's parent actor to be exposed to
52 // XPCOM (for both parent->child and child->parent construction),
53 // which simplifies the lifetime management.
54 SendVisitDocument(WrapNotNull(subActor
));
55 subActor
->Start(aSubDocument
);
60 WebBrowserPersistResourcesChild::VisitBrowsingContext(
61 nsIWebBrowserPersistDocument
* aDocument
,
62 dom::BrowsingContext
* aBrowsingContext
) {
63 SendVisitBrowsingContext(aBrowsingContext
);
68 WebBrowserPersistResourcesChild::EndVisit(
69 nsIWebBrowserPersistDocument
* aDocument
, nsresult aStatus
) {
70 Send__delete__(this, aStatus
);
74 } // namespace mozilla