From 0727b7098ce026df61e2c1b4c00b03313281ca6a Mon Sep 17 00:00:00 2001 From: Ben Turner Date: Thu, 23 Aug 2012 12:33:46 -0700 Subject: [PATCH] Bug 784726 - 'Remove old IPC::URI'. r=cjones+khuey. --HG-- rename : ipc/glue/IPCSerializableParams.ipdlh => ipc/glue/InputStreamParams.ipdlh extra : transplant_source : %A6%BC%8B%8D%3A_%7Df%2B%FE%AA%94%81%AB%CAW%15K%A7%03 --- content/base/src/nsDOMFile.cpp | 16 +- dom/base/Navigator.cpp | 2 + dom/browser-element/BrowserElementParent.cpp | 1 + dom/indexedDB/ipc/IndexedDBChild.cpp | 1 + dom/ipc/ContentChild.cpp | 12 +- dom/ipc/ContentChild.h | 15 +- dom/ipc/ContentParent.cpp | 50 +++-- dom/ipc/ContentParent.h | 23 +- dom/ipc/PBlobStream.ipdl | 2 +- dom/ipc/PBrowser.ipdl | 10 +- dom/ipc/PContent.ipdl | 23 +- dom/ipc/PContentPermissionRequest.ipdl | 3 - dom/ipc/TabChild.cpp | 4 +- dom/ipc/TabChild.h | 4 +- dom/ipc/TabParent.cpp | 4 +- dom/ipc/TabParent.h | 4 +- image/decoders/icon/android/nsIconChannel.cpp | 2 + ...leParams.ipdlh => InputStreamParams.ipdlh} | 1 - ipc/glue/InputStreamUtils.cpp | 8 +- ipc/glue/InputStreamUtils.h | 2 +- ipc/glue/Makefile.in | 7 +- ipc/glue/URIParams.ipdlh | 78 +++++++ ipc/glue/URIUtils.cpp | 207 ++++++++++++++++++ ipc/glue/URIUtils.h | 32 +++ ipc/glue/ipdl.mk | 5 +- ipc/glue/nsIIPCSerializableURI.h | 57 +++++ ipc/ipdl/ipdl/type.py | 4 + .../test/ipdl/ok/multipleUsingCxxTypes.ipdl | 7 + modules/libjar/Makefile.in | 2 + modules/libjar/nsJARURI.cpp | 55 +++++ modules/libjar/nsJARURI.h | 7 +- modules/libjar/objs.mk | 1 + netwerk/base/public/Makefile.in | 1 - .../public/nsIIPCSerializableObsolete.idl | 24 -- netwerk/base/src/nsBufferedStreams.cpp | 1 - netwerk/base/src/nsFileStreams.cpp | 98 +-------- netwerk/base/src/nsFileStreams.h | 4 - netwerk/base/src/nsMIMEInputStream.cpp | 1 - netwerk/base/src/nsSimpleNestedURI.cpp | 29 +-- netwerk/base/src/nsSimpleNestedURI.h | 1 - netwerk/base/src/nsSimpleURI.cpp | 74 ++++--- netwerk/base/src/nsSimpleURI.h | 8 +- netwerk/base/src/nsStandardURL.cpp | 163 +++++++------- netwerk/base/src/nsStandardURL.h | 10 +- netwerk/cookie/CookieServiceChild.cpp | 16 +- netwerk/cookie/CookieServiceParent.cpp | 12 +- netwerk/cookie/CookieServiceParent.h | 4 +- netwerk/cookie/PCookieService.ipdl | 9 +- netwerk/ipc/NeckoMessageUtils.h | 132 +---------- .../protocol/about/nsAboutProtocolHandler.cpp | 28 +-- .../protocol/about/nsAboutProtocolHandler.h | 3 +- netwerk/protocol/ftp/FTPChannelChild.cpp | 16 +- netwerk/protocol/ftp/FTPChannelChild.h | 4 +- netwerk/protocol/ftp/FTPChannelParent.cpp | 12 +- netwerk/protocol/ftp/FTPChannelParent.h | 2 +- netwerk/protocol/ftp/PFTPChannel.ipdl | 10 +- netwerk/protocol/http/HttpChannelChild.cpp | 23 +- netwerk/protocol/http/HttpChannelChild.h | 4 +- netwerk/protocol/http/HttpChannelParent.cpp | 25 ++- netwerk/protocol/http/HttpChannelParent.h | 12 +- .../protocol/http/HttpChannelParentListener.h | 2 - netwerk/protocol/http/PHttpChannel.ipdl | 16 +- netwerk/protocol/websocket/PWebSocket.ipdl | 9 +- .../websocket/WebSocketChannelChild.cpp | 6 +- .../websocket/WebSocketChannelParent.cpp | 14 +- .../websocket/WebSocketChannelParent.h | 3 +- netwerk/protocol/wyciwyg/PWyciwygChannel.ipdl | 8 +- .../protocol/wyciwyg/WyciwygChannelChild.cpp | 14 +- .../protocol/wyciwyg/WyciwygChannelParent.cpp | 15 +- .../protocol/wyciwyg/WyciwygChannelParent.h | 4 +- toolkit/components/places/History.cpp | 24 +- .../exthandler/ExternalHelperAppParent.cpp | 16 +- .../exthandler/ExternalHelperAppParent.h | 15 +- .../exthandler/nsExternalHelperAppService.cpp | 22 +- .../prefetch/OfflineCacheUpdateChild.cpp | 16 +- .../prefetch/OfflineCacheUpdateParent.cpp | 17 +- uriloader/prefetch/OfflineCacheUpdateParent.h | 16 +- uriloader/prefetch/POfflineCacheUpdate.ipdl | 4 - widget/xpwidgets/nsFilePickerProxy.cpp | 1 + xpcom/io/nsMultiplexInputStream.cpp | 6 +- xpcom/io/nsStringStream.cpp | 37 +--- 81 files changed, 943 insertions(+), 697 deletions(-) rename ipc/glue/{IPCSerializableParams.ipdlh => InputStreamParams.ipdlh} (99%) create mode 100644 ipc/glue/URIParams.ipdlh create mode 100644 ipc/glue/URIUtils.cpp create mode 100644 ipc/glue/URIUtils.h create mode 100644 ipc/glue/nsIIPCSerializableURI.h create mode 100644 ipc/ipdl/test/ipdl/ok/multipleUsingCxxTypes.ipdl delete mode 100644 netwerk/base/public/nsIIPCSerializableObsolete.idl diff --git a/content/base/src/nsDOMFile.cpp b/content/base/src/nsDOMFile.cpp index 27188432513..b9152825616 100644 --- a/content/base/src/nsDOMFile.cpp +++ b/content/base/src/nsDOMFile.cpp @@ -18,7 +18,6 @@ #include "nsIFileStreams.h" #include "nsIInputStream.h" #include "nsIIPCSerializableInputStream.h" -#include "nsIIPCSerializableObsolete.h" #include "nsIMIMEService.h" #include "nsIPlatformCharset.h" #include "nsISeekableStream.h" @@ -48,8 +47,6 @@ using namespace mozilla::dom; // stream is. We do that by passing back this class instead. class DataOwnerAdapter MOZ_FINAL : public nsIInputStream, public nsISeekableStream, - public nsIIPCSerializableObsolete, - public nsIClassInfo, public nsIIPCSerializableInputStream { typedef nsDOMMemoryFile::DataOwner DataOwner; @@ -65,10 +62,8 @@ public: NS_FORWARD_NSIINPUTSTREAM(mStream->) NS_FORWARD_NSISEEKABLESTREAM(mSeekableStream->) - // These are optional. We use a conditional QI to keep them from being called - // if the underlying stream doesn't QI to either interface. - NS_FORWARD_NSIIPCSERIALIZABLEOBSOLETE(mSerializableObsolete->) - NS_FORWARD_NSICLASSINFO(mClassInfo->) + // This is optional. We use a conditional QI to keep it from being called + // if the underlying stream doesn't support it. NS_FORWARD_NSIIPCSERIALIZABLEINPUTSTREAM(mSerializableInputStream->) private: @@ -76,8 +71,6 @@ private: nsIInputStream* aStream) : mDataOwner(aDataOwner), mStream(aStream), mSeekableStream(do_QueryInterface(aStream)), - mSerializableObsolete(do_QueryInterface(aStream)), - mClassInfo(do_QueryInterface(aStream)), mSerializableInputStream(do_QueryInterface(aStream)) { NS_ASSERTION(mSeekableStream, "Somebody gave us the wrong stream!"); @@ -86,8 +79,6 @@ private: nsRefPtr mDataOwner; nsCOMPtr mStream; nsCOMPtr mSeekableStream; - nsCOMPtr mSerializableObsolete; - nsCOMPtr mClassInfo; nsCOMPtr mSerializableInputStream; }; @@ -97,9 +88,6 @@ NS_IMPL_THREADSAFE_RELEASE(DataOwnerAdapter) NS_INTERFACE_MAP_BEGIN(DataOwnerAdapter) NS_INTERFACE_MAP_ENTRY(nsIInputStream) NS_INTERFACE_MAP_ENTRY(nsISeekableStream) - NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIIPCSerializableObsolete, - mSerializableObsolete) - NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIClassInfo, mClassInfo) NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIIPCSerializableInputStream, mSerializableInputStream) NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIInputStream) diff --git a/dom/base/Navigator.cpp b/dom/base/Navigator.cpp index 45a46305cc0..92dec74a7e4 100644 --- a/dom/base/Navigator.cpp +++ b/dom/base/Navigator.cpp @@ -39,6 +39,8 @@ #include "MobileConnection.h" #include "nsIIdleObserver.h" #include "nsIPermissionManager.h" +#include "nsNetUtil.h" +#include "nsIHttpChannel.h" #ifdef MOZ_MEDIA_NAVIGATOR #include "MediaManager.h" diff --git a/dom/browser-element/BrowserElementParent.cpp b/dom/browser-element/BrowserElementParent.cpp index fd72c30c6d5..630c97a6011 100644 --- a/dom/browser-element/BrowserElementParent.cpp +++ b/dom/browser-element/BrowserElementParent.cpp @@ -17,6 +17,7 @@ #include "nsOpenWindowEventDetail.h" #include "nsEventDispatcher.h" #include "nsIDOMCustomEvent.h" +#include "nsIInterfaceRequestorUtils.h" #include "nsVariant.h" using mozilla::dom::Element; diff --git a/dom/indexedDB/ipc/IndexedDBChild.cpp b/dom/indexedDB/ipc/IndexedDBChild.cpp index cb025faaa4e..f2211932274 100644 --- a/dom/indexedDB/ipc/IndexedDBChild.cpp +++ b/dom/indexedDB/ipc/IndexedDBChild.cpp @@ -7,6 +7,7 @@ #include "IndexedDBChild.h" #include "nsIAtom.h" +#include "nsIInputStream.h" #include "mozilla/Assertions.h" #include "mozilla/dom/ContentChild.h" diff --git a/dom/ipc/ContentChild.cpp b/dom/ipc/ContentChild.cpp index 60647b3bdd1..ac59c065d5d 100644 --- a/dom/ipc/ContentChild.cpp +++ b/dom/ipc/ContentChild.cpp @@ -94,6 +94,7 @@ #include "nsDOMFile.h" #include "nsIRemoteBlob.h" #include "StructuredCloneUtils.h" +#include "URIUtils.h" using namespace mozilla::docshell; using namespace mozilla::dom::devicestorage; @@ -624,12 +625,12 @@ ContentChild::DeallocPNecko(PNeckoChild* necko) } PExternalHelperAppChild* -ContentChild::AllocPExternalHelperApp(const IPC::URI& uri, +ContentChild::AllocPExternalHelperApp(const OptionalURIParams& uri, const nsCString& aMimeContentType, const nsCString& aContentDisposition, const bool& aForceSave, const int64_t& aContentLength, - const IPC::URI& aReferrer) + const OptionalURIParams& aReferrer) { ExternalHelperAppChild *child = new ExternalHelperAppChild(); child->AddRef(); @@ -785,9 +786,12 @@ ContentChild::RecvNotifyAlertsObserver(const nsCString& aType, const nsString& a } bool -ContentChild::RecvNotifyVisited(const IPC::URI& aURI) +ContentChild::RecvNotifyVisited(const URIParams& aURI) { - nsCOMPtr newURI(aURI); + nsCOMPtr newURI = DeserializeURI(aURI); + if (!newURI) { + return false; + } History::GetService()->NotifyVisited(newURI); return true; } diff --git a/dom/ipc/ContentChild.h b/dom/ipc/ContentChild.h index cae622de504..3ffcc4afc79 100644 --- a/dom/ipc/ContentChild.h +++ b/dom/ipc/ContentChild.h @@ -22,9 +22,14 @@ struct OverrideMapping; namespace mozilla { +namespace ipc { +class OptionalURIParams; +class URIParams; +}// namespace ipc + namespace layers { class PCompositorChild; -} +} // namespace layers namespace dom { @@ -38,6 +43,8 @@ class ContentChild : public PContentChild { typedef layers::PCompositorChild PCompositorChild; typedef mozilla::dom::ClonedMessageData ClonedMessageData; + typedef mozilla::ipc::OptionalURIParams OptionalURIParams; + typedef mozilla::ipc::URIParams URIParams; public: ContentChild(); @@ -111,12 +118,12 @@ public: virtual bool DeallocPNecko(PNeckoChild*); virtual PExternalHelperAppChild *AllocPExternalHelperApp( - const IPC::URI& uri, + const OptionalURIParams& uri, const nsCString& aMimeContentType, const nsCString& aContentDisposition, const bool& aForceSave, const int64_t& aContentLength, - const IPC::URI& aReferrer); + const OptionalURIParams& aReferrer); virtual bool DeallocPExternalHelperApp(PExternalHelperAppChild *aService); virtual PSmsChild* AllocPSms(); @@ -132,7 +139,7 @@ public: virtual bool RecvSetOffline(const bool& offline); - virtual bool RecvNotifyVisited(const IPC::URI& aURI); + virtual bool RecvNotifyVisited(const URIParams& aURI); // auto remove when alertfinished is received. nsresult AddRemoteAlertObserver(const nsString& aData, nsIObserver* aObserver); diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index e1c1ed4036b..b207ca139f8 100644 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -76,6 +76,7 @@ #include "SandboxHal.h" #include "StructuredCloneUtils.h" #include "TabParent.h" +#include "URIUtils.h" #ifdef ANDROID # include "gfxAndroidPlatform.h" @@ -1347,12 +1348,12 @@ ContentParent::DeallocPNecko(PNeckoParent* necko) } PExternalHelperAppParent* -ContentParent::AllocPExternalHelperApp(const IPC::URI& uri, +ContentParent::AllocPExternalHelperApp(const OptionalURIParams& uri, const nsCString& aMimeContentType, const nsCString& aContentDisposition, const bool& aForceSave, const int64_t& aContentLength, - const IPC::URI& aReferrer) + const OptionalURIParams& aReferrer) { ExternalHelperAppParent *parent = new ExternalHelperAppParent(uri, aContentLength); parent->AddRef(); @@ -1424,43 +1425,52 @@ ContentParent::RequestRunToCompletion() } bool -ContentParent::RecvStartVisitedQuery(const IPC::URI& aURI) +ContentParent::RecvStartVisitedQuery(const URIParams& aURI) { - nsCOMPtr newURI(aURI); + nsCOMPtr newURI = DeserializeURI(aURI); + if (!newURI) { + return false; + } nsCOMPtr history = services::GetHistoryService(); NS_ABORT_IF_FALSE(history, "History must exist at this point."); if (history) { - history->RegisterVisitedCallback(newURI, nullptr); + history->RegisterVisitedCallback(newURI, nullptr); } return true; } bool -ContentParent::RecvVisitURI(const IPC::URI& uri, - const IPC::URI& referrer, - const uint32_t& flags) +ContentParent::RecvVisitURI(const URIParams& uri, + const OptionalURIParams& referrer, + const uint32_t& flags) { - nsCOMPtr ourURI(uri); - nsCOMPtr ourReferrer(referrer); + nsCOMPtr ourURI = DeserializeURI(uri); + if (!ourURI) { + return false; + } + nsCOMPtr ourReferrer = DeserializeURI(referrer); nsCOMPtr history = services::GetHistoryService(); NS_ABORT_IF_FALSE(history, "History must exist at this point"); if (history) { - history->VisitURI(ourURI, ourReferrer, flags); + history->VisitURI(ourURI, ourReferrer, flags); } return true; } bool -ContentParent::RecvSetURITitle(const IPC::URI& uri, - const nsString& title) +ContentParent::RecvSetURITitle(const URIParams& uri, + const nsString& title) { - nsCOMPtr ourURI(uri); + nsCOMPtr ourURI = DeserializeURI(uri); + if (!ourURI) { + return false; + } nsCOMPtr history = services::GetHistoryService(); NS_ABORT_IF_FALSE(history, "History must exist at this point"); if (history) { - history->SetURITitle(ourURI, title); + history->SetURITitle(ourURI, title); } return true; } @@ -1541,12 +1551,16 @@ ContentParent::RecvShowFilePicker(const int16_t& mode, } bool -ContentParent::RecvLoadURIExternal(const IPC::URI& uri) +ContentParent::RecvLoadURIExternal(const URIParams& uri) { nsCOMPtr extProtService(do_GetService(NS_EXTERNALPROTOCOLSERVICE_CONTRACTID)); - if (!extProtService) + if (!extProtService) { return true; - nsCOMPtr ourURI(uri); + } + nsCOMPtr ourURI = DeserializeURI(uri); + if (!ourURI) { + return false; + } extProtService->LoadURI(ourURI, nullptr); return true; } diff --git a/dom/ipc/ContentParent.h b/dom/ipc/ContentParent.h index b2127949df1..96329ed680d 100644 --- a/dom/ipc/ContentParent.h +++ b/dom/ipc/ContentParent.h @@ -32,12 +32,14 @@ class nsIDOMBlob; namespace mozilla { namespace ipc { +class OptionalURIParams; +class URIParams; class TestShellParent; -} +} // namespace ipc namespace layers { class PCompositorParent; -} +} // namespace layers namespace dom { @@ -50,9 +52,10 @@ class ContentParent : public PContentParent , public nsIThreadObserver , public nsIDOMGeoPositionCallback { -private: typedef mozilla::ipc::GeckoChildProcessHost GeckoChildProcessHost; + typedef mozilla::ipc::OptionalURIParams OptionalURIParams; typedef mozilla::ipc::TestShellParent TestShellParent; + typedef mozilla::ipc::URIParams URIParams; typedef mozilla::layers::PCompositorParent PCompositorParent; typedef mozilla::dom::ClonedMessageData ClonedMessageData; @@ -198,12 +201,12 @@ private: virtual bool DeallocPNecko(PNeckoParent* necko); virtual PExternalHelperAppParent* AllocPExternalHelperApp( - const IPC::URI& uri, + const OptionalURIParams& aUri, const nsCString& aMimeContentType, const nsCString& aContentDisposition, const bool& aForceSave, const int64_t& aContentLength, - const IPC::URI& aReferrer); + const OptionalURIParams& aReferrer); virtual bool DeallocPExternalHelperApp(PExternalHelperAppParent* aService); virtual PSmsParent* AllocPSms(); @@ -226,13 +229,13 @@ private: virtual bool RecvGetIconForExtension(const nsCString& aFileExt, const uint32_t& aIconSize, InfallibleTArray* bits); virtual bool RecvGetShowPasswordSetting(bool* showPassword); - virtual bool RecvStartVisitedQuery(const IPC::URI& uri); + virtual bool RecvStartVisitedQuery(const URIParams& uri); - virtual bool RecvVisitURI(const IPC::URI& uri, - const IPC::URI& referrer, + virtual bool RecvVisitURI(const URIParams& uri, + const OptionalURIParams& referrer, const uint32_t& flags); - virtual bool RecvSetURITitle(const IPC::URI& uri, + virtual bool RecvSetURITitle(const URIParams& uri, const nsString& title); virtual bool RecvShowFilePicker(const int16_t& mode, @@ -251,7 +254,7 @@ private: const nsString& aText, const bool& aTextClickable, const nsString& aCookie, const nsString& aName); - virtual bool RecvLoadURIExternal(const IPC::URI& uri); + virtual bool RecvLoadURIExternal(const URIParams& uri); virtual bool RecvSyncMessage(const nsString& aMsg, const ClonedMessageData& aData, diff --git a/dom/ipc/PBlobStream.ipdl b/dom/ipc/PBlobStream.ipdl index aac11a1eabf..6232ac6ac6e 100644 --- a/dom/ipc/PBlobStream.ipdl +++ b/dom/ipc/PBlobStream.ipdl @@ -3,7 +3,7 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ include protocol PBlob; -include IPCSerializableParams; +include InputStreamParams; namespace mozilla { namespace dom { diff --git a/dom/ipc/PBrowser.ipdl b/dom/ipc/PBrowser.ipdl index 5c36c6eff3d..0c9c4a2f9ce 100644 --- a/dom/ipc/PBrowser.ipdl +++ b/dom/ipc/PBrowser.ipdl @@ -13,6 +13,8 @@ include protocol PContentPermissionRequest; include protocol PRenderFrame; include protocol POfflineCacheUpdate; include protocol PIndexedDB; +include DOMTypes; +include URIParams; include "gfxMatrix.h"; include "FrameMetrics.h"; @@ -20,11 +22,7 @@ include "IPC/nsGUIEventIPC.h"; include "mozilla/dom/TabMessageUtils.h"; include "mozilla/dom/PermissionMessageUtils.h"; include "mozilla/layout/RenderFrameUtils.h"; -include "mozilla/net/NeckoMessageUtils.h"; -include DOMTypes; - -using IPC::URI; using IPC::Principal; using gfxMatrix; using gfxRect; @@ -230,8 +228,8 @@ parent: * document will get cached and that we don't re-cache a document that * has already been cached (stickDocument=false). */ - POfflineCacheUpdate(URI manifestURI, URI documentURI, nsCString clientID, - bool stickDocument); + POfflineCacheUpdate(URIParams manifestURI, URIParams documentURI, + nsCString clientID, bool stickDocument); sync PIndexedDB(nsCString asciiOrigin) returns (bool allowed); diff --git a/dom/ipc/PContent.ipdl b/dom/ipc/PContent.ipdl index 6b481e78d53..bc6ca040712 100644 --- a/dom/ipc/PContent.ipdl +++ b/dom/ipc/PContent.ipdl @@ -18,6 +18,8 @@ include protocol PNecko; include protocol PSms; include protocol PStorage; include protocol PTestShell; +include DOMTypes; +include URIParams; include "mozilla/chrome/RegistryMessageUtils.h"; include "mozilla/net/NeckoMessageUtils.h"; @@ -25,15 +27,12 @@ include "mozilla/dom/TabMessageUtils.h"; include "nsGeoPositionIPCSerialiser.h"; -include DOMTypes; - using GeoPosition; using PrefTuple; using ChromePackage; using ResourceMapping; using OverrideMapping; -using IPC::URI; using IPC::Permission; using mozilla::null_t; using mozilla::void_t; @@ -208,7 +207,7 @@ child: async SetOffline(bool offline); - async NotifyVisited(URI uri); + async NotifyVisited(URIParams uri); PreferenceUpdate(PrefSetting pref); @@ -259,9 +258,9 @@ parent: // Services remoting - async StartVisitedQuery(URI uri); - async VisitURI(URI uri, URI referrer, uint32_t flags); - async SetURITitle(URI uri, nsString title); + async StartVisitedQuery(URIParams uri); + async VisitURI(URIParams uri, OptionalURIParams referrer, uint32_t flags); + async SetURITitle(URIParams uri, nsString title); // filepicker remoting sync ShowFilePicker(int16_t mode, int16_t selectedType, bool addToRecentDocs, @@ -269,7 +268,7 @@ parent: nsString[] filters, nsString[] filterNames) returns (nsString[] files, int16_t retValue, nsresult result); - async LoadURIExternal(URI uri); + async LoadURIExternal(URIParams uri); // PrefService message sync ReadPrefsArray() returns (PrefSetting[] prefs); @@ -286,10 +285,10 @@ parent: nsString cookie, nsString name); - PExternalHelperApp(URI uri, nsCString aMimeContentType, + PExternalHelperApp(OptionalURIParams uri, nsCString aMimeContentType, nsCString aContentDisposition, bool aForceSave, - int64_t aContentLength, URI aReferrer); - + int64_t aContentLength, OptionalURIParams aReferrer); + AddGeolocationListener(); RemoveGeolocationListener(); @@ -327,4 +326,4 @@ both: }; } -} +} \ No newline at end of file diff --git a/dom/ipc/PContentPermissionRequest.ipdl b/dom/ipc/PContentPermissionRequest.ipdl index d61fdf8f3c0..0f5ab3416fa 100644 --- a/dom/ipc/PContentPermissionRequest.ipdl +++ b/dom/ipc/PContentPermissionRequest.ipdl @@ -3,9 +3,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ include protocol PBrowser; -include "mozilla/net/NeckoMessageUtils.h"; - -using IPC::URI; namespace mozilla { namespace dom { diff --git a/dom/ipc/TabChild.cpp b/dom/ipc/TabChild.cpp index 10f260852b6..d9c132bd1c9 100644 --- a/dom/ipc/TabChild.cpp +++ b/dom/ipc/TabChild.cpp @@ -1030,8 +1030,8 @@ TabChild::RecvActivateFrameEvent(const nsString& aType, const bool& capture) } POfflineCacheUpdateChild* -TabChild::AllocPOfflineCacheUpdate(const URI& manifestURI, - const URI& documentURI, +TabChild::AllocPOfflineCacheUpdate(const URIParams& manifestURI, + const URIParams& documentURI, const nsCString& clientID, const bool& stickDocument) { diff --git a/dom/ipc/TabChild.h b/dom/ipc/TabChild.h index 682ac37a059..15ba7328aaa 100644 --- a/dom/ipc/TabChild.h +++ b/dom/ipc/TabChild.h @@ -245,8 +245,8 @@ public: virtual PContentPermissionRequestChild* AllocPContentPermissionRequest(const nsCString& aType, const IPC::Principal& aPrincipal); virtual bool DeallocPContentPermissionRequest(PContentPermissionRequestChild* actor); - virtual POfflineCacheUpdateChild* AllocPOfflineCacheUpdate(const URI& manifestURI, - const URI& documentURI, + virtual POfflineCacheUpdateChild* AllocPOfflineCacheUpdate(const URIParams& manifestURI, + const URIParams& documentURI, const nsCString& clientID, const bool& stickDocument); virtual bool DeallocPOfflineCacheUpdate(POfflineCacheUpdateChild* offlineCacheUpdate); diff --git a/dom/ipc/TabParent.cpp b/dom/ipc/TabParent.cpp index 4226e51b084..2dbb8ad44ff 100644 --- a/dom/ipc/TabParent.cpp +++ b/dom/ipc/TabParent.cpp @@ -954,8 +954,8 @@ TabParent::DeallocPRenderFrame(PRenderFrameParent* aFrame) } mozilla::docshell::POfflineCacheUpdateParent* -TabParent::AllocPOfflineCacheUpdate(const URI& aManifestURI, - const URI& aDocumentURI, +TabParent::AllocPOfflineCacheUpdate(const URIParams& aManifestURI, + const URIParams& aDocumentURI, const nsCString& aClientID, const bool& stickDocument) { diff --git a/dom/ipc/TabParent.h b/dom/ipc/TabParent.h index e07ff03f2e7..3e360438ade 100644 --- a/dom/ipc/TabParent.h +++ b/dom/ipc/TabParent.h @@ -159,8 +159,8 @@ public: virtual bool DeallocPContentPermissionRequest(PContentPermissionRequestParent* actor); virtual POfflineCacheUpdateParent* AllocPOfflineCacheUpdate( - const URI& aManifestURI, - const URI& aDocumentURI, + const URIParams& aManifestURI, + const URIParams& aDocumentURI, const nsCString& aClientID, const bool& stickDocument); virtual bool DeallocPOfflineCacheUpdate(POfflineCacheUpdateParent* actor); diff --git a/image/decoders/icon/android/nsIconChannel.cpp b/image/decoders/icon/android/nsIconChannel.cpp index f033dc98ceb..45ae987b9e4 100644 --- a/image/decoders/icon/android/nsIconChannel.cpp +++ b/image/decoders/icon/android/nsIconChannel.cpp @@ -9,6 +9,8 @@ #include "nsXULAppAPI.h" #include "AndroidBridge.h" #include "nsIconChannel.h" +#include "nsIStringStream.h" +#include "nsNetUtil.h" NS_IMPL_ISUPPORTS2(nsIconChannel, nsIRequest, diff --git a/ipc/glue/IPCSerializableParams.ipdlh b/ipc/glue/InputStreamParams.ipdlh similarity index 99% rename from ipc/glue/IPCSerializableParams.ipdlh rename to ipc/glue/InputStreamParams.ipdlh index ef31b6ddfb0..4db22c7bc1d 100644 --- a/ipc/glue/IPCSerializableParams.ipdlh +++ b/ipc/glue/InputStreamParams.ipdlh @@ -67,6 +67,5 @@ struct MIMEInputStreamParams bool addContentLength; }; - } // namespace ipc } // namespace mozilla diff --git a/ipc/glue/InputStreamUtils.cpp b/ipc/glue/InputStreamUtils.cpp index 52fa598d3f0..1188e71358a 100644 --- a/ipc/glue/InputStreamUtils.cpp +++ b/ipc/glue/InputStreamUtils.cpp @@ -42,14 +42,14 @@ SerializeInputStream(nsIInputStream* aInputStream, nsCOMPtr serializable = do_QueryInterface(aInputStream); if (!serializable) { - NS_WARNING("Input stream is not serializable!"); - return; + MOZ_NOT_REACHED("Input stream is not serializable!"); } serializable->Serialize(aParams); - NS_WARN_IF_FALSE(aParams.type() != InputStreamParams::T__None, - "Serialize failed!"); + if (aParams.type() == InputStreamParams::T__None) { + MOZ_NOT_REACHED("Serialize failed!"); + } } void diff --git a/ipc/glue/InputStreamUtils.h b/ipc/glue/InputStreamUtils.h index 76cb447d910..79b267d611b 100644 --- a/ipc/glue/InputStreamUtils.h +++ b/ipc/glue/InputStreamUtils.h @@ -5,7 +5,7 @@ #ifndef mozilla_ipc_InputStreamUtils_h #define mozilla_ipc_InputStreamUtils_h -#include "mozilla/ipc/IPCSerializableParams.h" +#include "mozilla/ipc/InputStreamParams.h" #include "nsCOMPtr.h" #include "nsIInputStream.h" diff --git a/ipc/glue/Makefile.in b/ipc/glue/Makefile.in index 467bf4f85e6..635339ac352 100644 --- a/ipc/glue/Makefile.in +++ b/ipc/glue/Makefile.in @@ -40,9 +40,13 @@ EXPORTS_mozilla/ipc = \ SyncChannel.h \ ScopedXREEmbed.h \ Transport.h \ + URIUtils.h \ $(NULL) -EXPORTS = nsIIPCSerializableInputStream.h +EXPORTS = \ + nsIIPCSerializableInputStream.h \ + nsIIPCSerializableURI.h \ + $(NULL) ifeq ($(OS_ARCH),WINNT) #{ EXPORTS_mozilla/ipc += \ @@ -79,6 +83,7 @@ CPPSRCS += \ Shmem.cpp \ StringUtil.cpp \ SyncChannel.cpp \ + URIUtils.cpp \ $(NULL) ifeq ($(OS_ARCH),WINNT) #{ diff --git a/ipc/glue/URIParams.ipdlh b/ipc/glue/URIParams.ipdlh new file mode 100644 index 00000000000..1ad7379ff99 --- /dev/null +++ b/ipc/glue/URIParams.ipdlh @@ -0,0 +1,78 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +include "IPC/IPCMessageUtils.h"; + +using mozilla::void_t; + +namespace mozilla { +namespace ipc { + +struct SimpleURIParams +{ + nsCString scheme; + nsCString path; + nsCString ref; + bool isMutable; +}; + +struct StandardURLSegment +{ + uint32_t position; + int32_t length; +}; + +struct StandardURLParams +{ + uint32_t urlType; + int32_t port; + int32_t defaultPort; + nsCString spec; + StandardURLSegment scheme; + StandardURLSegment authority; + StandardURLSegment username; + StandardURLSegment password; + StandardURLSegment host; + StandardURLSegment path; + StandardURLSegment filePath; + StandardURLSegment directory; + StandardURLSegment baseName; + StandardURLSegment extension; + StandardURLSegment query; + StandardURLSegment ref; + nsCString originCharset; + bool isMutable; + bool supportsFileURL; + uint32_t hostEncoding; +}; + +struct JARURIParams +{ + URIParams jarFile; + URIParams jarEntry; + nsCString charset; +}; + +struct GenericURIParams +{ + nsCString spec; + nsCString charset; +}; + +union URIParams +{ + SimpleURIParams; + StandardURLParams; + JARURIParams; + GenericURIParams; +}; + +union OptionalURIParams +{ + void_t; + URIParams; +}; + +} // namespace ipc +} // namespace mozilla diff --git a/ipc/glue/URIUtils.cpp b/ipc/glue/URIUtils.cpp new file mode 100644 index 00000000000..9a255d849be --- /dev/null +++ b/ipc/glue/URIUtils.cpp @@ -0,0 +1,207 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "URIUtils.h" + +#include "nsIIPCSerializableURI.h" + +#include "mozilla/Assertions.h" +#include "mozilla/Util.h" +#include "nsComponentManagerUtils.h" +#include "nsDebug.h" +#include "nsID.h" +#include "nsJARURI.h" +#include "nsNetCID.h" +#include "nsNetUtil.h" +#include "nsThreadUtils.h" + +using namespace mozilla::ipc; +using mozilla::ArrayLength; + +namespace { + +NS_DEFINE_CID(kSimpleURICID, NS_SIMPLEURI_CID); +NS_DEFINE_CID(kStandardURLCID, NS_STANDARDURL_CID); +NS_DEFINE_CID(kJARURICID, NS_JARURI_CID); + +struct StringWithLengh +{ + const char* string; + size_t length; +}; + +#define STRING_WITH_LENGTH(_str) \ + { _str, ArrayLength(_str) - 1 } + +const StringWithLengh kGenericURIAllowedSchemes[] = { + STRING_WITH_LENGTH("about:"), + STRING_WITH_LENGTH("javascript:"), + STRING_WITH_LENGTH("javascript") +}; + +#undef STRING_WITH_LENGTH + +} // anonymous namespace + +namespace mozilla { +namespace ipc { + +void +SerializeURI(nsIURI* aURI, + URIParams& aParams) +{ + MOZ_ASSERT(NS_IsMainThread()); + MOZ_ASSERT(aURI); + + nsCOMPtr serializable = do_QueryInterface(aURI); + if (serializable) { + serializable->Serialize(aParams); + if (aParams.type() == URIParams::T__None) { + MOZ_NOT_REACHED("Serialize failed!"); + } + return; + } + + nsCString scheme; + if (NS_FAILED(aURI->GetScheme(scheme))) { + MOZ_NOT_REACHED("This must never fail!"); + } + + bool allowed = false; + + for (size_t i = 0; i < ArrayLength(kGenericURIAllowedSchemes); i++) { + const StringWithLengh& entry = kGenericURIAllowedSchemes[i]; + if (scheme.EqualsASCII(entry.string, entry.length)) { + allowed = true; + break; + } + } + + if (!allowed) { + MOZ_NOT_REACHED("All IPDL URIs must be serializable or an allowed " + "scheme!"); + } + + GenericURIParams params; + if (NS_FAILED(aURI->GetSpec(params.spec())) || + NS_FAILED(aURI->GetOriginCharset(params.charset()))) { + MOZ_NOT_REACHED("This must never fail!"); + } + + aParams = params; +} + +void +SerializeURI(nsIURI* aURI, + OptionalURIParams& aParams) +{ + MOZ_ASSERT(NS_IsMainThread()); + + if (aURI) { + URIParams params; + SerializeURI(aURI, params); + aParams = params; + } + else { + aParams = mozilla::void_t(); + } +} + +already_AddRefed +DeserializeURI(const URIParams& aParams) +{ + MOZ_ASSERT(NS_IsMainThread()); + + nsCOMPtr uri; + + if (aParams.type() != URIParams::TGenericURIParams) { + nsCOMPtr serializable; + + switch (aParams.type()) { + case URIParams::TSimpleURIParams: + serializable = do_CreateInstance(kSimpleURICID); + break; + + case URIParams::TStandardURLParams: + serializable = do_CreateInstance(kStandardURLCID); + break; + + case URIParams::TJARURIParams: + serializable = do_CreateInstance(kJARURICID); + break; + + default: + MOZ_NOT_REACHED("Unknown params!"); + } + + MOZ_ASSERT(serializable); + + if (!serializable->Deserialize(aParams)) { + MOZ_ASSERT(false, "Deserialize failed!"); + return nullptr; + } + + uri = do_QueryInterface(serializable); + MOZ_ASSERT(uri); + + return uri.forget(); + } + + MOZ_ASSERT(aParams.type() == URIParams::TGenericURIParams); + + const GenericURIParams& params = aParams.get_GenericURIParams(); + + if (NS_FAILED(NS_NewURI(getter_AddRefs(uri), params.spec(), + params.charset().get()))) { + NS_WARNING("Failed to make new URI!"); + return nullptr; + } + + nsCString scheme; + if (NS_FAILED(uri->GetScheme(scheme))) { + MOZ_NOT_REACHED("This must never fail!"); + } + + bool allowed = false; + + for (size_t i = 0; i < ArrayLength(kGenericURIAllowedSchemes); i++) { + const StringWithLengh& entry = kGenericURIAllowedSchemes[i]; + if (scheme.EqualsASCII(entry.string, entry.length)) { + allowed = true; + break; + } + } + + if (!allowed) { + MOZ_ASSERT(false, "This type of URI is not allowed!"); + return nullptr; + } + + return uri.forget(); +} + +already_AddRefed +DeserializeURI(const OptionalURIParams& aParams) +{ + MOZ_ASSERT(NS_IsMainThread()); + + nsCOMPtr uri; + + switch (aParams.type()) { + case OptionalURIParams::Tvoid_t: + break; + + case OptionalURIParams::TURIParams: + uri = DeserializeURI(aParams.get_URIParams()); + break; + + default: + MOZ_NOT_REACHED("Unknown params!"); + } + + return uri.forget(); +} + +} // namespace ipc +} // namespace mozilla diff --git a/ipc/glue/URIUtils.h b/ipc/glue/URIUtils.h new file mode 100644 index 00000000000..ee4dd5ecb14 --- /dev/null +++ b/ipc/glue/URIUtils.h @@ -0,0 +1,32 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_ipc_URIUtils_h +#define mozilla_ipc_URIUtils_h + +#include "mozilla/ipc/URIParams.h" +#include "nsCOMPtr.h" +#include "nsIURI.h" + +namespace mozilla { +namespace ipc { + +void +SerializeURI(nsIURI* aURI, + URIParams& aParams); + +void +SerializeURI(nsIURI* aURI, + OptionalURIParams& aParams); + +already_AddRefed +DeserializeURI(const URIParams& aParams); + +already_AddRefed +DeserializeURI(const OptionalURIParams& aParams); + +} // namespace ipc +} // namespace mozilla + +#endif // mozilla_ipc_URIUtils_h diff --git a/ipc/glue/ipdl.mk b/ipc/glue/ipdl.mk index b2a320c7e60..3c0b2cd759d 100644 --- a/ipc/glue/ipdl.mk +++ b/ipc/glue/ipdl.mk @@ -2,4 +2,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -IPDLSRCS = IPCSerializableParams.ipdlh +IPDLSRCS = \ + InputStreamParams.ipdlh \ + URIParams.ipdlh \ + $(NULL) diff --git a/ipc/glue/nsIIPCSerializableURI.h b/ipc/glue/nsIIPCSerializableURI.h new file mode 100644 index 00000000000..5a351b90458 --- /dev/null +++ b/ipc/glue/nsIIPCSerializableURI.h @@ -0,0 +1,57 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_ipc_nsIIPCSerializableURI_h +#define mozilla_ipc_nsIIPCSerializableURI_h + +#include "nsISupports.h" +#include "mozilla/Attributes.h" + +namespace mozilla { +namespace ipc { +class URIParams; +} +} + +#define NS_IIPCSERIALIZABLEURI_IID \ + {0xfee3437d, 0x3daf, 0x411f, {0xb0, 0x1d, 0xdc, 0xd4, 0x88, 0x55, 0xe3, 0xd}} + +class NS_NO_VTABLE nsIIPCSerializableURI : public nsISupports +{ +public: + NS_DECLARE_STATIC_IID_ACCESSOR(NS_IIPCSERIALIZABLEURI_IID) + + virtual void + Serialize(mozilla::ipc::URIParams& aParams) = 0; + + virtual bool + Deserialize(const mozilla::ipc::URIParams& aParams) = 0; +}; + +NS_DEFINE_STATIC_IID_ACCESSOR(nsIIPCSerializableURI, + NS_IIPCSERIALIZABLEURI_IID) + +#define NS_DECL_NSIIPCSERIALIZABLEURI \ + virtual void \ + Serialize(mozilla::ipc::URIParams&) MOZ_OVERRIDE; \ + virtual bool \ + Deserialize(const mozilla::ipc::URIParams&) MOZ_OVERRIDE; + +#define NS_FORWARD_NSIIPCSERIALIZABLEURI(_to) \ + virtual void \ + Serialize(mozilla::ipc::URIParams& aParams) MOZ_OVERRIDE \ + { _to Serialize(aParams); } \ + virtual bool \ + Deserialize(const mozilla::ipc::URIParams& aParams) MOZ_OVERRIDE \ + { return _to Deserialize(aParams); } + +#define NS_FORWARD_SAFE_NSIIPCSERIALIZABLEURI(_to) \ + virtual void \ + Serialize(mozilla::ipc::URIParams& aParams) MOZ_OVERRIDE \ + { if (_to) { _to->Serialize(aParams); } } \ + virtual bool \ + Deserialize(const mozilla::ipc::URIParams& aParams) MOZ_OVERRIDE \ + { if (_to) { return _to->Deserialize(aParams); } return false; } + +#endif // mozilla_ipc_nsIIPCSerializableURI_h diff --git a/ipc/ipdl/ipdl/type.py b/ipc/ipdl/ipdl/type.py index b30534f22f3..3710c9286f3 100644 --- a/ipc/ipdl/ipdl/type.py +++ b/ipc/ipdl/ipdl/type.py @@ -804,6 +804,10 @@ class GatherDecls(TcheckVisitor): ipdltype = FDType(using.type.spec) else: ipdltype = ImportedCxxType(using.type.spec) + existingType = self.symtab.lookup(ipdltype.fullname()) + if existingType and existingType.fullname == ipdltype.fullname(): + using.decl = existingType + return using.decl = self.declare( loc=using.loc, type=ipdltype, diff --git a/ipc/ipdl/test/ipdl/ok/multipleUsingCxxTypes.ipdl b/ipc/ipdl/test/ipdl/ok/multipleUsingCxxTypes.ipdl new file mode 100644 index 00000000000..dbe208eef70 --- /dev/null +++ b/ipc/ipdl/test/ipdl/ok/multipleUsingCxxTypes.ipdl @@ -0,0 +1,7 @@ +using mozilla::void_t; +using mozilla::void_t; + +protocol multipleUsingCxxTypes { +child: + Msg(void_t foo); +}; diff --git a/modules/libjar/Makefile.in b/modules/libjar/Makefile.in index d8cfd7d6737..c4dd63b2172 100644 --- a/modules/libjar/Makefile.in +++ b/modules/libjar/Makefile.in @@ -37,4 +37,6 @@ XPIDLSRCS = $(MODULES_LIBJAR_LXPIDLSRCS) EXPORTS = $(MODULES_LIBJAR_LEXPORTS) +include $(topsrcdir)/config/config.mk +include $(topsrcdir)/ipc/chromium/chromium-config.mk include $(topsrcdir)/config/rules.mk diff --git a/modules/libjar/nsJARURI.cpp b/modules/libjar/nsJARURI.cpp index 9752a92a83e..92b2a0ccb42 100644 --- a/modules/libjar/nsJARURI.cpp +++ b/modules/libjar/nsJARURI.cpp @@ -4,6 +4,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include "base/basictypes.h" + #include "nsJARURI.h" #include "nsNetUtil.h" #include "nsIIOService.h" @@ -18,6 +20,9 @@ #include "nsIObjectInputStream.h" #include "nsIObjectOutputStream.h" #include "nsIProgrammingLanguage.h" +#include "mozilla/ipc/URIUtils.h" + +using namespace mozilla::ipc; static NS_DEFINE_CID(kJARURICID, NS_JARURI_CID); @@ -42,6 +47,7 @@ NS_INTERFACE_MAP_BEGIN(nsJARURI) NS_INTERFACE_MAP_ENTRY(nsISerializable) NS_INTERFACE_MAP_ENTRY(nsIClassInfo) NS_INTERFACE_MAP_ENTRY(nsINestedURI) + NS_INTERFACE_MAP_ENTRY(nsIIPCSerializableURI) // see nsJARURI::Equals if (aIID.Equals(NS_GET_IID(nsJARURI))) foundInterface = reinterpret_cast(this); @@ -816,3 +822,52 @@ nsJARURI::GetInnermostURI(nsIURI** uri) return NS_ImplGetInnermostURI(this, uri); } +//////////////////////////////////////////////////////////////////////////////// +// nsIIPCSerializableURI methods: + +void +nsJARURI::Serialize(URIParams& aParams) +{ + JARURIParams params; + + SerializeURI(mJARFile, params.jarFile()); + SerializeURI(mJAREntry, params.jarEntry()); + params.charset() = mCharsetHint; + + aParams = params; +} + +bool +nsJARURI::Deserialize(const URIParams& aParams) +{ + if (aParams.type() != URIParams::TJARURIParams) { + NS_ERROR("Received unknown parameters from the other process!"); + return false; + } + + const JARURIParams& params = aParams.get_JARURIParams(); + + nsCOMPtr file = DeserializeURI(params.jarFile()); + if (!file) { + NS_ERROR("Couldn't deserialize jar file URI!"); + return false; + } + + nsCOMPtr entry = DeserializeURI(params.jarEntry()); + if (!entry) { + NS_ERROR("Couldn't deserialize jar entry URI!"); + return false; + } + + nsCOMPtr entryURL = do_QueryInterface(entry); + if (!entryURL) { + NS_ERROR("Couldn't QI jar entry URI to nsIURL!"); + return false; + } + + mJARFile.swap(file); + mJAREntry.swap(entryURL); + mCharsetHint = params.charset(); + + return true; +} diff --git a/modules/libjar/nsJARURI.h b/modules/libjar/nsJARURI.h index 380c12171ec..79d8eaefdef 100644 --- a/modules/libjar/nsJARURI.h +++ b/modules/libjar/nsJARURI.h @@ -13,6 +13,7 @@ #include "nsCOMPtr.h" #include "nsString.h" #include "nsINestedURI.h" +#include "nsIIPCSerializableURI.h" #define NS_THIS_JARURI_IMPL_CID \ { /* 9a55f629-730b-4d08-b75b-fa7d9570a691 */ \ @@ -36,9 +37,10 @@ class nsJARURI : public nsIJARURI, public nsISerializable, public nsIClassInfo, - public nsINestedURI + public nsINestedURI, + public nsIIPCSerializableURI { -public: +public: NS_DECL_ISUPPORTS NS_DECL_NSIURI NS_DECL_NSIURL @@ -46,6 +48,7 @@ public: NS_DECL_NSISERIALIZABLE NS_DECL_NSICLASSINFO NS_DECL_NSINESTEDURI + NS_DECL_NSIIPCSERIALIZABLEURI NS_DECLARE_STATIC_IID_ACCESSOR(NS_THIS_JARURI_IMPL_CID) diff --git a/modules/libjar/objs.mk b/modules/libjar/objs.mk index 04948e64a4d..b29e30f3c2a 100644 --- a/modules/libjar/objs.mk +++ b/modules/libjar/objs.mk @@ -15,6 +15,7 @@ MODULES_LIBJAR_LCPPSRCS = \ MODULES_LIBJAR_LEXPORTS = \ zipstruct.h \ + nsJARURI.h \ nsZipArchive.h \ $(NULL) diff --git a/netwerk/base/public/Makefile.in b/netwerk/base/public/Makefile.in index 57a136c6ed0..4f366eec708 100644 --- a/netwerk/base/public/Makefile.in +++ b/netwerk/base/public/Makefile.in @@ -52,7 +52,6 @@ XPIDLSRCS = \ nsIInputStreamPump.idl \ nsIInputStreamChannel.idl \ nsIIOService2.idl \ - nsIIPCSerializableObsolete.idl \ nsIMIMEInputStream.idl \ nsINetAddr.idl \ nsINetworkLinkService.idl \ diff --git a/netwerk/base/public/nsIIPCSerializableObsolete.idl b/netwerk/base/public/nsIIPCSerializableObsolete.idl deleted file mode 100644 index 0a04b564753..00000000000 --- a/netwerk/base/public/nsIIPCSerializableObsolete.idl +++ /dev/null @@ -1,24 +0,0 @@ -/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */ -/* vim: set sw=2 ts=8 et tw=80 ft=cpp : */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "nsISupports.idl" - -%{C++ -namespace IPC { -class Message; -} -%} - -[ptr] native ConstMessage(const IPC::Message); -[ptr] native Message(IPC::Message); -[ptr] native Iterator(void*); - -[noscript, uuid(1f605ac7-666b-471f-9864-1a21a95f11c4)] -interface nsIIPCSerializableObsolete : nsISupports -{ - [notxpcom] boolean read(in ConstMessage msg, in Iterator iter); - [notxpcom] void write(in Message msg); -}; diff --git a/netwerk/base/src/nsBufferedStreams.cpp b/netwerk/base/src/nsBufferedStreams.cpp index f54384d1901..50460c6e026 100644 --- a/netwerk/base/src/nsBufferedStreams.cpp +++ b/netwerk/base/src/nsBufferedStreams.cpp @@ -12,7 +12,6 @@ #include "nsNetCID.h" #include "nsIClassInfoImpl.h" #include "mozilla/ipc/InputStreamUtils.h" -#include "mozilla/ipc/IPCSerializableParams.h" #ifdef DEBUG_brendan # define METERING diff --git a/netwerk/base/src/nsFileStreams.cpp b/netwerk/base/src/nsFileStreams.cpp index c70b41bb91e..f7c9252efab 100644 --- a/netwerk/base/src/nsFileStreams.cpp +++ b/netwerk/base/src/nsFileStreams.cpp @@ -28,7 +28,7 @@ #include "nsReadLine.h" #include "nsNetUtil.h" #include "nsIClassInfoImpl.h" -#include "mozilla/ipc/IPCSerializableParams.h" +#include "mozilla/ipc/InputStreamUtils.h" #define NS_NO_INPUT_BUFFERING 1 // see http://bugzilla.mozilla.org/show_bug.cgi?id=41067 @@ -329,7 +329,6 @@ NS_INTERFACE_MAP_BEGIN(nsFileInputStream) NS_INTERFACE_MAP_ENTRY(nsIInputStream) NS_INTERFACE_MAP_ENTRY(nsIFileInputStream) NS_INTERFACE_MAP_ENTRY(nsILineInputStream) - NS_INTERFACE_MAP_ENTRY(nsIIPCSerializableObsolete) NS_INTERFACE_MAP_ENTRY(nsIIPCSerializableInputStream) NS_IMPL_QUERY_CLASSINFO(nsFileInputStream) NS_INTERFACE_MAP_END_INHERITING(nsFileStreamBase) @@ -473,47 +472,6 @@ nsFileInputStream::Seek(int32_t aWhence, int64_t aOffset) return nsFileStreamBase::Seek(aWhence, aOffset); } -bool -nsFileInputStream::Read(const IPC::Message *aMsg, void **aIter) -{ - using IPC::ReadParam; - - nsCString path; - bool followLinks; - int32_t flags; - if (!ReadParam(aMsg, aIter, &path) || - !ReadParam(aMsg, aIter, &followLinks) || - !ReadParam(aMsg, aIter, &flags)) - return false; - - nsCOMPtr file; - nsresult rv = NS_NewNativeLocalFile(path, followLinks, getter_AddRefs(file)); - if (NS_FAILED(rv)) - return false; - - // IO flags = -1 means readonly, and - // permissions are unimportant since we're reading - rv = Init(file, -1, -1, flags); - if (NS_FAILED(rv)) - return false; - - return true; -} - -void -nsFileInputStream::Write(IPC::Message *aMsg) -{ - using IPC::WriteParam; - - nsCString path; - mFile->GetNativePath(path); - WriteParam(aMsg, path); - bool followLinks; - mFile->GetFollowLinks(&followLinks); - WriteParam(aMsg, followLinks); - WriteParam(aMsg, mBehaviorFlags); -} - void nsFileInputStream::Serialize(InputStreamParams& aParams) { @@ -599,7 +557,6 @@ NS_INTERFACE_MAP_BEGIN(nsPartialFileInputStream) NS_INTERFACE_MAP_ENTRY(nsIInputStream) NS_INTERFACE_MAP_ENTRY(nsIPartialFileInputStream) NS_INTERFACE_MAP_ENTRY(nsILineInputStream) - NS_INTERFACE_MAP_ENTRY(nsIIPCSerializableObsolete) NS_INTERFACE_MAP_ENTRY(nsIIPCSerializableInputStream) NS_IMPL_QUERY_CLASSINFO(nsPartialFileInputStream) NS_INTERFACE_MAP_END_INHERITING(nsFileStreamBase) @@ -708,57 +665,6 @@ nsPartialFileInputStream::Seek(int32_t aWhence, int64_t aOffset) return rv; } -bool -nsPartialFileInputStream::Read(const IPC::Message *aMsg, void **aIter) -{ - using IPC::ReadParam; - - // Grab our members first. - uint64_t start; - uint64_t length; - if (!ReadParam(aMsg, aIter, &start) || - !ReadParam(aMsg, aIter, &length)) - return false; - - // Then run base class deserialization. - if (!nsFileInputStream::Read(aMsg, aIter)) - return false; - - // Set members. - mStart = start; - mLength = length; - - // XXX This isn't really correct, we should probably set this to whatever - // the sender had. However, it doesn't look like nsFileInputStream deals - // with sending a partially-consumed stream either, so... - mPosition = 0; - - // Mirror nsPartialFileInputStream::Init here. We can't call it directly - // because nsFileInputStream::Read() already calls the base class Init - // method. - return NS_SUCCEEDED(nsFileInputStream::Seek(NS_SEEK_SET, start)); -} - -void -nsPartialFileInputStream::Write(IPC::Message *aMsg) -{ - using IPC::WriteParam; - - // Write our members first. - WriteParam(aMsg, mStart); - WriteParam(aMsg, mLength); - - // XXX This isn't really correct, we should probably send this too. However, - // it doesn't look like nsFileInputStream deals with sending a - // partially-consumed stream either, so... - if (mPosition) { - NS_WARNING("No support for sending a partially-consumed input stream!"); - } - - // Now run base class serialization. - nsFileInputStream::Write(aMsg); -} - void nsPartialFileInputStream::Serialize(InputStreamParams& aParams) { @@ -1074,4 +980,4 @@ nsFileStream::GetLastModified(int64_t* _retval) return NS_OK; } -//////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// \ No newline at end of file diff --git a/netwerk/base/src/nsFileStreams.h b/netwerk/base/src/nsFileStreams.h index ad7bf8470b2..fe2aec0a453 100644 --- a/netwerk/base/src/nsFileStreams.h +++ b/netwerk/base/src/nsFileStreams.h @@ -18,7 +18,6 @@ #include "prlog.h" #include "prio.h" #include "nsIIPCSerializableInputStream.h" -#include "nsIIPCSerializableObsolete.h" template class nsLineBuffer; @@ -103,14 +102,12 @@ protected: class nsFileInputStream : public nsFileStreamBase, public nsIFileInputStream, public nsILineInputStream, - public nsIIPCSerializableObsolete, public nsIIPCSerializableInputStream { public: NS_DECL_ISUPPORTS_INHERITED NS_DECL_NSIFILEINPUTSTREAM NS_DECL_NSILINEINPUTSTREAM - NS_DECL_NSIIPCSERIALIZABLEOBSOLETE NS_DECL_NSIIPCSERIALIZABLEINPUTSTREAM NS_IMETHOD Close(); @@ -184,7 +181,6 @@ public: using nsFileInputStream::Init; NS_DECL_ISUPPORTS_INHERITED NS_DECL_NSIPARTIALFILEINPUTSTREAM - NS_DECL_NSIIPCSERIALIZABLEOBSOLETE NS_DECL_NSIIPCSERIALIZABLEINPUTSTREAM nsPartialFileInputStream() diff --git a/netwerk/base/src/nsMIMEInputStream.cpp b/netwerk/base/src/nsMIMEInputStream.cpp index d58da2d50ae..6a7d267a3c7 100644 --- a/netwerk/base/src/nsMIMEInputStream.cpp +++ b/netwerk/base/src/nsMIMEInputStream.cpp @@ -21,7 +21,6 @@ #include "nsIClassInfoImpl.h" #include "nsIIPCSerializableInputStream.h" #include "mozilla/ipc/InputStreamUtils.h" -#include "mozilla/ipc/IPCSerializableParams.h" using namespace mozilla::ipc; diff --git a/netwerk/base/src/nsSimpleNestedURI.cpp b/netwerk/base/src/nsSimpleNestedURI.cpp index 9a5822a8dac..fc9e45b0073 100644 --- a/netwerk/base/src/nsSimpleNestedURI.cpp +++ b/netwerk/base/src/nsSimpleNestedURI.cpp @@ -3,8 +3,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "IPCMessageUtils.h" -#include "mozilla/net/NeckoMessageUtils.h" +#include "base/basictypes.h" #include "nsSimpleNestedURI.h" #include "nsIObjectInputStream.h" @@ -55,32 +54,6 @@ nsSimpleNestedURI::Write(nsIObjectOutputStream* aStream) return rv; } -// nsIIPCSerializableObsolete - -bool -nsSimpleNestedURI::Read(const IPC::Message *aMsg, void **aIter) -{ - if (!nsSimpleURI::Read(aMsg, aIter)) - return false; - - IPC::URI uri; - if (!ReadParam(aMsg, aIter, &uri)) - return false; - - mInnerURI = uri; - - return true; -} - -void -nsSimpleNestedURI::Write(IPC::Message *aMsg) -{ - nsSimpleURI::Write(aMsg); - - IPC::URI uri(mInnerURI); - WriteParam(aMsg, uri); -} - // nsINestedURI NS_IMETHODIMP diff --git a/netwerk/base/src/nsSimpleNestedURI.h b/netwerk/base/src/nsSimpleNestedURI.h index e0122f807a4..28a2b5d4fa5 100644 --- a/netwerk/base/src/nsSimpleNestedURI.h +++ b/netwerk/base/src/nsSimpleNestedURI.h @@ -36,7 +36,6 @@ public: NS_DECL_ISUPPORTS_INHERITED NS_DECL_NSINESTEDURI - NS_DECL_NSIIPCSERIALIZABLEOBSOLETE // Overrides for various methods nsSimpleURI implements follow. diff --git a/netwerk/base/src/nsSimpleURI.cpp b/netwerk/base/src/nsSimpleURI.cpp index 041cb27df1c..cb7f1230113 100644 --- a/netwerk/base/src/nsSimpleURI.cpp +++ b/netwerk/base/src/nsSimpleURI.cpp @@ -20,6 +20,10 @@ #include "nsError.h" #include "nsIProgrammingLanguage.h" #include "mozilla/Util.h" // for DebugOnly +#include "nsIIPCSerializableURI.h" +#include "mozilla/ipc/URIUtils.h" + +using namespace mozilla::ipc; static NS_DEFINE_CID(kThisSimpleURIImplementationCID, NS_THIS_SIMPLEURI_IMPLEMENTATION_CID); @@ -41,8 +45,8 @@ nsSimpleURI::~nsSimpleURI() NS_IMPL_ADDREF(nsSimpleURI) NS_IMPL_RELEASE(nsSimpleURI) NS_INTERFACE_TABLE_HEAD(nsSimpleURI) -NS_INTERFACE_TABLE5(nsSimpleURI, nsIURI, nsISerializable, - nsIIPCSerializableObsolete, nsIClassInfo, nsIMutable) +NS_INTERFACE_TABLE5(nsSimpleURI, nsIURI, nsISerializable, nsIClassInfo, + nsIMutable, nsIIPCSerializableURI) NS_INTERFACE_TABLE_TO_MAP_SEGUE if (aIID.Equals(kThisSimpleURIImplementationCID)) foundInterface = static_cast(this); @@ -118,39 +122,49 @@ nsSimpleURI::Write(nsIObjectOutputStream* aStream) } //////////////////////////////////////////////////////////////////////////////// -// nsIIPCSerializableObsolete methods: - -bool -nsSimpleURI::Read(const IPC::Message *aMsg, void **aIter) -{ - bool isMutable, isRefValid; - if (!ReadParam(aMsg, aIter, &isMutable) || - !ReadParam(aMsg, aIter, &mScheme) || - !ReadParam(aMsg, aIter, &mPath) || - !ReadParam(aMsg, aIter, &isRefValid)) - return false; - - mMutable = isMutable; - mIsRefValid = isRefValid; - - if (mIsRefValid) { - return ReadParam(aMsg, aIter, &mRef); - } - mRef.Truncate(); // invariant: mRef should be empty when it's not valid - - return true; -} +// nsIIPCSerializableURI methods: void -nsSimpleURI::Write(IPC::Message *aMsg) +nsSimpleURI::Serialize(URIParams& aParams) { - WriteParam(aMsg, bool(mMutable)); - WriteParam(aMsg, mScheme); - WriteParam(aMsg, mPath); - WriteParam(aMsg, mIsRefValid); + SimpleURIParams params; + + params.scheme() = mScheme; + params.path() = mPath; if (mIsRefValid) { - WriteParam(aMsg, mRef); + params.ref() = mRef; } + else { + params.ref().SetIsVoid(true); + } + params.isMutable() = mMutable; + + aParams = params; +} + +bool +nsSimpleURI::Deserialize(const URIParams& aParams) +{ + if (aParams.type() != URIParams::TSimpleURIParams) { + NS_ERROR("Received unknown parameters from the other process!"); + return false; + } + + const SimpleURIParams& params = aParams.get_SimpleURIParams(); + + mScheme = params.scheme(); + mPath = params.path(); + if (params.ref().IsVoid()) { + mRef.Truncate(); + mIsRefValid = false; + } + else { + mRef = params.ref(); + mIsRefValid = true; + } + mMutable = params.isMutable(); + + return true; } //////////////////////////////////////////////////////////////////////////////// diff --git a/netwerk/base/src/nsSimpleURI.h b/netwerk/base/src/nsSimpleURI.h index efe82ecc248..1c996332c98 100644 --- a/netwerk/base/src/nsSimpleURI.h +++ b/netwerk/base/src/nsSimpleURI.h @@ -9,11 +9,11 @@ #include "nsIURL.h" #include "nsAgg.h" #include "nsISerializable.h" -#include "nsIIPCSerializableObsolete.h" #include "nsString.h" #include "nsIClassInfo.h" #include "nsIMutable.h" #include "nsISizeOf.h" +#include "nsIIPCSerializableURI.h" #define NS_THIS_SIMPLEURI_IMPLEMENTATION_CID \ { /* 0b9bb0c2-fee6-470b-b9b9-9fd9462b5e19 */ \ @@ -25,18 +25,18 @@ class nsSimpleURI : public nsIURI, public nsISerializable, - public nsIIPCSerializableObsolete, public nsIClassInfo, public nsIMutable, - public nsISizeOf + public nsISizeOf, + public nsIIPCSerializableURI { public: NS_DECL_ISUPPORTS NS_DECL_NSIURI NS_DECL_NSISERIALIZABLE - NS_DECL_NSIIPCSERIALIZABLEOBSOLETE NS_DECL_NSICLASSINFO NS_DECL_NSIMUTABLE + NS_DECL_NSIIPCSERIALIZABLEURI // nsSimpleURI methods: diff --git a/netwerk/base/src/nsStandardURL.cpp b/netwerk/base/src/nsStandardURL.cpp index 954d4c9c7e6..8c572894fad 100644 --- a/netwerk/base/src/nsStandardURL.cpp +++ b/netwerk/base/src/nsStandardURL.cpp @@ -23,6 +23,9 @@ #include "nsAutoPtr.h" #include "nsIProgrammingLanguage.h" #include "nsVoidArray.h" +#include "mozilla/ipc/URIUtils.h" + +using namespace mozilla::ipc; static NS_DEFINE_CID(kThisImplCID, NS_THIS_STANDARDURL_IMPL_CID); static NS_DEFINE_CID(kStandardURLCID, NS_STANDARDURL_CID); @@ -873,20 +876,6 @@ nsStandardURL::WriteSegment(nsIBinaryOutputStream *stream, const URLSegment &seg return NS_OK; } -bool -nsStandardURL::ReadSegment(const IPC::Message *aMsg, void **aIter, URLSegment &seg) -{ - return (IPC::ReadParam(aMsg, aIter, &seg.mPos) && - IPC::ReadParam(aMsg, aIter, &seg.mLen)); -} - -void -nsStandardURL::WriteSegment(IPC::Message *aMsg, const URLSegment &seg) -{ - IPC::WriteParam(aMsg, seg.mPos); - IPC::WriteParam(aMsg, seg.mLen); -} - /* static */ void nsStandardURL::PrefsChanged(nsIPrefBranch *prefs, const char *pref) { @@ -937,9 +926,9 @@ NS_INTERFACE_MAP_BEGIN(nsStandardURL) NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIFileURL, mSupportsFileURL) NS_INTERFACE_MAP_ENTRY(nsIStandardURL) NS_INTERFACE_MAP_ENTRY(nsISerializable) - NS_INTERFACE_MAP_ENTRY(nsIIPCSerializableObsolete) NS_INTERFACE_MAP_ENTRY(nsIClassInfo) NS_INTERFACE_MAP_ENTRY(nsIMutable) + NS_INTERFACE_MAP_ENTRY(nsIIPCSerializableURI) // see nsStandardURL::Equals if (aIID.Equals(kThisImplCID)) foundInterface = static_cast(this); @@ -2876,24 +2865,69 @@ nsStandardURL::Write(nsIObjectOutputStream *stream) } //--------------------------------------------------------------------------- -// nsStandardURL::nsIIPCSerializableObsolete +// nsStandardURL::nsIIPCSerializableURI //--------------------------------------------------------------------------- -bool -nsStandardURL::Read(const IPC::Message *aMsg, void **aIter) +inline +mozilla::ipc::StandardURLSegment +ToIPCSegment(const nsStandardURL::URLSegment& aSegment) +{ + return mozilla::ipc::StandardURLSegment(aSegment.mPos, aSegment.mLen); +} + +inline +nsStandardURL::URLSegment +FromIPCSegment(const mozilla::ipc::StandardURLSegment& aSegment) +{ + return nsStandardURL::URLSegment(aSegment.position(), aSegment.length()); +} + +void +nsStandardURL::Serialize(URIParams& aParams) +{ + StandardURLParams params; + + params.urlType() = mURLType; + params.port() = mPort; + params.defaultPort() = mDefaultPort; + params.spec() = mSpec; + params.scheme() = ToIPCSegment(mScheme); + params.authority() = ToIPCSegment(mAuthority); + params.username() = ToIPCSegment(mUsername); + params.password() = ToIPCSegment(mPassword); + params.host() = ToIPCSegment(mHost); + params.path() = ToIPCSegment(mPath); + params.filePath() = ToIPCSegment(mFilepath); + params.directory() = ToIPCSegment(mDirectory); + params.baseName() = ToIPCSegment(mBasename); + params.extension() = ToIPCSegment(mExtension); + params.query() = ToIPCSegment(mQuery); + params.ref() = ToIPCSegment(mRef); + params.originCharset() = mOriginCharset; + params.isMutable() = !!mMutable; + params.supportsFileURL() = !!mSupportsFileURL; + params.hostEncoding() = mHostEncoding; + // mSpecEncoding and mHostA are just caches that can be recovered as needed. + + aParams = params; +} + +bool +nsStandardURL::Deserialize(const URIParams& aParams) { - using IPC::ReadParam; - NS_PRECONDITION(!mHostA, "Shouldn't have cached ASCII host"); NS_PRECONDITION(mSpecEncoding == eEncoding_Unknown, "Shouldn't have spec encoding here"); NS_PRECONDITION(!mFile, "Shouldn't have cached file"); - - uint32_t urlType; - if (!ReadParam(aMsg, aIter, &urlType)) + + if (aParams.type() != URIParams::TStandardURLParams) { + NS_ERROR("Received unknown parameters from the other process!"); return false; - - mURLType = urlType; + } + + const StandardURLParams& params = aParams.get_StandardURLParams(); + + mURLType = params.urlType(); switch (mURLType) { case URLTYPE_STANDARD: mParser = net_GetStdURLParser(); @@ -2909,70 +2943,36 @@ nsStandardURL::Read(const IPC::Message *aMsg, void **aIter) return false; } - uint32_t hostEncoding; - bool isMutable, supportsFileURL; - if (!ReadParam(aMsg, aIter, &mPort) || - !ReadParam(aMsg, aIter, &mDefaultPort) || - !ReadParam(aMsg, aIter, &mSpec) || - !ReadSegment(aMsg, aIter, mScheme) || - !ReadSegment(aMsg, aIter, mAuthority) || - !ReadSegment(aMsg, aIter, mUsername) || - !ReadSegment(aMsg, aIter, mPassword) || - !ReadSegment(aMsg, aIter, mHost) || - !ReadSegment(aMsg, aIter, mPath) || - !ReadSegment(aMsg, aIter, mFilepath) || - !ReadSegment(aMsg, aIter, mDirectory) || - !ReadSegment(aMsg, aIter, mBasename) || - !ReadSegment(aMsg, aIter, mExtension) || - !ReadSegment(aMsg, aIter, mQuery) || - !ReadSegment(aMsg, aIter, mRef) || - !ReadParam(aMsg, aIter, &mOriginCharset) || - !ReadParam(aMsg, aIter, &isMutable) || - !ReadParam(aMsg, aIter, &supportsFileURL) || - !ReadParam(aMsg, aIter, &hostEncoding)) - return false; - - if (hostEncoding != eEncoding_ASCII && hostEncoding != eEncoding_UTF8) { + if (params.hostEncoding() != eEncoding_ASCII && + params.hostEncoding() != eEncoding_UTF8) { NS_WARNING("Unexpected host encoding"); return false; } - mHostEncoding = hostEncoding; - mMutable = isMutable; - mSupportsFileURL = supportsFileURL; + + mPort = params.port(); + mDefaultPort = params.defaultPort(); + mSpec = params.spec(); + mScheme = FromIPCSegment(params.scheme()); + mAuthority = FromIPCSegment(params.authority()); + mUsername = FromIPCSegment(params.username()); + mPassword = FromIPCSegment(params.password()); + mHost = FromIPCSegment(params.host()); + mPath = FromIPCSegment(params.path()); + mFilepath = FromIPCSegment(params.filePath()); + mDirectory = FromIPCSegment(params.directory()); + mBasename = FromIPCSegment(params.baseName()); + mExtension = FromIPCSegment(params.extension()); + mQuery = FromIPCSegment(params.query()); + mRef = FromIPCSegment(params.ref()); + mOriginCharset = params.originCharset(); + mMutable = params.isMutable(); + mSupportsFileURL = params.supportsFileURL(); + mHostEncoding = params.hostEncoding(); // mSpecEncoding and mHostA are just caches that can be recovered as needed. - return true; } -void -nsStandardURL::Write(IPC::Message *aMsg) -{ - using IPC::WriteParam; - - WriteParam(aMsg, mURLType); - WriteParam(aMsg, mPort); - WriteParam(aMsg, mDefaultPort); - WriteParam(aMsg, mSpec); - WriteSegment(aMsg, mScheme); - WriteSegment(aMsg, mAuthority); - WriteSegment(aMsg, mUsername); - WriteSegment(aMsg, mPassword); - WriteSegment(aMsg, mHost); - WriteSegment(aMsg, mPath); - WriteSegment(aMsg, mFilepath); - WriteSegment(aMsg, mDirectory); - WriteSegment(aMsg, mBasename); - WriteSegment(aMsg, mExtension); - WriteSegment(aMsg, mQuery); - WriteSegment(aMsg, mRef); - WriteParam(aMsg, mOriginCharset); - WriteParam(aMsg, bool(mMutable)); - WriteParam(aMsg, bool(mSupportsFileURL)); - WriteParam(aMsg, mHostEncoding); - // mSpecEncoding and mHostA are just caches that can be recovered as needed. -} - //---------------------------------------------------------------------------- // nsStandardURL::nsIClassInfo //---------------------------------------------------------------------------- @@ -3057,4 +3057,3 @@ size_t nsStandardURL::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const { return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf); } - diff --git a/netwerk/base/src/nsStandardURL.h b/netwerk/base/src/nsStandardURL.h index 42f674078c9..17ade39c290 100644 --- a/netwerk/base/src/nsStandardURL.h +++ b/netwerk/base/src/nsStandardURL.h @@ -10,7 +10,6 @@ #include "nsDependentString.h" #include "nsDependentSubstring.h" #include "nsISerializable.h" -#include "nsIIPCSerializableObsolete.h" #include "nsIFileURL.h" #include "nsIStandardURL.h" #include "nsIFile.h" @@ -24,6 +23,7 @@ #include "nsISizeOf.h" #include "prclist.h" #include "mozilla/Attributes.h" +#include "nsIIPCSerializableURI.h" #ifdef NS_BUILD_REFCNT_LOGGING #define DEBUG_DUMP_URLS_AT_SHUTDOWN @@ -42,9 +42,9 @@ class nsIPrefBranch; class nsStandardURL : public nsIFileURL , public nsIStandardURL , public nsISerializable - , public nsIIPCSerializableObsolete , public nsIClassInfo , public nsISizeOf + , public nsIIPCSerializableURI { public: NS_DECL_ISUPPORTS @@ -53,9 +53,9 @@ public: NS_DECL_NSIFILEURL NS_DECL_NSISTANDARDURL NS_DECL_NSISERIALIZABLE - NS_DECL_NSIIPCSERIALIZABLEOBSOLETE NS_DECL_NSICLASSINFO NS_DECL_NSIMUTABLE + NS_DECL_NSIIPCSERIALIZABLEURI // nsISizeOf virtual size_t SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const; @@ -227,10 +227,6 @@ private: nsresult ReadSegment(nsIBinaryInputStream *, URLSegment &); nsresult WriteSegment(nsIBinaryOutputStream *, const URLSegment &); - // ipc helper functions - bool ReadSegment(const IPC::Message *, void **, URLSegment &); - void WriteSegment(IPC::Message *, const URLSegment &); - static void PrefsChanged(nsIPrefBranch *prefs, const char *pref); // mSpec contains the normalized version of the URL spec (UTF-8 encoded). diff --git a/netwerk/cookie/CookieServiceChild.cpp b/netwerk/cookie/CookieServiceChild.cpp index 4986e5fc782..fd5ff89f92f 100644 --- a/netwerk/cookie/CookieServiceChild.cpp +++ b/netwerk/cookie/CookieServiceChild.cpp @@ -4,11 +4,15 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "mozilla/net/CookieServiceChild.h" + +#include "mozilla/ipc/URIUtils.h" #include "mozilla/net/NeckoChild.h" #include "nsIURI.h" #include "nsIPrefService.h" #include "nsIPrefBranch.h" +using namespace mozilla::ipc; + namespace mozilla { namespace net { @@ -108,9 +112,12 @@ CookieServiceChild::GetCookieStringInternal(nsIURI *aHostURI, if (RequireThirdPartyCheck()) mThirdPartyUtil->IsThirdPartyChannel(aChannel, aHostURI, &isForeign); + URIParams uriParams; + SerializeURI(aHostURI, uriParams); + // Synchronously call the parent. nsCAutoString result; - SendGetCookieString(IPC::URI(aHostURI), !!isForeign, aFromHttp, &result); + SendGetCookieString(uriParams, !!isForeign, aFromHttp, &result); if (!result.IsEmpty()) *aCookieString = ToNewCString(result); @@ -137,9 +144,12 @@ CookieServiceChild::SetCookieStringInternal(nsIURI *aHostURI, if (aServerTime) serverTime.Rebind(aServerTime); + URIParams uriParams; + SerializeURI(aHostURI, uriParams); + // Synchronously call the parent. - SendSetCookieString(IPC::URI(aHostURI), !!isForeign, - cookieString, serverTime, aFromHttp); + SendSetCookieString(uriParams, !!isForeign, cookieString, serverTime, + aFromHttp); return NS_OK; } diff --git a/netwerk/cookie/CookieServiceParent.cpp b/netwerk/cookie/CookieServiceParent.cpp index 75dffe31417..4d292e4de37 100644 --- a/netwerk/cookie/CookieServiceParent.cpp +++ b/netwerk/cookie/CookieServiceParent.cpp @@ -4,9 +4,13 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "mozilla/net/CookieServiceParent.h" + +#include "mozilla/ipc/URIUtils.h" #include "nsCookieService.h" #include "nsNetUtil.h" +using namespace mozilla::ipc; + namespace mozilla { namespace net { @@ -27,7 +31,7 @@ CookieServiceParent::~CookieServiceParent() } bool -CookieServiceParent::RecvGetCookieString(const IPC::URI& aHost, +CookieServiceParent::RecvGetCookieString(const URIParams& aHost, const bool& aIsForeign, const bool& aFromHttp, nsCString* aResult) @@ -37,7 +41,7 @@ CookieServiceParent::RecvGetCookieString(const IPC::URI& aHost, // Deserialize URI. Having a host URI is mandatory and should always be // provided by the child; thus we consider failure fatal. - nsCOMPtr hostURI(aHost); + nsCOMPtr hostURI = DeserializeURI(aHost); if (!hostURI) return false; @@ -47,7 +51,7 @@ CookieServiceParent::RecvGetCookieString(const IPC::URI& aHost, } bool -CookieServiceParent::RecvSetCookieString(const IPC::URI& aHost, +CookieServiceParent::RecvSetCookieString(const URIParams& aHost, const bool& aIsForeign, const nsCString& aCookieString, const nsCString& aServerTime, @@ -58,7 +62,7 @@ CookieServiceParent::RecvSetCookieString(const IPC::URI& aHost, // Deserialize URI. Having a host URI is mandatory and should always be // provided by the child; thus we consider failure fatal. - nsCOMPtr hostURI(aHost); + nsCOMPtr hostURI = DeserializeURI(aHost); if (!hostURI) return false; diff --git a/netwerk/cookie/CookieServiceParent.h b/netwerk/cookie/CookieServiceParent.h index e1d2840149e..c4246476553 100644 --- a/netwerk/cookie/CookieServiceParent.h +++ b/netwerk/cookie/CookieServiceParent.h @@ -21,12 +21,12 @@ public: virtual ~CookieServiceParent(); protected: - virtual bool RecvGetCookieString(const IPC::URI& aHost, + virtual bool RecvGetCookieString(const URIParams& aHost, const bool& aIsForeign, const bool& aFromHttp, nsCString* aResult); - virtual bool RecvSetCookieString(const IPC::URI& aHost, + virtual bool RecvSetCookieString(const URIParams& aHost, const bool& aIsForeign, const nsCString& aCookieString, const nsCString& aServerTime, diff --git a/netwerk/cookie/PCookieService.ipdl b/netwerk/cookie/PCookieService.ipdl index c52f1dae914..e2cacbe5eb8 100644 --- a/netwerk/cookie/PCookieService.ipdl +++ b/netwerk/cookie/PCookieService.ipdl @@ -6,10 +6,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ include protocol PNecko; - -include "mozilla/net/NeckoMessageUtils.h"; - -using IPC::URI; +include URIParams; namespace mozilla { namespace net { @@ -57,7 +54,7 @@ parent: * * @return the resulting cookie string. */ - sync GetCookieString(URI host, + sync GetCookieString(URIParams host, bool isForeign, bool fromHttp) returns (nsCString result); @@ -88,7 +85,7 @@ parent: * @see nsICookieService.setCookieStringFromHttp * @see mozIThirdPartyUtil.isThirdPartyChannel */ - SetCookieString(URI host, + SetCookieString(URIParams host, bool isForeign, nsCString cookieString, nsCString serverTime, diff --git a/netwerk/ipc/NeckoMessageUtils.h b/netwerk/ipc/NeckoMessageUtils.h index 9d044efa446..a356ddc0b41 100644 --- a/netwerk/ipc/NeckoMessageUtils.h +++ b/netwerk/ipc/NeckoMessageUtils.h @@ -8,141 +8,11 @@ #include "IPC/IPCMessageUtils.h" #include "nsStringGlue.h" -#include "nsIURI.h" -#include "nsIIPCSerializableObsolete.h" -#include "nsIClassInfo.h" -#include "nsComponentManagerUtils.h" -#include "nsNetUtil.h" -#include "nsStringStream.h" #include "prio.h" #include "mozilla/Util.h" // for DebugOnly -#include "SerializedLoadContext.h" namespace IPC { -// Since IPDL doesn't have any knowledge of pointers, there's no easy way to -// pass around nsIURI pointers. This is a very thin wrapper that IPDL can -// easily work with, allowing for conversion to and from an nsIURI pointer. - -class URI { - public: - URI() : mURI(nullptr) {} - URI(nsIURI* aURI) : mURI(aURI) {} - operator nsIURI*() const { return mURI.get(); } - - friend struct ParamTraits; - - private: - // Unimplemented - URI& operator=(URI&); - - nsCOMPtr mURI; -}; - -template<> -struct ParamTraits -{ - typedef URI paramType; - - static void Write(Message* aMsg, const paramType& aParam) - { - bool isNull = !aParam.mURI; - WriteParam(aMsg, isNull); - if (isNull) - return; - - nsCOMPtr serializable = - do_QueryInterface(aParam.mURI); - if (!serializable) { - nsCString scheme; - aParam.mURI->GetScheme(scheme); - if (!scheme.EqualsASCII("about:") && - !scheme.EqualsASCII("javascript:") && - !scheme.EqualsASCII("javascript")) - NS_WARNING("All IPDL URIs must be serializable or an allowed scheme"); - } - - bool isSerialized = !!serializable; - WriteParam(aMsg, isSerialized); - if (!isSerialized) { - nsCString spec, charset; - aParam.mURI->GetSpec(spec); - aParam.mURI->GetOriginCharset(charset); - WriteParam(aMsg, spec); - WriteParam(aMsg, charset); - return; - } - - nsCOMPtr classInfo = do_QueryInterface(aParam.mURI); - char cidStr[NSID_LENGTH]; - nsCID cid; - mozilla::DebugOnly rv = classInfo->GetClassIDNoAlloc(&cid); - NS_ABORT_IF_FALSE(NS_SUCCEEDED(rv), "All IPDL URIs must report a valid class ID"); - - cid.ToProvidedString(cidStr); - WriteParam(aMsg, nsCAutoString(cidStr)); - serializable->Write(aMsg); - } - - static bool Read(const Message* aMsg, void** aIter, paramType* aResult) - { - bool isNull; - if (!ReadParam(aMsg, aIter, &isNull)) - return false; - if (isNull) { - aResult->mURI = nullptr; - return true; - } - - bool isSerialized; - if (!ReadParam(aMsg, aIter, &isSerialized)) - return false; - if (!isSerialized) { - nsCString spec, charset; - if (!ReadParam(aMsg, aIter, &spec) || - !ReadParam(aMsg, aIter, &charset)) - return false; - - nsCOMPtr uri; - nsresult rv = NS_NewURI(getter_AddRefs(uri), spec, charset.get()); - if (NS_FAILED(rv)) - return false; - - uri.swap(aResult->mURI); - return true; - } - - nsCAutoString cidStr; - nsCID cid; - if (!ReadParam(aMsg, aIter, &cidStr) || - !cid.Parse(cidStr.get())) - return false; - - nsCOMPtr uri = do_CreateInstance(cid); - if (!uri) - return false; - nsCOMPtr serializable = do_QueryInterface(uri); - if (!serializable || !serializable->Read(aMsg, aIter)) - return false; - - uri.swap(aResult->mURI); - return true; - } - - static void Log(const paramType& aParam, std::wstring* aLog) - { - nsIURI* uri = aParam.mURI; - if (uri) { - nsCString spec; - uri->GetSpec(spec); - aLog->append(StringPrintf(L"[%s]", spec.get())); - } - else { - aLog->append(L"[]"); - } - } -}; - // nsIPermissionManager utilities struct Permission @@ -253,4 +123,4 @@ struct ParamTraits } -#endif // mozilla_net_NeckoMessageUtils_h \ No newline at end of file +#endif // mozilla_net_NeckoMessageUtils_h diff --git a/netwerk/protocol/about/nsAboutProtocolHandler.cpp b/netwerk/protocol/about/nsAboutProtocolHandler.cpp index 89e65c59345..adc14dc01c2 100644 --- a/netwerk/protocol/about/nsAboutProtocolHandler.cpp +++ b/netwerk/protocol/about/nsAboutProtocolHandler.cpp @@ -3,8 +3,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "IPCMessageUtils.h" -#include "mozilla/net/NeckoMessageUtils.h" +#include "base/basictypes.h" #include "nsAboutProtocolHandler.h" #include "nsIURI.h" @@ -292,31 +291,6 @@ nsNestedAboutURI::Write(nsIObjectOutputStream* aStream) return NS_OK; } -// nsIIPCSerializableObsolete -bool -nsNestedAboutURI::Read(const IPC::Message *aMsg, void **aIter) -{ - if (!nsSimpleNestedURI::Read(aMsg, aIter)) - return false; - - IPC::URI uri; - if (!ReadParam(aMsg, aIter, &uri)) - return false; - - mBaseURI = uri; - - return true; -} - -void -nsNestedAboutURI::Write(IPC::Message *aMsg) -{ - nsSimpleNestedURI::Write(aMsg); - - IPC::URI uri(mBaseURI); - WriteParam(aMsg, uri); -} - // nsSimpleURI /* virtual */ nsSimpleURI* nsNestedAboutURI::StartClone(nsSimpleURI::RefHandlingEnum aRefHandlingMode) diff --git a/netwerk/protocol/about/nsAboutProtocolHandler.h b/netwerk/protocol/about/nsAboutProtocolHandler.h index 0fa9d85013f..9171e0dc2e7 100644 --- a/netwerk/protocol/about/nsAboutProtocolHandler.h +++ b/netwerk/protocol/about/nsAboutProtocolHandler.h @@ -12,6 +12,7 @@ class nsCString; class nsIAboutModule; +class nsIURI; class nsAboutProtocolHandler : public nsIProtocolHandler { @@ -45,8 +46,6 @@ private: // Class to allow us to propagate the base URI to about:blank correctly class nsNestedAboutURI : public nsSimpleNestedURI { public: - NS_DECL_NSIIPCSERIALIZABLEOBSOLETE - nsNestedAboutURI(nsIURI* aInnerURI, nsIURI* aBaseURI) : nsSimpleNestedURI(aInnerURI) , mBaseURI(aBaseURI) diff --git a/netwerk/protocol/ftp/FTPChannelChild.cpp b/netwerk/protocol/ftp/FTPChannelChild.cpp index 73f940931d6..44e2f4045c6 100644 --- a/netwerk/protocol/ftp/FTPChannelChild.cpp +++ b/netwerk/protocol/ftp/FTPChannelChild.cpp @@ -17,6 +17,7 @@ #include "nsCDefaultURIFixup.h" #include "base/compiler_specific.h" #include "mozilla/ipc/InputStreamUtils.h" +#include "mozilla/ipc/URIUtils.h" using namespace mozilla::ipc; @@ -163,10 +164,13 @@ FTPChannelChild::AsyncOpen(::nsIStreamListener* listener, nsISupports* aContext) if (mLoadGroup) mLoadGroup->AddRequest(this, nullptr); + URIParams uri; + SerializeURI(nsBaseChannel::URI(), uri); + OptionalInputStreamParams uploadStream; SerializeInputStream(mUploadStream, uploadStream); - SendAsyncOpen(nsBaseChannel::URI(), mStartPos, mEntityID, uploadStream, + SendAsyncOpen(uri, mStartPos, mEntityID, uploadStream, IPC::SerializedLoadContext(this)); // The socket transport layer in the chrome process now has a logical ref to @@ -204,7 +208,7 @@ class FTPStartRequestEvent : public ChannelEvent public: FTPStartRequestEvent(FTPChannelChild* aChild, const int32_t& aContentLength, const nsCString& aContentType, const PRTime& aLastModified, - const nsCString& aEntityID, const IPC::URI& aURI) + const nsCString& aEntityID, const URIParams& aURI) : mChild(aChild), mContentLength(aContentLength), mContentType(aContentType), mLastModified(aLastModified), mEntityID(aEntityID), mURI(aURI) {} void Run() { mChild->DoOnStartRequest(mContentLength, mContentType, @@ -215,7 +219,7 @@ class FTPStartRequestEvent : public ChannelEvent nsCString mContentType; PRTime mLastModified; nsCString mEntityID; - IPC::URI mURI; + URIParams mURI; }; bool @@ -223,7 +227,7 @@ FTPChannelChild::RecvOnStartRequest(const int32_t& aContentLength, const nsCString& aContentType, const PRTime& aLastModified, const nsCString& aEntityID, - const IPC::URI& aURI) + const URIParams& aURI) { if (mEventQ.ShouldEnqueue()) { mEventQ.Enqueue(new FTPStartRequestEvent(this, aContentLength, aContentType, @@ -240,7 +244,7 @@ FTPChannelChild::DoOnStartRequest(const int32_t& aContentLength, const nsCString& aContentType, const PRTime& aLastModified, const nsCString& aEntityID, - const IPC::URI& aURI) + const URIParams& aURI) { LOG(("FTPChannelChild::RecvOnStartRequest [this=%x]\n", this)); @@ -250,7 +254,7 @@ FTPChannelChild::DoOnStartRequest(const int32_t& aContentLength, mEntityID = aEntityID; nsCString spec; - nsCOMPtr uri(aURI); + nsCOMPtr uri = DeserializeURI(aURI); uri->GetSpec(spec); nsBaseChannel::URI()->SetSpec(spec); diff --git a/netwerk/protocol/ftp/FTPChannelChild.h b/netwerk/protocol/ftp/FTPChannelChild.h index 808c823e2a9..e5fd9d178fa 100644 --- a/netwerk/protocol/ftp/FTPChannelChild.h +++ b/netwerk/protocol/ftp/FTPChannelChild.h @@ -72,7 +72,7 @@ protected: const nsCString& aContentType, const PRTime& aLastModified, const nsCString& aEntityID, - const IPC::URI& aURI) MOZ_OVERRIDE; + const URIParams& aURI) MOZ_OVERRIDE; bool RecvOnDataAvailable(const nsCString& data, const uint32_t& offset, const uint32_t& count) MOZ_OVERRIDE; @@ -84,7 +84,7 @@ protected: const nsCString& aContentType, const PRTime& aLastModified, const nsCString& aEntityID, - const IPC::URI& aURI); + const URIParams& aURI); void DoOnDataAvailable(const nsCString& data, const uint32_t& offset, const uint32_t& count); diff --git a/netwerk/protocol/ftp/FTPChannelParent.cpp b/netwerk/protocol/ftp/FTPChannelParent.cpp index 5329f7123fc..1fa01d4ffe2 100644 --- a/netwerk/protocol/ftp/FTPChannelParent.cpp +++ b/netwerk/protocol/ftp/FTPChannelParent.cpp @@ -13,6 +13,7 @@ #include "nsFtpProtocolHandler.h" #include "mozilla/LoadContext.h" #include "mozilla/ipc/InputStreamUtils.h" +#include "mozilla/ipc/URIUtils.h" using namespace mozilla::ipc; @@ -58,13 +59,15 @@ NS_IMPL_ISUPPORTS4(FTPChannelParent, //----------------------------------------------------------------------------- bool -FTPChannelParent::RecvAsyncOpen(const IPC::URI& aURI, +FTPChannelParent::RecvAsyncOpen(const URIParams& aURI, const uint64_t& aStartPos, const nsCString& aEntityID, const OptionalInputStreamParams& aUploadStream, const IPC::SerializedLoadContext& loadContext) { - nsCOMPtr uri(aURI); + nsCOMPtr uri = DeserializeURI(aURI); + if (!uri) + return false; #ifdef DEBUG nsCString uriSpec; @@ -167,8 +170,11 @@ FTPChannelParent::OnStartRequest(nsIRequest* aRequest, nsISupports* aContext) PRTime lastModified; chan->GetLastModifiedTime(&lastModified); + URIParams uri; + SerializeURI(chan->URI(), uri); + if (mIPCClosed || !SendOnStartRequest(aContentLength, contentType, - lastModified, entityID, chan->URI())) { + lastModified, entityID, uri)) { return NS_ERROR_UNEXPECTED; } diff --git a/netwerk/protocol/ftp/FTPChannelParent.h b/netwerk/protocol/ftp/FTPChannelParent.h index 6ffd9910ad1..39e5fff7df0 100644 --- a/netwerk/protocol/ftp/FTPChannelParent.h +++ b/netwerk/protocol/ftp/FTPChannelParent.h @@ -34,7 +34,7 @@ public: virtual ~FTPChannelParent(); protected: - virtual bool RecvAsyncOpen(const IPC::URI& uri, + virtual bool RecvAsyncOpen(const URIParams& uri, const uint64_t& startPos, const nsCString& entityID, const OptionalInputStreamParams& uploadStream, diff --git a/netwerk/protocol/ftp/PFTPChannel.ipdl b/netwerk/protocol/ftp/PFTPChannel.ipdl index 47fc8ebd404..2fa9af62aca 100644 --- a/netwerk/protocol/ftp/PFTPChannel.ipdl +++ b/netwerk/protocol/ftp/PFTPChannel.ipdl @@ -6,11 +6,11 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ include protocol PNecko; +include InputStreamParams; +include URIParams; -include "mozilla/net/NeckoMessageUtils.h"; -include IPCSerializableParams; +include "SerializedLoadContext.h"; -using IPC::URI; using IPC::SerializedLoadContext; using PRTime; @@ -24,7 +24,7 @@ async protocol PFTPChannel parent: __delete__(); - AsyncOpen(URI uri, + AsyncOpen(URIParams uri, uint64_t startPos, nsCString entityID, OptionalInputStreamParams uploadStream, @@ -37,7 +37,7 @@ parent: child: OnStartRequest(int32_t aContentLength, nsCString aContentType, - PRTime aLastModified, nsCString aEntityID, URI aURI); + PRTime aLastModified, nsCString aEntityID, URIParams aURI); OnDataAvailable(nsCString data, uint32_t offset, uint32_t count); OnStopRequest(nsresult statusCode); FailedAsyncOpen(nsresult statusCode); diff --git a/netwerk/protocol/http/HttpChannelChild.cpp b/netwerk/protocol/http/HttpChannelChild.cpp index 924177fbd5d..5d82f7e5708 100644 --- a/netwerk/protocol/http/HttpChannelChild.cpp +++ b/netwerk/protocol/http/HttpChannelChild.cpp @@ -17,7 +17,9 @@ #include "nsSerializationHelper.h" #include "base/compiler_specific.h" #include "mozilla/ipc/InputStreamUtils.h" +#include "mozilla/ipc/URIUtils.h" +using namespace mozilla::dom; using namespace mozilla::ipc; namespace mozilla { @@ -655,7 +657,7 @@ class Redirect1Event : public ChannelEvent public: Redirect1Event(HttpChannelChild* child, const uint32_t& newChannelId, - const IPC::URI& newURI, + const URIParams& newURI, const uint32_t& redirectFlags, const nsHttpResponseHead& responseHead) : mChild(child) @@ -672,14 +674,14 @@ class Redirect1Event : public ChannelEvent private: HttpChannelChild* mChild; uint32_t mNewChannelId; - IPC::URI mNewURI; + URIParams mNewURI; uint32_t mRedirectFlags; nsHttpResponseHead mResponseHead; }; bool HttpChannelChild::RecvRedirect1Begin(const uint32_t& newChannelId, - const URI& newUri, + const URIParams& newUri, const uint32_t& redirectFlags, const nsHttpResponseHead& responseHead) { @@ -694,7 +696,7 @@ HttpChannelChild::RecvRedirect1Begin(const uint32_t& newChannelId, void HttpChannelChild::Redirect1Begin(const uint32_t& newChannelId, - const IPC::URI& newURI, + const URIParams& newUri, const uint32_t& redirectFlags, const nsHttpResponseHead& responseHead) { @@ -708,7 +710,7 @@ HttpChannelChild::Redirect1Begin(const uint32_t& newChannelId, return; } - nsCOMPtr uri(newURI); + nsCOMPtr uri = DeserializeURI(newUri); nsCOMPtr newChannel; rv = ioService->NewChannelFromURI(uri, getter_AddRefs(newChannel)); @@ -1037,11 +1039,18 @@ HttpChannelChild::AsyncOpen(nsIStreamListener *listener, nsISupports *aContext) gNeckoChild->SendPHttpChannelConstructor(this, tabChild); + URIParams uri; + SerializeURI(mURI, uri); + + OptionalURIParams originalURI, documentURI, referrer; + SerializeURI(mOriginalURI, originalURI); + SerializeURI(mDocumentURI, documentURI); + SerializeURI(mReferrer, referrer); + OptionalInputStreamParams uploadStream; SerializeInputStream(mUploadStream, uploadStream); - SendAsyncOpen(IPC::URI(mURI), IPC::URI(mOriginalURI), - IPC::URI(mDocumentURI), IPC::URI(mReferrer), mLoadFlags, + SendAsyncOpen(uri, originalURI, documentURI, referrer, mLoadFlags, mClientSetRequestHeaders, mRequestHead.Method(), uploadStream, mUploadStreamHasHeaders, mPriority, mRedirectionLimit, mAllowPipelining, mForceAllowThirdPartyCookie, mSendResumeAt, diff --git a/netwerk/protocol/http/HttpChannelChild.h b/netwerk/protocol/http/HttpChannelChild.h index 2e71b0a5a69..3bc2fb77b8d 100644 --- a/netwerk/protocol/http/HttpChannelChild.h +++ b/netwerk/protocol/http/HttpChannelChild.h @@ -110,7 +110,7 @@ protected: bool RecvOnStatus(const nsresult& status); bool RecvFailedAsyncOpen(const nsresult& status); bool RecvRedirect1Begin(const uint32_t& newChannel, - const URI& newURI, + const URIParams& newURI, const uint32_t& redirectFlags, const nsHttpResponseHead& responseHead); bool RecvRedirect3Complete(); @@ -165,7 +165,7 @@ private: void FailedAsyncOpen(const nsresult& status); void HandleAsyncAbort(); void Redirect1Begin(const uint32_t& newChannelId, - const URI& newUri, + const URIParams& newUri, const uint32_t& redirectFlags, const nsHttpResponseHead& responseHead); void Redirect3Complete(); diff --git a/netwerk/protocol/http/HttpChannelParent.cpp b/netwerk/protocol/http/HttpChannelParent.cpp index 152dca3d2ba..0a9ccc4ec47 100644 --- a/netwerk/protocol/http/HttpChannelParent.cpp +++ b/netwerk/protocol/http/HttpChannelParent.cpp @@ -25,7 +25,9 @@ #include "mozilla/LoadContext.h" #include "prinit.h" #include "mozilla/ipc/InputStreamUtils.h" +#include "mozilla/ipc/URIUtils.h" +using namespace mozilla::dom; using namespace mozilla::ipc; namespace mozilla { @@ -104,10 +106,10 @@ HttpChannelParent::GetInterface(const nsIID& aIID, void **result) //----------------------------------------------------------------------------- bool -HttpChannelParent::RecvAsyncOpen(const IPC::URI& aURI, - const IPC::URI& aOriginalURI, - const IPC::URI& aDocURI, - const IPC::URI& aReferrerURI, +HttpChannelParent::RecvAsyncOpen(const URIParams& aURI, + const OptionalURIParams& aOriginalURI, + const OptionalURIParams& aDocURI, + const OptionalURIParams& aReferrerURI, const uint32_t& loadFlags, const RequestHeaderTuples& requestHeaders, const nsHttpAtom& requestMethod, @@ -125,10 +127,10 @@ HttpChannelParent::RecvAsyncOpen(const IPC::URI& aURI, const bool& allowSpdy, const IPC::SerializedLoadContext& loadContext) { - nsCOMPtr uri(aURI); - nsCOMPtr originalUri(aOriginalURI); - nsCOMPtr docUri(aDocURI); - nsCOMPtr referrerUri(aReferrerURI); + nsCOMPtr uri = DeserializeURI(aURI); + nsCOMPtr originalUri = DeserializeURI(aOriginalURI); + nsCOMPtr docUri = DeserializeURI(aDocURI); + nsCOMPtr referrerUri = DeserializeURI(aReferrerURI); nsCString uriSpec; uri->GetSpec(uriSpec); @@ -563,11 +565,12 @@ HttpChannelParent::StartRedirect(uint32_t newChannelId, nsCOMPtr newURI; newChannel->GetURI(getter_AddRefs(newURI)); + URIParams uriParams; + SerializeURI(newURI, uriParams); + nsHttpChannel *httpChan = static_cast(mChannel.get()); nsHttpResponseHead *responseHead = httpChan->GetResponseHead(); - bool result = SendRedirect1Begin(newChannelId, - IPC::URI(newURI), - redirectFlags, + bool result = SendRedirect1Begin(newChannelId, uriParams, redirectFlags, responseHead ? *responseHead : nsHttpResponseHead()); if (!result) { diff --git a/netwerk/protocol/http/HttpChannelParent.h b/netwerk/protocol/http/HttpChannelParent.h index 94d6ec84c96..e869d63afcd 100644 --- a/netwerk/protocol/http/HttpChannelParent.h +++ b/netwerk/protocol/http/HttpChannelParent.h @@ -17,8 +17,6 @@ #include "nsITabParent.h" #include "nsHttpChannel.h" -using namespace mozilla::dom; - class nsICacheEntryDescriptor; class nsIAssociatedContentSecurity; @@ -41,14 +39,14 @@ public: NS_DECL_NSIPROGRESSEVENTSINK NS_DECL_NSIINTERFACEREQUESTOR - HttpChannelParent(PBrowserParent* iframeEmbedding); + HttpChannelParent(mozilla::dom::PBrowserParent* iframeEmbedding); virtual ~HttpChannelParent(); protected: - virtual bool RecvAsyncOpen(const IPC::URI& uri, - const IPC::URI& originalUri, - const IPC::URI& docUri, - const IPC::URI& referrerUri, + virtual bool RecvAsyncOpen(const URIParams& uri, + const OptionalURIParams& originalUri, + const OptionalURIParams& docUri, + const OptionalURIParams& referrerUri, const uint32_t& loadFlags, const RequestHeaderTuples& requestHeaders, const nsHttpAtom& requestMethod, diff --git a/netwerk/protocol/http/HttpChannelParentListener.h b/netwerk/protocol/http/HttpChannelParentListener.h index 09340b1ba00..fff171ea348 100644 --- a/netwerk/protocol/http/HttpChannelParentListener.h +++ b/netwerk/protocol/http/HttpChannelParentListener.h @@ -17,8 +17,6 @@ #include "nsIRedirectResultListener.h" #include "nsIProgressEventSink.h" -using namespace mozilla::dom; - class nsICacheEntryDescriptor; namespace mozilla { diff --git a/netwerk/protocol/http/PHttpChannel.ipdl b/netwerk/protocol/http/PHttpChannel.ipdl index 404477f64d1..c13c9690f68 100644 --- a/netwerk/protocol/http/PHttpChannel.ipdl +++ b/netwerk/protocol/http/PHttpChannel.ipdl @@ -6,18 +6,18 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ include protocol PNecko; +include InputStreamParams; +include URIParams; include "mozilla/net/PHttpChannelParams.h"; include "mozilla/net/NeckoMessageUtils.h"; include "prio.h"; - -include IPCSerializableParams; +include "SerializedLoadContext.h"; using RequestHeaderTuples; using nsHttpHeaderArray; using nsHttpResponseHead; using nsHttpAtom; -using IPC::URI; using IPC::SerializedLoadContext; using PRNetAddr; @@ -30,13 +30,13 @@ protocol PHttpChannel manager PNecko; parent: - AsyncOpen(URI uri, + AsyncOpen(URIParams uri, // - TODO: bug 571161: unclear if any HTTP channel clients ever // set originalURI != uri (about:credits?); also not clear if // chrome channel would ever need to know. Get rid of next arg? - URI original, - URI doc, - URI referrer, + OptionalURIParams original, + OptionalURIParams doc, + OptionalURIParams referrer, uint32_t loadFlags, RequestHeaderTuples requestHeaders, nsHttpAtom requestMethod, @@ -130,7 +130,7 @@ child: // Called to initiate content channel redirect, starts talking to sinks // on the content process and reports result via Redirect2Verify above Redirect1Begin(uint32_t newChannelId, - URI newUri, + URIParams newUri, uint32_t redirectFlags, nsHttpResponseHead responseHead); diff --git a/netwerk/protocol/websocket/PWebSocket.ipdl b/netwerk/protocol/websocket/PWebSocket.ipdl index 7b37290a829..8735f3bf80b 100644 --- a/netwerk/protocol/websocket/PWebSocket.ipdl +++ b/netwerk/protocol/websocket/PWebSocket.ipdl @@ -7,11 +7,10 @@ include protocol PNecko; include protocol PBrowser; +include InputStreamParams; +include URIParams; -include "mozilla/net/NeckoMessageUtils.h"; -include IPCSerializableParams; - -using IPC::URI; +include "SerializedLoadContext.h"; using IPC::SerializedLoadContext; namespace mozilla { @@ -23,7 +22,7 @@ async protocol PWebSocket parent: // Forwarded methods corresponding to methods on nsIWebSocketChannel - AsyncOpen(URI aURI, + AsyncOpen(URIParams aURI, nsCString aOrigin, nsCString aProtocol, bool aSecure, diff --git a/netwerk/protocol/websocket/WebSocketChannelChild.cpp b/netwerk/protocol/websocket/WebSocketChannelChild.cpp index 96bd0824b81..6e4baa678d2 100644 --- a/netwerk/protocol/websocket/WebSocketChannelChild.cpp +++ b/netwerk/protocol/websocket/WebSocketChannelChild.cpp @@ -12,6 +12,7 @@ #include "nsILoadContext.h" #include "nsNetUtil.h" #include "mozilla/ipc/InputStreamUtils.h" +#include "mozilla/ipc/URIUtils.h" using namespace mozilla::ipc; @@ -331,11 +332,14 @@ WebSocketChannelChild::AsyncOpen(nsIURI *aURI, tabChild = static_cast(iTabChild.get()); } + URIParams uri; + SerializeURI(aURI, uri); + // Corresponding release in DeallocPWebSocket AddIPDLReference(); gNeckoChild->SendPWebSocketConstructor(this, tabChild); - if (!SendAsyncOpen(aURI, nsCString(aOrigin), mProtocol, mEncrypted, + if (!SendAsyncOpen(uri, nsCString(aOrigin), mProtocol, mEncrypted, IPC::SerializedLoadContext(this))) return NS_ERROR_UNEXPECTED; diff --git a/netwerk/protocol/websocket/WebSocketChannelParent.cpp b/netwerk/protocol/websocket/WebSocketChannelParent.cpp index 6769f998209..819e9a458dc 100644 --- a/netwerk/protocol/websocket/WebSocketChannelParent.cpp +++ b/netwerk/protocol/websocket/WebSocketChannelParent.cpp @@ -9,6 +9,7 @@ #include "nsIAuthPromptProvider.h" #include "mozilla/LoadContext.h" #include "mozilla/ipc/InputStreamUtils.h" +#include "mozilla/ipc/URIUtils.h" using namespace mozilla::ipc; @@ -43,14 +44,17 @@ WebSocketChannelParent::RecvDeleteSelf() } bool -WebSocketChannelParent::RecvAsyncOpen(const IPC::URI& aURI, +WebSocketChannelParent::RecvAsyncOpen(const URIParams& aURI, const nsCString& aOrigin, const nsCString& aProtocol, const bool& aSecure, const IPC::SerializedLoadContext& loadContext) { LOG(("WebSocketChannelParent::RecvAsyncOpen() %p\n", this)); + nsresult rv; + nsCOMPtr uri; + if (aSecure) { mChannel = do_CreateInstance("@mozilla.org/network/protocol;1?name=wss", &rv); @@ -72,7 +76,13 @@ WebSocketChannelParent::RecvAsyncOpen(const IPC::URI& aURI, if (NS_FAILED(rv)) goto fail; - rv = mChannel->AsyncOpen(aURI, aOrigin, this, nullptr); + uri = DeserializeURI(aURI); + if (!uri) { + rv = NS_ERROR_FAILURE; + goto fail; + } + + rv = mChannel->AsyncOpen(uri, aOrigin, this, nullptr); if (NS_FAILED(rv)) goto fail; diff --git a/netwerk/protocol/websocket/WebSocketChannelParent.h b/netwerk/protocol/websocket/WebSocketChannelParent.h index 6555d3b3723..fa70ad72a35 100644 --- a/netwerk/protocol/websocket/WebSocketChannelParent.h +++ b/netwerk/protocol/websocket/WebSocketChannelParent.h @@ -8,6 +8,7 @@ #define mozilla_net_WebSocketChannelParent_h #include "mozilla/net/PWebSocketParent.h" +#include "nsIInterfaceRequestor.h" #include "nsIWebSocketListener.h" #include "nsIWebSocketChannel.h" #include "nsILoadContext.h" @@ -31,7 +32,7 @@ class WebSocketChannelParent : public PWebSocketParent, WebSocketChannelParent(nsIAuthPromptProvider* aAuthProvider); private: - bool RecvAsyncOpen(const IPC::URI& aURI, + bool RecvAsyncOpen(const URIParams& aURI, const nsCString& aOrigin, const nsCString& aProtocol, const bool& aSecure, diff --git a/netwerk/protocol/wyciwyg/PWyciwygChannel.ipdl b/netwerk/protocol/wyciwyg/PWyciwygChannel.ipdl index 33776ea041b..5f73f945b4c 100644 --- a/netwerk/protocol/wyciwyg/PWyciwygChannel.ipdl +++ b/netwerk/protocol/wyciwyg/PWyciwygChannel.ipdl @@ -3,10 +3,10 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ include protocol PNecko; +include URIParams; -include "mozilla/net/NeckoMessageUtils.h"; +include "SerializedLoadContext.h"; -using IPC::URI; using IPC::SerializedLoadContext; namespace mozilla { @@ -20,8 +20,8 @@ protocol PWyciwygChannel parent: __delete__(); - Init(URI uri); - AsyncOpen(URI originalURI, + Init(URIParams uri); + AsyncOpen(URIParams originalURI, uint32_t loadFlags, SerializedLoadContext loadContext); diff --git a/netwerk/protocol/wyciwyg/WyciwygChannelChild.cpp b/netwerk/protocol/wyciwyg/WyciwygChannelChild.cpp index 304dc4ddd58..6f98b448a72 100644 --- a/netwerk/protocol/wyciwyg/WyciwygChannelChild.cpp +++ b/netwerk/protocol/wyciwyg/WyciwygChannelChild.cpp @@ -14,6 +14,9 @@ #include "nsISerializable.h" #include "nsSerializationHelper.h" #include "nsILoadContext.h" +#include "mozilla/ipc/URIUtils.h" + +using namespace mozilla::ipc; namespace mozilla { namespace net { @@ -69,7 +72,10 @@ WyciwygChannelChild::Init(nsIURI* uri) mURI = uri; mOriginalURI = uri; - SendInit(IPC::URI(mURI)); + URIParams serializedUri; + SerializeURI(uri, serializedUri); + + SendInit(serializedUri); return NS_OK; } @@ -562,8 +568,10 @@ WyciwygChannelChild::AsyncOpen(nsIStreamListener *aListener, nsISupports *aConte if (mLoadGroup) mLoadGroup->AddRequest(this, nullptr); - SendAsyncOpen(IPC::URI(mOriginalURI), mLoadFlags, - IPC::SerializedLoadContext(this)); + URIParams originalURI; + SerializeURI(mOriginalURI, originalURI); + + SendAsyncOpen(originalURI, mLoadFlags, IPC::SerializedLoadContext(this)); mState = WCC_OPENED; diff --git a/netwerk/protocol/wyciwyg/WyciwygChannelParent.cpp b/netwerk/protocol/wyciwyg/WyciwygChannelParent.cpp index a2b5802ed3c..b06f67c939d 100644 --- a/netwerk/protocol/wyciwyg/WyciwygChannelParent.cpp +++ b/netwerk/protocol/wyciwyg/WyciwygChannelParent.cpp @@ -12,6 +12,9 @@ #include "nsISerializable.h" #include "nsSerializationHelper.h" #include "mozilla/LoadContext.h" +#include "mozilla/ipc/URIUtils.h" + +using namespace mozilla::ipc; namespace mozilla { namespace net { @@ -51,11 +54,13 @@ NS_IMPL_ISUPPORTS3(WyciwygChannelParent, //----------------------------------------------------------------------------- bool -WyciwygChannelParent::RecvInit(const IPC::URI& aURI) +WyciwygChannelParent::RecvInit(const URIParams& aURI) { nsresult rv; - nsCOMPtr uri(aURI); + nsCOMPtr uri = DeserializeURI(aURI); + if (!uri) + return false; nsCString uriSpec; uri->GetSpec(uriSpec); @@ -79,11 +84,13 @@ WyciwygChannelParent::RecvInit(const IPC::URI& aURI) } bool -WyciwygChannelParent::RecvAsyncOpen(const IPC::URI& aOriginal, +WyciwygChannelParent::RecvAsyncOpen(const URIParams& aOriginal, const uint32_t& aLoadFlags, const IPC::SerializedLoadContext& loadContext) { - nsCOMPtr original(aOriginal); + nsCOMPtr original = DeserializeURI(aOriginal); + if (!original) + return false; LOG(("WyciwygChannelParent RecvAsyncOpen [this=%x]\n", this)); diff --git a/netwerk/protocol/wyciwyg/WyciwygChannelParent.h b/netwerk/protocol/wyciwyg/WyciwygChannelParent.h index 9c12354356d..819c31031f8 100644 --- a/netwerk/protocol/wyciwyg/WyciwygChannelParent.h +++ b/netwerk/protocol/wyciwyg/WyciwygChannelParent.h @@ -30,8 +30,8 @@ public: virtual ~WyciwygChannelParent(); protected: - virtual bool RecvInit(const IPC::URI& uri); - virtual bool RecvAsyncOpen(const IPC::URI& original, + virtual bool RecvInit(const URIParams& uri); + virtual bool RecvAsyncOpen(const URIParams& original, const uint32_t& loadFlags, const IPC::SerializedLoadContext& loadContext); virtual bool RecvWriteToCacheEntry(const nsString& data); diff --git a/toolkit/components/places/History.cpp b/toolkit/components/places/History.cpp index 89227766702..8c0f7e4c546 100644 --- a/toolkit/components/places/History.cpp +++ b/toolkit/components/places/History.cpp @@ -28,11 +28,13 @@ #include "nsContentUtils.h" #include "nsIMemoryReporter.h" #include "mozilla/Attributes.h" +#include "mozilla/ipc/URIUtils.h" // Initial size for the cache holding visited status observers. #define VISIT_OBSERVERS_INITIAL_CACHE_SIZE 128 using namespace mozilla::dom; +using namespace mozilla::ipc; using mozilla::unused; namespace mozilla { @@ -308,10 +310,13 @@ public: // If we are a content process, always remote the request to the // parent process. if (XRE_GetProcessType() == GeckoProcessType_Content) { + URIParams uri; + SerializeURI(aURI, uri); + mozilla::dom::ContentChild* cpc = mozilla::dom::ContentChild::GetSingleton(); NS_ASSERTION(cpc, "Content Protocol is NULL!"); - (void)cpc->SendStartVisitedQuery(aURI); + (void)cpc->SendStartVisitedQuery(uri); return NS_OK; } @@ -1457,10 +1462,12 @@ History::NotifyVisited(nsIURI* aURI) nsAutoScriptBlocker scriptBlocker; if (XRE_GetProcessType() == GeckoProcessType_Default) { + URIParams uri; + SerializeURI(aURI, uri); nsTArray cplist; ContentParent::GetAll(cplist); for (uint32_t i = 0; i < cplist.Length(); ++i) { - unused << cplist[i]->SendNotifyVisited(aURI); + unused << cplist[i]->SendNotifyVisited(uri); } } @@ -1792,10 +1799,16 @@ History::VisitURI(nsIURI* aURI, } if (XRE_GetProcessType() == GeckoProcessType_Content) { + URIParams uri; + SerializeURI(aURI, uri); + + OptionalURIParams lastVisitedURI; + SerializeURI(aLastVisitedURI, lastVisitedURI); + mozilla::dom::ContentChild* cpc = mozilla::dom::ContentChild::GetSingleton(); NS_ASSERTION(cpc, "Content Protocol is NULL!"); - (void)cpc->SendVisitURI(aURI, aLastVisitedURI, aFlags); + (void)cpc->SendVisitURI(uri, lastVisitedURI, aFlags); return NS_OK; } @@ -1995,10 +2008,13 @@ History::SetURITitle(nsIURI* aURI, const nsAString& aTitle) } if (XRE_GetProcessType() == GeckoProcessType_Content) { + URIParams uri; + SerializeURI(aURI, uri); + mozilla::dom::ContentChild * cpc = mozilla::dom::ContentChild::GetSingleton(); NS_ASSERTION(cpc, "Content Protocol is NULL!"); - (void)cpc->SendSetURITitle(aURI, nsString(aTitle)); + (void)cpc->SendSetURITitle(uri, nsString(aTitle)); return NS_OK; } diff --git a/uriloader/exthandler/ExternalHelperAppParent.cpp b/uriloader/exthandler/ExternalHelperAppParent.cpp index e25a651118f..91b9e0e3a5a 100644 --- a/uriloader/exthandler/ExternalHelperAppParent.cpp +++ b/uriloader/exthandler/ExternalHelperAppParent.cpp @@ -11,10 +11,13 @@ #include "mozilla/dom/ContentParent.h" #include "nsIBrowserDOMWindow.h" #include "nsStringStream.h" +#include "mozilla/ipc/URIUtils.h" #include "mozilla/unused.h" #include "mozilla/Util.h" // for DebugOnly +using namespace mozilla::ipc; + namespace mozilla { namespace dom { @@ -26,9 +29,9 @@ NS_IMPL_ISUPPORTS_INHERITED4(ExternalHelperAppParent, nsIResumableChannel) ExternalHelperAppParent::ExternalHelperAppParent( - const IPC::URI& uri, + const OptionalURIParams& uri, const int64_t& aContentLength) - : mURI(uri) + : mURI(DeserializeURI(uri)) , mPending(false) , mLoadFlags(0) , mStatus(NS_OK) @@ -41,7 +44,7 @@ ExternalHelperAppParent::Init(ContentParent *parent, const nsCString& aMimeContentType, const nsCString& aContentDispositionHeader, const bool& aForceSave, - const IPC::URI& aReferrer) + const OptionalURIParams& aReferrer) { nsHashPropertyBag::Init(); @@ -50,8 +53,11 @@ ExternalHelperAppParent::Init(ContentParent *parent, NS_ASSERTION(helperAppService, "No Helper App Service!"); SetPropertyAsInt64(NS_CHANNEL_PROP_CONTENT_LENGTH, mContentLength); - if (aReferrer) - SetPropertyAsInterface(NS_LITERAL_STRING("docshell.internalReferrer"), aReferrer); + + nsCOMPtr referrer = DeserializeURI(aReferrer); + if (referrer) + SetPropertyAsInterface(NS_LITERAL_STRING("docshell.internalReferrer"), referrer); + mContentDispositionHeader = aContentDispositionHeader; NS_GetFilenameFromDisposition(mContentDispositionFilename, mContentDispositionHeader, mURI); mContentDisposition = NS_GetContentDispositionFromHeader(mContentDispositionHeader, this); diff --git a/uriloader/exthandler/ExternalHelperAppParent.h b/uriloader/exthandler/ExternalHelperAppParent.h index c739ab5c84c..c2739a49ba3 100644 --- a/uriloader/exthandler/ExternalHelperAppParent.h +++ b/uriloader/exthandler/ExternalHelperAppParent.h @@ -15,6 +15,11 @@ class URI; } namespace mozilla { + +namespace ipc { +class OptionalURIParams; +} // namespace ipc + namespace dom { class ContentParent; @@ -25,6 +30,8 @@ class ExternalHelperAppParent : public PExternalHelperAppParent , public nsIMultiPartChannel , public nsIResumableChannel { + typedef mozilla::ipc::OptionalURIParams OptionalURIParams; + public: NS_DECL_ISUPPORTS NS_DECL_NSIREQUEST @@ -35,13 +42,13 @@ public: bool RecvOnStartRequest(const nsCString& entityID); bool RecvOnDataAvailable(const nsCString& data, const uint32_t& offset, const uint32_t& count); bool RecvOnStopRequest(const nsresult& code); - - ExternalHelperAppParent(const IPC::URI& uri, const int64_t& contentLength); + + ExternalHelperAppParent(const OptionalURIParams& uri, const int64_t& contentLength); void Init(ContentParent *parent, const nsCString& aMimeContentType, const nsCString& aContentDisposition, const bool& aForceSave, - const IPC::URI& aReferrer); + const OptionalURIParams& aReferrer); virtual ~ExternalHelperAppParent(); private: @@ -58,4 +65,4 @@ private: }; } // namespace dom -} // namespace mozilla +} // namespace mozilla \ No newline at end of file diff --git a/uriloader/exthandler/nsExternalHelperAppService.cpp b/uriloader/exthandler/nsExternalHelperAppService.cpp index 24a0ed6379e..b7f229714db 100644 --- a/uriloader/exthandler/nsExternalHelperAppService.cpp +++ b/uriloader/exthandler/nsExternalHelperAppService.cpp @@ -112,8 +112,10 @@ #endif #include "mozilla/Preferences.h" +#include "mozilla/ipc/URIUtils.h" using namespace mozilla; +using namespace mozilla::ipc; // Buffer file writes in 32kb chunks #define BUFFERED_OUTPUT_SIZE (1024 * 32) @@ -586,16 +588,19 @@ NS_IMETHODIMP nsExternalHelperAppService::DoContent(const nsACString& aMimeConte nsCOMPtr referrer; rv = NS_GetReferrerFromChannel(channel, getter_AddRefs(referrer)); + OptionalURIParams uriParams, referrerParams; + SerializeURI(uri, uriParams); + SerializeURI(referrer, referrerParams); + // Now we build a protocol for forwarding our data to the parent. The // protocol will act as a listener on the child-side and create a "real" // helperAppService listener on the parent-side, via another call to // DoContent. - mozilla::dom::PExternalHelperAppChild *pc; - pc = child->SendPExternalHelperAppConstructor(IPC::URI(uri), - nsCString(aMimeContentType), - disp, - aForceSave, contentLength, - IPC::URI(referrer)); + mozilla::dom::PExternalHelperAppChild *pc = + child->SendPExternalHelperAppConstructor(uriParams, + nsCString(aMimeContentType), + disp, aForceSave, contentLength, + referrerParams); ExternalHelperAppChild *childListener = static_cast(pc); NS_ADDREF(*aStreamListener = childListener); @@ -840,7 +845,10 @@ nsExternalHelperAppService::LoadURI(nsIURI *aURI, NS_ENSURE_ARG_POINTER(aURI); if (XRE_GetProcessType() == GeckoProcessType_Content) { - mozilla::dom::ContentChild::GetSingleton()->SendLoadURIExternal(aURI); + URIParams uri; + SerializeURI(aURI, uri); + + mozilla::dom::ContentChild::GetSingleton()->SendLoadURIExternal(uri); return NS_OK; } diff --git a/uriloader/prefetch/OfflineCacheUpdateChild.cpp b/uriloader/prefetch/OfflineCacheUpdateChild.cpp index 85bfaa00459..96486cbf8d3 100644 --- a/uriloader/prefetch/OfflineCacheUpdateChild.cpp +++ b/uriloader/prefetch/OfflineCacheUpdateChild.cpp @@ -7,6 +7,7 @@ #include "nsOfflineCacheUpdate.h" #include "mozilla/dom/ContentChild.h" #include "mozilla/dom/TabChild.h" +#include "mozilla/ipc/URIUtils.h" #include "nsIApplicationCacheContainer.h" #include "nsIApplicationCacheChannel.h" @@ -29,6 +30,8 @@ #include "prlog.h" #include "nsIAsyncVerifyRedirectCallback.h" +using namespace mozilla::ipc; + #if defined(PR_LOGGING) // // To enable logging (see prlog.h for full details): @@ -377,13 +380,17 @@ OfflineCacheUpdateChild::Schedule() nsCOMPtr owner; item->GetTreeOwner(getter_AddRefs(owner)); - + nsCOMPtr tabchild = do_GetInterface(owner); if (!tabchild) { NS_WARNING("tab is null"); return NS_ERROR_FAILURE; } + URIParams manifestURI, documentURI; + SerializeURI(mManifestURI, manifestURI); + SerializeURI(mDocumentURI, documentURI); + // because owner implements nsITabChild, we can assume that it is // the one and only TabChild. mozilla::dom::TabChild* child = static_cast(tabchild.get()); @@ -409,11 +416,8 @@ OfflineCacheUpdateChild::Schedule() // Need to addref ourself here, because the IPC stack doesn't hold // a reference to us. Will be released in RecvFinish() that identifies // the work has been done. - child->SendPOfflineCacheUpdateConstructor(this, - IPC::URI(mManifestURI), - IPC::URI(mDocumentURI), - mClientID, - stickDocument); + child->SendPOfflineCacheUpdateConstructor(this, manifestURI, documentURI, + mClientID, stickDocument); mIPCActivated = true; this->AddRef(); diff --git a/uriloader/prefetch/OfflineCacheUpdateParent.cpp b/uriloader/prefetch/OfflineCacheUpdateParent.cpp index 2414f48a7c4..53013a4b460 100644 --- a/uriloader/prefetch/OfflineCacheUpdateParent.cpp +++ b/uriloader/prefetch/OfflineCacheUpdateParent.cpp @@ -4,9 +4,13 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "OfflineCacheUpdateParent.h" + +#include "mozilla/ipc/URIUtils.h" #include "nsOfflineCacheUpdate.h" #include "nsIApplicationCache.h" +using namespace mozilla::ipc; + #if defined(PR_LOGGING) // // To enable logging (see prlog.h for full details): @@ -60,16 +64,21 @@ OfflineCacheUpdateParent::ActorDestroy(ActorDestroyReason why) } nsresult -OfflineCacheUpdateParent::Schedule(const URI& aManifestURI, - const URI& aDocumentURI, +OfflineCacheUpdateParent::Schedule(const URIParams& aManifestURI, + const URIParams& aDocumentURI, const nsCString& aClientID, const bool& stickDocument) { LOG(("OfflineCacheUpdateParent::RecvSchedule [%p]", this)); nsRefPtr update; - nsCOMPtr manifestURI(aManifestURI); - nsCOMPtr documentURI(aDocumentURI); + nsCOMPtr manifestURI = DeserializeURI(aManifestURI); + if (!manifestURI) + return NS_ERROR_FAILURE; + + nsCOMPtr documentURI = DeserializeURI(aDocumentURI); + if (!documentURI) + return NS_ERROR_FAILURE; nsOfflineCacheUpdateService* service = nsOfflineCacheUpdateService::EnsureService(); diff --git a/uriloader/prefetch/OfflineCacheUpdateParent.h b/uriloader/prefetch/OfflineCacheUpdateParent.h index b086c634bd6..0b96cf58801 100644 --- a/uriloader/prefetch/OfflineCacheUpdateParent.h +++ b/uriloader/prefetch/OfflineCacheUpdateParent.h @@ -12,17 +12,25 @@ #include "nsString.h" namespace mozilla { + +namespace ipc { +class URIParams; +} // namespace ipc + namespace docshell { class OfflineCacheUpdateParent : public POfflineCacheUpdateParent , public nsIOfflineCacheUpdateObserver { + typedef mozilla::ipc::URIParams URIParams; + +public: NS_DECL_ISUPPORTS NS_DECL_NSIOFFLINECACHEUPDATEOBSERVER nsresult - Schedule(const URI& manifestURI, - const URI& documentURI, + Schedule(const URIParams& manifestURI, + const URIParams& documentURI, const nsCString& clientID, const bool& stickDocument); @@ -36,7 +44,7 @@ private: bool mIPCClosed; }; -} -} +} // namespace docshell +} // namespace mozilla #endif diff --git a/uriloader/prefetch/POfflineCacheUpdate.ipdl b/uriloader/prefetch/POfflineCacheUpdate.ipdl index 4de139a2871..d11b5a23873 100644 --- a/uriloader/prefetch/POfflineCacheUpdate.ipdl +++ b/uriloader/prefetch/POfflineCacheUpdate.ipdl @@ -7,10 +7,6 @@ include protocol PBrowser; -include "mozilla/net/NeckoMessageUtils.h"; - -using IPC::URI; - namespace mozilla { namespace docshell { diff --git a/widget/xpwidgets/nsFilePickerProxy.cpp b/widget/xpwidgets/nsFilePickerProxy.cpp index 1b2de6e4b1b..f82cc8875ee 100644 --- a/widget/xpwidgets/nsFilePickerProxy.cpp +++ b/widget/xpwidgets/nsFilePickerProxy.cpp @@ -6,6 +6,7 @@ #include "mozilla/dom/ContentChild.h" #include "nsFilePickerProxy.h" +#include "nsNetUtil.h" NS_IMPL_ISUPPORTS1(nsFilePickerProxy, nsIFilePicker) diff --git a/xpcom/io/nsMultiplexInputStream.cpp b/xpcom/io/nsMultiplexInputStream.cpp index 10f308a47ee..e5bddbcd4b2 100644 --- a/xpcom/io/nsMultiplexInputStream.cpp +++ b/xpcom/io/nsMultiplexInputStream.cpp @@ -8,19 +8,17 @@ * stream. */ -#include "IPC/IPCMessageUtils.h" -#include "mozilla/Attributes.h" +#include "base/basictypes.h" #include "nsMultiplexInputStream.h" +#include "mozilla/Attributes.h" #include "nsIMultiplexInputStream.h" #include "nsISeekableStream.h" #include "nsCOMPtr.h" #include "nsCOMArray.h" -#include "nsIIPCSerializableObsolete.h" #include "nsIClassInfoImpl.h" #include "nsIIPCSerializableInputStream.h" #include "mozilla/ipc/InputStreamUtils.h" -#include "mozilla/ipc/IPCSerializableParams.h" using namespace mozilla::ipc; diff --git a/xpcom/io/nsStringStream.cpp b/xpcom/io/nsStringStream.cpp index 8dc1989cb34..b6b08690a06 100644 --- a/xpcom/io/nsStringStream.cpp +++ b/xpcom/io/nsStringStream.cpp @@ -19,9 +19,8 @@ #include "prerror.h" #include "plstr.h" #include "nsIClassInfoImpl.h" -#include "nsIIPCSerializableObsolete.h" #include "mozilla/Attributes.h" -#include "mozilla/ipc/IPCSerializableParams.h" +#include "mozilla/ipc/InputStreamUtils.h" #include "nsIIPCSerializableInputStream.h" using namespace mozilla::ipc; @@ -33,7 +32,6 @@ using namespace mozilla::ipc; class nsStringInputStream MOZ_FINAL : public nsIStringInputStream , public nsISeekableStream , public nsISupportsCString - , public nsIIPCSerializableObsolete , public nsIIPCSerializableInputStream { public: @@ -43,7 +41,6 @@ public: NS_DECL_NSISEEKABLESTREAM NS_DECL_NSISUPPORTSPRIMITIVE NS_DECL_NSISUPPORTSCSTRING - NS_DECL_NSIIPCSERIALIZABLEOBSOLETE NS_DECL_NSIIPCSERIALIZABLEINPUTSTREAM nsStringInputStream() @@ -86,12 +83,11 @@ NS_IMPL_THREADSAFE_RELEASE(nsStringInputStream) NS_IMPL_CLASSINFO(nsStringInputStream, NULL, nsIClassInfo::THREADSAFE, NS_STRINGINPUTSTREAM_CID) -NS_IMPL_QUERY_INTERFACE6_CI(nsStringInputStream, +NS_IMPL_QUERY_INTERFACE5_CI(nsStringInputStream, nsIStringInputStream, nsIInputStream, nsISupportsCString, nsISeekableStream, - nsIIPCSerializableObsolete, nsIIPCSerializableInputStream) NS_IMPL_CI_INTERFACE_GETTER4(nsStringInputStream, nsIStringInputStream, @@ -293,35 +289,6 @@ nsStringInputStream::SetEOF() return NS_OK; } -///////// -// nsIIPCSerializableObsolete implementation -///////// - -bool -nsStringInputStream::Read(const IPC::Message *aMsg, void **aIter) -{ - using IPC::ReadParam; - - nsCString value; - - if (!ReadParam(aMsg, aIter, &value)) - return false; - - nsresult rv = SetData(value); - if (NS_FAILED(rv)) - return false; - - return true; -} - -void -nsStringInputStream::Write(IPC::Message *aMsg) -{ - using IPC::WriteParam; - - WriteParam(aMsg, static_cast(PromiseFlatCString(mData))); -} - void nsStringInputStream::Serialize(InputStreamParams& aParams) {