コード例 #1
0
void
WebBrowserPersistDocumentChild::Start(nsIWebBrowserPersistDocument* aDocument)
{
    MOZ_ASSERT(!mDocument);
    if (!aDocument) {
        SendInitFailure(NS_ERROR_FAILURE);
        return;
    }

    nsCOMPtr<nsIPrincipal> principal;
    WebBrowserPersistDocumentAttrs attrs;
    nsCOMPtr<nsIInputStream> postDataStream;
#define ENSURE(e) do {           \
        nsresult rv = (e);       \
        if (NS_FAILED(rv)) {     \
            SendInitFailure(rv); \
            return;              \
        }                        \
    } while(0)
    ENSURE(aDocument->GetIsPrivate(&(attrs.isPrivate())));
    ENSURE(aDocument->GetDocumentURI(attrs.documentURI()));
    ENSURE(aDocument->GetBaseURI(attrs.baseURI()));
    ENSURE(aDocument->GetContentType(attrs.contentType()));
    ENSURE(aDocument->GetCharacterSet(attrs.characterSet()));
    ENSURE(aDocument->GetTitle(attrs.title()));
    ENSURE(aDocument->GetReferrer(attrs.referrer()));
    ENSURE(aDocument->GetContentDisposition(attrs.contentDisposition()));
    ENSURE(aDocument->GetCacheKey(&(attrs.cacheKey())));
    ENSURE(aDocument->GetPersistFlags(&(attrs.persistFlags())));

    ENSURE(aDocument->GetPrincipal(getter_AddRefs(principal)));
    ENSURE(ipc::PrincipalToPrincipalInfo(principal, &(attrs.principal())));

    ENSURE(aDocument->GetPostData(getter_AddRefs(postDataStream)));
#undef ENSURE

    mozilla::ipc::AutoIPCStream autoStream;
    autoStream.Serialize(postDataStream,
                         static_cast<mozilla::dom::ContentChild*>(Manager()));

    mDocument = aDocument;
    SendAttributes(attrs, autoStream.TakeOptionalValue());
}
コード例 #2
0
void
WebBrowserPersistDocumentChild::Start(nsIWebBrowserPersistDocument* aDocument)
{
    MOZ_ASSERT(!mDocument);
    if (!aDocument) {
        SendInitFailure(NS_ERROR_FAILURE);
        return;
    }

    WebBrowserPersistDocumentAttrs attrs;
    nsCOMPtr<nsIInputStream> postDataStream;
    OptionalInputStreamParams postData;
    nsTArray<FileDescriptor> postFiles;
#define ENSURE(e) do {           \
        nsresult rv = (e);       \
        if (NS_FAILED(rv)) {     \
            SendInitFailure(rv); \
            return;              \
        }                        \
    } while(0)
    ENSURE(aDocument->GetIsPrivate(&(attrs.isPrivate())));
    ENSURE(aDocument->GetDocumentURI(attrs.documentURI()));
    ENSURE(aDocument->GetBaseURI(attrs.baseURI()));
    ENSURE(aDocument->GetContentType(attrs.contentType()));
    ENSURE(aDocument->GetCharacterSet(attrs.characterSet()));
    ENSURE(aDocument->GetTitle(attrs.title()));
    ENSURE(aDocument->GetReferrer(attrs.referrer()));
    ENSURE(aDocument->GetContentDisposition(attrs.contentDisposition()));
    ENSURE(aDocument->GetCacheKey(&(attrs.cacheKey())));
    ENSURE(aDocument->GetPersistFlags(&(attrs.persistFlags())));
    ENSURE(aDocument->GetPostData(getter_AddRefs(postDataStream)));
    ipc::SerializeInputStream(postDataStream,
                              postData,
                              postFiles);
#undef ENSURE
    mDocument = aDocument;
    SendAttributes(attrs, postData, postFiles);
}