Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/webbrowserpersist/WebBrowserPersistResourcesChild.cpp
Line
Count
Source (jump to first uncovered line)
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
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/. */
6
7
#include "WebBrowserPersistResourcesChild.h"
8
9
#include "WebBrowserPersistDocumentChild.h"
10
#include "mozilla/dom/ContentChild.h"
11
12
namespace mozilla {
13
14
NS_IMPL_ISUPPORTS(WebBrowserPersistResourcesChild,
15
                  nsIWebBrowserPersistResourceVisitor)
16
17
WebBrowserPersistResourcesChild::WebBrowserPersistResourcesChild()
18
0
{
19
0
}
20
21
0
WebBrowserPersistResourcesChild::~WebBrowserPersistResourcesChild() = default;
22
23
NS_IMETHODIMP
24
WebBrowserPersistResourcesChild::VisitResource(nsIWebBrowserPersistDocument *aDocument,
25
                                               const nsACString& aURI)
26
0
{
27
0
    nsCString copiedURI(aURI); // Yay, XPIDL/IPDL mismatch.
28
0
    SendVisitResource(copiedURI);
29
0
    return NS_OK;
30
0
}
31
32
NS_IMETHODIMP
33
WebBrowserPersistResourcesChild::VisitDocument(nsIWebBrowserPersistDocument* aDocument,
34
                                               nsIWebBrowserPersistDocument* aSubDocument)
35
0
{
36
0
    auto* subActor = new WebBrowserPersistDocumentChild();
37
0
    // As a consequence of how PWebBrowserPersistDocumentConstructor
38
0
    // can be sent by both the parent and the child, we must pass the
39
0
    // aBrowser and outerWindowID arguments here, but the values are
40
0
    // ignored by the parent.  In particular, the TabChild in which
41
0
    // persistence started does not necessarily exist at this point;
42
0
    // see bug 1203602.
43
0
    if (!Manager()->Manager()
44
0
        ->SendPWebBrowserPersistDocumentConstructor(subActor, nullptr, 0)) {
45
0
        // NOTE: subActor is freed at this point.
46
0
        return NS_ERROR_FAILURE;
47
0
    }
48
0
    // ...but here, IPC won't free subActor until after this returns
49
0
    // to the event loop.
50
0
51
0
    // The order of these two messages will be preserved, because
52
0
    // they're the same toplevel protocol and priority.
53
0
    //
54
0
    // With this ordering, it's always the transition out of START
55
0
    // state that causes a document's parent actor to be exposed to
56
0
    // XPCOM (for both parent->child and child->parent construction),
57
0
    // which simplifies the lifetime management.
58
0
    SendVisitDocument(subActor);
59
0
    subActor->Start(aSubDocument);
60
0
    return NS_OK;
61
0
}
62
63
NS_IMETHODIMP
64
WebBrowserPersistResourcesChild::EndVisit(nsIWebBrowserPersistDocument *aDocument,
65
                                          nsresult aStatus)
66
0
{
67
0
    Send__delete__(this, aStatus);
68
0
    return NS_OK;
69
0
}
70
71
} // namespace mozilla