Commit 1fd1bc39 authored by Andrea Marchesini's avatar Andrea Marchesini
Browse files

Bug 1343933 - Renaming Principal classes - part 2 - NullPrincipal, r=qdot

--HG--
rename : caps/nsNullPrincipal.cpp => caps/NullPrincipal.cpp
rename : caps/nsNullPrincipal.h => caps/NullPrincipal.h
rename : caps/nsNullPrincipalURI.cpp => caps/NullPrincipalURI.cpp
rename : caps/nsNullPrincipalURI.h => caps/NullPrincipalURI.h
parent 68207654
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -19,7 +19,7 @@
#include "nsPrincipal.h"
#include "nsNetUtil.h"
#include "nsIURIWithPrincipal.h"
#include "nsNullPrincipal.h"
#include "NullPrincipal.h"
#include "nsScriptSecurityManager.h"
#include "nsServiceManagerUtils.h"

@@ -645,7 +645,7 @@ BasePrincipal::CreateCodebasePrincipal(nsIURI* aURI, const OriginAttributes& aAt
  nsresult rv = NS_URIChainHasFlags(aURI, nsIProtocolHandler::URI_INHERITS_SECURITY_CONTEXT,
                                    &inheritsPrincipal);
  if (NS_FAILED(rv) || inheritsPrincipal) {
    return nsNullPrincipal::Create(aAttrs);
    return NullPrincipal::Create(aAttrs);
  }

  // Check whether the URI knows what its principal is supposed to be.
@@ -654,7 +654,7 @@ BasePrincipal::CreateCodebasePrincipal(nsIURI* aURI, const OriginAttributes& aAt
    nsCOMPtr<nsIPrincipal> principal;
    uriPrinc->GetPrincipal(getter_AddRefs(principal));
    if (!principal) {
      return nsNullPrincipal::Create(aAttrs);
      return NullPrincipal::Create(aAttrs);
    }
    RefPtr<BasePrincipal> concrete = Cast(principal);
    return concrete.forget();
@@ -674,7 +674,7 @@ BasePrincipal::CreateCodebasePrincipal(const nsACString& aOrigin)
             "CreateCodebasePrincipal does not support System and Expanded principals");

  MOZ_ASSERT(!StringBeginsWith(aOrigin, NS_LITERAL_CSTRING(NS_NULLPRINCIPAL_SCHEME ":")),
             "CreateCodebasePrincipal does not support nsNullPrincipal");
             "CreateCodebasePrincipal does not support NullPrincipal");

  nsAutoCString originNoSuffix;
  mozilla::OriginAttributes attrs;
+30 −29
Original line number Diff line number Diff line
@@ -13,8 +13,8 @@
#include "mozilla/ArrayUtils.h"

#include "nsDocShell.h"
#include "nsNullPrincipal.h"
#include "nsNullPrincipalURI.h"
#include "NullPrincipal.h"
#include "NullPrincipalURI.h"
#include "nsMemory.h"
#include "nsIURIWithPrincipal.h"
#include "nsIClassInfoImpl.h"
@@ -27,40 +27,40 @@

using namespace mozilla;

NS_IMPL_CLASSINFO(nsNullPrincipal, nullptr, nsIClassInfo::MAIN_THREAD_ONLY,
NS_IMPL_CLASSINFO(NullPrincipal, nullptr, nsIClassInfo::MAIN_THREAD_ONLY,
                  NS_NULLPRINCIPAL_CID)
NS_IMPL_QUERY_INTERFACE_CI(nsNullPrincipal,
NS_IMPL_QUERY_INTERFACE_CI(NullPrincipal,
                           nsIPrincipal,
                           nsISerializable)
NS_IMPL_CI_INTERFACE_GETTER(nsNullPrincipal,
NS_IMPL_CI_INTERFACE_GETTER(NullPrincipal,
                            nsIPrincipal,
                            nsISerializable)

/* static */ already_AddRefed<nsNullPrincipal>
nsNullPrincipal::CreateWithInheritedAttributes(nsIPrincipal* aInheritFrom)
/* static */ already_AddRefed<NullPrincipal>
NullPrincipal::CreateWithInheritedAttributes(nsIPrincipal* aInheritFrom)
{
  RefPtr<nsNullPrincipal> nullPrin = new nsNullPrincipal();
  RefPtr<NullPrincipal> nullPrin = new NullPrincipal();
  nsresult rv = nullPrin->Init(Cast(aInheritFrom)->OriginAttributesRef());
  MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
  return nullPrin.forget();
}

/* static */ already_AddRefed<nsNullPrincipal>
nsNullPrincipal::CreateWithInheritedAttributes(nsIDocShell* aDocShell, bool aIsFirstParty)
/* static */ already_AddRefed<NullPrincipal>
NullPrincipal::CreateWithInheritedAttributes(nsIDocShell* aDocShell, bool aIsFirstParty)
{
  OriginAttributes attrs = nsDocShell::Cast(aDocShell)->GetOriginAttributes();
  attrs.SetFirstPartyDomain(aIsFirstParty, NS_LITERAL_CSTRING(NULL_PRINCIPAL_FIRST_PARTY_DOMAIN));

  RefPtr<nsNullPrincipal> nullPrin = new nsNullPrincipal();
  RefPtr<NullPrincipal> nullPrin = new NullPrincipal();
  nsresult rv = nullPrin->Init(attrs);
  MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
  return nullPrin.forget();
}

/* static */ already_AddRefed<nsNullPrincipal>
nsNullPrincipal::Create(const OriginAttributes& aOriginAttributes, nsIURI* aURI)
/* static */ already_AddRefed<NullPrincipal>
NullPrincipal::Create(const OriginAttributes& aOriginAttributes, nsIURI* aURI)
{
  RefPtr<nsNullPrincipal> nullPrin = new nsNullPrincipal();
  RefPtr<NullPrincipal> nullPrin = new NullPrincipal();
  nsresult rv = nullPrin->Init(aOriginAttributes, aURI);
  MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));

@@ -68,7 +68,7 @@ nsNullPrincipal::Create(const OriginAttributes& aOriginAttributes, nsIURI* aURI)
}

nsresult
nsNullPrincipal::Init(const OriginAttributes& aOriginAttributes, nsIURI* aURI)
NullPrincipal::Init(const OriginAttributes& aOriginAttributes, nsIURI* aURI)
{
  mOriginAttributes = aOriginAttributes;

@@ -82,7 +82,7 @@ nsNullPrincipal::Init(const OriginAttributes& aOriginAttributes, nsIURI* aURI)

    mURI = aURI;
  } else {
    mURI = nsNullPrincipalURI::Create();
    mURI = NullPrincipalURI::Create();
    NS_ENSURE_TRUE(mURI, NS_ERROR_NOT_AVAILABLE);
  }

@@ -92,7 +92,7 @@ nsNullPrincipal::Init(const OriginAttributes& aOriginAttributes, nsIURI* aURI)
}

nsresult
nsNullPrincipal::GetScriptLocation(nsACString &aStr)
NullPrincipal::GetScriptLocation(nsACString &aStr)
{
  return mURI->GetSpec(aStr);
}
@@ -102,14 +102,15 @@ nsNullPrincipal::GetScriptLocation(nsACString &aStr)
 */

NS_IMETHODIMP
nsNullPrincipal::GetHashValue(uint32_t *aResult)
NullPrincipal::GetHashValue(uint32_t *aResult)
{
  *aResult = (NS_PTR_TO_INT32(this) >> 2);
  return NS_OK;
}

NS_IMETHODIMP
nsNullPrincipal::SetCsp(nsIContentSecurityPolicy* aCsp) {
NullPrincipal::SetCsp(nsIContentSecurityPolicy* aCsp)
{
  // Never destroy an existing CSP on the principal.
  // This method should only be called in rare cases.

@@ -123,19 +124,19 @@ nsNullPrincipal::SetCsp(nsIContentSecurityPolicy* aCsp) {
}

NS_IMETHODIMP
nsNullPrincipal::GetURI(nsIURI** aURI)
NullPrincipal::GetURI(nsIURI** aURI)
{
  return NS_EnsureSafeToReturn(mURI, aURI);
}

NS_IMETHODIMP
nsNullPrincipal::GetDomain(nsIURI** aDomain)
NullPrincipal::GetDomain(nsIURI** aDomain)
{
  return NS_EnsureSafeToReturn(mURI, aDomain);
}

NS_IMETHODIMP
nsNullPrincipal::SetDomain(nsIURI* aDomain)
NullPrincipal::SetDomain(nsIURI* aDomain)
{
  // I think the right thing to do here is to just throw...  Silently failing
  // seems counterproductive.
@@ -143,13 +144,13 @@ nsNullPrincipal::SetDomain(nsIURI* aDomain)
}

nsresult
nsNullPrincipal::GetOriginInternal(nsACString& aOrigin)
NullPrincipal::GetOriginInternal(nsACString& aOrigin)
{
  return mURI->GetSpec(aOrigin);
}

bool
nsNullPrincipal::MayLoadInternal(nsIURI* aURI)
NullPrincipal::MayLoadInternal(nsIURI* aURI)
{
  // Also allow the load if we are the principal of the URI being checked.
  nsCOMPtr<nsIURIWithPrincipal> uriPrinc = do_QueryInterface(aURI);
@@ -166,14 +167,14 @@ nsNullPrincipal::MayLoadInternal(nsIURI* aURI)
}

NS_IMETHODIMP
nsNullPrincipal::GetBaseDomain(nsACString& aBaseDomain)
NullPrincipal::GetBaseDomain(nsACString& aBaseDomain)
{
  // For a null principal, we use our unique uuid as the base domain.
  return mURI->GetPath(aBaseDomain);
}

NS_IMETHODIMP
nsNullPrincipal::GetAddonId(nsAString& aAddonId)
NullPrincipal::GetAddonId(nsAString& aAddonId)
{
  aAddonId.Truncate();
  return NS_OK;
@@ -183,9 +184,9 @@ nsNullPrincipal::GetAddonId(nsAString& aAddonId)
 * nsISerializable implementation
 */
NS_IMETHODIMP
nsNullPrincipal::Read(nsIObjectInputStream* aStream)
NullPrincipal::Read(nsIObjectInputStream* aStream)
{
  // Note - nsNullPrincipal use NS_GENERIC_FACTORY_CONSTRUCTOR_INIT, which means
  // Note - NullPrincipal use NS_GENERIC_FACTORY_CONSTRUCTOR_INIT, which means
  // that the Init() method has already been invoked by the time we deserialize.
  // This is in contrast to nsPrincipal, which uses NS_GENERIC_FACTORY_CONSTRUCTOR,
  // in which case ::Read needs to invoke Init().
@@ -210,7 +211,7 @@ nsNullPrincipal::Read(nsIObjectInputStream* aStream)
}

NS_IMETHODIMP
nsNullPrincipal::Write(nsIObjectOutputStream* aStream)
NullPrincipal::Write(nsIObjectOutputStream* aStream)
{
  NS_ENSURE_STATE(mURI);

+10 −9
Original line number Diff line number Diff line
@@ -9,8 +9,8 @@
 * same-origin with anything but themselves.
 */

#ifndef nsNullPrincipal_h__
#define nsNullPrincipal_h__
#ifndef NullPrincipal_h
#define NullPrincipal_h

#include "nsIPrincipal.h"
#include "nsJSPrincipals.h"
@@ -30,13 +30,13 @@ class nsIURI;

#define NS_NULLPRINCIPAL_SCHEME "moz-nullprincipal"

class nsNullPrincipal final : public mozilla::BasePrincipal
class NullPrincipal final : public mozilla::BasePrincipal
{
public:
  // This should only be used by deserialization, and the factory constructor.
  // Other consumers should use the Create and CreateWithInheritedAttributes
  // methods.
  nsNullPrincipal()
  NullPrincipal()
    : BasePrincipal(eNullPrincipal)
  {
  }
@@ -53,15 +53,16 @@ public:
  NS_IMETHOD GetAddonId(nsAString& aAddonId) override;
  nsresult GetOriginInternal(nsACString& aOrigin) override;

  static already_AddRefed<nsNullPrincipal> CreateWithInheritedAttributes(nsIPrincipal* aInheritFrom);
  static already_AddRefed<NullPrincipal> CreateWithInheritedAttributes(nsIPrincipal* aInheritFrom);

  // Create NullPrincipal with origin attributes from docshell.
  // If aIsFirstParty is true, and the pref 'privacy.firstparty.isolate' is also
  // enabled, the mFirstPartyDomain value of the origin attributes will be set
  // to NULL_PRINCIPAL_FIRST_PARTY_DOMAIN.
  static already_AddRefed<nsNullPrincipal> CreateWithInheritedAttributes(nsIDocShell* aDocShell, bool aIsFirstParty = false);
  static already_AddRefed<NullPrincipal>
  CreateWithInheritedAttributes(nsIDocShell* aDocShell, bool aIsFirstParty = false);

  static already_AddRefed<nsNullPrincipal>
  static already_AddRefed<NullPrincipal>
  Create(const mozilla::OriginAttributes& aOriginAttributes = mozilla::OriginAttributes(),
         nsIURI* aURI = nullptr);

@@ -71,7 +72,7 @@ public:
  virtual nsresult GetScriptLocation(nsACString &aStr) override;

 protected:
  virtual ~nsNullPrincipal() {}
  virtual ~NullPrincipal() = default;

  bool SubsumesInternal(nsIPrincipal* aOther, DocumentDomainConsideration aConsideration) override
  {
@@ -83,4 +84,4 @@ public:
  nsCOMPtr<nsIURI> mURI;
};

#endif // nsNullPrincipal_h__
#endif // NullPrincipal_h__
+65 −65
Original line number Diff line number Diff line
@@ -4,7 +4,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 "nsNullPrincipalURI.h"
#include "NullPrincipalURI.h"

#include "mozilla/DebugOnly.h"
#include "mozilla/MemoryReporting.h"
@@ -16,21 +16,21 @@
#include "nsIUUIDGenerator.h"

////////////////////////////////////////////////////////////////////////////////
//// nsNullPrincipalURI
//// NullPrincipalURI

nsNullPrincipalURI::nsNullPrincipalURI()
NullPrincipalURI::NullPrincipalURI()
  : mPath(mPathBytes, ArrayLength(mPathBytes), ArrayLength(mPathBytes) - 1)
{
}

nsNullPrincipalURI::nsNullPrincipalURI(const nsNullPrincipalURI& aOther)
NullPrincipalURI::NullPrincipalURI(const NullPrincipalURI& aOther)
  : mPath(mPathBytes, ArrayLength(mPathBytes), ArrayLength(mPathBytes) - 1)
{
  mPath.Assign(aOther.mPath);
}

nsresult
nsNullPrincipalURI::Init()
NullPrincipalURI::Init()
{
  // FIXME: bug 327161 -- make sure the uuid generator is reseeding-resistant.
  nsCOMPtr<nsIUUIDGenerator> uuidgen = services::GetUUIDGenerator();
@@ -51,10 +51,10 @@ nsNullPrincipalURI::Init()
}

/* static */
already_AddRefed<nsNullPrincipalURI>
nsNullPrincipalURI::Create()
already_AddRefed<NullPrincipalURI>
NullPrincipalURI::Create()
{
  RefPtr<nsNullPrincipalURI> uri = new nsNullPrincipalURI();
  RefPtr<NullPrincipalURI> uri = new NullPrincipalURI();
  nsresult rv = uri->Init();
  NS_ENSURE_SUCCESS(rv, nullptr);
  return uri.forget();
@@ -63,10 +63,10 @@ nsNullPrincipalURI::Create()
static NS_DEFINE_CID(kNullPrincipalURIImplementationCID,
                     NS_NULLPRINCIPALURI_IMPLEMENTATION_CID);

NS_IMPL_ADDREF(nsNullPrincipalURI)
NS_IMPL_RELEASE(nsNullPrincipalURI)
NS_IMPL_ADDREF(NullPrincipalURI)
NS_IMPL_RELEASE(NullPrincipalURI)

NS_INTERFACE_MAP_BEGIN(nsNullPrincipalURI)
NS_INTERFACE_MAP_BEGIN(NullPrincipalURI)
  NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIURI)
  if (aIID.Equals(kNullPrincipalURIImplementationCID))
    foundInterface = static_cast<nsIURI*>(this);
@@ -80,23 +80,23 @@ NS_INTERFACE_MAP_END
//// nsIURI

NS_IMETHODIMP
nsNullPrincipalURI::GetAsciiHost(nsACString &_host)
NullPrincipalURI::GetAsciiHost(nsACString& _host)
{
  _host.Truncate();
  return NS_OK;
}

NS_IMETHODIMP
nsNullPrincipalURI::GetAsciiHostPort(nsACString &_hostport)
NullPrincipalURI::GetAsciiHostPort(nsACString& _hostport)
{
  return NS_ERROR_NOT_IMPLEMENTED;
}

NS_IMETHODIMP
nsNullPrincipalURI::GetAsciiSpec(nsACString &_spec)
NullPrincipalURI::GetAsciiSpec(nsACString& _spec)
{
  nsAutoCString buffer;
  // Ignore the return value -- nsNullPrincipalURI::GetSpec() is infallible.
  // Ignore the return value -- NullPrincipalURI::GetSpec() is infallible.
  Unused << GetSpec(buffer);
  // This uses the infallible version of |NS_EscapeURL| as |GetSpec| is
  // already infallible.
@@ -105,141 +105,141 @@ nsNullPrincipalURI::GetAsciiSpec(nsACString &_spec)
}

NS_IMETHODIMP
nsNullPrincipalURI::GetHost(nsACString &_host)
NullPrincipalURI::GetHost(nsACString& _host)
{
  _host.Truncate();
  return NS_OK;
}

NS_IMETHODIMP
nsNullPrincipalURI::SetHost(const nsACString &aHost)
NullPrincipalURI::SetHost(const nsACString& aHost)
{
  return NS_ERROR_NOT_IMPLEMENTED;
}

NS_IMETHODIMP
nsNullPrincipalURI::GetHostPort(nsACString &_host)
NullPrincipalURI::GetHostPort(nsACString& _host)
{
  return NS_ERROR_NOT_IMPLEMENTED;
}

NS_IMETHODIMP
nsNullPrincipalURI::SetHostPort(const nsACString &aHost)
NullPrincipalURI::SetHostPort(const nsACString& aHost)
{
  return NS_ERROR_NOT_IMPLEMENTED;
}

NS_IMETHODIMP
nsNullPrincipalURI::SetHostAndPort(const nsACString &aHost)
NullPrincipalURI::SetHostAndPort(const nsACString& aHost)
{
  return NS_ERROR_NOT_IMPLEMENTED;
}

NS_IMETHODIMP
nsNullPrincipalURI::GetOriginCharset(nsACString &_charset)
NullPrincipalURI::GetOriginCharset(nsACString& _charset)
{
  _charset.Truncate();
  return NS_OK;
}

NS_IMETHODIMP
nsNullPrincipalURI::GetPassword(nsACString &_password)
NullPrincipalURI::GetPassword(nsACString& _password)
{
  return NS_ERROR_NOT_IMPLEMENTED;
}

NS_IMETHODIMP
nsNullPrincipalURI::SetPassword(const nsACString &aPassword)
NullPrincipalURI::SetPassword(const nsACString& aPassword)
{
  return NS_ERROR_NOT_IMPLEMENTED;
}

NS_IMETHODIMP
nsNullPrincipalURI::GetPath(nsACString &_path)
NullPrincipalURI::GetPath(nsACString& _path)
{
  _path = mPath;
  return NS_OK;
}

NS_IMETHODIMP
nsNullPrincipalURI::SetPath(const nsACString &aPath)
NullPrincipalURI::SetPath(const nsACString& aPath)
{
  return NS_ERROR_NOT_IMPLEMENTED;
}

NS_IMETHODIMP
nsNullPrincipalURI::GetFilePath(nsACString &aFilePath)
NullPrincipalURI::GetFilePath(nsACString& aFilePath)
{
  aFilePath.Truncate();
  return NS_ERROR_NOT_IMPLEMENTED;
}

NS_IMETHODIMP
nsNullPrincipalURI::SetFilePath(const nsACString &aFilePath)
NullPrincipalURI::SetFilePath(const nsACString& aFilePath)
{
  return NS_ERROR_NOT_IMPLEMENTED;
}

NS_IMETHODIMP
nsNullPrincipalURI::GetQuery(nsACString &aQuery)
NullPrincipalURI::GetQuery(nsACString& aQuery)
{
  aQuery.Truncate();
  return NS_ERROR_NOT_IMPLEMENTED;
}

NS_IMETHODIMP
nsNullPrincipalURI::SetQuery(const nsACString &aQuery)
NullPrincipalURI::SetQuery(const nsACString& aQuery)
{
  return NS_ERROR_NOT_IMPLEMENTED;
}

NS_IMETHODIMP
nsNullPrincipalURI::GetRef(nsACString &_ref)
NullPrincipalURI::GetRef(nsACString& _ref)
{
  _ref.Truncate();
  return NS_ERROR_NOT_IMPLEMENTED;
}

NS_IMETHODIMP
nsNullPrincipalURI::SetRef(const nsACString &aRef)
NullPrincipalURI::SetRef(const nsACString& aRef)
{
  return NS_ERROR_NOT_IMPLEMENTED;
}

NS_IMETHODIMP
nsNullPrincipalURI::GetPrePath(nsACString &_prePath)
NullPrincipalURI::GetPrePath(nsACString& _prePath)
{
  _prePath = NS_LITERAL_CSTRING(NS_NULLPRINCIPAL_SCHEME ":");
  return NS_OK;
}

NS_IMETHODIMP
nsNullPrincipalURI::GetPort(int32_t *_port)
NullPrincipalURI::GetPort(int32_t* _port)
{
  return NS_ERROR_NOT_IMPLEMENTED;
}

NS_IMETHODIMP
nsNullPrincipalURI::SetPort(int32_t aPort)
NullPrincipalURI::SetPort(int32_t aPort)
{
  return NS_ERROR_NOT_IMPLEMENTED;
}

NS_IMETHODIMP
nsNullPrincipalURI::GetScheme(nsACString &_scheme)
NullPrincipalURI::GetScheme(nsACString& _scheme)
{
  _scheme = NS_LITERAL_CSTRING(NS_NULLPRINCIPAL_SCHEME);
  return NS_OK;
}

NS_IMETHODIMP
nsNullPrincipalURI::SetScheme(const nsACString &aScheme)
NullPrincipalURI::SetScheme(const nsACString& aScheme)
{
  return NS_ERROR_NOT_IMPLEMENTED;
}

NS_IMETHODIMP
nsNullPrincipalURI::GetSpec(nsACString &_spec)
NullPrincipalURI::GetSpec(nsACString& _spec)
{
  _spec = NS_LITERAL_CSTRING(NS_NULLPRINCIPAL_SCHEME ":") + mPath;
  return NS_OK;
@@ -247,77 +247,77 @@ nsNullPrincipalURI::GetSpec(nsACString &_spec)

// result may contain unescaped UTF-8 characters
NS_IMETHODIMP
nsNullPrincipalURI::GetSpecIgnoringRef(nsACString &result)
NullPrincipalURI::GetSpecIgnoringRef(nsACString& _result)
{
  return GetSpec(result);
  return GetSpec(_result);
}

NS_IMETHODIMP
nsNullPrincipalURI::GetHasRef(bool *result)
NullPrincipalURI::GetHasRef(bool* _result)
{
  *result = false;
  *_result = false;
  return NS_OK;
}

NS_IMETHODIMP
nsNullPrincipalURI::SetSpec(const nsACString &aSpec)
NullPrincipalURI::SetSpec(const nsACString& aSpec)
{
  return NS_ERROR_NOT_IMPLEMENTED;
}

NS_IMETHODIMP
nsNullPrincipalURI::GetUsername(nsACString &_username)
NullPrincipalURI::GetUsername(nsACString& _username)
{
  return NS_ERROR_NOT_IMPLEMENTED;
}

NS_IMETHODIMP
nsNullPrincipalURI::SetUsername(const nsACString &aUsername)
NullPrincipalURI::SetUsername(const nsACString& aUsername)
{
  return NS_ERROR_NOT_IMPLEMENTED;
}

NS_IMETHODIMP
nsNullPrincipalURI::GetUserPass(nsACString &_userPass)
NullPrincipalURI::GetUserPass(nsACString& _userPass)
{
  return NS_ERROR_NOT_IMPLEMENTED;
}

NS_IMETHODIMP
nsNullPrincipalURI::SetUserPass(const nsACString &aUserPass)
NullPrincipalURI::SetUserPass(const nsACString& aUserPass)
{
  return NS_ERROR_NOT_IMPLEMENTED;
}

NS_IMETHODIMP
nsNullPrincipalURI::Clone(nsIURI **_newURI)
NullPrincipalURI::Clone(nsIURI** _newURI)
{
  nsCOMPtr<nsIURI> uri = new nsNullPrincipalURI(*this);
  nsCOMPtr<nsIURI> uri = new NullPrincipalURI(*this);
  uri.forget(_newURI);
  return NS_OK;
}

NS_IMETHODIMP
nsNullPrincipalURI::CloneIgnoringRef(nsIURI **_newURI)
NullPrincipalURI::CloneIgnoringRef(nsIURI** _newURI)
{
  // GetRef/SetRef not supported by nsNullPrincipalURI, so
  // GetRef/SetRef not supported by NullPrincipalURI, so
  // CloneIgnoringRef() is the same as Clone().
  return Clone(_newURI);
}

NS_IMETHODIMP
nsNullPrincipalURI::CloneWithNewRef(const nsACString& newRef, nsIURI **_newURI)
NullPrincipalURI::CloneWithNewRef(const nsACString& newRef, nsIURI** _newURI)
{
  // GetRef/SetRef not supported by nsNullPrincipalURI, so
  // GetRef/SetRef not supported by NullPrincipalURI, so
  // CloneWithNewRef() is the same as Clone().
  return Clone(_newURI);
}

NS_IMETHODIMP
nsNullPrincipalURI::Equals(nsIURI *aOther, bool *_equals)
NullPrincipalURI::Equals(nsIURI* aOther, bool* _equals)
{
  *_equals = false;
  RefPtr<nsNullPrincipalURI> otherURI;
  RefPtr<NullPrincipalURI> otherURI;
  nsresult rv = aOther->QueryInterface(kNullPrincipalURIImplementationCID,
                                       getter_AddRefs(otherURI));
  if (NS_SUCCEEDED(rv)) {
@@ -327,15 +327,15 @@ nsNullPrincipalURI::Equals(nsIURI *aOther, bool *_equals)
}

NS_IMETHODIMP
nsNullPrincipalURI::EqualsExceptRef(nsIURI *aOther, bool *_equals)
NullPrincipalURI::EqualsExceptRef(nsIURI* aOther, bool* _equals)
{
  // GetRef/SetRef not supported by nsNullPrincipalURI, so
  // GetRef/SetRef not supported by NullPrincipalURI, so
  // EqualsExceptRef() is the same as Equals().
  return Equals(aOther, _equals);
}

NS_IMETHODIMP
nsNullPrincipalURI::Resolve(const nsACString &aRelativePath,
NullPrincipalURI::Resolve(const nsACString& aRelativePath,
                            nsACString& _resolvedURI)
{
  _resolvedURI = aRelativePath;
@@ -343,7 +343,7 @@ nsNullPrincipalURI::Resolve(const nsACString &aRelativePath,
}

NS_IMETHODIMP
nsNullPrincipalURI::SchemeIs(const char *aScheme, bool *_schemeIs)
NullPrincipalURI::SchemeIs(const char* aScheme, bool* _schemeIs)
{
  *_schemeIs = (0 == nsCRT::strcasecmp(NS_NULLPRINCIPAL_SCHEME, aScheme));
  return NS_OK;
@@ -353,13 +353,13 @@ nsNullPrincipalURI::SchemeIs(const char *aScheme, bool *_schemeIs)
//// nsIIPCSerializableURI

void
nsNullPrincipalURI::Serialize(mozilla::ipc::URIParams &aParams)
NullPrincipalURI::Serialize(mozilla::ipc::URIParams& aParams)
{
  aParams = mozilla::ipc::NullPrincipalURIParams();
}

bool
nsNullPrincipalURI::Deserialize(const mozilla::ipc::URIParams &aParams)
NullPrincipalURI::Deserialize(const mozilla::ipc::URIParams& aParams)
{
  if (aParams.type() != mozilla::ipc::URIParams::TNullPrincipalURIParams) {
    MOZ_ASSERT_UNREACHABLE("unexpected URIParams type");
@@ -376,13 +376,13 @@ nsNullPrincipalURI::Deserialize(const mozilla::ipc::URIParams &aParams)
//// nsISizeOf

size_t
nsNullPrincipalURI::SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
NullPrincipalURI::SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
{
  return mPath.SizeOfExcludingThisIfUnshared(aMallocSizeOf);
}

size_t
nsNullPrincipalURI::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const {
NullPrincipalURI::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
{
  return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
}
+11 −11
Original line number Diff line number Diff line
@@ -8,8 +8,8 @@
 * This wraps nsSimpleURI so that all calls to it are done on the main thread.
 */

#ifndef __nsNullPrincipalURI_h__
#define __nsNullPrincipalURI_h__
#ifndef __NullPrincipalURI_h__
#define __NullPrincipalURI_h__

#include "nsIURI.h"
#include "nsISizeOf.h"
@@ -17,7 +17,7 @@
#include "mozilla/Attributes.h"
#include "nsIIPCSerializableURI.h"
#include "mozilla/MemoryReporting.h"
#include "nsNullPrincipal.h"
#include "NullPrincipal.h"
#include "nsID.h"

// {51fcd543-3b52-41f7-b91b-6b54102236e6}
@@ -25,7 +25,7 @@
  {0x51fcd543, 0x3b52, 0x41f7, \
    {0xb9, 0x1b, 0x6b, 0x54, 0x10, 0x22, 0x36, 0xe6} }

class nsNullPrincipalURI final : public nsIURI
class NullPrincipalURI final : public nsIURI
                             , public nsISizeOf
                             , public nsIIPCSerializableURI
{
@@ -40,15 +40,15 @@ public:

  // NB: This constructor exists only for deserialization.  Everyone
  // else should call Create.
  nsNullPrincipalURI();
  NullPrincipalURI();

  // Returns null on failure.
  static already_AddRefed<nsNullPrincipalURI> Create();
  static already_AddRefed<NullPrincipalURI> Create();

private:
  nsNullPrincipalURI(const nsNullPrincipalURI& aOther);
  NullPrincipalURI(const NullPrincipalURI& aOther);

  ~nsNullPrincipalURI() {}
  ~NullPrincipalURI() {}

  nsresult Init();

@@ -56,4 +56,4 @@ private:
  nsFixedCString mPath;
};

#endif // __nsNullPrincipalURI_h__
#endif // __NullPrincipalURI_h__
Loading