Bug 1339713 - Use IPCStream everywhere - part 1 - PWebBrowserPersistDocument, r=smaug

This commit is contained in:
Andrea Marchesini 2017-03-09 14:09:11 +01:00
parent 7cb8574d6c
commit a7dbdfbd6c
4 changed files with 16 additions and 17 deletions

View File

@ -6,8 +6,10 @@
include protocol PContent; include protocol PContent;
include protocol PWebBrowserPersistResources; include protocol PWebBrowserPersistResources;
include protocol PWebBrowserPersistSerialize; include protocol PWebBrowserPersistSerialize;
include protocol PFileDescriptorSet;
include protocol PSendStream;
include InputStreamParams; include IPCStream;
namespace mozilla { namespace mozilla {
@ -60,8 +62,7 @@ parent:
// is either a response to the constructor (if it was parent->child) // is either a response to the constructor (if it was parent->child)
// or sent after it (if it was child->parent). // or sent after it (if it was child->parent).
async Attributes(WebBrowserPersistDocumentAttrs aAttrs, async Attributes(WebBrowserPersistDocumentAttrs aAttrs,
OptionalInputStreamParams postData, OptionalIPCStream stream);
FileDescriptor[] postFiles);
async InitFailure(nsresult aStatus); async InitFailure(nsresult aStatus);
child: child:

View File

@ -6,7 +6,8 @@
#include "WebBrowserPersistDocumentChild.h" #include "WebBrowserPersistDocumentChild.h"
#include "mozilla/ipc/InputStreamUtils.h" #include "mozilla/dom/ContentChild.h"
#include "mozilla/ipc/IPCStreamUtils.h"
#include "nsIDocument.h" #include "nsIDocument.h"
#include "nsIInputStream.h" #include "nsIInputStream.h"
#include "WebBrowserPersistLocalDocument.h" #include "WebBrowserPersistLocalDocument.h"
@ -42,8 +43,6 @@ WebBrowserPersistDocumentChild::Start(nsIWebBrowserPersistDocument* aDocument)
WebBrowserPersistDocumentAttrs attrs; WebBrowserPersistDocumentAttrs attrs;
nsCOMPtr<nsIInputStream> postDataStream; nsCOMPtr<nsIInputStream> postDataStream;
OptionalInputStreamParams postData;
nsTArray<FileDescriptor> postFiles;
#define ENSURE(e) do { \ #define ENSURE(e) do { \
nsresult rv = (e); \ nsresult rv = (e); \
if (NS_FAILED(rv)) { \ if (NS_FAILED(rv)) { \
@ -62,12 +61,14 @@ WebBrowserPersistDocumentChild::Start(nsIWebBrowserPersistDocument* aDocument)
ENSURE(aDocument->GetCacheKey(&(attrs.cacheKey()))); ENSURE(aDocument->GetCacheKey(&(attrs.cacheKey())));
ENSURE(aDocument->GetPersistFlags(&(attrs.persistFlags()))); ENSURE(aDocument->GetPersistFlags(&(attrs.persistFlags())));
ENSURE(aDocument->GetPostData(getter_AddRefs(postDataStream))); ENSURE(aDocument->GetPostData(getter_AddRefs(postDataStream)));
ipc::SerializeInputStream(postDataStream,
postData,
postFiles);
#undef ENSURE #undef ENSURE
mozilla::ipc::AutoIPCStream autoStream;
autoStream.Serialize(postDataStream,
static_cast<mozilla::dom::ContentChild*>(Manager()));
mDocument = aDocument; mDocument = aDocument;
SendAttributes(attrs, postData, postFiles); SendAttributes(attrs, autoStream.TakeOptionalValue());
} }
mozilla::ipc::IPCResult mozilla::ipc::IPCResult

View File

@ -6,7 +6,7 @@
#include "WebBrowserPersistDocumentParent.h" #include "WebBrowserPersistDocumentParent.h"
#include "mozilla/ipc/InputStreamUtils.h" #include "mozilla/ipc/IPCStreamUtils.h"
#include "mozilla/dom/PContentParent.h" #include "mozilla/dom/PContentParent.h"
#include "nsIInputStream.h" #include "nsIInputStream.h"
#include "nsThreadUtils.h" #include "nsThreadUtils.h"
@ -60,12 +60,10 @@ WebBrowserPersistDocumentParent::~WebBrowserPersistDocumentParent()
mozilla::ipc::IPCResult mozilla::ipc::IPCResult
WebBrowserPersistDocumentParent::RecvAttributes(const Attrs& aAttrs, WebBrowserPersistDocumentParent::RecvAttributes(const Attrs& aAttrs,
const OptionalInputStreamParams& aPostData, const OptionalIPCStream& aPostStream)
nsTArray<FileDescriptor>&& aPostFiles)
{ {
// Deserialize the postData unconditionally so that fds aren't leaked. // Deserialize the postData unconditionally so that fds aren't leaked.
nsCOMPtr<nsIInputStream> postData = nsCOMPtr<nsIInputStream> postData = mozilla::ipc::DeserializeIPCStream(aPostStream);
ipc::DeserializeInputStream(aPostData, aPostFiles);
if (!mOnReady || mReflection) { if (!mOnReady || mReflection) {
return IPC_FAIL_NO_REASON(this); return IPC_FAIL_NO_REASON(this);
} }

View File

@ -47,8 +47,7 @@ public:
// IPDL methods: // IPDL methods:
virtual mozilla::ipc::IPCResult virtual mozilla::ipc::IPCResult
RecvAttributes(const Attrs& aAttrs, RecvAttributes(const Attrs& aAttrs,
const OptionalInputStreamParams& aPostData, const OptionalIPCStream& aPostStream) override;
nsTArray<FileDescriptor>&& aPostFiles) override;
virtual mozilla::ipc::IPCResult virtual mozilla::ipc::IPCResult
RecvInitFailure(const nsresult& aFailure) override; RecvInitFailure(const nsresult& aFailure) override;