зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1584007 - initial implementation of FutureClientSourceParent r=dom-workers-and-storage-reviewers,mattwoodrow,asuth
Also implements SourceTableEntry and nsIDHasher to switch ClientManagerService's nsDataHashTable to a mozilla::HashMap<nsID, SourceTableEntry> in following changesets. Differential Revision: https://phabricator.services.mozilla.com/D66144 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
c80fa7258c
Коммит
b5b13cec75
|
@ -107,6 +107,10 @@ RefPtr<GenericPromise> OnShutdown() {
|
|||
|
||||
} // anonymous namespace
|
||||
|
||||
ClientManagerService::FutureClientSourceParent::FutureClientSourceParent(
|
||||
const IPCClientInfo& aClientInfo)
|
||||
: mPrincipalInfo(aClientInfo.principalInfo()) {}
|
||||
|
||||
ClientManagerService::ClientManagerService() : mShutdown(false) {
|
||||
AssertIsOnBackgroundThread();
|
||||
|
||||
|
|
|
@ -6,7 +6,12 @@
|
|||
#ifndef _mozilla_dom_ClientManagerService_h
|
||||
#define _mozilla_dom_ClientManagerService_h
|
||||
|
||||
#include "ClientHandleParent.h"
|
||||
#include "ClientOpPromise.h"
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/HashTable.h"
|
||||
#include "mozilla/MozPromise.h"
|
||||
#include "mozilla/Variant.h"
|
||||
#include "nsDataHashtable.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
@ -28,6 +33,55 @@ class ContentParent;
|
|||
// browser. This service runs on the PBackground thread. To interact
|
||||
// it with it please use the ClientManager and ClientHandle classes.
|
||||
class ClientManagerService final {
|
||||
// Placeholder type that represents a ClientSourceParent that may be created
|
||||
// in the future (e.g. while a redirect chain is being resolved).
|
||||
//
|
||||
// Each FutureClientSourceParent has a promise that callbacks may be chained
|
||||
// to; the promise will be resolved when the associated ClientSourceParent is
|
||||
// created or rejected when it's known that it'll never be created.
|
||||
class FutureClientSourceParent {
|
||||
public:
|
||||
explicit FutureClientSourceParent(const IPCClientInfo& aClientInfo);
|
||||
|
||||
const mozilla::ipc::PrincipalInfo& PrincipalInfo() const {
|
||||
return mPrincipalInfo;
|
||||
}
|
||||
|
||||
already_AddRefed<SourcePromise> Promise() {
|
||||
return mPromiseHolder.Ensure(__func__);
|
||||
}
|
||||
|
||||
void ResolvePromiseIfExists(ClientSourceParent* aSource) {
|
||||
MOZ_ASSERT(aSource);
|
||||
mPromiseHolder.ResolveIfExists(aSource, __func__);
|
||||
}
|
||||
|
||||
void RejectPromiseIfExists(const CopyableErrorResult& aRv) {
|
||||
MOZ_ASSERT(aRv.Failed());
|
||||
mPromiseHolder.RejectIfExists(aRv, __func__);
|
||||
}
|
||||
|
||||
private:
|
||||
const mozilla::ipc::PrincipalInfo mPrincipalInfo;
|
||||
MozPromiseHolder<SourcePromise> mPromiseHolder;
|
||||
};
|
||||
|
||||
using SourceTableEntry =
|
||||
Variant<FutureClientSourceParent, ClientSourceParent*>;
|
||||
|
||||
struct nsIDHasher {
|
||||
using Key = nsID;
|
||||
using Lookup = Key;
|
||||
|
||||
static HashNumber hash(const Lookup& aLookup) {
|
||||
return HashBytes(&aLookup, sizeof(Lookup));
|
||||
}
|
||||
|
||||
static bool match(const Key& aKey, const Lookup& aLookup) {
|
||||
return aKey.Equals(aLookup);
|
||||
}
|
||||
};
|
||||
|
||||
// Store the ClientSourceParent objects in a hash table. We want to
|
||||
// optimize for insertion, removal, and lookup by UUID.
|
||||
nsDataHashtable<nsIDHashKey, ClientSourceParent*> mSourceTable;
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
EXPORTS.mozilla.dom += [
|
||||
'ClientChannelHelper.h',
|
||||
'ClientHandle.h',
|
||||
'ClientHandleParent.h',
|
||||
'ClientInfo.h',
|
||||
'ClientIPCUtils.h',
|
||||
'ClientManager.h',
|
||||
|
|
Загрузка…
Ссылка в новой задаче