Skip to content

Commit

Permalink
Bug 1622619 - Replace URIParams with nsIURI in PContent.ipdl r=valentin
Browse files Browse the repository at this point in the history
  • Loading branch information
sonakshisaxena1 committed Mar 31, 2020
1 parent 8df31dd commit f147451
Show file tree
Hide file tree
Showing 24 changed files with 229 additions and 312 deletions.
31 changes: 15 additions & 16 deletions caps/DomainPolicy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,8 @@ static nsresult BroadcastDomainSetChange(DomainSetType aSetType,
return NS_OK;
}

Maybe<URIParams> uri;
SerializeURI(aDomain, uri);

for (uint32_t i = 0; i < parents.Length(); i++) {
Unused << parents[i]->SendDomainSetChanged(aSetType, aChangeType, uri);
Unused << parents[i]->SendDomainSetChanged(aSetType, aChangeType, aDomain);
}
return NS_OK;
}
Expand Down Expand Up @@ -118,10 +115,13 @@ void DomainPolicy::CloneDomainPolicy(DomainPolicyClone* aClone) {
mSuperAllowlist->CloneSet(&aClone->superAllowlist());
}

static void CopyURIs(const nsTArray<URIParams>& aDomains, nsIDomainSet* aSet) {
static void CopyURIs(const nsTArray<RefPtr<nsIURI>>& aDomains,
nsIDomainSet* aSet) {
for (uint32_t i = 0; i < aDomains.Length(); i++) {
nsCOMPtr<nsIURI> uri = DeserializeURI(aDomains[i]);
aSet->Add(uri);
if (NS_WARN_IF(!aDomains[i])) {
continue;
}
aSet->Add(aDomains[i]);
}
}

Expand Down Expand Up @@ -149,8 +149,9 @@ DomainSet::Add(nsIURI* aDomain) {
nsCOMPtr<nsIURI> clone = GetCanonicalClone(aDomain);
NS_ENSURE_TRUE(clone, NS_ERROR_FAILURE);
mHashTable.PutEntry(clone);
if (XRE_IsParentProcess())
if (XRE_IsParentProcess()) {
return BroadcastDomainSetChange(mType, ADD_DOMAIN, aDomain);
}

return NS_OK;
}
Expand All @@ -160,17 +161,19 @@ DomainSet::Remove(nsIURI* aDomain) {
nsCOMPtr<nsIURI> clone = GetCanonicalClone(aDomain);
NS_ENSURE_TRUE(clone, NS_ERROR_FAILURE);
mHashTable.RemoveEntry(clone);
if (XRE_IsParentProcess())
if (XRE_IsParentProcess()) {
return BroadcastDomainSetChange(mType, REMOVE_DOMAIN, aDomain);
}

return NS_OK;
}

NS_IMETHODIMP
DomainSet::Clear() {
mHashTable.Clear();
if (XRE_IsParentProcess())
if (XRE_IsParentProcess()) {
return BroadcastDomainSetChange(mType, CLEAR_DOMAINS);
}

return NS_OK;
}
Expand Down Expand Up @@ -212,14 +215,10 @@ DomainSet::ContainsSuperDomain(nsIURI* aDomain, bool* aContains) {
return NS_OK;
}

void DomainSet::CloneSet(nsTArray<URIParams>* aDomains) {
void DomainSet::CloneSet(nsTArray<RefPtr<nsIURI>>* aDomains) {
for (auto iter = mHashTable.Iter(); !iter.Done(); iter.Next()) {
nsIURI* key = iter.Get()->GetKey();

URIParams uri;
SerializeURI(key, uri);

aDomains->AppendElement(uri);
aDomains->AppendElement(key);
}
}

Expand Down
6 changes: 1 addition & 5 deletions caps/DomainPolicy.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@

namespace mozilla {

namespace ipc {
class URIParams;
} // namespace ipc

enum DomainSetChangeType {
ACTIVATE_POLICY,
DEACTIVATE_POLICY,
Expand All @@ -40,7 +36,7 @@ class DomainSet final : public nsIDomainSet {

explicit DomainSet(DomainSetType aType) : mType(aType) {}

void CloneSet(nsTArray<mozilla::ipc::URIParams>* aDomains);
void CloneSet(nsTArray<RefPtr<nsIURI>>* aDomains);

protected:
virtual ~DomainSet() {}
Expand Down
5 changes: 2 additions & 3 deletions docshell/base/nsDefaultURIFixup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ nsDefaultURIFixup::KeywordToURI(const nsACString& aKeyword,
}

RefPtr<nsIInputStream> postData;
Maybe<mozilla::ipc::URIParams> uri;
RefPtr<nsIURI> uri;
nsAutoString providerName;
if (!contentChild->SendKeywordToURI(keyword, aIsPrivateContext,
&providerName, &postData, &uri)) {
Expand All @@ -403,8 +403,7 @@ nsDefaultURIFixup::KeywordToURI(const nsACString& aKeyword,
postData.forget(aPostData);
}

nsCOMPtr<nsIURI> temp = DeserializeURI(uri);
info->mPreferredURI = std::move(temp);
info->mPreferredURI = uri.forget();
return NS_OK;
}

Expand Down
11 changes: 3 additions & 8 deletions docshell/base/nsDocShell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3682,11 +3682,9 @@ nsDocShell::DisplayLoadError(nsresult aError, nsIURI* aURI,
} else {
mozilla::dom::ContentChild* cc =
mozilla::dom::ContentChild::GetSingleton();
mozilla::ipc::URIParams uri;
SerializeURI(aURI, uri);
cc->SendIsSecureURI(nsISiteSecurityService::HEADER_HSTS, uri, flags,
cc->SendIsSecureURI(nsISiteSecurityService::HEADER_HSTS, aURI, flags,
mOriginAttributes, &isStsHost);
cc->SendIsSecureURI(nsISiteSecurityService::HEADER_HPKP, uri, flags,
cc->SendIsSecureURI(nsISiteSecurityService::HEADER_HPKP, aURI, flags,
mOriginAttributes, &isPinnedHost);
}

Expand Down Expand Up @@ -8131,10 +8129,7 @@ void nsDocShell::CopyFavicon(nsIURI* aOldURI, nsIURI* aNewURI,
if (XRE_IsContentProcess()) {
dom::ContentChild* contentChild = dom::ContentChild::GetSingleton();
if (contentChild) {
mozilla::ipc::URIParams oldURI, newURI;
SerializeURI(aOldURI, oldURI);
SerializeURI(aNewURI, newURI);
contentChild->SendCopyFavicon(oldURI, newURI,
contentChild->SendCopyFavicon(aOldURI, aNewURI,
IPC::Principal(aLoadingPrincipal),
aInPrivateBrowsing);
}
Expand Down
6 changes: 2 additions & 4 deletions dom/base/Document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1809,11 +1809,9 @@ void Document::GetFailedCertSecurityInfo(FailedCertSecurityInfo& aInfo,
if (XRE_IsContentProcess()) {
ContentChild* cc = ContentChild::GetSingleton();
MOZ_ASSERT(cc);
mozilla::ipc::URIParams uri;
SerializeURI(aURI, uri);
cc->SendIsSecureURI(nsISiteSecurityService::HEADER_HSTS, uri, flags, attrs,
cc->SendIsSecureURI(nsISiteSecurityService::HEADER_HSTS, aURI, flags, attrs,
&aInfo.mHasHSTS);
cc->SendIsSecureURI(nsISiteSecurityService::HEADER_HPKP, uri, flags, attrs,
cc->SendIsSecureURI(nsISiteSecurityService::HEADER_HPKP, aURI, flags, attrs,
&aInfo.mHasHPKP);
} else {
nsCOMPtr<nsISiteSecurityService> sss =
Expand Down
49 changes: 17 additions & 32 deletions dom/ipc/ContentChild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -934,17 +934,14 @@ nsresult ContentChild::ProvideWindowCommon(
return rv;
}

Maybe<URIParams> uriToLoad;
SerializeURI(aURI, uriToLoad);

if (name.LowerCaseEqualsLiteral("_blank")) {
name = EmptyString();
}

MOZ_DIAGNOSTIC_ASSERT(!nsContentUtils::IsSpecialName(name));

Unused << SendCreateWindowInDifferentProcess(
aTabOpener, aChromeFlags, aCalledFromJS, aWidthSpecified, uriToLoad,
aTabOpener, aChromeFlags, aCalledFromJS, aWidthSpecified, aURI,
features, fullZoom, name, triggeringPrincipal, csp, referrerInfo);

// We return NS_ERROR_ABORT, so that the caller knows that we've abandoned
Expand Down Expand Up @@ -1192,13 +1189,7 @@ nsresult ContentChild::ProvideWindowCommon(
return rv;
}

Maybe<URIParams> uriToLoad;
if (aURI) {
SerializeURI(aURI, uriToLoad);
}

SendCreateWindow(aTabOpener, newChild, aChromeFlags, aCalledFromJS,
aWidthSpecified, uriToLoad, features, fullZoom,
SendCreateWindow(aTabOpener, newChild, aChromeFlags, aCalledFromJS, aWidthSpecified, aURI, features, fullZoom,
Principal(triggeringPrincipal), csp, referrerInfo,
std::move(resolve), std::move(reject));
}
Expand Down Expand Up @@ -1401,7 +1392,7 @@ void ContentChild::InitXPCOM(
}

// The stylesheet cache is not ready yet. Store this URL for future use.
nsCOMPtr<nsIURI> ucsURL = DeserializeURI(aXPCOMInit.userContentSheetURL());
nsCOMPtr<nsIURI> ucsURL = aXPCOMInit.userContentSheetURL();
GlobalStyleSheetCache::SetUserContentCSSURL(ucsURL);

GfxInfoBase::SetFeatureStatus(aXPCOMInit.gfxFeatureStatus());
Expand Down Expand Up @@ -2365,7 +2356,7 @@ mozilla::ipc::IPCResult ContentChild::RecvNotifyVisited(
return IPC_OK();
}
for (const VisitedQueryResult& result : aURIs) {
nsCOMPtr<nsIURI> newURI = DeserializeURI(result.uri());
nsCOMPtr<nsIURI> newURI = result.uri();
if (!newURI) {
return IPC_FAIL_NO_REASON(this);
}
Expand Down Expand Up @@ -2747,38 +2738,35 @@ mozilla::ipc::IPCResult ContentChild::RecvNotifyIdleObserver(
}

mozilla::ipc::IPCResult ContentChild::RecvLoadAndRegisterSheet(
const URIParams& aURI, const uint32_t& aType) {
nsCOMPtr<nsIURI> uri = DeserializeURI(aURI);
if (!uri) {
nsIURI* aURI, const uint32_t& aType) {
if (!aURI) {
return IPC_OK();
}

nsStyleSheetService* sheetService = nsStyleSheetService::GetInstance();
if (sheetService) {
sheetService->LoadAndRegisterSheet(uri, aType);
sheetService->LoadAndRegisterSheet(aURI, aType);
}

return IPC_OK();
}

mozilla::ipc::IPCResult ContentChild::RecvUnregisterSheet(
const URIParams& aURI, const uint32_t& aType) {
nsCOMPtr<nsIURI> uri = DeserializeURI(aURI);
if (!uri) {
nsIURI* aURI, const uint32_t& aType) {
if (!aURI) {
return IPC_OK();
}

nsStyleSheetService* sheetService = nsStyleSheetService::GetInstance();
if (sheetService) {
sheetService->UnregisterSheet(uri, aType);
sheetService->UnregisterSheet(aURI, aType);
}

return IPC_OK();
}

mozilla::ipc::IPCResult ContentChild::RecvDomainSetChanged(
const uint32_t& aSetType, const uint32_t& aChangeType,
const Maybe<URIParams>& aDomain) {
const uint32_t& aSetType, const uint32_t& aChangeType, nsIURI* aDomain) {
if (aChangeType == ACTIVATE_POLICY) {
if (mPolicy) {
return IPC_OK();
Expand Down Expand Up @@ -2827,16 +2815,14 @@ mozilla::ipc::IPCResult ContentChild::RecvDomainSetChanged(

MOZ_ASSERT(set);

nsCOMPtr<nsIURI> uri = DeserializeURI(aDomain);

switch (aChangeType) {
case ADD_DOMAIN:
NS_ENSURE_TRUE(uri, IPC_FAIL_NO_REASON(this));
set->Add(uri);
NS_ENSURE_TRUE(aDomain, IPC_FAIL_NO_REASON(this));
set->Add(aDomain);
break;
case REMOVE_DOMAIN:
NS_ENSURE_TRUE(uri, IPC_FAIL_NO_REASON(this));
set->Remove(uri);
NS_ENSURE_TRUE(aDomain, IPC_FAIL_NO_REASON(this));
set->Remove(aDomain);
break;
case CLEAR_DOMAINS:
set->Clear();
Expand Down Expand Up @@ -3263,7 +3249,7 @@ bool ContentChild::DeallocPURLClassifierChild(PURLClassifierChild* aActor) {
}

PURLClassifierLocalChild* ContentChild::AllocPURLClassifierLocalChild(
const URIParams& aUri, const nsTArray<IPCURLClassifierFeature>& aFeatures) {
nsIURI* aUri, const nsTArray<IPCURLClassifierFeature>& aFeatures) {
return new URLClassifierLocalChild();
}

Expand All @@ -3274,8 +3260,7 @@ bool ContentChild::DeallocPURLClassifierLocalChild(
return true;
}

PLoginReputationChild* ContentChild::AllocPLoginReputationChild(
const URIParams& aUri) {
PLoginReputationChild* ContentChild::AllocPLoginReputationChild(nsIURI* aUri) {
return new PLoginReputationChild();
}

Expand Down
16 changes: 5 additions & 11 deletions dom/ipc/ContentChild.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,6 @@ using mozilla::loader::PScriptCacheChild;
bool IsDevelopmentBuild();
#endif /* !XP_WIN */

namespace ipc {
class URIParams;
} // namespace ipc

namespace dom {

namespace ipc {
Expand All @@ -88,7 +84,6 @@ class ContentChild final
typedef mozilla::dom::ClonedMessageData ClonedMessageData;
typedef mozilla::ipc::FileDescriptor FileDescriptor;
typedef mozilla::ipc::PFileDescriptorSetChild PFileDescriptorSetChild;
typedef mozilla::ipc::URIParams URIParams;

friend class PContentChild;

Expand Down Expand Up @@ -421,10 +416,10 @@ class ContentChild final

mozilla::ipc::IPCResult RecvMinimizeMemoryUsage();

mozilla::ipc::IPCResult RecvLoadAndRegisterSheet(const URIParams& aURI,
mozilla::ipc::IPCResult RecvLoadAndRegisterSheet(nsIURI* aURI,
const uint32_t& aType);

mozilla::ipc::IPCResult RecvUnregisterSheet(const URIParams& aURI,
mozilla::ipc::IPCResult RecvUnregisterSheet(nsIURI* aURI,
const uint32_t& aType);

void AddIdleObserver(nsIObserver* aObserver, uint32_t aIdleTimeInS);
Expand All @@ -439,7 +434,7 @@ class ContentChild final

mozilla::ipc::IPCResult RecvDomainSetChanged(const uint32_t& aSetType,
const uint32_t& aChangeType,
const Maybe<URIParams>& aDomain);
nsIURI* aDomain);

mozilla::ipc::IPCResult RecvShutdown();

Expand Down Expand Up @@ -601,11 +596,10 @@ class ContentChild final

// PURLClassifierLocalChild
PURLClassifierLocalChild* AllocPURLClassifierLocalChild(
const URIParams& aUri,
const nsTArray<IPCURLClassifierFeature>& aFeatures);
nsIURI* aUri, const nsTArray<IPCURLClassifierFeature>& aFeatures);
bool DeallocPURLClassifierLocalChild(PURLClassifierLocalChild* aActor);

PLoginReputationChild* AllocPLoginReputationChild(const URIParams& aUri);
PLoginReputationChild* AllocPLoginReputationChild(nsIURI* aUri);

bool DeallocPLoginReputationChild(PLoginReputationChild* aActor);

Expand Down
Loading

0 comments on commit f147451

Please sign in to comment.