зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1429486
Expose GetClientInfo() and GetController() on nsIGlobalObject. r=asuth
This commit is contained in:
Родитель
95ceb13927
Коммит
eecacb4a97
|
@ -348,9 +348,9 @@ public:
|
|||
virtual bool IsFrozen() const override;
|
||||
void SyncStateFromParentWindow();
|
||||
|
||||
mozilla::Maybe<mozilla::dom::ClientInfo> GetClientInfo() const;
|
||||
mozilla::Maybe<mozilla::dom::ClientInfo> GetClientInfo() const override;
|
||||
mozilla::Maybe<mozilla::dom::ClientState> GetClientState() const;
|
||||
mozilla::Maybe<mozilla::dom::ServiceWorkerDescriptor> GetController() const;
|
||||
mozilla::Maybe<mozilla::dom::ServiceWorkerDescriptor> GetController() const override;
|
||||
|
||||
void NoteCalledRegisterForServiceWorkerScope(const nsACString& aScope);
|
||||
|
||||
|
|
|
@ -9,6 +9,10 @@
|
|||
#include "nsThreadUtils.h"
|
||||
#include "nsHostObjectProtocolHandler.h"
|
||||
|
||||
using mozilla::Maybe;
|
||||
using mozilla::dom::ClientInfo;
|
||||
using mozilla::dom::ServiceWorkerDescriptor;
|
||||
|
||||
nsIGlobalObject::~nsIGlobalObject()
|
||||
{
|
||||
UnlinkHostObjectURIs();
|
||||
|
@ -112,3 +116,19 @@ nsIGlobalObject::TraverseHostObjectURIs(nsCycleCollectionTraversalCallback &aCb)
|
|||
nsHostObjectProtocolHandler::Traverse(mHostObjectURIs[index], aCb);
|
||||
}
|
||||
}
|
||||
|
||||
Maybe<ClientInfo>
|
||||
nsIGlobalObject::GetClientInfo() const
|
||||
{
|
||||
// By default globals do not expose themselves as a client. Only real
|
||||
// window and worker globals are currently considered clients.
|
||||
return Maybe<ClientInfo>();
|
||||
}
|
||||
|
||||
Maybe<ServiceWorkerDescriptor>
|
||||
nsIGlobalObject::GetController() const
|
||||
{
|
||||
// By default globals do not have a service worker controller. Only real
|
||||
// window and worker globals can currently be controlled as a client.
|
||||
return Maybe<ServiceWorkerDescriptor>();
|
||||
}
|
||||
|
|
|
@ -7,7 +7,10 @@
|
|||
#ifndef nsIGlobalObject_h__
|
||||
#define nsIGlobalObject_h__
|
||||
|
||||
#include "mozilla/Maybe.h"
|
||||
#include "mozilla/dom/ClientInfo.h"
|
||||
#include "mozilla/dom/DispatcherTrait.h"
|
||||
#include "mozilla/dom/ServiceWorkerDescriptor.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsStringFwd.h"
|
||||
#include "nsTArray.h"
|
||||
|
@ -76,6 +79,12 @@ public:
|
|||
|
||||
virtual bool IsInSyncOperation() { return false; }
|
||||
|
||||
virtual mozilla::Maybe<mozilla::dom::ClientInfo>
|
||||
GetClientInfo() const;
|
||||
|
||||
virtual mozilla::Maybe<mozilla::dom::ServiceWorkerDescriptor>
|
||||
GetController() const;
|
||||
|
||||
protected:
|
||||
virtual ~nsIGlobalObject();
|
||||
|
||||
|
|
|
@ -1380,7 +1380,7 @@ DeleteFilesRunnable::Open()
|
|||
quotaManager->OpenDirectory(mFileManager->Type(),
|
||||
mFileManager->Group(),
|
||||
mFileManager->Origin(),
|
||||
Client::IDB,
|
||||
quota::Client::IDB,
|
||||
/* aExclusive */ false,
|
||||
this);
|
||||
|
||||
|
|
|
@ -49,6 +49,7 @@
|
|||
#include "mozilla/dom/BindingUtils.h"
|
||||
#include "mozilla/dom/ClientManager.h"
|
||||
#include "mozilla/dom/ClientSource.h"
|
||||
#include "mozilla/dom/ClientState.h"
|
||||
#include "mozilla/dom/Console.h"
|
||||
#include "mozilla/dom/DocGroup.h"
|
||||
#include "mozilla/dom/ErrorEvent.h"
|
||||
|
@ -5333,6 +5334,24 @@ WorkerPrivate::GetClientInfo() const
|
|||
return mClientSource->Info();
|
||||
}
|
||||
|
||||
const ClientState
|
||||
WorkerPrivate::GetClientState() const
|
||||
{
|
||||
AssertIsOnWorkerThread();
|
||||
MOZ_DIAGNOSTIC_ASSERT(mClientSource);
|
||||
ClientState state;
|
||||
mClientSource->SnapshotState(&state);
|
||||
return Move(state);
|
||||
}
|
||||
|
||||
const Maybe<ServiceWorkerDescriptor>
|
||||
WorkerPrivate::GetController() const
|
||||
{
|
||||
AssertIsOnWorkerThread();
|
||||
MOZ_DIAGNOSTIC_ASSERT(mClientSource);
|
||||
return mClientSource->GetController();
|
||||
}
|
||||
|
||||
void
|
||||
WorkerPrivate::Control(const ServiceWorkerDescriptor& aServiceWorker)
|
||||
{
|
||||
|
|
|
@ -1494,6 +1494,12 @@ public:
|
|||
const ClientInfo&
|
||||
GetClientInfo() const;
|
||||
|
||||
const ClientState
|
||||
GetClientState() const;
|
||||
|
||||
const Maybe<ServiceWorkerDescriptor>
|
||||
GetController() const;
|
||||
|
||||
void
|
||||
Control(const ServiceWorkerDescriptor& aServiceWorker);
|
||||
|
||||
|
|
|
@ -515,6 +515,28 @@ WorkerGlobalScope::AbstractMainThreadFor(TaskCategory aCategory)
|
|||
MOZ_CRASH("AbstractMainThreadFor not supported for workers.");
|
||||
}
|
||||
|
||||
Maybe<ClientInfo>
|
||||
WorkerGlobalScope::GetClientInfo() const
|
||||
{
|
||||
Maybe<ClientInfo> info;
|
||||
info.emplace(mWorkerPrivate->GetClientInfo());
|
||||
return Move(info);
|
||||
}
|
||||
|
||||
Maybe<ClientState>
|
||||
WorkerGlobalScope::GetClientState() const
|
||||
{
|
||||
Maybe<ClientState> state;
|
||||
state.emplace(mWorkerPrivate->GetClientState());
|
||||
return Move(state);
|
||||
}
|
||||
|
||||
Maybe<ServiceWorkerDescriptor>
|
||||
WorkerGlobalScope::GetController() const
|
||||
{
|
||||
return mWorkerPrivate->GetController();
|
||||
}
|
||||
|
||||
DedicatedWorkerGlobalScope::DedicatedWorkerGlobalScope(WorkerPrivate* aWorkerPrivate,
|
||||
const nsString& aName)
|
||||
: WorkerGlobalScope(aWorkerPrivate)
|
||||
|
|
|
@ -19,7 +19,9 @@ namespace dom {
|
|||
|
||||
class AnyCallback;
|
||||
struct ChannelPixelLayout;
|
||||
class ClientInfo;
|
||||
class Clients;
|
||||
class ClientState;
|
||||
class Console;
|
||||
class Crypto;
|
||||
class Function;
|
||||
|
@ -221,6 +223,15 @@ public:
|
|||
|
||||
AbstractThread*
|
||||
AbstractMainThreadFor(TaskCategory aCategory) override;
|
||||
|
||||
Maybe<ClientInfo>
|
||||
GetClientInfo() const override;
|
||||
|
||||
Maybe<ClientState>
|
||||
GetClientState() const;
|
||||
|
||||
Maybe<ServiceWorkerDescriptor>
|
||||
GetController() const override;
|
||||
};
|
||||
|
||||
class DedicatedWorkerGlobalScope final : public WorkerGlobalScope
|
||||
|
|
Загрузка…
Ссылка в новой задаче