Bug 1456466 P1 Expose a GetPrincipal() convenience method on service worker descriptor classes. r=baku

This commit is contained in:
Ben Kelly 2018-04-24 06:32:14 -07:00
Родитель 6df5d73ab0
Коммит c87c8a28af
4 изменённых файлов: 29 добавлений и 0 удалений

Просмотреть файл

@ -12,6 +12,9 @@
namespace mozilla { namespace mozilla {
namespace dom { namespace dom {
using mozilla::ipc::PrincipalInfo;
using mozilla::ipc::PrincipalInfoToPrincipal;
ServiceWorkerDescriptor::ServiceWorkerDescriptor(uint64_t aId, ServiceWorkerDescriptor::ServiceWorkerDescriptor(uint64_t aId,
nsIPrincipal* aPrincipal, nsIPrincipal* aPrincipal,
const nsACString& aScope, const nsACString& aScope,
@ -95,6 +98,14 @@ ServiceWorkerDescriptor::PrincipalInfo() const
return mData->principalInfo(); return mData->principalInfo();
} }
nsCOMPtr<nsIPrincipal>
ServiceWorkerDescriptor::GetPrincipal() const
{
AssertIsOnMainThread();
nsCOMPtr<nsIPrincipal> ref = PrincipalInfoToPrincipal(mData->principalInfo());
return Move(ref);
}
const nsCString& const nsCString&
ServiceWorkerDescriptor::Scope() const ServiceWorkerDescriptor::Scope() const
{ {

Просмотреть файл

@ -7,6 +7,7 @@
#define _mozilla_dom_ServiceWorkerDescriptor_h #define _mozilla_dom_ServiceWorkerDescriptor_h
#include "mozilla/UniquePtr.h" #include "mozilla/UniquePtr.h"
#include "nsCOMPtr.h"
#include "nsString.h" #include "nsString.h"
class nsIPrincipal; class nsIPrincipal;
@ -69,6 +70,9 @@ public:
const mozilla::ipc::PrincipalInfo& const mozilla::ipc::PrincipalInfo&
PrincipalInfo() const; PrincipalInfo() const;
nsCOMPtr<nsIPrincipal>
GetPrincipal() const;
const nsCString& const nsCString&
Scope() const; Scope() const;

Просмотреть файл

@ -13,6 +13,9 @@
namespace mozilla { namespace mozilla {
namespace dom { namespace dom {
using mozilla::ipc::PrincipalInfo;
using mozilla::ipc::PrincipalInfoToPrincipal;
Maybe<IPCServiceWorkerDescriptor> Maybe<IPCServiceWorkerDescriptor>
ServiceWorkerRegistrationDescriptor::NewestInternal() const ServiceWorkerRegistrationDescriptor::NewestInternal() const
{ {
@ -130,6 +133,14 @@ ServiceWorkerRegistrationDescriptor::PrincipalInfo() const
return mData->principalInfo(); return mData->principalInfo();
} }
nsCOMPtr<nsIPrincipal>
ServiceWorkerRegistrationDescriptor::GetPrincipal() const
{
AssertIsOnMainThread();
nsCOMPtr<nsIPrincipal> ref = PrincipalInfoToPrincipal(mData->principalInfo());
return Move(ref);
}
const nsCString& const nsCString&
ServiceWorkerRegistrationDescriptor::Scope() const ServiceWorkerRegistrationDescriptor::Scope() const
{ {

Просмотреть файл

@ -73,6 +73,9 @@ public:
const mozilla::ipc::PrincipalInfo& const mozilla::ipc::PrincipalInfo&
PrincipalInfo() const; PrincipalInfo() const;
nsCOMPtr<nsIPrincipal>
GetPrincipal() const;
const nsCString& const nsCString&
Scope() const; Scope() const;