Bug 1338446 Part 1 - Label dispatching ShortTermURISpecCache by using SystemGroup. draft
authorTing-Yu Lin <tlin@mozilla.com>
Thu, 09 Mar 2017 17:33:50 +0800
changeset 501446 aff2e09af1606b80f316e62f6b83c427f6b4540c
parent 501295 1b9293be51637f841275541d8991314ca56561a5
child 501447 1018a755d49ecad1ce89ad3f4f45e5a08e2b9265
push id49988
push userbmo:tlin@mozilla.com
push dateMon, 20 Mar 2017 10:12:33 +0000
bugs1338446
milestone55.0a1
Bug 1338446 Part 1 - Label dispatching ShortTermURISpecCache by using SystemGroup. In ErrorReporter::~ErrorReporter(), we dispatch sSpecCache to clear itself. It's not related to content, so label it by using SystemGroup. Use another runnable pointer to keep sSpecCache alive. MozReview-Commit-ID: JN1qrS2jxFs
layout/style/ErrorReporter.cpp
--- a/layout/style/ErrorReporter.cpp
+++ b/layout/style/ErrorReporter.cpp
@@ -6,16 +6,17 @@
 /* diagnostic reporting for CSS style sheet parser */
 
 #include "mozilla/css/ErrorReporter.h"
 
 #include "mozilla/StyleSheetInlines.h"
 #include "mozilla/css/Loader.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/Services.h"
+#include "mozilla/SystemGroup.h"
 #include "nsCSSScanner.h"
 #include "nsIConsoleService.h"
 #include "nsIDocument.h"
 #include "nsIFactory.h"
 #include "nsIScriptError.h"
 #include "nsIStringBundle.h"
 #include "nsServiceManagerUtils.h"
 #include "nsStyleUtil.h"
@@ -148,17 +149,21 @@ ErrorReporter::ErrorReporter(const nsCSS
 }
 
 ErrorReporter::~ErrorReporter()
 {
   // Schedule deferred cleanup for cached data. We want to strike a
   // balance between performance and memory usage, so we only allow
   // short-term caching.
   if (sSpecCache && sSpecCache->IsInUse() && !sSpecCache->IsPending()) {
-    if (NS_FAILED(NS_DispatchToCurrentThread(sSpecCache))) {
+    nsCOMPtr<nsIRunnable> runnable(sSpecCache);
+    nsresult rv =
+      SystemGroup::Dispatch("ShortTermURISpecCache", TaskCategory::Other,
+                            runnable.forget());
+    if (NS_FAILED(rv)) {
       // Peform the "deferred" cleanup immediately if the dispatch fails.
       sSpecCache->Run();
     } else {
       sSpecCache->SetPending();
     }
   }
 }