gecko-dev/dom/webbrowserpersist/WebBrowserPersistRemoteDocument.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

174 lines
4.9 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* 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 "WebBrowserPersistRemoteDocument.h"
#include "WebBrowserPersistDocumentParent.h"
#include "WebBrowserPersistResourcesParent.h"
#include "WebBrowserPersistSerializeParent.h"
#include "mozilla/Unused.h"
#include "mozilla/ipc/BackgroundUtils.h"
#include "nsIPrincipal.h"
namespace mozilla {
NS_IMPL_ISUPPORTS(WebBrowserPersistRemoteDocument, nsIWebBrowserPersistDocument)
WebBrowserPersistRemoteDocument ::WebBrowserPersistRemoteDocument(
WebBrowserPersistDocumentParent* aActor, const Attrs& aAttrs,
nsIInputStream* aPostData)
: mActor(aActor), mAttrs(aAttrs), mPostData(aPostData) {
nsresult rv;
mPrincipal = ipc::PrincipalInfoToPrincipal(mAttrs.principal(), &rv);
}
WebBrowserPersistRemoteDocument::~WebBrowserPersistRemoteDocument() {
if (mActor) {
Unused << WebBrowserPersistDocumentParent::Send__delete__(mActor);
// That will call mActor->ActorDestroy, which calls this->ActorDestroy
// (whether or not the IPC send succeeds).
}
MOZ_ASSERT(!mActor);
}
void WebBrowserPersistRemoteDocument::ActorDestroy(void) { mActor = nullptr; }
NS_IMETHODIMP
WebBrowserPersistRemoteDocument::GetIsPrivate(bool* aIsPrivate) {
*aIsPrivate = mAttrs.isPrivate();
return NS_OK;
}
NS_IMETHODIMP
WebBrowserPersistRemoteDocument::GetDocumentURI(nsACString& aURISpec) {
aURISpec = mAttrs.documentURI();
return NS_OK;
}
NS_IMETHODIMP
WebBrowserPersistRemoteDocument::GetBaseURI(nsACString& aURISpec) {
aURISpec = mAttrs.baseURI();
return NS_OK;
}
NS_IMETHODIMP
WebBrowserPersistRemoteDocument::GetContentType(nsACString& aContentType) {
aContentType = mAttrs.contentType();
return NS_OK;
}
NS_IMETHODIMP
WebBrowserPersistRemoteDocument::GetCharacterSet(nsACString& aCharSet) {
aCharSet = mAttrs.characterSet();
return NS_OK;
}
NS_IMETHODIMP
WebBrowserPersistRemoteDocument::GetTitle(nsAString& aTitle) {
aTitle = mAttrs.title();
return NS_OK;
}
NS_IMETHODIMP
WebBrowserPersistRemoteDocument::GetReferrer(nsAString& aReferrer) {
aReferrer = mAttrs.referrer();
return NS_OK;
}
NS_IMETHODIMP
WebBrowserPersistRemoteDocument::GetContentDisposition(nsAString& aDisp) {
aDisp = mAttrs.contentDisposition();
return NS_OK;
}
NS_IMETHODIMP
WebBrowserPersistRemoteDocument::GetCacheKey(uint32_t* aCacheKey) {
*aCacheKey = mAttrs.cacheKey();
return NS_OK;
}
NS_IMETHODIMP
WebBrowserPersistRemoteDocument::GetPersistFlags(uint32_t* aFlags) {
*aFlags = mAttrs.persistFlags();
return NS_OK;
}
NS_IMETHODIMP
WebBrowserPersistRemoteDocument::SetPersistFlags(uint32_t aFlags) {
if (!mActor) {
return NS_ERROR_FAILURE;
}
if (!mActor->SendSetPersistFlags(aFlags)) {
return NS_ERROR_FAILURE;
}
mAttrs.persistFlags() = aFlags;
return NS_OK;
}
NS_IMETHODIMP
WebBrowserPersistRemoteDocument::GetPostData(nsIInputStream** aStream) {
nsCOMPtr<nsIInputStream> stream = mPostData;
stream.forget(aStream);
return NS_OK;
}
NS_IMETHODIMP
WebBrowserPersistRemoteDocument::GetPrincipal(nsIPrincipal** aPrincipal) {
nsCOMPtr<nsIPrincipal> nodePrincipal = mPrincipal;
nodePrincipal.forget(aPrincipal);
return NS_OK;
}
NS_IMETHODIMP
WebBrowserPersistRemoteDocument::ReadResources(
nsIWebBrowserPersistResourceVisitor* aVisitor) {
if (!mActor) {
return NS_ERROR_FAILURE;
}
Bug 1207245 - part 6 - rename nsRefPtr<T> to RefPtr<T>; r=ehsan; a=Tomcat The bulk of this commit was generated with a script, executed at the top level of a typical source code checkout. The only non-machine-generated part was modifying MFBT's moz.build to reflect the new naming. CLOSED TREE makes big refactorings like this a piece of cake. # The main substitution. find . -name '*.cpp' -o -name '*.cc' -o -name '*.h' -o -name '*.mm' -o -name '*.idl'| \ xargs perl -p -i -e ' s/nsRefPtr\.h/RefPtr\.h/g; # handle includes s/nsRefPtr ?</RefPtr</g; # handle declarations and variables ' # Handle a special friend declaration in gfx/layers/AtomicRefCountedWithFinalize.h. perl -p -i -e 's/::nsRefPtr;/::RefPtr;/' gfx/layers/AtomicRefCountedWithFinalize.h # Handle nsRefPtr.h itself, a couple places that define constructors # from nsRefPtr, and code generators specially. We do this here, rather # than indiscriminantly s/nsRefPtr/RefPtr/, because that would rename # things like nsRefPtrHashtable. perl -p -i -e 's/nsRefPtr/RefPtr/g' \ mfbt/nsRefPtr.h \ xpcom/glue/nsCOMPtr.h \ xpcom/base/OwningNonNull.h \ ipc/ipdl/ipdl/lower.py \ ipc/ipdl/ipdl/builtin.py \ dom/bindings/Codegen.py \ python/lldbutils/lldbutils/utils.py # In our indiscriminate substitution above, we renamed # nsRefPtrGetterAddRefs, the class behind getter_AddRefs. Fix that up. find . -name '*.cpp' -o -name '*.h' -o -name '*.idl' | \ xargs perl -p -i -e 's/nsRefPtrGetterAddRefs/RefPtrGetterAddRefs/g' if [ -d .git ]; then git mv mfbt/nsRefPtr.h mfbt/RefPtr.h else hg mv mfbt/nsRefPtr.h mfbt/RefPtr.h fi --HG-- rename : mfbt/nsRefPtr.h => mfbt/RefPtr.h
2015-10-18 05:24:48 +00:00
RefPtr<WebBrowserPersistResourcesParent> subActor =
new WebBrowserPersistResourcesParent(this, aVisitor);
return mActor->SendPWebBrowserPersistResourcesConstructor(
subActor.forget().take())
? NS_OK
: NS_ERROR_FAILURE;
}
NS_IMETHODIMP
WebBrowserPersistRemoteDocument::WriteContent(
nsIOutputStream* aStream, nsIWebBrowserPersistURIMap* aMap,
const nsACString& aRequestedContentType, uint32_t aEncoderFlags,
uint32_t aWrapColumn, nsIWebBrowserPersistWriteCompletion* aCompletion) {
if (!mActor) {
return NS_ERROR_FAILURE;
}
nsresult rv;
WebBrowserPersistURIMap map;
uint32_t numMappedURIs;
if (aMap) {
rv = aMap->GetTargetBaseURI(map.targetBaseURI());
NS_ENSURE_SUCCESS(rv, rv);
rv = aMap->GetNumMappedURIs(&numMappedURIs);
NS_ENSURE_SUCCESS(rv, rv);
for (uint32_t i = 0; i < numMappedURIs; ++i) {
WebBrowserPersistURIMapEntry& nextEntry =
*(map.mapURIs().AppendElement());
rv = aMap->GetURIMapping(i, nextEntry.mapFrom(), nextEntry.mapTo());
NS_ENSURE_SUCCESS(rv, rv);
}
}
auto* subActor =
new WebBrowserPersistSerializeParent(this, aStream, aCompletion);
nsCString requestedContentType(aRequestedContentType); // Sigh.
return mActor->SendPWebBrowserPersistSerializeConstructor(
subActor, map, requestedContentType, aEncoderFlags, aWrapColumn)
? NS_OK
: NS_ERROR_FAILURE;
}
} // namespace mozilla