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
This commit is contained in:
Ben Turner 2012-08-23 12:33:46 -07:00
parent 13c6c0ca0a
commit 0727b7098c
81 changed files with 943 additions and 697 deletions

View File

@ -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<DataOwner> mDataOwner;
nsCOMPtr<nsIInputStream> mStream;
nsCOMPtr<nsISeekableStream> mSeekableStream;
nsCOMPtr<nsIIPCSerializableObsolete> mSerializableObsolete;
nsCOMPtr<nsIClassInfo> mClassInfo;
nsCOMPtr<nsIIPCSerializableInputStream> 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)

View File

@ -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"

View File

@ -17,6 +17,7 @@
#include "nsOpenWindowEventDetail.h"
#include "nsEventDispatcher.h"
#include "nsIDOMCustomEvent.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsVariant.h"
using mozilla::dom::Element;

View File

@ -7,6 +7,7 @@
#include "IndexedDBChild.h"
#include "nsIAtom.h"
#include "nsIInputStream.h"
#include "mozilla/Assertions.h"
#include "mozilla/dom/ContentChild.h"

View File

@ -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<nsIURI> newURI(aURI);
nsCOMPtr<nsIURI> newURI = DeserializeURI(aURI);
if (!newURI) {
return false;
}
History::GetService()->NotifyVisited(newURI);
return true;
}

View File

@ -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);

View File

@ -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,9 +1425,12 @@ ContentParent::RequestRunToCompletion()
}
bool
ContentParent::RecvStartVisitedQuery(const IPC::URI& aURI)
ContentParent::RecvStartVisitedQuery(const URIParams& aURI)
{
nsCOMPtr<nsIURI> newURI(aURI);
nsCOMPtr<nsIURI> newURI = DeserializeURI(aURI);
if (!newURI) {
return false;
}
nsCOMPtr<IHistory> history = services::GetHistoryService();
NS_ABORT_IF_FALSE(history, "History must exist at this point.");
if (history) {
@ -1437,12 +1441,15 @@ ContentParent::RecvStartVisitedQuery(const IPC::URI& aURI)
bool
ContentParent::RecvVisitURI(const IPC::URI& uri,
const IPC::URI& referrer,
ContentParent::RecvVisitURI(const URIParams& uri,
const OptionalURIParams& referrer,
const uint32_t& flags)
{
nsCOMPtr<nsIURI> ourURI(uri);
nsCOMPtr<nsIURI> ourReferrer(referrer);
nsCOMPtr<nsIURI> ourURI = DeserializeURI(uri);
if (!ourURI) {
return false;
}
nsCOMPtr<nsIURI> ourReferrer = DeserializeURI(referrer);
nsCOMPtr<IHistory> history = services::GetHistoryService();
NS_ABORT_IF_FALSE(history, "History must exist at this point");
if (history) {
@ -1453,10 +1460,13 @@ ContentParent::RecvVisitURI(const IPC::URI& uri,
bool
ContentParent::RecvSetURITitle(const IPC::URI& uri,
ContentParent::RecvSetURITitle(const URIParams& uri,
const nsString& title)
{
nsCOMPtr<nsIURI> ourURI(uri);
nsCOMPtr<nsIURI> ourURI = DeserializeURI(uri);
if (!ourURI) {
return false;
}
nsCOMPtr<IHistory> history = services::GetHistoryService();
NS_ABORT_IF_FALSE(history, "History must exist at this point");
if (history) {
@ -1541,12 +1551,16 @@ ContentParent::RecvShowFilePicker(const int16_t& mode,
}
bool
ContentParent::RecvLoadURIExternal(const IPC::URI& uri)
ContentParent::RecvLoadURIExternal(const URIParams& uri)
{
nsCOMPtr<nsIExternalProtocolService> extProtService(do_GetService(NS_EXTERNALPROTOCOLSERVICE_CONTRACTID));
if (!extProtService)
if (!extProtService) {
return true;
nsCOMPtr<nsIURI> ourURI(uri);
}
nsCOMPtr<nsIURI> ourURI = DeserializeURI(uri);
if (!ourURI) {
return false;
}
extProtService->LoadURI(ourURI, nullptr);
return true;
}

View File

@ -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<uint8_t>* 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,

View File

@ -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 {

View File

@ -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);

View File

@ -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,9 +285,9 @@ 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();

View File

@ -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 {

View File

@ -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)
{

View File

@ -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);

View File

@ -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)
{

View File

@ -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);

View File

@ -9,6 +9,8 @@
#include "nsXULAppAPI.h"
#include "AndroidBridge.h"
#include "nsIconChannel.h"
#include "nsIStringStream.h"
#include "nsNetUtil.h"
NS_IMPL_ISUPPORTS2(nsIconChannel,
nsIRequest,

View File

@ -67,6 +67,5 @@ struct MIMEInputStreamParams
bool addContentLength;
};
} // namespace ipc
} // namespace mozilla

View File

@ -42,14 +42,14 @@ SerializeInputStream(nsIInputStream* aInputStream,
nsCOMPtr<nsIIPCSerializableInputStream> 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

View File

@ -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"

View File

@ -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) #{

78
ipc/glue/URIParams.ipdlh Normal file
View File

@ -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

207
ipc/glue/URIUtils.cpp Normal file
View File

@ -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<nsIIPCSerializableURI> 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<nsIURI>
DeserializeURI(const URIParams& aParams)
{
MOZ_ASSERT(NS_IsMainThread());
nsCOMPtr<nsIURI> uri;
if (aParams.type() != URIParams::TGenericURIParams) {
nsCOMPtr<nsIIPCSerializableURI> 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<nsIURI>
DeserializeURI(const OptionalURIParams& aParams)
{
MOZ_ASSERT(NS_IsMainThread());
nsCOMPtr<nsIURI> 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

32
ipc/glue/URIUtils.h Normal file
View File

@ -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<nsIURI>
DeserializeURI(const URIParams& aParams);
already_AddRefed<nsIURI>
DeserializeURI(const OptionalURIParams& aParams);
} // namespace ipc
} // namespace mozilla
#endif // mozilla_ipc_URIUtils_h

View File

@ -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)

View File

@ -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

View File

@ -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,

View File

@ -0,0 +1,7 @@
using mozilla::void_t;
using mozilla::void_t;
protocol multipleUsingCxxTypes {
child:
Msg(void_t foo);
};

View File

@ -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

View File

@ -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<nsISupports*>(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<nsIURI> file = DeserializeURI(params.jarFile());
if (!file) {
NS_ERROR("Couldn't deserialize jar file URI!");
return false;
}
nsCOMPtr<nsIURI> entry = DeserializeURI(params.jarEntry());
if (!entry) {
NS_ERROR("Couldn't deserialize jar entry URI!");
return false;
}
nsCOMPtr<nsIURL> 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;
}

View File

@ -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,7 +37,8 @@
class nsJARURI : public nsIJARURI,
public nsISerializable,
public nsIClassInfo,
public nsINestedURI
public nsINestedURI,
public nsIIPCSerializableURI
{
public:
NS_DECL_ISUPPORTS
@ -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)

View File

@ -15,6 +15,7 @@ MODULES_LIBJAR_LCPPSRCS = \
MODULES_LIBJAR_LEXPORTS = \
zipstruct.h \
nsJARURI.h \
nsZipArchive.h \
$(NULL)

View File

@ -52,7 +52,6 @@ XPIDLSRCS = \
nsIInputStreamPump.idl \
nsIInputStreamChannel.idl \
nsIIOService2.idl \
nsIIPCSerializableObsolete.idl \
nsIMIMEInputStream.idl \
nsINetAddr.idl \
nsINetworkLinkService.idl \

View File

@ -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);
};

View File

@ -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

View File

@ -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<nsIFile> 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)
{

View File

@ -18,7 +18,6 @@
#include "prlog.h"
#include "prio.h"
#include "nsIIPCSerializableInputStream.h"
#include "nsIIPCSerializableObsolete.h"
template<class CharType> 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()

View File

@ -21,7 +21,6 @@
#include "nsIClassInfoImpl.h"
#include "nsIIPCSerializableInputStream.h"
#include "mozilla/ipc/InputStreamUtils.h"
#include "mozilla/ipc/IPCSerializableParams.h"
using namespace mozilla::ipc;

View File

@ -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

View File

@ -36,7 +36,6 @@ public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSINESTEDURI
NS_DECL_NSIIPCSERIALIZABLEOBSOLETE
// Overrides for various methods nsSimpleURI implements follow.

View File

@ -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<nsIURI*>(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;
}
////////////////////////////////////////////////////////////////////////////////

View File

@ -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:

View File

@ -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<nsIURI *>(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)
{
using IPC::ReadParam;
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)
{
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);
}

View File

@ -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).

View File

@ -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;
}

View File

@ -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<nsIURI> hostURI(aHost);
nsCOMPtr<nsIURI> 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<nsIURI> hostURI(aHost);
nsCOMPtr<nsIURI> hostURI = DeserializeURI(aHost);
if (!hostURI)
return false;

View File

@ -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,

View File

@ -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,

View File

@ -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<URI>;
private:
// Unimplemented
URI& operator=(URI&);
nsCOMPtr<nsIURI> mURI;
};
template<>
struct ParamTraits<URI>
{
typedef URI paramType;
static void Write(Message* aMsg, const paramType& aParam)
{
bool isNull = !aParam.mURI;
WriteParam(aMsg, isNull);
if (isNull)
return;
nsCOMPtr<nsIIPCSerializableObsolete> 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<nsIClassInfo> classInfo = do_QueryInterface(aParam.mURI);
char cidStr[NSID_LENGTH];
nsCID cid;
mozilla::DebugOnly<nsresult> 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<nsIURI> 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<nsIURI> uri = do_CreateInstance(cid);
if (!uri)
return false;
nsCOMPtr<nsIIPCSerializableObsolete> 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

View File

@ -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)

View File

@ -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)

View File

@ -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<nsIURI> uri(aURI);
nsCOMPtr<nsIURI> uri = DeserializeURI(aURI);
uri->GetSpec(spec);
nsBaseChannel::URI()->SetSpec(spec);

View File

@ -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);

View File

@ -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<nsIURI> uri(aURI);
nsCOMPtr<nsIURI> 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;
}

View File

@ -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,

View File

@ -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);

View File

@ -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<nsIURI> uri(newURI);
nsCOMPtr<nsIURI> uri = DeserializeURI(newUri);
nsCOMPtr<nsIChannel> 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,

View File

@ -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();

View File

@ -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<nsIURI> uri(aURI);
nsCOMPtr<nsIURI> originalUri(aOriginalURI);
nsCOMPtr<nsIURI> docUri(aDocURI);
nsCOMPtr<nsIURI> referrerUri(aReferrerURI);
nsCOMPtr<nsIURI> uri = DeserializeURI(aURI);
nsCOMPtr<nsIURI> originalUri = DeserializeURI(aOriginalURI);
nsCOMPtr<nsIURI> docUri = DeserializeURI(aDocURI);
nsCOMPtr<nsIURI> referrerUri = DeserializeURI(aReferrerURI);
nsCString uriSpec;
uri->GetSpec(uriSpec);
@ -563,11 +565,12 @@ HttpChannelParent::StartRedirect(uint32_t newChannelId,
nsCOMPtr<nsIURI> newURI;
newChannel->GetURI(getter_AddRefs(newURI));
URIParams uriParams;
SerializeURI(newURI, uriParams);
nsHttpChannel *httpChan = static_cast<nsHttpChannel *>(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) {

View File

@ -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,

View File

@ -17,8 +17,6 @@
#include "nsIRedirectResultListener.h"
#include "nsIProgressEventSink.h"
using namespace mozilla::dom;
class nsICacheEntryDescriptor;
namespace mozilla {

View File

@ -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);

View File

@ -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,

View File

@ -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<mozilla::dom::TabChild*>(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;

View File

@ -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<nsIURI> 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;

View File

@ -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,

View File

@ -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);

View File

@ -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;

View File

@ -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<nsIURI> uri(aURI);
nsCOMPtr<nsIURI> 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<nsIURI> original(aOriginal);
nsCOMPtr<nsIURI> original = DeserializeURI(aOriginal);
if (!original)
return false;
LOG(("WyciwygChannelParent RecvAsyncOpen [this=%x]\n", this));

View File

@ -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);

View File

@ -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<ContentParent*> 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;
}

View File

@ -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<nsIURI> referrer = DeserializeURI(aReferrer);
if (referrer)
SetPropertyAsInterface(NS_LITERAL_STRING("docshell.internalReferrer"), referrer);
mContentDispositionHeader = aContentDispositionHeader;
NS_GetFilenameFromDisposition(mContentDispositionFilename, mContentDispositionHeader, mURI);
mContentDisposition = NS_GetContentDispositionFromHeader(mContentDispositionHeader, this);

View File

@ -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
@ -36,12 +43,12 @@ public:
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:

View File

@ -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<nsIURI> 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),
mozilla::dom::PExternalHelperAppChild *pc =
child->SendPExternalHelperAppConstructor(uriParams,
nsCString(aMimeContentType),
disp,
aForceSave, contentLength,
IPC::URI(referrer));
disp, aForceSave, contentLength,
referrerParams);
ExternalHelperAppChild *childListener = static_cast<ExternalHelperAppChild *>(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;
}

View File

@ -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):
@ -384,6 +387,10 @@ OfflineCacheUpdateChild::Schedule()
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<mozilla::dom::TabChild*>(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();

View File

@ -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<nsOfflineCacheUpdate> update;
nsCOMPtr<nsIURI> manifestURI(aManifestURI);
nsCOMPtr<nsIURI> documentURI(aDocumentURI);
nsCOMPtr<nsIURI> manifestURI = DeserializeURI(aManifestURI);
if (!manifestURI)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIURI> documentURI = DeserializeURI(aDocumentURI);
if (!documentURI)
return NS_ERROR_FAILURE;
nsOfflineCacheUpdateService* service =
nsOfflineCacheUpdateService::EnsureService();

View File

@ -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

View File

@ -7,10 +7,6 @@
include protocol PBrowser;
include "mozilla/net/NeckoMessageUtils.h";
using IPC::URI;
namespace mozilla {
namespace docshell {

View File

@ -6,6 +6,7 @@
#include "mozilla/dom/ContentChild.h"
#include "nsFilePickerProxy.h"
#include "nsNetUtil.h"
NS_IMPL_ISUPPORTS1(nsFilePickerProxy, nsIFilePicker)

View File

@ -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;

View File

@ -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<const nsCString&>(PromiseFlatCString(mData)));
}
void
nsStringInputStream::Serialize(InputStreamParams& aParams)
{