зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1693541 - Improve uses of nsBaseHashtable and descendants and avoid multiple subsequent lookups in dom/media. r=bryce
Differential Revision: https://phabricator.services.mozilla.com/D106095
This commit is contained in:
Родитель
371c154035
Коммит
d2cf2fa5cc
|
@ -473,23 +473,16 @@ void GeckoMediaPluginServiceChild::RemoveShutdownBlockerIfNeeded() {
|
|||
|
||||
already_AddRefed<GMPContentParent> GMPServiceChild::GetBridgedGMPContentParent(
|
||||
ProcessId aOtherPid, ipc::Endpoint<PGMPContentParent>&& endpoint) {
|
||||
RefPtr<GMPContentParent> parent;
|
||||
mContentParents.Get(aOtherPid, getter_AddRefs(parent));
|
||||
return do_AddRef(mContentParents.LookupOrInsertWith(aOtherPid, [&] {
|
||||
MOZ_ASSERT(aOtherPid == endpoint.OtherPid());
|
||||
|
||||
if (parent) {
|
||||
return parent.forget();
|
||||
}
|
||||
auto parent = MakeRefPtr<GMPContentParent>();
|
||||
|
||||
MOZ_ASSERT(aOtherPid == endpoint.OtherPid());
|
||||
DebugOnly<bool> ok = endpoint.Bind(parent);
|
||||
MOZ_ASSERT(ok);
|
||||
|
||||
parent = new GMPContentParent();
|
||||
|
||||
DebugOnly<bool> ok = endpoint.Bind(parent);
|
||||
MOZ_ASSERT(ok);
|
||||
|
||||
mContentParents.InsertOrUpdate(aOtherPid, RefPtr{parent});
|
||||
|
||||
return parent.forget();
|
||||
return parent;
|
||||
}));
|
||||
}
|
||||
|
||||
void GMPServiceChild::RemoveGMPContentParent(
|
||||
|
|
|
@ -1037,12 +1037,8 @@ nsresult ReadSalt(nsIFile* aPath, nsACString& aOutData) {
|
|||
|
||||
already_AddRefed<GMPStorage> GeckoMediaPluginServiceParent::GetMemoryStorageFor(
|
||||
const nsACString& aNodeId) {
|
||||
RefPtr<GMPStorage> s;
|
||||
if (!mTempGMPStorage.Get(aNodeId, getter_AddRefs(s))) {
|
||||
s = CreateGMPMemoryStorage();
|
||||
mTempGMPStorage.InsertOrUpdate(aNodeId, RefPtr{s});
|
||||
}
|
||||
return s.forget();
|
||||
return do_AddRef(mTempGMPStorage.LookupOrInsertWith(
|
||||
aNodeId, [] { return CreateGMPMemoryStorage(); }));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
|
@ -104,11 +104,8 @@ bool MediaPlaybackStatus::IsAnyMediaBeingControlled() const {
|
|||
MediaPlaybackStatus::ContextMediaInfo&
|
||||
MediaPlaybackStatus::GetNotNullContextInfo(uint64_t aContextId) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
if (!mContextInfoMap.Contains(aContextId)) {
|
||||
mContextInfoMap.InsertOrUpdate(aContextId,
|
||||
MakeUnique<ContextMediaInfo>(aContextId));
|
||||
}
|
||||
return *(mContextInfoMap.GetValue(aContextId)->get());
|
||||
return *mContextInfoMap.LookupOrInsertWith(
|
||||
aContextId, [&] { return MakeUnique<ContextMediaInfo>(aContextId); });
|
||||
}
|
||||
|
||||
Maybe<uint64_t> MediaPlaybackStatus::GetAudioFocusOwnerContextId() const {
|
||||
|
|
|
@ -62,28 +62,33 @@ void MediaStatusManager::NotifyMediaAudibleChanged(uint64_t aBrowsingContextId,
|
|||
}
|
||||
|
||||
void MediaStatusManager::NotifySessionCreated(uint64_t aBrowsingContextId) {
|
||||
if (mMediaSessionInfoMap.Contains(aBrowsingContextId)) {
|
||||
return;
|
||||
}
|
||||
if (!mMediaSessionInfoMap.WithEntryHandle(
|
||||
aBrowsingContextId, [&](auto&& entry) {
|
||||
if (entry) return true;
|
||||
|
||||
LOG("Session %" PRIu64 " has been created", aBrowsingContextId);
|
||||
mMediaSessionInfoMap.InsertOrUpdate(aBrowsingContextId,
|
||||
MediaSessionInfo::EmptyInfo());
|
||||
if (IsSessionOwningAudioFocus(aBrowsingContextId)) {
|
||||
SetActiveMediaSessionContextId(aBrowsingContextId);
|
||||
LOG("Session %" PRIu64 " has been created", aBrowsingContextId);
|
||||
entry.Insert(MediaSessionInfo::EmptyInfo());
|
||||
return false;
|
||||
})) {
|
||||
// This can't be done from within the WithEntryHandle functor, since it
|
||||
// accesses mMediaSessionInfoMap.
|
||||
if (IsSessionOwningAudioFocus(aBrowsingContextId)) {
|
||||
SetActiveMediaSessionContextId(aBrowsingContextId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MediaStatusManager::NotifySessionDestroyed(uint64_t aBrowsingContextId) {
|
||||
if (!mMediaSessionInfoMap.Contains(aBrowsingContextId)) {
|
||||
return;
|
||||
}
|
||||
LOG("Session %" PRIu64 " has been destroyed", aBrowsingContextId);
|
||||
mMediaSessionInfoMap.Remove(aBrowsingContextId);
|
||||
if (mActiveMediaSessionContextId &&
|
||||
*mActiveMediaSessionContextId == aBrowsingContextId) {
|
||||
ClearActiveMediaSessionContextIdIfNeeded();
|
||||
}
|
||||
mMediaSessionInfoMap.WithEntryHandle(aBrowsingContextId, [&](auto&& entry) {
|
||||
if (entry) return;
|
||||
|
||||
LOG("Session %" PRIu64 " has been destroyed", aBrowsingContextId);
|
||||
entry.Remove();
|
||||
if (mActiveMediaSessionContextId &&
|
||||
*mActiveMediaSessionContextId == aBrowsingContextId) {
|
||||
ClearActiveMediaSessionContextIdIfNeeded();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void MediaStatusManager::UpdateMetadata(
|
||||
|
|
|
@ -145,12 +145,12 @@ class EMEDecryptor : public MediaDataDecoder,
|
|||
return;
|
||||
}
|
||||
|
||||
mDecrypts.InsertOrUpdate(aSample,
|
||||
MakeUnique<DecryptPromiseRequestHolder>());
|
||||
const auto& decrypt = mDecrypts.InsertOrUpdate(
|
||||
aSample, MakeUnique<DecryptPromiseRequestHolder>());
|
||||
mProxy->Decrypt(aSample)
|
||||
->Then(mThread, __func__, this, &EMEDecryptor::Decrypted,
|
||||
&EMEDecryptor::Decrypted)
|
||||
->Track(*mDecrypts.Get(aSample));
|
||||
->Track(*decrypt);
|
||||
}
|
||||
|
||||
void Decrypted(const DecryptResult& aDecrypted) {
|
||||
|
|
|
@ -122,7 +122,7 @@ bool MediaSystemResourceManager::IsIpcClosed() { return mChild ? true : false; }
|
|||
void MediaSystemResourceManager::Register(MediaSystemResourceClient* aClient) {
|
||||
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
|
||||
MOZ_ASSERT(aClient);
|
||||
MOZ_ASSERT(!mResourceClients.Get(aClient->mId));
|
||||
MOZ_ASSERT(!mResourceClients.Contains(aClient->mId));
|
||||
|
||||
mResourceClients.InsertOrUpdate(aClient->mId, aClient);
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ void MediaSystemResourceManager::Unregister(
|
|||
MediaSystemResourceClient* aClient) {
|
||||
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
|
||||
MOZ_ASSERT(aClient);
|
||||
MOZ_ASSERT(mResourceClients.Get(aClient->mId));
|
||||
MOZ_ASSERT(mResourceClients.Contains(aClient->mId));
|
||||
MOZ_ASSERT(mResourceClients.Get(aClient->mId) == aClient);
|
||||
|
||||
mResourceClients.Remove(aClient->mId);
|
||||
|
|
Загрузка…
Ссылка в новой задаче