@@ -81,7 +81,7 @@ GMPParent::GMPParent()
81
81
mChildLaunchArch (base::PROCESS_ARCH_INVALID),
82
82
#endif
83
83
mMainThread (GetMainThreadSerialEventTarget()) {
84
- MOZ_ASSERT (GMPEventTarget ()-> IsOnCurrentThread ());
84
+ MOZ_ASSERT (IsOnGMPEventTarget ());
85
85
GMP_PARENT_LOG_DEBUG (" GMPParent ctor id=%u" , mPluginId );
86
86
}
87
87
@@ -92,7 +92,7 @@ GMPParent::~GMPParent() {
92
92
}
93
93
94
94
void GMPParent::CloneFrom (const GMPParent* aOther) {
95
- MOZ_ASSERT (GMPEventTarget ()-> IsOnCurrentThread ());
95
+ MOZ_ASSERT (IsOnGMPEventTarget ());
96
96
MOZ_ASSERT (aOther->mDirectory && aOther->mService , " null plugin directory" );
97
97
98
98
mService = aOther->mService ;
@@ -169,7 +169,7 @@ RefPtr<GenericPromise> GMPParent::Init(GeckoMediaPluginServiceParent* aService,
169
169
nsIFile* aPluginDir) {
170
170
MOZ_ASSERT (aPluginDir);
171
171
MOZ_ASSERT (aService);
172
- MOZ_ASSERT (GMPEventTarget ()-> IsOnCurrentThread ());
172
+ MOZ_ASSERT (IsOnGMPEventTarget ());
173
173
174
174
mService = aService;
175
175
mDirectory = aPluginDir;
@@ -343,7 +343,7 @@ class NotifyGMPProcessLoadedTask : public Runnable {
343
343
344
344
nsresult GMPParent::LoadProcess () {
345
345
MOZ_ASSERT (mDirectory , " Plugin directory cannot be NULL!" );
346
- MOZ_ASSERT (GMPEventTarget ()-> IsOnCurrentThread ());
346
+ MOZ_ASSERT (IsOnGMPEventTarget ());
347
347
MOZ_ASSERT (mState == GMPState::NotLoaded);
348
348
349
349
if (NS_WARN_IF(mPluginType == GMPPluginType::WidevineL1)) {
@@ -433,7 +433,7 @@ nsresult GMPParent::LoadProcess() {
433
433
}
434
434
435
435
void GMPParent::OnPreferenceChange (const mozilla::dom::Pref& aPref) {
436
- MOZ_ASSERT (GMPEventTarget ()-> IsOnCurrentThread ());
436
+ MOZ_ASSERT (IsOnGMPEventTarget ());
437
437
GMP_PARENT_LOG_DEBUG (" %s" , __FUNCTION__);
438
438
439
439
if (!mProcess || !mProcess ->UseXPCOM ()) {
@@ -501,7 +501,7 @@ mozilla::ipc::IPCResult GMPParent::RecvGetModulesTrust(
501
501
#endif // defined(XP_WIN)
502
502
503
503
void GMPParent::CloseIfUnused () {
504
- MOZ_ASSERT (GMPEventTarget ()-> IsOnCurrentThread ());
504
+ MOZ_ASSERT (IsOnGMPEventTarget ());
505
505
GMP_PARENT_LOG_DEBUG (" %s" , __FUNCTION__);
506
506
507
507
if ((mDeleteProcessOnlyOnUnload || mState == GMPState::Loaded ||
@@ -524,7 +524,7 @@ void GMPParent::CloseIfUnused() {
524
524
}
525
525
526
526
void GMPParent::CloseActive (bool aDieWhenUnloaded) {
527
- MOZ_ASSERT (GMPEventTarget ()-> IsOnCurrentThread ());
527
+ MOZ_ASSERT (IsOnGMPEventTarget ());
528
528
GMP_PARENT_LOG_DEBUG (" %s: state %u" , __FUNCTION__,
529
529
uint32_t (GMPState (mState )));
530
530
@@ -548,7 +548,7 @@ void GMPParent::MarkForDeletion() {
548
548
bool GMPParent::IsMarkedForDeletion () { return mIsBlockingDeletion ; }
549
549
550
550
void GMPParent::Shutdown () {
551
- MOZ_ASSERT (GMPEventTarget ()-> IsOnCurrentThread ());
551
+ MOZ_ASSERT (IsOnGMPEventTarget ());
552
552
GMP_PARENT_LOG_DEBUG (" %s" , __FUNCTION__);
553
553
554
554
if (mAbnormalShutdownInProgress ) {
@@ -615,7 +615,7 @@ void GMPParent::ChildTerminated() {
615
615
}
616
616
617
617
void GMPParent::DeleteProcess () {
618
- MOZ_ASSERT (GMPEventTarget ()-> IsOnCurrentThread ());
618
+ MOZ_ASSERT (IsOnGMPEventTarget ());
619
619
620
620
switch (mState ) {
621
621
case GMPState::Closed:
@@ -701,7 +701,17 @@ void GMPParent::DeleteProcess() {
701
701
702
702
GMPState GMPParent::State () const { return mState ; }
703
703
704
- nsCOMPtr<nsISerialEventTarget> GMPParent::GMPEventTarget () {
704
+ bool GMPParent::IsOnGMPEventTarget () const {
705
+ auto target = GMPEventTarget ();
706
+ if (!target) {
707
+ // We can't get the GMP event target if it has started shutting down, but it
708
+ // may still run tasks.
709
+ return AppShutdown::IsInOrBeyond (ShutdownPhase::XPCOMShutdownThreads);
710
+ }
711
+ return target->IsOnCurrentThread ();
712
+ }
713
+
714
+ nsCOMPtr<nsISerialEventTarget> GMPParent::GMPEventTarget () const {
705
715
nsCOMPtr<mozIGeckoMediaPluginService> mps =
706
716
do_GetService (" @mozilla.org/gecko-media-plugin-service;1" );
707
717
MOZ_ASSERT (mps);
@@ -813,9 +823,8 @@ static void GMPNotifyObservers(const uint32_t aPluginID,
813
823
}
814
824
815
825
void GMPParent::ActorDestroy (ActorDestroyReason aWhy) {
816
- MOZ_ASSERT (GMPEventTarget ()->IsOnCurrentThread ());
817
- GMP_PARENT_LOG_DEBUG (" %s: (%d), state=%u" , __FUNCTION__, (int )aWhy,
818
- static_cast <GMPState>(mState ));
826
+ MOZ_ASSERT (IsOnGMPEventTarget ());
827
+ GMP_PARENT_LOG_DEBUG (" %s: (%d)" , __FUNCTION__, (int )aWhy);
819
828
820
829
if (AbnormalShutdown == aWhy) {
821
830
Telemetry::Accumulate (Telemetry::SUBPROCESS_ABNORMAL_ABORT, " gmplugin" _ns,
@@ -840,8 +849,7 @@ void GMPParent::ActorDestroy(ActorDestroyReason aWhy) {
840
849
mAbnormalShutdownInProgress = true ;
841
850
CloseActive (false );
842
851
843
- // Normal Shutdown() will delete the process on unwind. GMPProcessParent
844
- // blocks shutdown to avoid races.
852
+ // Normal Shutdown() will delete the process on unwind.
845
853
if (AbnormalShutdown == aWhy) {
846
854
RefPtr<GMPParent> self (this );
847
855
// Must not call Close() again in DeleteProcess(), as we'll recurse
@@ -908,7 +916,7 @@ bool ReadInfoField(GMPInfoFileParser& aParser, const nsCString& aKey,
908
916
}
909
917
910
918
RefPtr<GenericPromise> GMPParent::ReadGMPMetaData () {
911
- MOZ_ASSERT (GMPEventTarget ()-> IsOnCurrentThread ());
919
+ MOZ_ASSERT (IsOnGMPEventTarget ());
912
920
MOZ_ASSERT (mDirectory , " Plugin directory cannot be NULL!" );
913
921
MOZ_ASSERT (!mName .IsEmpty (), " Plugin mName cannot be empty!" );
914
922
@@ -997,7 +1005,7 @@ static nsresult ParseVersion(const nsACString& aVersion,
997
1005
}
998
1006
999
1007
RefPtr<GenericPromise> GMPParent::ReadGMPInfoFile (nsIFile* aFile) {
1000
- MOZ_ASSERT (GMPEventTarget ()-> IsOnCurrentThread ());
1008
+ MOZ_ASSERT (IsOnGMPEventTarget ());
1001
1009
GMPInfoFileParser parser;
1002
1010
if (!parser.Init (aFile)) {
1003
1011
return GenericPromise::CreateAndReject (NS_ERROR_FAILURE, __func__);
@@ -1105,7 +1113,7 @@ RefPtr<GenericPromise> GMPParent::ReadGMPInfoFile(nsIFile* aFile) {
1105
1113
}
1106
1114
1107
1115
RefPtr<GenericPromise> GMPParent::ReadChromiumManifestFile (nsIFile* aFile) {
1108
- MOZ_ASSERT (GMPEventTarget ()-> IsOnCurrentThread ());
1116
+ MOZ_ASSERT (IsOnGMPEventTarget ());
1109
1117
nsAutoCString json;
1110
1118
if (!ReadIntoString (aFile, json, 5 * 1024 )) {
1111
1119
return GenericPromise::CreateAndReject (NS_ERROR_FAILURE, __func__);
@@ -1335,7 +1343,7 @@ void GMPParent::ResolveGetContentParentPromises() {
1335
1343
}
1336
1344
1337
1345
bool GMPParent::OpenPGMPContent () {
1338
- MOZ_ASSERT (GMPEventTarget ()-> IsOnCurrentThread ());
1346
+ MOZ_ASSERT (IsOnGMPEventTarget ());
1339
1347
MOZ_ASSERT (!mGMPContentParent );
1340
1348
1341
1349
Endpoint<PGMPContentParent> parent;
@@ -1372,7 +1380,7 @@ void GMPParent::RejectGetContentParentPromises() {
1372
1380
1373
1381
void GMPParent::GetGMPContentParent (
1374
1382
UniquePtr<MozPromiseHolder<GetGMPContentParentPromise>>&& aPromiseHolder) {
1375
- MOZ_ASSERT (GMPEventTarget ()-> IsOnCurrentThread ());
1383
+ MOZ_ASSERT (IsOnGMPEventTarget ());
1376
1384
GMP_PARENT_LOG_DEBUG (" %s %p" , __FUNCTION__, this );
1377
1385
1378
1386
if (mGMPContentParent ) {
0 commit comments