Bug 561085 - Make wyciwyg channel work in e10s. r=dwitte sr=biesi
authorMichal Novotny <michal.novotny@gmail.com>
Mon, 11 Oct 2010 13:35:10 +0200
changeset 56090 c56bcfa6defbb51a722681fe6647454c0a13078a
parent 56089 fe519f659d606e728a29fcd20b98cb2a49837462
child 56091 45fa68335edf043820041180357bd21146200f98
push id16404
push userjmatthews@mozilla.com
push dateTue, 19 Oct 2010 15:15:55 +0000
treeherdermozilla-central@45fa68335edf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdwitte, biesi
bugs561085
milestone2.0b8pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 561085 - Make wyciwyg channel work in e10s. r=dwitte sr=biesi
configure.in
content/base/public/nsContentCID.h
content/html/document/public/Makefile.in
content/html/document/public/nsIWyciwygChannel.idl
content/html/document/src/Makefile.in
content/html/document/src/nsWyciwygChannel.cpp
content/html/document/src/nsWyciwygChannel.h
content/html/document/src/nsWyciwygProtocolHandler.cpp
content/html/document/src/nsWyciwygProtocolHandler.h
ipc/ipdl/Makefile.in
layout/build/nsLayoutModule.cpp
netwerk/base/src/nsSimpleNestedURI.cpp
netwerk/base/src/nsSimpleNestedURI.h
netwerk/base/src/nsSimpleURI.cpp
netwerk/base/src/nsSimpleURI.h
netwerk/build/nsNetCID.h
netwerk/build/nsNetModule.cpp
netwerk/ipc/NeckoChild.cpp
netwerk/ipc/NeckoChild.h
netwerk/ipc/NeckoParent.cpp
netwerk/ipc/NeckoParent.h
netwerk/ipc/PNecko.ipdl
netwerk/necko-config.h.in
netwerk/protocol/Makefile.in
netwerk/protocol/about/Makefile.in
netwerk/protocol/about/nsAboutProtocolHandler.cpp
netwerk/protocol/about/nsAboutProtocolHandler.h
netwerk/protocol/wyciwyg/Makefile.in
netwerk/protocol/wyciwyg/PWyciwygChannel.ipdl
netwerk/protocol/wyciwyg/WyciwygChannelChild.cpp
netwerk/protocol/wyciwyg/WyciwygChannelChild.h
netwerk/protocol/wyciwyg/WyciwygChannelParent.cpp
netwerk/protocol/wyciwyg/WyciwygChannelParent.h
netwerk/protocol/wyciwyg/ipdl.mk
netwerk/protocol/wyciwyg/nsIWyciwygChannel.idl
netwerk/protocol/wyciwyg/nsWyciwyg.cpp
netwerk/protocol/wyciwyg/nsWyciwyg.h
netwerk/protocol/wyciwyg/nsWyciwygChannel.cpp
netwerk/protocol/wyciwyg/nsWyciwygChannel.h
netwerk/protocol/wyciwyg/nsWyciwygProtocolHandler.cpp
netwerk/protocol/wyciwyg/nsWyciwygProtocolHandler.h
--- a/configure.in
+++ b/configure.in
@@ -4995,17 +4995,17 @@ MOZ_XTF=1
 MOZ_XUL=1
 MOZ_ZIPWRITER=1
 NS_PRINTING=1
 MOZ_DISABLE_DOMCRYPTO=
 NSS_DISABLE_DBM=
 NECKO_WIFI=1
 NECKO_COOKIES=1
 NECKO_DISK_CACHE=1
-NECKO_PROTOCOLS_DEFAULT="about data file ftp http res viewsource"
+NECKO_PROTOCOLS_DEFAULT="about data file ftp http res viewsource wyciwyg"
 USE_ARM_KUSER=
 BUILD_CTYPES=1
 XPC_IDISPATCH_SUPPORT=
 
 
 case "$target_os" in
 darwin*|*wince*|*winmo*)
     ACCESSIBILITY=
--- a/content/base/public/nsContentCID.h
+++ b/content/base/public/nsContentCID.h
@@ -64,21 +64,16 @@
 #define NS_LAYOUT_DEBUGGER_CID \
  { 0xa6cf90f9, 0x15b3, 0x11d2,{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
 
 #define NS_HTMLDOCUMENT_CID                       \
 { /* 5d0fcdd0-4daa-11d2-b328-00805f8a3859 */      \
  0x5d0fcdd0, 0x4daa, 0x11d2,                      \
  {0xb3, 0x28, 0x00, 0x80, 0x5f, 0x8a, 0x38, 0x59}}
 
-#define NS_WYCIWYGPROTOCOLHANDLER_CID             \
-{ /* e7509b46-2eB2-410a-9d7c-c3ce73284d01 */      \
-  0xe7509b46, 0x2eb2, 0x410a,                     \
-  {0x9d, 0x7c, 0xc3, 0xce, 0x73, 0x28, 0x4d, 0x01}}
-
 #define NS_XMLDOCUMENT_CID                        \
 { /* a6cf9063-15b3-11d2-932e-00805f8add32 */      \
  0xa6cf9063, 0x15b3, 0x11d2,                      \
  {0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
 
 #define NS_IMAGEDOCUMENT_CID                      \
 { /* e11a6080-4daa-11d2-b328-00805f8a3859 */      \
  0xe11a6080, 0x4daa, 0x11d2,                      \
--- a/content/html/document/public/Makefile.in
+++ b/content/html/document/public/Makefile.in
@@ -42,12 +42,11 @@ VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 MODULE		= content
 XPIDL_MODULE	= content_htmldoc
 
 XPIDLSRCS 	= \
 		nsIImageDocument.idl \
-		nsIWyciwygChannel.idl \
         	$(NULL)
 
 include $(topsrcdir)/config/rules.mk
--- a/content/html/document/src/Makefile.in
+++ b/content/html/document/src/Makefile.in
@@ -49,18 +49,16 @@ LIBXUL_LIBRARY	= 1
 
 CPPSRCS		= \
 		nsHTMLContentSink.cpp \
 		nsHTMLFragmentContentSink.cpp \
 		nsHTMLDocument.cpp \
 		nsImageDocument.cpp \
 		nsMediaDocument.cpp \
 		nsPluginDocument.cpp \
-		nsWyciwygChannel.cpp \
-		nsWyciwygProtocolHandler.cpp \
 		$(NULL)
 
 ifdef MOZ_MEDIA
 CPPSRCS += nsVideoDocument.cpp
 endif
 
 EXPORTS		= \
 		nsIHTMLDocument.h \
--- a/ipc/ipdl/Makefile.in
+++ b/ipc/ipdl/Makefile.in
@@ -60,16 +60,17 @@ IPDLDIRS =  \
   gfx/layers/ipc \
   ipc/ipdl/test/cxx  \
   ipc/testshell  \
   js/ipc  \
   js/jetpack \
   layout/ipc \
   netwerk/ipc  \
   netwerk/protocol/http  \
+  netwerk/protocol/wyciwyg \
   netwerk/cookie  \
   $(NULL)
 ##-----------------------------------------------------------------------------
 
 ifdef MOZ_IPDL_TESTS
 DIRS += test
 endif
 
--- a/layout/build/nsLayoutModule.cpp
+++ b/layout/build/nsLayoutModule.cpp
@@ -81,17 +81,16 @@
 #include "nsISelection.h"
 #include "nsIXBLService.h"
 #include "nsCaret.h"
 #include "nsPlainTextSerializer.h"
 #include "mozSanitizingSerializer.h"
 #include "nsXMLContentSerializer.h"
 #include "nsXHTMLContentSerializer.h"
 #include "nsRuleNode.h"
-#include "nsWyciwygProtocolHandler.h"
 #include "nsContentAreaDragDrop.h"
 #include "nsContentList.h"
 #include "nsSyncLoadService.h"
 #include "nsBox.h"
 #include "nsIFrameTraversal.h"
 #include "nsLayoutCID.h"
 #include "nsILanguageAtomService.h"
 #include "nsStyleSheetService.h"
@@ -566,17 +565,16 @@ MAKE_CTOR(CreateXULPopupManager,      ns
 MAKE_CTOR(CreateXTFService,               nsIXTFService,               NS_NewXTFService)
 MAKE_CTOR(CreateXMLContentBuilder,        nsIXMLContentBuilder,        NS_NewXMLContentBuilder)
 #endif
 MAKE_CTOR(CreateContentDLF,               nsIDocumentLoaderFactory,    NS_NewContentDocumentLoaderFactory)
 MAKE_CTOR(CreateEventListenerService,     nsIEventListenerService,     NS_NewEventListenerService)
 MAKE_CTOR(CreateGlobalMessageManager,     nsIChromeFrameMessageManager,NS_NewGlobalMessageManager)
 MAKE_CTOR(CreateParentMessageManager,     nsIFrameMessageManager,NS_NewParentProcessMessageManager)
 MAKE_CTOR(CreateChildMessageManager,     nsISyncMessageSender,NS_NewChildProcessMessageManager)
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsWyciwygProtocolHandler)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsDataDocumentContentPolicy)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsNoDataProtocolContentPolicy)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsSyncLoadService)
 MAKE_CTOR(CreatePluginDocument,           nsIDocument,                 NS_NewPluginDocument)
 #ifdef MOZ_MEDIA
 MAKE_CTOR(CreateVideoDocument,            nsIDocument,                 NS_NewVideoDocument)
 #endif
 MAKE_CTOR(CreateFocusManager,             nsIFocusManager,      NS_NewFocusManager)
@@ -820,17 +818,16 @@ NS_DEFINE_NAMED_CID(NS_XULPOPUPMANAGER_C
 NS_DEFINE_NAMED_CID(NS_XULDOCUMENT_CID);
 NS_DEFINE_NAMED_CID(NS_XULPROTOTYPECACHE_CID);
 #endif
 #ifdef MOZ_XTF
 NS_DEFINE_NAMED_CID(NS_XTFSERVICE_CID);
 NS_DEFINE_NAMED_CID(NS_XMLCONTENTBUILDER_CID);
 #endif
 NS_DEFINE_NAMED_CID(NS_CONTENT_DOCUMENT_LOADER_FACTORY_CID);
-NS_DEFINE_NAMED_CID(NS_WYCIWYGPROTOCOLHANDLER_CID);
 NS_DEFINE_NAMED_CID(NS_SYNCLOADDOMSERVICE_CID);
 NS_DEFINE_NAMED_CID(NS_DOM_SCRIPT_OBJECT_FACTORY_CID);
 NS_DEFINE_NAMED_CID(NS_BASE_DOM_EXCEPTION_CID);
 NS_DEFINE_NAMED_CID(NS_JSPROTOCOLHANDLER_CID);
 NS_DEFINE_NAMED_CID(NS_JSURI_CID);
 NS_DEFINE_NAMED_CID(NS_WINDOWCOMMANDTABLE_CID);
 NS_DEFINE_NAMED_CID(NS_WINDOWCONTROLLER_CID);
 NS_DEFINE_NAMED_CID(NS_VIEW_MANAGER_CID);
@@ -971,17 +968,16 @@ static const mozilla::Module::CIDEntry k
   { &kNS_XULDOCUMENT_CID, false, NULL, CreateXULDocument },
   { &kNS_XULPROTOTYPECACHE_CID, false, NULL, NS_NewXULPrototypeCache },
 #endif
 #ifdef MOZ_XTF
   { &kNS_XTFSERVICE_CID, false, NULL, CreateXTFService },
   { &kNS_XMLCONTENTBUILDER_CID, false, NULL, CreateXMLContentBuilder },
 #endif
   { &kNS_CONTENT_DOCUMENT_LOADER_FACTORY_CID, false, NULL, CreateContentDLF },
-  { &kNS_WYCIWYGPROTOCOLHANDLER_CID, false, NULL, nsWyciwygProtocolHandlerConstructor },
   { &kNS_SYNCLOADDOMSERVICE_CID, false, NULL, nsSyncLoadServiceConstructor },
   { &kNS_DOM_SCRIPT_OBJECT_FACTORY_CID, false, NULL, nsDOMScriptObjectFactoryConstructor },
   { &kNS_BASE_DOM_EXCEPTION_CID, false, NULL, nsBaseDOMExceptionConstructor },
   { &kNS_JSPROTOCOLHANDLER_CID, false, NULL, nsJSProtocolHandler::Create },
   { &kNS_JSURI_CID, false, NULL, nsJSURIConstructor },
   { &kNS_WINDOWCOMMANDTABLE_CID, false, NULL, CreateWindowCommandTableConstructor },
   { &kNS_WINDOWCONTROLLER_CID, false, NULL, CreateWindowControllerWithSingletonCommandTable },
   { &kNS_VIEW_MANAGER_CID, false, NULL, nsViewManagerConstructor },
@@ -1124,17 +1120,16 @@ static const mozilla::Module::ContractID
   { "@mozilla.org/xul/xul-document;1", &kNS_XULDOCUMENT_CID },
   { "@mozilla.org/xul/xul-prototype-cache;1", &kNS_XULPROTOTYPECACHE_CID },
 #endif
 #ifdef MOZ_XTF
   { NS_XTFSERVICE_CONTRACTID, &kNS_XTFSERVICE_CID },
   { NS_XMLCONTENTBUILDER_CONTRACTID, &kNS_XMLCONTENTBUILDER_CID },
 #endif
   { CONTENT_DLF_CONTRACTID, &kNS_CONTENT_DOCUMENT_LOADER_FACTORY_CID },
-  { NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "wyciwyg", &kNS_WYCIWYGPROTOCOLHANDLER_CID },
   { NS_SYNCLOADDOMSERVICE_CONTRACTID, &kNS_SYNCLOADDOMSERVICE_CID },
   { NS_JSPROTOCOLHANDLER_CONTRACTID, &kNS_JSPROTOCOLHANDLER_CID },
   { NS_WINDOWCONTROLLER_CONTRACTID, &kNS_WINDOWCONTROLLER_CID },
   { "@mozilla.org/view-manager;1", &kNS_VIEW_MANAGER_CID },
   { PLUGIN_DLF_CONTRACTID, &kNS_PLUGINDOCLOADERFACTORY_CID },
   { NS_STYLESHEETSERVICE_CONTRACTID, &kNS_STYLESHEETSERVICE_CID },
   { TRANSFORMIIX_XSLT_PROCESSOR_CONTRACTID, &kTRANSFORMIIX_XSLT_PROCESSOR_CID },
   { NS_XPATH_EVALUATOR_CONTRACTID, &kTRANSFORMIIX_XPATH_EVALUATOR_CID },
--- a/netwerk/base/src/nsSimpleNestedURI.cpp
+++ b/netwerk/base/src/nsSimpleNestedURI.cpp
@@ -31,16 +31,21 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
+#ifdef MOZ_IPC
+#include "IPCMessageUtils.h"
+#include "mozilla/net/NeckoMessageUtils.h"
+#endif
+
 #include "nsSimpleNestedURI.h"
 #include "nsIObjectInputStream.h"
 #include "nsIObjectOutputStream.h"
 #include "nsNetUtil.h"
 
 NS_IMPL_ISUPPORTS_INHERITED1(nsSimpleNestedURI, nsSimpleURI, nsINestedURI)
 
 nsSimpleNestedURI::nsSimpleNestedURI(nsIURI* innerURI)
@@ -80,16 +85,47 @@ nsSimpleNestedURI::Write(nsIObjectOutput
     nsresult rv = nsSimpleURI::Write(aStream);
     if (NS_FAILED(rv)) return rv;
 
     rv = aStream->WriteCompoundObject(mInnerURI, NS_GET_IID(nsIURI),
                                       PR_TRUE);
     return rv;
 }
 
+// nsIIPCSerializable
+
+PRBool
+nsSimpleNestedURI::Read(const IPC::Message *aMsg, void **aIter)
+{
+#ifdef MOZ_IPC
+    if (!nsSimpleURI::Read(aMsg, aIter))
+        return PR_FALSE;
+
+    IPC::URI uri;
+    if (!ReadParam(aMsg, aIter, &uri))
+        return PR_FALSE;
+
+    mInnerURI = uri;
+
+    return PR_TRUE;
+#endif
+    return PR_FALSE;
+}
+
+void
+nsSimpleNestedURI::Write(IPC::Message *aMsg)
+{
+#ifdef MOZ_IPC
+    nsSimpleURI::Write(aMsg);
+
+    IPC::URI uri(mInnerURI);
+    WriteParam(aMsg, uri);
+#endif
+}
+
 // nsINestedURI
 
 NS_IMETHODIMP
 nsSimpleNestedURI::GetInnerURI(nsIURI** uri)
 {
     NS_ENSURE_TRUE(mInnerURI, NS_ERROR_NOT_INITIALIZED);
     
     return NS_EnsureSafeToReturn(mInnerURI, uri);
--- a/netwerk/base/src/nsSimpleNestedURI.h
+++ b/netwerk/base/src/nsSimpleNestedURI.h
@@ -64,16 +64,17 @@ public:
     }
 
     // Constructor that should generally be used when constructing an object of
     // this class with |operator new|.
     nsSimpleNestedURI(nsIURI* innerURI);
 
     NS_DECL_ISUPPORTS_INHERITED
     NS_DECL_NSINESTEDURI
+    NS_DECL_NSIIPCSERIALIZABLE
 
     // Overrides for various methods nsSimpleURI implements follow.
   
     // nsIURI overrides
     NS_IMETHOD Equals(nsIURI* other, PRBool *result);
     virtual nsSimpleURI* StartClone();
 
     // nsISerializable overrides
--- a/netwerk/base/src/nsSimpleURI.cpp
+++ b/netwerk/base/src/nsSimpleURI.cpp
@@ -33,16 +33,20 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
+#ifdef MOZ_IPC
+#include "IPCMessageUtils.h"
+#endif
+
 #include "nsSimpleURI.h"
 #include "nscore.h"
 #include "nsCRT.h"
 #include "nsString.h"
 #include "nsReadableUtils.h"
 #include "prmem.h"
 #include "prprf.h"
 #include "nsURLHelper.h"
@@ -67,17 +71,17 @@ nsSimpleURI::nsSimpleURI()
 
 nsSimpleURI::~nsSimpleURI()
 {
 }
 
 NS_IMPL_ADDREF(nsSimpleURI)
 NS_IMPL_RELEASE(nsSimpleURI)
 NS_INTERFACE_TABLE_HEAD(nsSimpleURI)
-NS_INTERFACE_TABLE4(nsSimpleURI, nsIURI, nsISerializable, nsIClassInfo, nsIMutable)
+NS_INTERFACE_TABLE5(nsSimpleURI, nsIURI, nsISerializable, nsIIPCSerializable, nsIClassInfo, nsIMutable)
 NS_INTERFACE_TABLE_TO_MAP_SEGUE
   if (aIID.Equals(kThisSimpleURIImplementationCID))
     foundInterface = static_cast<nsIURI*>(this);
   else
 NS_INTERFACE_MAP_END
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsISerializable methods:
@@ -112,16 +116,46 @@ nsSimpleURI::Write(nsIObjectOutputStream
 
     rv = aStream->WriteStringZ(mPath.get());
     if (NS_FAILED(rv)) return rv;
 
     return NS_OK;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
+// nsIIPCSerializable methods:
+
+PRBool
+nsSimpleURI::Read(const IPC::Message *aMsg, void **aIter)
+{
+#ifdef MOZ_IPC
+    bool isMutable;
+    if (!ReadParam(aMsg, aIter, &isMutable) ||
+        !ReadParam(aMsg, aIter, &mScheme) ||
+        !ReadParam(aMsg, aIter, &mPath))
+        return PR_FALSE;
+
+    mMutable = isMutable;
+    return PR_TRUE;
+#else
+    return PR_FALSE;
+#endif
+}
+
+void
+nsSimpleURI::Write(IPC::Message *aMsg)
+{
+#ifdef MOZ_IPC
+    WriteParam(aMsg, bool(mMutable));
+    WriteParam(aMsg, mScheme);
+    WriteParam(aMsg, mPath);
+#endif
+}
+
+////////////////////////////////////////////////////////////////////////////////
 // nsIURI methods:
 
 NS_IMETHODIMP
 nsSimpleURI::GetSpec(nsACString &result)
 {
     result = mScheme + NS_LITERAL_CSTRING(":") + mPath;
     return NS_OK;
 }
--- a/netwerk/base/src/nsSimpleURI.h
+++ b/netwerk/base/src/nsSimpleURI.h
@@ -36,37 +36,40 @@
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef nsSimpleURI_h__
 #define nsSimpleURI_h__
 
 #include "nsIURL.h"
 #include "nsAgg.h"
 #include "nsISerializable.h"
+#include "nsIIPCSerializable.h"
 #include "nsString.h"
 #include "nsIClassInfo.h"
 #include "nsIMutable.h"
 
 #define NS_THIS_SIMPLEURI_IMPLEMENTATION_CID         \
 { /* 22b8f64a-2f7b-11d3-8cd0-0060b0fc14a3 */         \
     0x22b8f64a,                                      \
     0x2f7b,                                          \
     0x11d3,                                          \
     {0x8c, 0xd0, 0x00, 0x60, 0xb0, 0xfc, 0x14, 0xa3} \
 }
 
 class nsSimpleURI : public nsIURI,
                     public nsISerializable,
+                    public nsIIPCSerializable,
                     public nsIClassInfo,
                     public nsIMutable
 {
 public:
     NS_DECL_ISUPPORTS
     NS_DECL_NSIURI
     NS_DECL_NSISERIALIZABLE
+    NS_DECL_NSIIPCSERIALIZABLE
     NS_DECL_NSICLASSINFO
     NS_DECL_NSIMUTABLE
 
     // nsSimpleURI methods:
 
     nsSimpleURI();
     virtual ~nsSimpleURI();
 
--- a/netwerk/build/nsNetCID.h
+++ b/netwerk/build/nsNetCID.h
@@ -681,16 +681,28 @@
 { /* {0x9c7ec5d1-23f9-11d5-aea8-8fcc0793e97f} */     \
     0x9c7ec5d1,                                      \
     0x23f9,                                          \
     0x11d5,                                          \
     {0xae, 0xa8, 0x8f, 0xcc, 0x07, 0x93, 0xe9, 0x7f} \
 }
 
 /******************************************************************************
+ * netwerk/protocol/wyciwyg/ classes
+ */
+
+#define NS_WYCIWYGPROTOCOLHANDLER_CID                \
+{ /* {0xe7509b46-2eB2-410a-9d7c-c3ce73284d01} */     \
+  0xe7509b46,                                        \
+  0x2eb2,                                            \
+  0x410a,                                            \
+  {0x9d, 0x7c, 0xc3, 0xce, 0x73, 0x28, 0x4d, 0x01}   \
+}
+
+/******************************************************************************
  * netwerk/protocol/about/ classes
  */
 
 #define NS_ABOUTPROTOCOLHANDLER_CLASSNAME \
     "About Protocol Handler"
 #define NS_ABOUTPROTOCOLHANDLER_CID                  \
 { /* 9e3b6c90-2f75-11d3-8cd0-0060b0fc14a3 */         \
     0x9e3b6c90,                                      \
--- a/netwerk/build/nsNetModule.cpp
+++ b/netwerk/build/nsNetModule.cpp
@@ -264,16 +264,21 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceP
 #include "nsViewSourceHandler.h"
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsViewSourceHandler)
 #endif
 
 #ifdef NECKO_PROTOCOL_data
 #include "nsDataHandler.h"
 #endif
 
+#ifdef NECKO_PROTOCOL_wyciwyg
+#include "nsWyciwygProtocolHandler.h"
+NS_GENERIC_FACTORY_CONSTRUCTOR(nsWyciwygProtocolHandler)
+#endif
+
 ///////////////////////////////////////////////////////////////////////////////
 
 #include "nsURIChecker.h"
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsURIChecker)
 
 ///////////////////////////////////////////////////////////////////////////////
 
 #include "nsURLParsers.h"
@@ -716,16 +721,19 @@ NS_DEFINE_NAMED_CID(NS_WIFI_MONITOR_COMP
 NS_DEFINE_NAMED_CID(NS_DATAPROTOCOLHANDLER_CID);
 #endif
 #ifdef NECKO_PROTOCOL_device
 NS_DEFINE_NAMED_CID(NS_DEVICEPROTOCOLHANDLER_CID);
 #endif
 #ifdef NECKO_PROTOCOL_viewsource
 NS_DEFINE_NAMED_CID(NS_VIEWSOURCEHANDLER_CID);
 #endif
+#ifdef NECKO_PROTOCOL_wyciwyg
+NS_DEFINE_NAMED_CID(NS_WYCIWYGPROTOCOLHANDLER_CID);
+#endif
 #if defined(XP_WIN)
 NS_DEFINE_NAMED_CID(NS_NETWORK_LINK_SERVICE_CID);
 #elif defined(MOZ_WIDGET_COCOA)
 NS_DEFINE_NAMED_CID(NS_NETWORK_LINK_SERVICE_CID);
 #elif defined(MOZ_ENABLE_LIBCONIC)
 NS_DEFINE_NAMED_CID(NS_NETWORK_LINK_SERVICE_CID);
 #elif defined(MOZ_ENABLE_QTNETWORK)
 NS_DEFINE_NAMED_CID(NS_NETWORK_LINK_SERVICE_CID);
@@ -837,16 +845,19 @@ static const mozilla::Module::CIDEntry k
     { &kNS_DATAPROTOCOLHANDLER_CID, false, NULL, nsDataHandler::Create },
 #endif
 #ifdef NECKO_PROTOCOL_device
     { &kNS_DEVICEPROTOCOLHANDLER_CID, false, NULL, nsDeviceProtocolHandlerConstructor},
 #endif
 #ifdef NECKO_PROTOCOL_viewsource
     { &kNS_VIEWSOURCEHANDLER_CID, false, NULL, nsViewSourceHandlerConstructor },
 #endif
+#ifdef NECKO_PROTOCOL_wyciwyg
+    { &kNS_WYCIWYGPROTOCOLHANDLER_CID, false, NULL, nsWyciwygProtocolHandlerConstructor },
+#endif
 #if defined(XP_WIN)
     { &kNS_NETWORK_LINK_SERVICE_CID, false, NULL, nsNotifyAddrListenerConstructor },
 #elif defined(MOZ_WIDGET_COCOA)
     { &kNS_NETWORK_LINK_SERVICE_CID, false, NULL, nsNetworkLinkServiceConstructor },
 #elif defined(MOZ_ENABLE_LIBCONIC)
     { &kNS_NETWORK_LINK_SERVICE_CID, false, NULL, nsMaemoNetworkLinkServiceConstructor },
 #elif defined(MOZ_ENABLE_QTNETWORK)
     { &kNS_NETWORK_LINK_SERVICE_CID, false, NULL, nsQtNetworkLinkServiceConstructor },
@@ -965,16 +976,19 @@ static const mozilla::Module::ContractID
     { NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "data", &kNS_DATAPROTOCOLHANDLER_CID },
 #endif
 #ifdef NECKO_PROTOCOL_device
     { NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "moz-device", &kNS_DEVICEPROTOCOLHANDLER_CID },
 #endif
 #ifdef NECKO_PROTOCOL_viewsource
     { NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "view-source", &kNS_VIEWSOURCEHANDLER_CID },
 #endif
+#ifdef NECKO_PROTOCOL_wyciwyg
+    { NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "wyciwyg", &kNS_WYCIWYGPROTOCOLHANDLER_CID },
+#endif
 #if defined(XP_WIN)
     { NS_NETWORK_LINK_SERVICE_CONTRACTID, &kNS_NETWORK_LINK_SERVICE_CID },
 #elif defined(MOZ_WIDGET_COCOA)
     { NS_NETWORK_LINK_SERVICE_CONTRACTID, &kNS_NETWORK_LINK_SERVICE_CID },
 #elif defined(MOZ_ENABLE_LIBCONIC)
     { NS_NETWORK_LINK_SERVICE_CONTRACTID, &kNS_NETWORK_LINK_SERVICE_CID },
 #elif defined(MOZ_ENABLE_QTNETWORK)
     { NS_NETWORK_LINK_SERVICE_CONTRACTID, &kNS_NETWORK_LINK_SERVICE_CID },
--- a/netwerk/ipc/NeckoChild.cpp
+++ b/netwerk/ipc/NeckoChild.cpp
@@ -39,16 +39,17 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsHttp.h"
 #include "mozilla/net/NeckoChild.h"
 #include "mozilla/dom/ContentChild.h"
 #include "mozilla/net/HttpChannelChild.h"
 #include "mozilla/net/CookieServiceChild.h"
+#include "mozilla/net/WyciwygChannelChild.h"
 
 namespace mozilla {
 namespace net {
 
 PNeckoChild *gNeckoChild = nsnull;
 
 // C++ file contents
 NeckoChild::NeckoChild()
@@ -124,10 +125,28 @@ NeckoChild::DeallocPCookieService(PCooki
 {
   NS_ASSERTION(IsNeckoChild(), "DeallocPCookieService called by non-child!");
 
   CookieServiceChild *p = static_cast<CookieServiceChild*>(cs);
   p->Release();
   return true;
 }
 
+PWyciwygChannelChild*
+NeckoChild::AllocPWyciwygChannel()
+{
+  WyciwygChannelChild *p = new WyciwygChannelChild();
+  p->AddIPDLReference();
+  return p;
+}
+
+bool
+NeckoChild::DeallocPWyciwygChannel(PWyciwygChannelChild* channel)
+{
+  NS_ABORT_IF_FALSE(IsNeckoChild(), "DeallocPWyciwygChannel called by non-child!");
+
+  WyciwygChannelChild *p = static_cast<WyciwygChannelChild*>(channel);
+  p->ReleaseIPDLReference();
+  return true;
+}
+
 }} // mozilla::net
 
--- a/netwerk/ipc/NeckoChild.h
+++ b/netwerk/ipc/NeckoChild.h
@@ -58,16 +58,18 @@ public:
   static void InitNeckoChild();
   static void DestroyNeckoChild();
 
 protected:
   virtual PHttpChannelChild* AllocPHttpChannel(PBrowserChild* iframeEmbedding);
   virtual bool DeallocPHttpChannel(PHttpChannelChild*);
   virtual PCookieServiceChild* AllocPCookieService();
   virtual bool DeallocPCookieService(PCookieServiceChild*);
+  virtual PWyciwygChannelChild* AllocPWyciwygChannel();
+  virtual bool DeallocPWyciwygChannel(PWyciwygChannelChild*);
 };
 
 /**
  * Reference to the PNecko Child protocol.
  * Null if this is not a content process.
  */
 extern PNeckoChild *gNeckoChild;
 
--- a/netwerk/ipc/NeckoParent.cpp
+++ b/netwerk/ipc/NeckoParent.cpp
@@ -37,16 +37,17 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsHttp.h"
 #include "mozilla/net/NeckoParent.h"
 #include "mozilla/net/HttpChannelParent.h"
 #include "mozilla/net/CookieServiceParent.h"
+#include "mozilla/net/WyciwygChannelParent.h"
 
 #include "nsHTMLDNSPrefetch.h"
 
 namespace mozilla {
 namespace net {
 
 // C++ file contents
 NeckoParent::NeckoParent()
@@ -81,16 +82,32 @@ NeckoParent::AllocPCookieService()
 
 bool 
 NeckoParent::DeallocPCookieService(PCookieServiceParent* cs)
 {
   delete cs;
   return true;
 }
 
+PWyciwygChannelParent*
+NeckoParent::AllocPWyciwygChannel()
+{
+  WyciwygChannelParent *p = new WyciwygChannelParent();
+  p->AddRef();
+  return p;
+}
+
+bool
+NeckoParent::DeallocPWyciwygChannel(PWyciwygChannelParent* channel)
+{
+  WyciwygChannelParent *p = static_cast<WyciwygChannelParent *>(channel);
+  p->Release();
+  return true;
+}
+
 bool
 NeckoParent::RecvHTMLDNSPrefetch(const nsString& hostname,
                                  const PRUint16& flags)
 {
   nsAutoString h(hostname);
   nsHTMLDNSPrefetch::Prefetch(h, flags);
   return true;
 }
--- a/netwerk/ipc/NeckoParent.h
+++ b/netwerk/ipc/NeckoParent.h
@@ -55,16 +55,18 @@ public:
   NeckoParent();
   virtual ~NeckoParent();
 
 protected:
   virtual PHttpChannelParent* AllocPHttpChannel(PBrowserParent* browser);
   virtual bool DeallocPHttpChannel(PHttpChannelParent*);
   virtual PCookieServiceParent* AllocPCookieService();
   virtual bool DeallocPCookieService(PCookieServiceParent*);
+  virtual PWyciwygChannelParent* AllocPWyciwygChannel();
+  virtual bool DeallocPWyciwygChannel(PWyciwygChannelParent*);
   virtual bool RecvHTMLDNSPrefetch(const nsString& hostname,
                                    const PRUint16& flags);
 };
 
 } // namespace net
 } // namespace mozilla
 
 #endif // mozilla_net_NeckoParent_h
--- a/netwerk/ipc/PNecko.ipdl
+++ b/netwerk/ipc/PNecko.ipdl
@@ -37,32 +37,35 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 include protocol PContent;
 include protocol PHttpChannel;
 include protocol PCookieService;
 include protocol PBrowser;
+include protocol PWyciwygChannel;
 
 namespace mozilla {
 namespace net {
 
 
 //-------------------------------------------------------------------
 sync protocol PNecko
 {
   manager PContent;
   manages PHttpChannel;
   manages PCookieService;
+  manages PWyciwygChannel;
 
 parent:
   __delete__();
 
   PCookieService();
+  PWyciwygChannel();
 
   HTMLDNSPrefetch(nsString hostname, PRUint16 flags);
 
 both:
   PHttpChannel(nullable PBrowser browser);
 };
 
 
--- a/netwerk/necko-config.h.in
+++ b/netwerk/necko-config.h.in
@@ -46,10 +46,11 @@
 #undef NECKO_PROTOCOL_about
 #undef NECKO_PROTOCOL_data
 #undef NECKO_PROTOCOL_device
 #undef NECKO_PROTOCOL_file
 #undef NECKO_PROTOCOL_ftp
 #undef NECKO_PROTOCOL_http
 #undef NECKO_PROTOCOL_res
 #undef NECKO_PROTOCOL_viewsource
+#undef NECKO_PROTOCOL_wyciwyg
 
 #endif
--- a/netwerk/protocol/Makefile.in
+++ b/netwerk/protocol/Makefile.in
@@ -46,13 +46,14 @@ PARALLEL_DIRS = \
   about \
   data \
   device \
   file \
   ftp \
   http \
   res \
   viewsource \
+  wyciwyg \
   $(NULL)
 
 include $(topsrcdir)/config/rules.mk
 
 DEFINES += -DIMPL_NS_NET
--- a/netwerk/protocol/about/Makefile.in
+++ b/netwerk/protocol/about/Makefile.in
@@ -61,11 +61,13 @@ CPPSRCS = \
   nsAboutCache.cpp \
   nsAboutCacheEntry.cpp \
   $(NULL)
 
 LOCAL_INCLUDES = \
   -I$(srcdir)/../../base/src \
   $(NULL)
 
+include $(topsrcdir)/config/config.mk
+include $(topsrcdir)/ipc/chromium/chromium-config.mk
 include $(topsrcdir)/config/rules.mk
 
 DEFINES += -DIMPL_NS_NET
--- a/netwerk/protocol/about/nsAboutProtocolHandler.cpp
+++ b/netwerk/protocol/about/nsAboutProtocolHandler.cpp
@@ -31,16 +31,21 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
+#ifdef MOZ_IPC
+#include "IPCMessageUtils.h"
+#include "mozilla/net/NeckoMessageUtils.h"
+#endif
+
 #include "nsAboutProtocolHandler.h"
 #include "nsIURI.h"
 #include "nsIIOService.h"
 #include "nsCRT.h"
 #include "nsIComponentManager.h"
 #include "nsIServiceManager.h"
 #include "nsIAboutModule.h"
 #include "nsString.h"
@@ -317,16 +322,46 @@ nsNestedAboutURI::Write(nsIObjectOutputS
         rv = aStream->WriteCompoundObject(mBaseURI, NS_GET_IID(nsISupports),
                                           PR_TRUE);
         if (NS_FAILED(rv)) return rv;
     }
 
     return NS_OK;
 }
 
+// nsIIPCSerializable
+PRBool
+nsNestedAboutURI::Read(const IPC::Message *aMsg, void **aIter)
+{
+#ifdef MOZ_IPC
+    if (!nsSimpleNestedURI::Read(aMsg, aIter))
+        return PR_FALSE;
+
+    IPC::URI uri;
+    if (!ReadParam(aMsg, aIter, &uri))
+        return PR_FALSE;
+
+    mBaseURI = uri;
+
+    return PR_TRUE;
+#endif
+    return PR_FALSE;
+}
+
+void
+nsNestedAboutURI::Write(IPC::Message *aMsg)
+{
+#ifdef MOZ_IPC
+    nsSimpleNestedURI::Write(aMsg);
+
+    IPC::URI uri(mBaseURI);
+    WriteParam(aMsg, uri);
+#endif
+}
+
 // nsSimpleURI
 /* virtual */ nsSimpleURI*
 nsNestedAboutURI::StartClone()
 {
     // Sadly, we can't make use of nsSimpleNestedURI::StartClone here.
     NS_ENSURE_TRUE(mInnerURI, nsnull);
 
     nsCOMPtr<nsIURI> innerClone;
--- a/netwerk/protocol/about/nsAboutProtocolHandler.h
+++ b/netwerk/protocol/about/nsAboutProtocolHandler.h
@@ -71,16 +71,18 @@ public:
 private:
     ~nsSafeAboutProtocolHandler() {}
 };
 
 
 // Class to allow us to propagate the base URI to about:blank correctly
 class nsNestedAboutURI : public nsSimpleNestedURI {
 public:
+    NS_DECL_NSIIPCSERIALIZABLE
+
     nsNestedAboutURI(nsIURI* aInnerURI, nsIURI* aBaseURI)
         : nsSimpleNestedURI(aInnerURI)
         , mBaseURI(aBaseURI)
     {}
 
     // For use only from deserialization
     nsNestedAboutURI() : nsSimpleNestedURI() {}
 
new file mode 100644
--- /dev/null
+++ b/netwerk/protocol/wyciwyg/Makefile.in
@@ -0,0 +1,85 @@
+# ***** BEGIN LICENSE BLOCK *****
+# Version: MPL 1.1/GPL 2.0/LGPL 2.1
+#
+# The contents of this file are subject to the Mozilla Public License Version
+# 1.1 (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+# http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+# for the specific language governing rights and limitations under the
+# License.
+#
+# The Original Code is mozilla.org build system.
+#
+# The Initial Developer of the Original Code is Mozilla Foundation
+# Portions created by the Initial Developer are Copyright (C) 2010
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+#   Michal Novotny <michal.novotny@gmail.com>
+#
+# Alternatively, the contents of this file may be used under the terms of
+# either the GNU General Public License Version 2 or later (the "GPL"), or
+# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+# in which case the provisions of the GPL or the LGPL are applicable instead
+# of those above. If you wish to allow use of your version of this file only
+# under the terms of either the GPL or the LGPL, and not to allow others to
+# use your version of this file under the terms of the MPL, indicate your
+# decision by deleting the provisions above and replace them with the notice
+# and other provisions required by the GPL or the LGPL. If you do not delete
+# the provisions above, a recipient may use your version of this file under
+# the terms of any one of the MPL, the GPL or the LGPL.
+#
+# ***** END LICENSE BLOCK *****
+
+DEPTH		= ../../..
+topsrcdir	= @top_srcdir@
+srcdir		= @srcdir@
+VPATH		= @srcdir@
+
+include $(DEPTH)/config/autoconf.mk
+
+MODULE		= necko
+LIBRARY_NAME	= nkwyciwyg_s
+LIBXUL_LIBRARY	= 1
+XPIDL_MODULE	= necko_wyciwyg
+GRE_MODULE	= 1
+FORCE_STATIC_LIB = 1
+
+EXPORTS_NAMESPACES = mozilla/net
+
+XPIDLSRCS	= \
+		nsIWyciwygChannel.idl \
+		$(NULL)
+
+ifdef MOZ_IPC
+EXPORTS_mozilla/net += \
+  WyciwygChannelParent.h \
+  WyciwygChannelChild.h  \
+  $(NULL)
+endif
+
+CPPSRCS		= \
+		nsWyciwyg.cpp \
+		nsWyciwygChannel.cpp \
+		nsWyciwygProtocolHandler.cpp \
+		$(NULL)
+
+ifdef MOZ_IPC
+CPPSRCS += \
+  WyciwygChannelParent.cpp \
+  WyciwygChannelChild.cpp \
+  $(NULL)
+endif
+
+LOCAL_INCLUDES = \
+  -I$(srcdir)/../../base/src \
+  $(NULL)
+
+include $(topsrcdir)/config/config.mk
+include $(topsrcdir)/ipc/chromium/chromium-config.mk
+include $(topsrcdir)/config/rules.mk
+
+DEFINES += -DIMPL_NS_NET
new file mode 100644
--- /dev/null
+++ b/netwerk/protocol/wyciwyg/PWyciwygChannel.ipdl
@@ -0,0 +1,80 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is
+ *  The Mozilla Foundation
+ * Portions created by the Initial Developer are Copyright (C) 2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *   Michal Novotny <michal.novotny@gmail.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+include protocol PNecko;
+
+include "mozilla/net/NeckoMessageUtils.h";
+
+using IPC::URI;
+
+namespace mozilla {
+namespace net {
+
+//-------------------------------------------------------------------
+protocol PWyciwygChannel
+{
+  manager PNecko;
+
+parent:
+  __delete__();
+
+  Init(URI uri);
+  AsyncOpen(URI      originalURI,
+            PRUint32 loadFlags);
+
+  // methods corresponding to those of nsIWyciwygChannel
+  WriteToCacheEntry(nsString data);
+  CloseCacheEntry(nsresult reason);
+  SetCharsetAndSource(PRInt32 source, nsCString charset);
+  SetSecurityInfo(nsCString securityInfo);
+
+child:
+  OnStartRequest(nsresult  statusCode,
+                 PRInt32   contentLength,
+                 PRInt32   source,
+                 nsCString charset,
+                 nsCString securityInfo);
+
+  OnDataAvailable(nsCString data,
+                  PRUint32  offset);
+
+  OnStopRequest(nsresult statusCode);
+};
+
+
+} // namespace net
+} // namespace mozilla
new file mode 100644
--- /dev/null
+++ b/netwerk/protocol/wyciwyg/WyciwygChannelChild.cpp
@@ -0,0 +1,526 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is
+ *  The Mozilla Foundation
+ * Portions created by the Initial Developer are Copyright (C) 2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *   Michal Novotny <michal.novotny@gmail.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#include "nsWyciwyg.h"
+
+#include "mozilla/net/NeckoChild.h"
+#include "WyciwygChannelChild.h"
+
+#include "nsIParser.h"
+#include "nsStringStream.h"
+#include "nsMimeTypes.h"
+#include "nsNetUtil.h"
+#include "nsISerializable.h"
+#include "nsSerializationHelper.h"
+
+namespace mozilla {
+namespace net {
+
+NS_IMPL_ISUPPORTS3(WyciwygChannelChild,
+                   nsIRequest,
+                   nsIChannel,
+                   nsIWyciwygChannel);
+
+
+WyciwygChannelChild::WyciwygChannelChild()
+  : mStatus(NS_OK)
+  , mIsPending(PR_FALSE)
+  , mLoadFlags(LOAD_NORMAL)
+  , mContentLength(-1)
+  , mCharsetSource(kCharsetUninitialized)
+  , mState(WCC_NEW)
+  , mIPCOpen(false)
+{
+  LOG(("Creating WyciwygChannelChild @%x\n", this));
+}
+
+WyciwygChannelChild::~WyciwygChannelChild()
+{
+  LOG(("Destroying WyciwygChannelChild @%x\n", this));
+}
+
+void
+WyciwygChannelChild::AddIPDLReference()
+{
+  NS_ABORT_IF_FALSE(!mIPCOpen, "Attempt to retain more than one IPDL reference");
+  mIPCOpen = true;
+  AddRef();
+}
+
+void
+WyciwygChannelChild::ReleaseIPDLReference()
+{
+  NS_ABORT_IF_FALSE(mIPCOpen, "Attempt to release nonexistent IPDL reference");
+  mIPCOpen = false;
+  Release();
+}
+
+nsresult
+WyciwygChannelChild::Init(nsIURI* uri)
+{
+  NS_ENSURE_ARG_POINTER(uri);
+
+  mState = WCC_INIT;
+
+  mURI = uri;
+  mOriginalURI = uri;
+
+  SendInit(IPC::URI(mURI));
+  return NS_OK;
+}
+
+//-----------------------------------------------------------------------------
+// WyciwygChannelChild::PWyciwygChannelChild
+//-----------------------------------------------------------------------------
+
+bool
+WyciwygChannelChild::RecvOnStartRequest(const nsresult& statusCode,
+                                        const PRInt32& contentLength,
+                                        const PRInt32& source,
+                                        const nsCString& charset,
+                                        const nsCString& securityInfo)
+{
+  LOG(("WyciwygChannelChild::RecvOnStartRequest [this=%x]\n", this));
+
+  mState = WCC_ONSTART;
+
+  mStatus = statusCode;
+  mContentLength = contentLength;
+  mCharsetSource = source;
+  mCharset = charset;
+
+  if (!securityInfo.IsEmpty()) {
+    NS_DeserializeObject(securityInfo, getter_AddRefs(mSecurityInfo));
+  }
+
+  nsresult rv = mListener->OnStartRequest(this, mListenerContext);
+  if (NS_FAILED(rv)) {
+    // TODO: Cancel request:
+    //  - Send Cancel msg to parent
+    //  - drop any in flight OnDataAvail msgs we receive
+    //  - make sure we do call OnStopRequest eventually
+    //  - return true here, not false
+    return false;
+  }
+  return true;
+}
+
+bool
+WyciwygChannelChild::RecvOnDataAvailable(const nsCString& data,
+                                         const PRUint32& offset)
+{
+  LOG(("WyciwygChannelChild::RecvOnDataAvailable [this=%x]\n", this));
+
+  mState = WCC_ONDATA;
+
+  // NOTE: the OnDataAvailable contract requires the client to read all the data
+  // in the inputstream.  This code relies on that ('data' will go away after
+  // this function).  Apparently the previous, non-e10s behavior was to actually
+  // support only reading part of the data, allowing later calls to read the
+  // rest.
+  nsCOMPtr<nsIInputStream> stringStream;
+  nsresult rv = NS_NewByteInputStream(getter_AddRefs(stringStream),
+                                      data.get(),
+                                      data.Length(),
+                                      NS_ASSIGNMENT_DEPEND);
+  if (NS_FAILED(rv)) {
+    // TODO:  what to do here?  Cancel request?  Very unlikely to fail.
+    return false;
+  }
+  rv = mListener->OnDataAvailable(this, mListenerContext,
+                                  stringStream, offset, data.Length());
+  if (NS_FAILED(rv)) {
+    // TODO: Cancel request: see notes in OnStartRequest
+    return false;
+  }
+
+  if (mProgressSink && NS_SUCCEEDED(rv) && !(mLoadFlags & LOAD_BACKGROUND))
+    mProgressSink->OnProgress(this, nsnull, PRUint64(offset + data.Length()),
+                              PRUint64(mContentLength));
+
+  return true;
+}
+
+bool
+WyciwygChannelChild::RecvOnStopRequest(const nsresult& statusCode)
+{
+  LOG(("WyciwygChannelChild::RecvOnStopRequest [this=%x status=%u]\n",
+           this, statusCode));
+
+  mState = WCC_ONSTOP;
+
+  mIsPending = PR_FALSE;
+  mStatus = statusCode;
+
+  mListener->OnStopRequest(this, mListenerContext, statusCode);
+
+  mListener = 0;
+  mListenerContext = 0;
+
+  if (mLoadGroup)
+    mLoadGroup->RemoveRequest(this, nsnull, mStatus);
+
+  mCallbacks = 0;
+  mProgressSink = 0;
+
+  if (mIPCOpen)
+    PWyciwygChannelChild::Send__delete__(this);
+
+  return true;
+}
+
+
+//-----------------------------------------------------------------------------
+// nsIRequest
+//-----------------------------------------------------------------------------
+
+/* readonly attribute AUTF8String name; */
+NS_IMETHODIMP
+WyciwygChannelChild::GetName(nsACString & aName)
+{
+  return mURI->GetSpec(aName);
+}
+
+/* boolean isPending (); */
+NS_IMETHODIMP
+WyciwygChannelChild::IsPending(PRBool *aIsPending)
+{
+  *aIsPending = mIsPending;
+  return NS_OK;
+}
+
+/* readonly attribute nsresult status; */
+NS_IMETHODIMP
+WyciwygChannelChild::GetStatus(nsresult *aStatus)
+{
+  *aStatus = mStatus;
+  return NS_OK;
+}
+
+/* void cancel (in nsresult aStatus); */
+NS_IMETHODIMP
+WyciwygChannelChild::Cancel(nsresult aStatus)
+{
+  return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* void suspend (); */
+NS_IMETHODIMP
+WyciwygChannelChild::Suspend()
+{
+  return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* void resume (); */
+NS_IMETHODIMP
+WyciwygChannelChild::Resume()
+{
+  return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* attribute nsILoadGroup loadGroup; */
+NS_IMETHODIMP
+WyciwygChannelChild::GetLoadGroup(nsILoadGroup * *aLoadGroup)
+{
+  *aLoadGroup = mLoadGroup;
+  NS_IF_ADDREF(*aLoadGroup);
+  return NS_OK;
+}
+NS_IMETHODIMP
+WyciwygChannelChild::SetLoadGroup(nsILoadGroup * aLoadGroup)
+{
+  mLoadGroup = aLoadGroup;
+  NS_QueryNotificationCallbacks(mCallbacks,
+                                mLoadGroup,
+                                NS_GET_IID(nsIProgressEventSink),
+                                getter_AddRefs(mProgressSink));
+  return NS_OK;
+}
+
+/* attribute nsLoadFlags loadFlags; */
+NS_IMETHODIMP
+WyciwygChannelChild::GetLoadFlags(nsLoadFlags *aLoadFlags)
+{
+  *aLoadFlags = mLoadFlags;
+  return NS_OK;
+}
+NS_IMETHODIMP
+WyciwygChannelChild::SetLoadFlags(nsLoadFlags aLoadFlags)
+{
+  mLoadFlags = aLoadFlags;
+  return NS_OK;
+}
+
+
+//-----------------------------------------------------------------------------
+// nsIChannel
+//-----------------------------------------------------------------------------
+
+/* attribute nsIURI originalURI; */
+NS_IMETHODIMP
+WyciwygChannelChild::GetOriginalURI(nsIURI * *aOriginalURI)
+{
+  *aOriginalURI = mOriginalURI;
+  NS_ADDREF(*aOriginalURI);
+  return NS_OK;
+}
+NS_IMETHODIMP
+WyciwygChannelChild::SetOriginalURI(nsIURI * aOriginalURI)
+{
+  NS_ENSURE_TRUE(mState == WCC_INIT, NS_ERROR_UNEXPECTED);
+
+  NS_ENSURE_ARG_POINTER(aOriginalURI);
+  mOriginalURI = aOriginalURI;
+  return NS_OK;
+}
+
+/* readonly attribute nsIURI URI; */
+NS_IMETHODIMP
+WyciwygChannelChild::GetURI(nsIURI * *aURI)
+{
+  *aURI = mURI;
+  NS_IF_ADDREF(*aURI);
+  return NS_OK;
+}
+
+/* attribute nsISupports owner; */
+NS_IMETHODIMP
+WyciwygChannelChild::GetOwner(nsISupports * *aOwner)
+{
+  NS_PRECONDITION(mOwner, "Must have a principal!");
+  NS_ENSURE_STATE(mOwner);
+
+  NS_ADDREF(*aOwner = mOwner);
+  return NS_OK;
+}
+NS_IMETHODIMP
+WyciwygChannelChild::SetOwner(nsISupports * aOwner)
+{
+  mOwner = aOwner;
+  return NS_OK;
+}
+
+/* attribute nsIInterfaceRequestor notificationCallbacks; */
+NS_IMETHODIMP
+WyciwygChannelChild::GetNotificationCallbacks(nsIInterfaceRequestor * *aCallbacks)
+{
+  *aCallbacks = mCallbacks;
+  NS_IF_ADDREF(*aCallbacks);
+  return NS_OK;
+}
+NS_IMETHODIMP
+WyciwygChannelChild::SetNotificationCallbacks(nsIInterfaceRequestor * aCallbacks)
+{
+  mCallbacks = aCallbacks;
+  NS_QueryNotificationCallbacks(mCallbacks,
+                                mLoadGroup,
+                                NS_GET_IID(nsIProgressEventSink),
+                                getter_AddRefs(mProgressSink));
+  return NS_OK;
+}
+
+/* readonly attribute nsISupports securityInfo; */
+NS_IMETHODIMP
+WyciwygChannelChild::GetSecurityInfo(nsISupports * *aSecurityInfo)
+{
+  NS_IF_ADDREF(*aSecurityInfo = mSecurityInfo);
+
+  return NS_OK;
+}
+
+/* attribute ACString contentType; */
+NS_IMETHODIMP
+WyciwygChannelChild::GetContentType(nsACString & aContentType)
+{
+  aContentType.AssignLiteral(WYCIWYG_TYPE);
+  return NS_OK;
+}
+NS_IMETHODIMP
+WyciwygChannelChild::SetContentType(const nsACString & aContentType)
+{
+  return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* attribute ACString contentCharset; */
+NS_IMETHODIMP
+WyciwygChannelChild::GetContentCharset(nsACString & aContentCharset)
+{
+  aContentCharset.Assign("UTF-16");
+  return NS_OK;
+}
+NS_IMETHODIMP
+WyciwygChannelChild::SetContentCharset(const nsACString & aContentCharset)
+{
+  return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* attribute long contentLength; */
+NS_IMETHODIMP
+WyciwygChannelChild::GetContentLength(PRInt32 *aContentLength)
+{
+  return NS_ERROR_NOT_IMPLEMENTED;
+}
+NS_IMETHODIMP
+WyciwygChannelChild::SetContentLength(PRInt32 aContentLength)
+{
+  return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* nsIInputStream open (); */
+NS_IMETHODIMP
+WyciwygChannelChild::Open(nsIInputStream **_retval)
+{
+  return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* void asyncOpen (in nsIStreamListener aListener, in nsISupports aContext); */
+NS_IMETHODIMP
+WyciwygChannelChild::AsyncOpen(nsIStreamListener *aListener, nsISupports *aContext)
+{
+  LOG(("WyciwygChannelChild::AsyncOpen [this=%x]\n", this));
+
+  // The only places creating wyciwyg: channels should be
+  // HTMLDocument::OpenCommon and session history.  Both should be setting an
+  // owner.
+  NS_PRECONDITION(mOwner, "Must have a principal");
+  NS_ENSURE_STATE(mOwner);
+
+  NS_ENSURE_ARG_POINTER(aListener);
+  NS_ENSURE_TRUE(!mIsPending, NS_ERROR_IN_PROGRESS);
+
+  mListener = aListener;
+  mListenerContext = aContext;
+  mIsPending = PR_TRUE;
+
+  if (mLoadGroup)
+    mLoadGroup->AddRequest(this, nsnull);
+
+  SendAsyncOpen(IPC::URI(mOriginalURI), mLoadFlags);
+
+  mState = WCC_OPENED;
+
+  return NS_OK;
+}
+
+
+//-----------------------------------------------------------------------------
+// nsIWyciwygChannel
+//-----------------------------------------------------------------------------
+
+/* void writeToCacheEntry (in AString aData); */
+NS_IMETHODIMP
+WyciwygChannelChild::WriteToCacheEntry(const nsAString & aData)
+{
+  NS_ENSURE_TRUE((mState == WCC_INIT) ||
+                 (mState == WCC_ONWRITE), NS_ERROR_UNEXPECTED);
+
+  SendWriteToCacheEntry(PromiseFlatString(aData));
+  mState = WCC_ONWRITE;
+  return NS_OK;
+}
+
+/* void closeCacheEntry (in nsresult reason); */
+NS_IMETHODIMP
+WyciwygChannelChild::CloseCacheEntry(nsresult reason)
+{
+  NS_ENSURE_TRUE(mState == WCC_ONWRITE, NS_ERROR_UNEXPECTED);
+
+  SendCloseCacheEntry(reason);
+  mState = WCC_ONCLOSED;
+
+  if (mIPCOpen)
+    PWyciwygChannelChild::Send__delete__(this);
+
+  return NS_OK;
+}
+
+/* void setSecurityInfo (in nsISupports aSecurityInfo); */
+NS_IMETHODIMP
+WyciwygChannelChild::SetSecurityInfo(nsISupports *aSecurityInfo)
+{
+  mSecurityInfo = aSecurityInfo;
+
+  if (mSecurityInfo) {
+    nsCOMPtr<nsISerializable> serializable = do_QueryInterface(mSecurityInfo);
+    if (serializable) {
+      nsCString secInfoStr;
+      NS_SerializeToString(serializable, secInfoStr);
+      SendSetSecurityInfo(secInfoStr);
+    }
+    else {
+      NS_WARNING("Can't serialize security info");
+    }
+  }
+
+  return NS_OK;
+}
+
+/* void setCharsetAndSource (in long aSource, in ACString aCharset); */
+NS_IMETHODIMP
+WyciwygChannelChild::SetCharsetAndSource(PRInt32 aSource, const nsACString & aCharset)
+{
+  // mState == WCC_ONSTART when reading from the channel
+  // mState == WCC_INIT when writing to the cache
+  NS_ENSURE_TRUE((mState == WCC_ONSTART) ||
+                 (mState == WCC_INIT), NS_ERROR_UNEXPECTED);
+
+  mCharsetSource = aSource;
+  mCharset = aCharset;
+
+  // TODO ensure that nsWyciwygChannel in the parent has still the cache entry
+  SendSetCharsetAndSource(mCharsetSource, mCharset);
+  return NS_OK;
+}
+
+/* ACString getCharsetAndSource (out long aSource); */
+NS_IMETHODIMP
+WyciwygChannelChild::GetCharsetAndSource(PRInt32 *aSource NS_OUTPARAM, nsACString & _retval)
+{
+  NS_ENSURE_TRUE((mState == WCC_ONSTART) ||
+                 (mState == WCC_ONDATA) ||
+                 (mState == WCC_ONSTOP), NS_ERROR_NOT_AVAILABLE);
+
+  if (mCharsetSource == kCharsetUninitialized)
+    return NS_ERROR_NOT_AVAILABLE;
+
+  *aSource = mCharsetSource;
+  _retval = mCharset;
+  return NS_OK;
+}
+
+//------------------------------------------------------------------------------
+}} // mozilla::net
new file mode 100644
--- /dev/null
+++ b/netwerk/protocol/wyciwyg/WyciwygChannelChild.h
@@ -0,0 +1,120 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is
+ *  The Mozilla Foundation
+ * Portions created by the Initial Developer are Copyright (C) 2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *   Michal Novotny <michal.novotny@gmail.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef mozilla_net_WyciwygChannelChild_h
+#define mozilla_net_WyciwygChannelChild_h
+
+#include "mozilla/net/PWyciwygChannelChild.h"
+#include "nsIWyciwygChannel.h"
+#include "nsIChannel.h"
+#include "nsIProgressEventSink.h"
+
+namespace mozilla {
+namespace net {
+
+// TODO: replace with IPDL states
+enum WyciwygChannelChildState {
+  WCC_NEW,
+  WCC_INIT,
+
+  // States when reading from the channel
+  WCC_OPENED,
+  WCC_ONSTART,
+  WCC_ONDATA,
+  WCC_ONSTOP,
+
+  // States when writing to the cache
+  WCC_ONWRITE,
+  WCC_ONCLOSED
+};
+
+
+// Header file contents
+class WyciwygChannelChild : public PWyciwygChannelChild
+                          , public nsIWyciwygChannel
+{
+public:
+  NS_DECL_ISUPPORTS
+  NS_DECL_NSIREQUEST
+  NS_DECL_NSICHANNEL
+  NS_DECL_NSIWYCIWYGCHANNEL
+
+  WyciwygChannelChild();
+  virtual ~WyciwygChannelChild();
+
+  void AddIPDLReference();
+  void ReleaseIPDLReference();
+
+  nsresult Init(nsIURI *uri);
+
+protected:
+  bool RecvOnStartRequest(const nsresult& statusCode,
+                          const PRInt32& contentLength,
+                          const PRInt32& source,
+                          const nsCString& charset,
+                          const nsCString& securityInfo);
+  bool RecvOnDataAvailable(const nsCString& data,
+                           const PRUint32& offset);
+  bool RecvOnStopRequest(const nsresult& statusCode);
+
+private:
+  nsresult                          mStatus;
+  PRBool                            mIsPending;
+  PRUint32                          mLoadFlags;
+  PRInt32                           mContentLength;
+  PRInt32                           mCharsetSource;
+  nsCString                         mCharset;
+  nsCOMPtr<nsIURI>                  mURI;
+  nsCOMPtr<nsIURI>                  mOriginalURI;
+  nsCOMPtr<nsISupports>             mOwner;
+  nsCOMPtr<nsIInterfaceRequestor>   mCallbacks;
+  nsCOMPtr<nsIProgressEventSink>    mProgressSink;
+  nsCOMPtr<nsILoadGroup>            mLoadGroup;
+  nsCOMPtr<nsIStreamListener>       mListener;
+  nsCOMPtr<nsISupports>             mListenerContext;
+  nsCOMPtr<nsISupports>             mSecurityInfo;
+
+  // FIXME: replace with IPDL states (bug 536319)
+  enum WyciwygChannelChildState mState;
+
+  bool mIPCOpen;
+};
+
+} // namespace net
+} // namespace mozilla
+
+#endif // mozilla_net_WyciwygChannelChild_h
new file mode 100644
--- /dev/null
+++ b/netwerk/protocol/wyciwyg/WyciwygChannelParent.cpp
@@ -0,0 +1,249 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is
+ *  The Mozilla Foundation
+ * Portions created by the Initial Developer are Copyright (C) 2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *   Michal Novotny <michal.novotny@gmail.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#include "nsWyciwyg.h"
+
+#include "mozilla/net/WyciwygChannelParent.h"
+#include "nsWyciwygChannel.h"
+#include "nsNetUtil.h"
+#include "nsISupportsPriority.h"
+#include "nsIParser.h"
+#include "nsISerializable.h"
+#include "nsSerializationHelper.h"
+
+namespace mozilla {
+namespace net {
+
+WyciwygChannelParent::WyciwygChannelParent()
+ : mIPCClosed(false)
+{
+#if defined(PR_LOGGING)
+  if (!gWyciwygLog)
+    gWyciwygLog = PR_NewLogModule("nsWyciwygChannel");
+#endif
+}
+
+WyciwygChannelParent::~WyciwygChannelParent()
+{
+}
+
+void
+WyciwygChannelParent::ActorDestroy(ActorDestroyReason why)
+{
+  // We may still have refcount>0 if the channel hasn't called OnStopRequest
+  // yet, but we must not send any more msgs to child.
+  mIPCClosed = true;
+}
+
+//-----------------------------------------------------------------------------
+// WyciwygChannelParent::nsISupports
+//-----------------------------------------------------------------------------
+
+NS_IMPL_ISUPPORTS2(WyciwygChannelParent,
+                   nsIStreamListener,
+                   nsIRequestObserver);
+
+//-----------------------------------------------------------------------------
+// WyciwygChannelParent::PWyciwygChannelParent
+//-----------------------------------------------------------------------------
+
+bool
+WyciwygChannelParent::RecvInit(const IPC::URI& aURI)
+{
+  nsresult rv;
+
+  nsCOMPtr<nsIURI> uri(aURI);
+
+  nsCString uriSpec;
+  uri->GetSpec(uriSpec);
+  LOG(("WyciwygChannelParent RecvAsyncOpen [this=%x uri=%s]\n",
+       this, uriSpec.get()));
+
+  nsCOMPtr<nsIIOService> ios(do_GetIOService(&rv));
+  if (NS_FAILED(rv))
+    return false;       // TODO: send fail msg to child, return true
+
+  nsCOMPtr<nsIChannel> chan;
+  rv = NS_NewChannel(getter_AddRefs(chan), uri, ios);
+  if (NS_FAILED(rv))
+    return false;       // TODO: send fail msg to child, return true
+
+  mChannel = do_QueryInterface(chan, &rv);
+  if (NS_FAILED(rv))
+    return false;       // TODO: send fail msg to child, return true
+
+  return true;
+}
+
+bool
+WyciwygChannelParent::RecvAsyncOpen(const IPC::URI& aOriginal,
+                                    const PRUint32& aLoadFlags)
+{
+  nsCOMPtr<nsIURI> original(aOriginal);
+
+  nsresult rv;
+
+  rv = mChannel->SetOriginalURI(original);
+  if (NS_FAILED(rv))
+    return false;       // TODO: send fail msg to child, return true
+
+  rv = mChannel->SetLoadFlags(aLoadFlags);
+  if (NS_FAILED(rv))
+    return false;       // TODO: send fail msg to child, return true
+
+  rv = mChannel->AsyncOpen(this, nsnull);
+  if (NS_FAILED(rv))
+    return false;       // TODO: send fail msg to child, return true
+
+  return true;
+}
+
+bool
+WyciwygChannelParent::RecvWriteToCacheEntry(const nsString& data)
+{
+  mChannel->WriteToCacheEntry(data);
+  return true;
+}
+
+bool
+WyciwygChannelParent::RecvCloseCacheEntry(const nsresult& reason)
+{
+  mChannel->CloseCacheEntry(reason);
+  return true;
+}
+
+bool
+WyciwygChannelParent::RecvSetCharsetAndSource(const PRInt32& aCharsetSource,
+                                              const nsCString& aCharset)
+{
+  mChannel->SetCharsetAndSource(aCharsetSource, aCharset);
+  return true;
+}
+
+bool
+WyciwygChannelParent::RecvSetSecurityInfo(const nsCString& aSecurityInfo)
+{
+  nsCOMPtr<nsISupports> securityInfo;
+  NS_DeserializeObject(aSecurityInfo, getter_AddRefs(securityInfo));
+  mChannel->SetSecurityInfo(securityInfo);
+  return true;
+}
+
+//-----------------------------------------------------------------------------
+// WyciwygChannelParent::nsIRequestObserver
+//-----------------------------------------------------------------------------
+
+NS_IMETHODIMP
+WyciwygChannelParent::OnStartRequest(nsIRequest *aRequest, nsISupports *aContext)
+{
+  LOG(("WyciwygChannelParent::OnStartRequest [this=%x]\n", this));
+
+  nsresult rv;
+
+  nsCOMPtr<nsIWyciwygChannel> chan = do_QueryInterface(aRequest, &rv);
+  NS_ENSURE_SUCCESS(rv, rv);
+
+  nsresult status;
+  chan->GetStatus(&status);
+
+  PRInt32 contentLength = -1;
+  chan->GetContentLength(&contentLength);
+
+  PRInt32 charsetSource = kCharsetUninitialized;
+  nsCAutoString charset;
+  chan->GetCharsetAndSource(&charsetSource, charset);
+
+  nsCOMPtr<nsISupports> securityInfo;
+  chan->GetSecurityInfo(getter_AddRefs(securityInfo));
+  nsCString secInfoStr;
+  if (securityInfo) {
+    nsCOMPtr<nsISerializable> serializable = do_QueryInterface(securityInfo);
+    if (serializable)
+      NS_SerializeToString(serializable, secInfoStr);
+    else
+      NS_WARNING("Can't serialize security info");
+  }
+
+  if (mIPCClosed ||
+      !SendOnStartRequest(status, contentLength, charsetSource, charset, secInfoStr)) {
+    return NS_ERROR_UNEXPECTED;
+  }
+
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+WyciwygChannelParent::OnStopRequest(nsIRequest *aRequest,
+                                    nsISupports *aContext,
+                                    nsresult aStatusCode)
+{
+  LOG(("WyciwygChannelParent::OnStopRequest: [this=%x status=%ul]\n",
+       this, aStatusCode));
+
+  if (mIPCClosed || !SendOnStopRequest(aStatusCode)) {
+    return NS_ERROR_UNEXPECTED;
+  }
+
+  return NS_OK;
+}
+
+//-----------------------------------------------------------------------------
+// WyciwygChannelParent::nsIStreamListener
+//-----------------------------------------------------------------------------
+
+NS_IMETHODIMP
+WyciwygChannelParent::OnDataAvailable(nsIRequest *aRequest,
+                                      nsISupports *aContext,
+                                      nsIInputStream *aInputStream,
+                                      PRUint32 aOffset,
+                                      PRUint32 aCount)
+{
+  LOG(("WyciwygChannelParent::OnDataAvailable [this=%x]\n", this));
+
+  nsCString data;
+  nsresult rv = NS_ReadInputStreamToString(aInputStream, data, aCount);
+  if (NS_FAILED(rv))
+    return rv;
+
+  if (mIPCClosed || !SendOnDataAvailable(data, aOffset)) {
+    return NS_ERROR_UNEXPECTED;
+  }
+
+  return NS_OK;
+}
+
+}} // mozilla::net
new file mode 100644
--- /dev/null
+++ b/netwerk/protocol/wyciwyg/WyciwygChannelParent.h
@@ -0,0 +1,80 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is
+ *  The Mozilla Foundation
+ * Portions created by the Initial Developer are Copyright (C) 2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *   Michal Novotny <michal.novotny@gmail.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef mozilla_net_WyciwygChannelParent_h
+#define mozilla_net_WyciwygChannelParent_h
+
+#include "mozilla/net/PWyciwygChannelParent.h"
+#include "mozilla/net/NeckoCommon.h"
+#include "nsIStreamListener.h"
+
+#include "nsIWyciwygChannel.h"
+
+namespace mozilla {
+namespace net {
+
+class WyciwygChannelParent : public PWyciwygChannelParent
+                           , public nsIStreamListener
+{
+public:
+  NS_DECL_ISUPPORTS
+  NS_DECL_NSIREQUESTOBSERVER
+  NS_DECL_NSISTREAMLISTENER
+
+  WyciwygChannelParent();
+  virtual ~WyciwygChannelParent();
+
+protected:
+  virtual bool RecvInit(const IPC::URI& uri);
+  virtual bool RecvAsyncOpen(const IPC::URI& original,
+                             const PRUint32& loadFlags);
+  virtual bool RecvWriteToCacheEntry(const nsString& data);
+  virtual bool RecvCloseCacheEntry(const nsresult& reason);
+  virtual bool RecvSetCharsetAndSource(const PRInt32& source,
+                                       const nsCString& charset);
+  virtual bool RecvSetSecurityInfo(const nsCString& securityInfo);
+
+  virtual void ActorDestroy(ActorDestroyReason why);
+
+  nsCOMPtr<nsIWyciwygChannel> mChannel;
+  bool mIPCClosed;
+};
+
+} // namespace net
+} // namespace mozilla
+
+#endif // mozilla_net_WyciwygChannelParent_h
new file mode 100644
--- /dev/null
+++ b/netwerk/protocol/wyciwyg/ipdl.mk
@@ -0,0 +1,41 @@
+# ***** BEGIN LICENSE BLOCK *****
+# Version: MPL 1.1/GPL 2.0/LGPL 2.1
+#
+# The contents of this file are subject to the Mozilla Public License Version
+# 1.1 (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+# http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+# for the specific language governing rights and limitations under the
+# License.
+#
+# The Original Code is Mozilla Firefox.
+#
+# The Initial Developer of the Original Code is
+# The Mozilla Foundation <http://www.mozilla.org/>.
+# Portions created by the Initial Developer are Copyright (C) 2010
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+#   Michal Novotny <michal.novotny@gmail.com>
+#
+# Alternatively, the contents of this file may be used under the terms of
+# either the GNU General Public License Version 2 or later (the "GPL"), or
+# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+# in which case the provisions of the GPL or the LGPL are applicable instead
+# of those above. If you wish to allow use of your version of this file only
+# under the terms of either the GPL or the LGPL, and not to allow others to
+# use your version of this file under the terms of the MPL, indicate your
+# decision by deleting the provisions above and replace them with the notice
+# and other provisions required by the GPL or the LGPL. If you do not delete
+# the provisions above, a recipient may use your version of this file under
+# the terms of any one of the MPL, the GPL or the LGPL.
+#
+# ***** END LICENSE BLOCK *****
+
+IPDLSRCS =          \
+  PWyciwygChannel.ipdl \
+  $(NULL)
+
rename from content/html/document/public/nsIWyciwygChannel.idl
rename to netwerk/protocol/wyciwyg/nsIWyciwygChannel.idl
new file mode 100644
--- /dev/null
+++ b/netwerk/protocol/wyciwyg/nsWyciwyg.cpp
@@ -0,0 +1,43 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is
+ *  The Mozilla Foundation
+ * Portions created by the Initial Developer are Copyright (C) 2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *   Michal Novotny <michal.novotny@gmail.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#include "nsWyciwyg.h"
+
+#if defined(PR_LOGGING)
+PRLogModuleInfo *gWyciwygLog = nsnull;
+#endif
+
new file mode 100644
--- /dev/null
+++ b/netwerk/protocol/wyciwyg/nsWyciwyg.h
@@ -0,0 +1,97 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is
+ *  The Mozilla Foundation
+ * Portions created by the Initial Developer are Copyright (C) 2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *   Michal Novotny <michal.novotny@gmail.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef nsWyciwyg_h__
+#define nsWyciwyg_h__
+
+#if defined(MOZ_LOGGING)
+#define FORCE_PR_LOG
+#endif
+
+#ifdef MOZ_IPC
+// e10s mess: IPDL-generatd headers include chromium which both #includes
+// prlog.h, and #defines LOG in conflict with this file.
+// Solution: (as described in bug 545995)
+// 1) ensure that this file is #included before any IPDL-generated files and
+//    anything else that #includes prlog.h, so that we can make sure prlog.h
+//    sees FORCE_PR_LOG if needed.
+// 2) #include IPDL boilerplate, and then undef LOG so our LOG wins.
+// 3) nsNetModule.cpp does its own crazy stuff with #including prlog.h
+//    multiple times; allow it to define ALLOW_LATE_NSHTTP_H_INCLUDE to bypass
+//    check. 
+#if defined(PR_LOG) && !defined(ALLOW_LATE_NSHTTP_H_INCLUDE)
+#error "If nsWyciwyg.h #included it must come before any IPDL-generated files or other files that #include prlog.h"
+#endif
+#include "mozilla/net/NeckoChild.h"
+#undef LOG
+#endif // MOZ_IPC
+
+#include "plstr.h"
+#include "prlog.h"
+#include "prtime.h"
+
+#if defined(PR_LOGGING)
+//
+// Log module for HTTP Protocol logging...
+//
+// To enable logging (see prlog.h for full details):
+//
+//    set NSPR_LOG_MODULES=nsWyciwyg:5
+//    set NSPR_LOG_FILE=wyciwyg.log
+//
+// this enables PR_LOG_ALWAYS level information and places all output in
+// the file wyciwyg.log
+//
+extern PRLogModuleInfo *gWyciwygLog;
+#endif
+
+// http logging
+#define LOG1(args) PR_LOG(gWyciwygLog, 1, args)
+#define LOG2(args) PR_LOG(gWyciwygLog, 2, args)
+#define LOG3(args) PR_LOG(gWyciwygLog, 3, args)
+#define LOG4(args) PR_LOG(gWyciwygLog, 4, args)
+#define LOG(args) LOG4(args)
+
+#define LOG1_ENABLED() PR_LOG_TEST(gWyciwygLog, 1)
+#define LOG2_ENABLED() PR_LOG_TEST(gWyciwygLog, 2)
+#define LOG3_ENABLED() PR_LOG_TEST(gWyciwygLog, 3)
+#define LOG4_ENABLED() PR_LOG_TEST(gWyciwygLog, 4)
+#define LOG_ENABLED() LOG4_ENABLED()
+
+#define WYCIWYG_TYPE "text/html"
+
+#endif // nsWyciwyg_h__
rename from content/html/document/src/nsWyciwygChannel.cpp
rename to netwerk/protocol/wyciwyg/nsWyciwygChannel.cpp
--- a/content/html/document/src/nsWyciwygChannel.cpp
+++ b/netwerk/protocol/wyciwyg/nsWyciwygChannel.cpp
@@ -32,32 +32,28 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
+#include "nsWyciwyg.h"
 #include "nsWyciwygChannel.h"
 #include "nsIServiceManager.h"
 #include "nsILoadGroup.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsNetUtil.h"
 #include "nsContentUtils.h"
 #include "nsICacheService.h"
 #include "nsICacheSession.h"
 #include "nsIParser.h"
 #include "nsThreadUtils.h"
 
-PRLogModuleInfo * gWyciwygLog = nsnull;
-
-#define wyciwyg_TYPE "text/html"
-#define LOG(args)  PR_LOG(gWyciwygLog, 4, args)
-
 // nsWyciwygChannel methods 
 nsWyciwygChannel::nsWyciwygChannel()
   : mStatus(NS_OK),
     mIsPending(PR_FALSE),
     mNeedToWriteCharset(PR_FALSE),
     mCharsetSource(kCharsetUninitialized),
     mContentLength(-1),
     mLoadFlags(LOAD_NORMAL)
@@ -147,16 +143,20 @@ nsWyciwygChannel::GetLoadGroup(nsILoadGr
   NS_IF_ADDREF(*aLoadGroup);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsWyciwygChannel::SetLoadGroup(nsILoadGroup* aLoadGroup)
 {
   mLoadGroup = aLoadGroup;
+  NS_QueryNotificationCallbacks(mCallbacks,
+                                mLoadGroup,
+                                NS_GET_IID(nsIProgressEventSink),
+                                getter_AddRefs(mProgressSink));
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsWyciwygChannel::SetLoadFlags(PRUint32 aLoadFlags)
 {
   mLoadFlags = aLoadFlags;
   return NS_OK;
@@ -221,32 +221,35 @@ nsWyciwygChannel::GetNotificationCallbac
   NS_IF_ADDREF(*aCallbacks);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsWyciwygChannel::SetNotificationCallbacks(nsIInterfaceRequestor* aNotificationCallbacks)
 {
   mCallbacks = aNotificationCallbacks;
-  mProgressSink = do_GetInterface(mCallbacks);
+  NS_QueryNotificationCallbacks(mCallbacks,
+                                mLoadGroup,
+                                NS_GET_IID(nsIProgressEventSink),
+                                getter_AddRefs(mProgressSink));
   return NS_OK;
 }
 
 NS_IMETHODIMP 
 nsWyciwygChannel::GetSecurityInfo(nsISupports * *aSecurityInfo)
 {
   NS_IF_ADDREF(*aSecurityInfo = mSecurityInfo);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsWyciwygChannel::GetContentType(nsACString &aContentType)
 {
-  aContentType.AssignLiteral(wyciwyg_TYPE);
+  aContentType.AssignLiteral(WYCIWYG_TYPE);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsWyciwygChannel::SetContentType(const nsACString &aContentType)
 {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
@@ -262,17 +265,18 @@ NS_IMETHODIMP
 nsWyciwygChannel::SetContentCharset(const nsACString &aContentCharset)
 {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 NS_IMETHODIMP
 nsWyciwygChannel::GetContentLength(PRInt32 *aContentLength)
 {
-  return NS_ERROR_NOT_IMPLEMENTED;
+  *aContentLength = mContentLength;
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsWyciwygChannel::SetContentLength(PRInt32 aContentLength)
 {
   mContentLength = aContentLength;
 
   return NS_OK;
@@ -282,25 +286,27 @@ NS_IMETHODIMP
 nsWyciwygChannel::Open(nsIInputStream ** aReturn)
 {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 NS_IMETHODIMP
 nsWyciwygChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *ctx)
 {
+  LOG(("nsWyciwygChannel::AsyncOpen [this=%x]\n", this));
+
+#ifndef MOZ_IPC
   // The only places creating wyciwyg: channels should be
   // HTMLDocument::OpenCommon and session history.  Both should be setting an
   // owner.
   NS_PRECONDITION(mOwner, "Must have a principal");
-  
-  LOG(("nsWyciwygChannel::AsyncOpen [this=%x]\n", this));
+  NS_ENSURE_STATE(mOwner);
+#endif
 
   NS_ENSURE_TRUE(!mIsPending, NS_ERROR_IN_PROGRESS);
-  NS_ENSURE_STATE(mOwner);
   NS_ENSURE_ARG_POINTER(listener);
 
   nsCAutoString spec;
   mURI->GetSpec(spec);
 
   // open a cache entry for this channel...
   PRBool delayed = PR_FALSE;
   nsresult rv = OpenCacheEntry(spec, nsICache::ACCESS_READ, &delayed);
rename from content/html/document/src/nsWyciwygChannel.h
rename to netwerk/protocol/wyciwyg/nsWyciwygChannel.h
--- a/content/html/document/src/nsWyciwygChannel.h
+++ b/netwerk/protocol/wyciwyg/nsWyciwygChannel.h
@@ -38,17 +38,16 @@
 
 #ifndef nsWyciwygChannel_h___
 #define nsWyciwygChannel_h___
 
 #include "nsWyciwygProtocolHandler.h"
 #include "nsXPIDLString.h"
 #include "nsString.h"
 #include "nsCOMPtr.h"
-#include "prlog.h"
 
 #include "nsIWyciwygChannel.h"
 #include "nsILoadGroup.h"
 #include "nsIOutputStream.h"
 #include "nsIInputStream.h"
 #include "nsIInputStreamPump.h"
 #include "nsIInterfaceRequestor.h"
 #include "nsIProgressEventSink.h"
rename from content/html/document/src/nsWyciwygProtocolHandler.cpp
rename to netwerk/protocol/wyciwyg/nsWyciwygProtocolHandler.cpp
--- a/content/html/document/src/nsWyciwygProtocolHandler.cpp
+++ b/netwerk/protocol/wyciwyg/nsWyciwygProtocolHandler.cpp
@@ -32,34 +32,47 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
+#include "nsWyciwyg.h"
 #include "nsWyciwygChannel.h"
 #include "nsWyciwygProtocolHandler.h"
 #include "nsIURL.h"
 #include "nsIComponentManager.h"
 #include "nsNetCID.h"
 
+#ifdef MOZ_IPC
+#include "mozilla/net/NeckoChild.h"
+#endif
+
+using namespace mozilla::net;
+#ifdef MOZ_IPC
+#include "mozilla/net/WyciwygChannelChild.h"
+#endif
+
 ////////////////////////////////////////////////////////////////////////////////
 
 nsWyciwygProtocolHandler::nsWyciwygProtocolHandler() 
 {
+#if defined(PR_LOGGING)
+  if (!gWyciwygLog)
+    gWyciwygLog = PR_NewLogModule("nsWyciwygChannel");
+#endif
 
-#if defined(PR_LOGGING)
-  gWyciwygLog = PR_NewLogModule("nsWyciwygChannel");
-#endif
+  LOG(("Creating nsWyciwygProtocolHandler [this=%x].\n", this));
 }
 
 nsWyciwygProtocolHandler::~nsWyciwygProtocolHandler() 
 {
+  LOG(("Deleting nsWyciwygProtocolHandler [this=%x]\n", this));
 }
 
 NS_IMPL_ISUPPORTS1(nsWyciwygProtocolHandler, nsIProtocolHandler)
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsIProtocolHandler methods:
 ////////////////////////////////////////////////////////////////////////////////
 
@@ -102,30 +115,54 @@ nsWyciwygProtocolHandler::NewURI(const n
   NS_ADDREF(*result);
 
   return rv;
 }
 
 NS_IMETHODIMP
 nsWyciwygProtocolHandler::NewChannel(nsIURI* url, nsIChannel* *result)
 {
+#ifdef MOZ_IPC
+  if (mozilla::net::IsNeckoChild())
+    mozilla::net::NeckoChild::InitNeckoChild();
+#endif // MOZ_IPC
+
   NS_ENSURE_ARG_POINTER(url);
   nsresult rv;
-    
-  nsWyciwygChannel* channel = new nsWyciwygChannel();
-  if (!channel)
-    return NS_ERROR_OUT_OF_MEMORY;
-  NS_ADDREF(channel);
-  rv = channel->Init(url);
+
+  nsCOMPtr<nsIWyciwygChannel> channel;
+#ifdef MOZ_IPC
+  if (IsNeckoChild()) {
+    NS_ENSURE_TRUE(gNeckoChild != nsnull, NS_ERROR_FAILURE);
+
+    WyciwygChannelChild *wcc = static_cast<WyciwygChannelChild *>(
+                                 gNeckoChild->SendPWyciwygChannelConstructor());
+    if (!wcc)
+      return NS_ERROR_OUT_OF_MEMORY;
+
+    channel = wcc;
+    rv = wcc->Init(url);
+    if (NS_FAILED(rv))
+      PWyciwygChannelChild::Send__delete__(wcc);
+  } else
+#endif
+  {
+    nsWyciwygChannel *wc = new nsWyciwygChannel();
+    if (!wc)
+      return NS_ERROR_OUT_OF_MEMORY;
+    channel = wc;
+    rv = wc->Init(url);
+  }
+
+  *result = channel.forget().get();
   if (NS_FAILED(rv)) {
-    NS_RELEASE(channel);
+    NS_RELEASE(*result);
     return rv;
   }
 
-  *result = channel;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsWyciwygProtocolHandler::GetProtocolFlags(PRUint32 *result) 
 {
   // Should this be an an nsINestedURI?  We don't really want random webpages
   // loading these URIs...
rename from content/html/document/src/nsWyciwygProtocolHandler.h
rename to netwerk/protocol/wyciwyg/nsWyciwygProtocolHandler.h
--- a/content/html/document/src/nsWyciwygProtocolHandler.h
+++ b/netwerk/protocol/wyciwyg/nsWyciwygProtocolHandler.h
@@ -44,17 +44,13 @@
 
             
 class nsWyciwygProtocolHandler : public nsIProtocolHandler
 {
 public:
     NS_DECL_ISUPPORTS
     NS_DECL_NSIPROTOCOLHANDLER
 
-    // nsWyciwygProtocolHandler methods:
     nsWyciwygProtocolHandler();
     virtual ~nsWyciwygProtocolHandler();
-
-    // Define a Create method to be used with a factory:
-//    static NS_METHOD Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult);
 };
 
 #endif /* nsWyciwygProtocolHandler_h___ */