diff --git a/ipc/glue/IPCMessageUtils.h b/ipc/glue/IPCMessageUtils.h index 04be310761..e30a5fa952 100644 --- a/ipc/glue/IPCMessageUtils.h +++ b/ipc/glue/IPCMessageUtils.h @@ -385,6 +385,18 @@ struct ParamTraits : ParamTraits typedef nsLiteralCString paramType; }; +template <> +struct ParamTraits : ParamTraits +{ + typedef nsDependentSubstring paramType; +}; + +template <> +struct ParamTraits : ParamTraits +{ + typedef nsDependentCSubstring paramType; +}; + #ifdef MOZILLA_INTERNAL_API template<> diff --git a/ipc/ipdl/ipdl/builtin.py b/ipc/ipdl/ipdl/builtin.py index 3a49b5c7ee..3c332cf838 100644 --- a/ipc/ipdl/ipdl/builtin.py +++ b/ipc/ipdl/ipdl/builtin.py @@ -36,6 +36,8 @@ Types = ( 'nsresult', 'nsString', 'nsCString', + 'nsDependentSubstring', + 'nsDependentCSubstring', 'mozilla::ipc::Shmem', 'mozilla::ipc::FileDescriptor' ) diff --git a/netwerk/protocol/wyciwyg/PWyciwygChannel.ipdl b/netwerk/protocol/wyciwyg/PWyciwygChannel.ipdl index b1eabc4fdb..939f106988 100644 --- a/netwerk/protocol/wyciwyg/PWyciwygChannel.ipdl +++ b/netwerk/protocol/wyciwyg/PWyciwygChannel.ipdl @@ -35,7 +35,7 @@ parent: async AppData(SerializedLoadContext loadContext, PBrowserOrId browser); // methods corresponding to those of nsIWyciwygChannel - async WriteToCacheEntry(nsString data); + async WriteToCacheEntry(nsDependentSubstring data); async CloseCacheEntry(nsresult reason); async SetCharsetAndSource(int32_t source, nsCString charset); async SetSecurityInfo(nsCString securityInfo); diff --git a/netwerk/protocol/wyciwyg/WyciwygChannelChild.cpp b/netwerk/protocol/wyciwyg/WyciwygChannelChild.cpp index 2a794df3b4..9966df90fc 100644 --- a/netwerk/protocol/wyciwyg/WyciwygChannelChild.cpp +++ b/netwerk/protocol/wyciwyg/WyciwygChannelChild.cpp @@ -689,8 +689,22 @@ WyciwygChannelChild::WriteToCacheEntry(const nsAString & aData) mSentAppData = true; } - SendWriteToCacheEntry(PromiseFlatString(aData)); mState = WCC_ONWRITE; + + // Give ourselves a megabyte of headroom for the message size. Convert bytes + // to wide chars. + static const size_t kMaxMessageSize = (IPC::Channel::kMaximumMessageSize - 1024) / 2; + + size_t curIndex = 0; + size_t charsRemaining = aData.Length(); + do { + size_t chunkSize = std::min(charsRemaining, kMaxMessageSize); + SendWriteToCacheEntry(Substring(aData, curIndex, chunkSize)); + + charsRemaining -= chunkSize; + curIndex += chunkSize; + } while (charsRemaining != 0); + return NS_OK; } diff --git a/netwerk/protocol/wyciwyg/WyciwygChannelParent.cpp b/netwerk/protocol/wyciwyg/WyciwygChannelParent.cpp index be00c2d869..6a7d34e1dc 100644 --- a/netwerk/protocol/wyciwyg/WyciwygChannelParent.cpp +++ b/netwerk/protocol/wyciwyg/WyciwygChannelParent.cpp @@ -213,7 +213,7 @@ WyciwygChannelParent::RecvAsyncOpen(const URIParams& aOriginal, } bool -WyciwygChannelParent::RecvWriteToCacheEntry(const nsString& data) +WyciwygChannelParent::RecvWriteToCacheEntry(const nsDependentSubstring& data) { if (!mReceivedAppData) { printf_stderr("WyciwygChannelParent::RecvWriteToCacheEntry: FATAL ERROR: didn't receive app data\n"); diff --git a/netwerk/protocol/wyciwyg/WyciwygChannelParent.h b/netwerk/protocol/wyciwyg/WyciwygChannelParent.h index be009487b1..7a0a948271 100644 --- a/netwerk/protocol/wyciwyg/WyciwygChannelParent.h +++ b/netwerk/protocol/wyciwyg/WyciwygChannelParent.h @@ -45,7 +45,7 @@ protected: const uint32_t& loadFlags, const IPC::SerializedLoadContext& loadContext, const PBrowserOrId &parent) override; - virtual bool RecvWriteToCacheEntry(const nsString& data) override; + virtual bool RecvWriteToCacheEntry(const nsDependentSubstring& data) override; virtual bool RecvCloseCacheEntry(const nsresult& reason) override; virtual bool RecvSetCharsetAndSource(const int32_t& source, const nsCString& charset) override;