Skip to content

Commit

Permalink
Bug 1615321 - Remove GetUri call in StorageObserver r=ckerschb
Browse files Browse the repository at this point in the history
Differential Revision: https://phabricator.services.mozilla.com/D62765

--HG--
extra : moz-landing-system : lando
  • Loading branch information
strseb committed Feb 24, 2020
1 parent 675474d commit 4018f86
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
11 changes: 11 additions & 0 deletions caps/BasePrincipal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,17 @@ BasePrincipal::GetHostPort(nsACString& aRes) {
return prinURI->GetHostPort(aRes);
}

NS_IMETHODIMP
BasePrincipal::GetHost(nsACString& aRes) {
aRes.Truncate();
nsCOMPtr<nsIURI> prinURI;
nsresult rv = GetURI(getter_AddRefs(prinURI));
if (NS_FAILED(rv) || !prinURI) {
return NS_OK;
}
return prinURI->GetHost(aRes);
}

NS_IMETHODIMP
BasePrincipal::GetOriginNoSuffix(nsACString& aOrigin) {
MOZ_ASSERT(mInitialized);
Expand Down
1 change: 1 addition & 0 deletions caps/BasePrincipal.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ class BasePrincipal : public nsJSPrincipals {
NS_IMETHOD GetAsciiSpec(nsACString& aSpec) override;
NS_IMETHOD GetExposablePrePath(nsACString& aResult) override;
NS_IMETHOD GetHostPort(nsACString& aRes) override;
NS_IMETHOD GetHost(nsACString& aRes) override;
NS_IMETHOD GetPrepath(nsACString& aResult) override;
NS_IMETHOD GetOriginSuffix(nsACString& aOriginSuffix) final;
NS_IMETHOD GetIsOnion(bool* aIsOnion) override;
Expand Down
6 changes: 6 additions & 0 deletions caps/nsIPrincipal.idl
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,12 @@ interface nsIPrincipal : nsISerializable
[noscript] readonly attribute ACString asciiHost;


/**
* Returns the "host" portion of the
* Principals URI, if any.
*/
[noscript] readonly attribute ACString host;

/**
* Returns the prepath of the principals uri
* follows the format scheme:
Expand Down
8 changes: 1 addition & 7 deletions dom/storage/StorageObserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,14 +265,8 @@ StorageObserver::Observe(nsISupports* aSubject, const char* aTopic,
BasePrincipal::Cast(principal)->OriginAttributesRef().CreateSuffix(
originSuffix);

nsCOMPtr<nsIURI> origin;
principal->GetURI(getter_AddRefs(origin));
if (!origin) {
return NS_OK;
}

nsAutoCString host;
origin->GetHost(host);
principal->GetHost(host);
if (host.IsEmpty()) {
return NS_OK;
}
Expand Down

0 comments on commit 4018f86

Please sign in to comment.