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

View File

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

View File

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

View File

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