mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Bug 708901 - Migrate to nsTHashSet in dom/plugins. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D109323
This commit is contained in:
parent
71619f5f54
commit
d5157cb1ac
@ -1927,10 +1927,10 @@ NPError PluginModuleChild::PluginRequiresAudioDeviceChanges(
|
||||
}
|
||||
}
|
||||
if (rv == NPERR_NO_ERROR) {
|
||||
mAudioNotificationSet.PutEntry(aInstance);
|
||||
mAudioNotificationSet.Insert(aInstance);
|
||||
}
|
||||
} else if (!mAudioNotificationSet.IsEmpty()) {
|
||||
mAudioNotificationSet.RemoveEntry(aInstance);
|
||||
mAudioNotificationSet.Remove(aInstance);
|
||||
if (mAudioNotificationSet.IsEmpty()) {
|
||||
// We released the last plugin. Unregister from the PluginModuleParent.
|
||||
if (!CallNPN_SetValue_NPPVpluginRequiresAudioDeviceChanges(
|
||||
@ -1954,9 +1954,7 @@ PluginModuleChild::RecvNPP_SetValue_NPNVaudioDeviceChangeDetails(
|
||||
details.flow = detailsIPC.flow;
|
||||
details.role = detailsIPC.role;
|
||||
details.defaultDevice = detailsIPC.defaultDevice.c_str();
|
||||
for (auto iter = mAudioNotificationSet.ConstIter(); !iter.Done();
|
||||
iter.Next()) {
|
||||
PluginInstanceChild* pluginInst = iter.Get()->GetKey();
|
||||
for (PluginInstanceChild* pluginInst : mAudioNotificationSet) {
|
||||
pluginInst->DefaultAudioDeviceChanged(details);
|
||||
}
|
||||
return IPC_OK();
|
||||
@ -1973,9 +1971,7 @@ PluginModuleChild::RecvNPP_SetValue_NPNVaudioDeviceStateChanged(
|
||||
NPAudioDeviceStateChanged stateChange;
|
||||
stateChange.newState = aDeviceStateIPC.state;
|
||||
stateChange.device = aDeviceStateIPC.device.c_str();
|
||||
for (auto iter = mAudioNotificationSet.ConstIter(); !iter.Done();
|
||||
iter.Next()) {
|
||||
PluginInstanceChild* pluginInst = iter.Get()->GetKey();
|
||||
for (PluginInstanceChild* pluginInst : mAudioNotificationSet) {
|
||||
pluginInst->AudioDeviceStateChanged(stateChange);
|
||||
}
|
||||
return IPC_OK();
|
||||
|
@ -19,8 +19,9 @@
|
||||
#include "npapi.h"
|
||||
#include "npfunctions.h"
|
||||
|
||||
#include "nsTHashtable.h"
|
||||
#include "nsHashKeys.h"
|
||||
#if defined(XP_WIN)
|
||||
# include "nsTHashSet.h"
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_WIDGET_COCOA
|
||||
# include "PluginInterposeOSX.h"
|
||||
@ -282,7 +283,7 @@ class PluginModuleChild : public PPluginModuleChild {
|
||||
#endif
|
||||
|
||||
#if defined(XP_WIN)
|
||||
typedef nsTHashtable<nsPtrHashKey<PluginInstanceChild>> PluginInstanceSet;
|
||||
typedef nsTHashSet<PluginInstanceChild*> PluginInstanceSet;
|
||||
// Set of plugins that have registered to be notified when the audio device
|
||||
// changes.
|
||||
PluginInstanceSet mAudioNotificationSet;
|
||||
|
@ -47,7 +47,7 @@ PluginProcessParent::PluginProcessParent(const std::string& aPluginFilePath)
|
||||
PluginProcessParent::~PluginProcessParent() {
|
||||
#ifdef XP_WIN
|
||||
if (sPidSet && mChildPid) {
|
||||
sPidSet->RemoveEntry(mChildPid);
|
||||
sPidSet->Remove(mChildPid);
|
||||
if (sPidSet->IsEmpty()) {
|
||||
delete sPidSet;
|
||||
sPidSet = nullptr;
|
||||
@ -165,7 +165,7 @@ void PluginProcessParent::OnChannelConnected(int32_t peer_pid) {
|
||||
if (!sPidSet) {
|
||||
sPidSet = new PluginProcessParent::PidSet();
|
||||
}
|
||||
sPidSet->PutEntry(mChildPid);
|
||||
sPidSet->Insert(mChildPid);
|
||||
#endif
|
||||
|
||||
GeckoChildProcessHost::OnChannelConnected(peer_pid);
|
||||
|
@ -19,8 +19,10 @@
|
||||
#include "mozilla/ipc/TaskFactory.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsTHashtable.h"
|
||||
#include "nsHashKeys.h"
|
||||
|
||||
#if defined(XP_WIN)
|
||||
# include "nsTHashSet.h"
|
||||
#endif
|
||||
|
||||
namespace mozilla {
|
||||
namespace plugins {
|
||||
@ -80,7 +82,7 @@ class PluginProcessParent final : public mozilla::ipc::GeckoChildProcessHost {
|
||||
UniquePtr<LaunchCompleteTask> mLaunchCompleteTask;
|
||||
MessageLoop* mMainMsgLoop;
|
||||
#ifdef XP_WIN
|
||||
typedef nsTHashtable<nsUint32HashKey> PidSet;
|
||||
typedef nsTHashSet<uint32_t> PidSet;
|
||||
// Set of PIDs for all plugin child processes or NULL if empty.
|
||||
static PidSet* sPidSet;
|
||||
uint32_t mChildPid;
|
||||
|
@ -9,13 +9,14 @@
|
||||
#include "PluginUtilsWin.h"
|
||||
#include "PluginModuleParent.h"
|
||||
#include "mozilla/StaticMutex.h"
|
||||
#include "nsTHashSet.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace plugins {
|
||||
namespace PluginUtilsWin {
|
||||
|
||||
class AudioNotification;
|
||||
typedef nsTHashtable<nsPtrHashKey<PluginModuleParent>> PluginModuleSet;
|
||||
typedef nsTHashSet<PluginModuleParent*> PluginModuleSet;
|
||||
StaticMutex sMutex;
|
||||
|
||||
class AudioDeviceMessageRunnable : public Runnable {
|
||||
@ -147,12 +148,12 @@ class AudioNotification final : public IMMNotificationClient {
|
||||
|
||||
void AddModule(PluginModuleParent* aModule) {
|
||||
StaticMutexAutoLock lock(sMutex);
|
||||
mAudioNotificationSet.PutEntry(aModule);
|
||||
mAudioNotificationSet.Insert(aModule);
|
||||
}
|
||||
|
||||
void RemoveModule(PluginModuleParent* aModule) {
|
||||
StaticMutexAutoLock lock(sMutex);
|
||||
mAudioNotificationSet.RemoveEntry(aModule);
|
||||
mAudioNotificationSet.Remove(aModule);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -247,9 +248,7 @@ AudioDeviceMessageRunnable::Run() {
|
||||
mAudioNotification->GetModuleSet()->Count()));
|
||||
|
||||
bool success = true;
|
||||
for (auto iter = mAudioNotification->GetModuleSet()->ConstIter();
|
||||
!iter.Done(); iter.Next()) {
|
||||
PluginModuleParent* pluginModule = iter.Get()->GetKey();
|
||||
for (PluginModuleParent* pluginModule : *mAudioNotification->GetModuleSet()) {
|
||||
switch (mMessageType) {
|
||||
case DEFAULT_DEVICE_CHANGED:
|
||||
success &= pluginModule->SendNPP_SetValue_NPNVaudioDeviceChangeDetails(
|
||||
|
Loading…
Reference in New Issue
Block a user