Bug 1127209 - cleanup downloadable font logging. r=m_kato
authorJohn Daggett <jdaggett@mozilla.com>
Thu, 29 Jan 2015 16:44:59 +0900
changeset 226466 28a19205f0409884b7203292f737377234f9ec65
parent 226465 9dcf0be77eab2403d14f289c2aa1dfeb0113e9c8
child 226467 e5c85f765f2dbe032c269c8d00dc735c573c014a
push id54845
push userjdaggett@mozilla.com
push dateThu, 29 Jan 2015 07:48:00 +0000
treeherdermozilla-inbound@28a19205f040 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersm_kato
bugs1127209
milestone38.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1127209 - cleanup downloadable font logging. r=m_kato
gfx/thebes/gfxUserFontSet.cpp
layout/style/FontFaceSet.cpp
layout/style/nsFontFaceLoader.cpp
layout/style/nsFontFaceLoader.h
--- a/gfx/thebes/gfxUserFontSet.cpp
+++ b/gfx/thebes/gfxUserFontSet.cpp
@@ -645,19 +645,20 @@ gfxUserFontEntry::LoadPlatformFont(const
         fe->mLanguageOverride = mLanguageOverride;
         fe->mFamilyName = mFamilyName;
         StoreUserFontData(fe, mFontSet->GetPrivateBrowsing(), originalFullName,
                           &metadata, metaOrigLen, compression);
 #ifdef PR_LOGGING
         if (LOG_ENABLED()) {
             nsAutoCString fontURI;
             mSrcList[mSrcIndex].mURI->GetSpec(fontURI);
-            LOG(("userfonts (%p) [src %d] loaded uri: (%s) for (%s) gen: %8.8x\n",
+            LOG(("userfonts (%p) [src %d] loaded uri: (%s) for (%s) (%p) gen: %8.8x\n",
                  mFontSet, mSrcIndex, fontURI.get(),
                  NS_ConvertUTF16toUTF8(mFamilyName).get(),
+                 this,
                  uint32_t(mFontSet->mGeneration)));
         }
 #endif
         mPlatformFontEntry = fe;
         SetLoadState(STATUS_LOADED);
         gfxUserFontSet::UserFontCache::CacheFont(fe);
     } else {
 #ifdef PR_LOGGING
@@ -781,27 +782,16 @@ gfxUserFontSet::FindOrCreateUserFontEntr
                                           aUnicodeRanges);
     }
 
     if (!entry) {
       entry = CreateUserFontEntry(aFontFaceSrcList, aWeight, aStretch,
                                   aItalicStyle, aFeatureSettings,
                                   aLanguageOverride, aUnicodeRanges);
       entry->mFamilyName = aFamilyName;
-
-#ifdef PR_LOGGING
-      if (LOG_ENABLED()) {
-          LOG(("userfonts (%p) created \"%s\" (%p) with style: %s weight: %d "
-               "stretch: %d",
-               this, NS_ConvertUTF16toUTF8(aFamilyName).get(), entry.get(),
-               (aItalicStyle & NS_FONT_STYLE_ITALIC ? "italic" :
-                   (aItalicStyle & NS_FONT_STYLE_OBLIQUE ? "oblique" : "normal")),
-               aWeight, aStretch));
-      }
-#endif
     }
 
     return entry.forget();
 }
 
 already_AddRefed<gfxUserFontEntry>
 gfxUserFontSet::CreateUserFontEntry(
                                const nsTArray<gfxFontFaceSrc>& aFontFaceSrcList,
@@ -860,18 +850,21 @@ void
 gfxUserFontSet::AddUserFontEntry(const nsAString& aFamilyName,
                                  gfxUserFontEntry* aUserFontEntry)
 {
     gfxUserFontFamily* family = GetFamily(aFamilyName);
     family->AddFontEntry(aUserFontEntry);
 
 #ifdef PR_LOGGING
     if (LOG_ENABLED()) {
-        LOG(("userfonts (%p) added \"%s\" (%p)",
-             this, NS_ConvertUTF16toUTF8(aFamilyName).get(), aUserFontEntry));
+        LOG(("userfonts (%p) added to \"%s\" (%p) style: %s weight: %d "
+             "stretch: %d",
+             this, NS_ConvertUTF16toUTF8(aFamilyName).get(), aUserFontEntry,
+             (aUserFontEntry->IsItalic() ? "italic" : "normal"),
+             aUserFontEntry->Weight(), aUserFontEntry->Stretch()));
     }
 #endif
 }
 
 gfxUserFontEntry*
 gfxUserFontSet::FindUserFontEntryAndLoad(gfxFontFamily* aFamily,
                                          const gfxFontStyle& aFontStyle,
                                          bool& aNeedsBold,
--- a/layout/style/FontFaceSet.cpp
+++ b/layout/style/FontFaceSet.cpp
@@ -405,26 +405,24 @@ FontFaceSet::StartLoad(gfxUserFontEntry*
 
   nsRefPtr<nsFontFaceLoader> fontLoader =
     new nsFontFaceLoader(aUserFontEntry, aFontFaceSrc->mURI, this, channel);
 
   if (!fontLoader)
     return NS_ERROR_OUT_OF_MEMORY;
 
 #ifdef PR_LOGGING
-  if (PR_LOG_TEST(nsFontFaceLoader::GetFontDownloaderLog(),
-                  PR_LOG_DEBUG)) {
+  if (LOG_ENABLED()) {
     nsAutoCString fontURI, referrerURI;
     aFontFaceSrc->mURI->GetSpec(fontURI);
     if (aFontFaceSrc->mReferrer)
       aFontFaceSrc->mReferrer->GetSpec(referrerURI);
-    PR_LOG(nsFontFaceLoader::GetFontDownloaderLog(), PR_LOG_DEBUG,
-           ("fontdownloader (%p) download start - font uri: (%s) "
-            "referrer uri: (%s)\n",
-            fontLoader.get(), fontURI.get(), referrerURI.get()));
+    LOG(("userfonts (%p) download start - font uri: (%s) "
+         "referrer uri: (%s)\n",
+         fontLoader.get(), fontURI.get(), referrerURI.get()));
   }
 #endif
 
   nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(channel));
   if (httpChannel) {
     httpChannel->SetReferrerWithPolicy(aFontFaceSrc->mReferrer,
                                        ps->GetDocument()->GetReferrerPolicy());
     nsAutoCString accept("application/font-woff;q=0.9,*/*;q=0.8");
@@ -607,20 +605,22 @@ FontFaceSet::UpdateRules(const nsTArray<
     CheckLoadingStarted();
     CheckLoadingFinished();
   }
 
   // local rules have been rebuilt, so clear the flag
   mUserFontSet->mLocalRulesUsed = false;
 
 #if PR_LOGGING
-  LOG(("userfonts (%p) userfont rules update (%s) rule count: %d",
-       mUserFontSet.get(),
-       (modified ? "modified" : "not modified"),
-       mRuleFaces.Length()));
+  if (LOG_ENABLED() && !mRuleFaces.IsEmpty()) {
+    LOG(("userfonts (%p) userfont rules update (%s) rule count: %d",
+         mUserFontSet.get(),
+         (modified ? "modified" : "not modified"),
+         mRuleFaces.Length()));
+  }
 #endif
 
   return modified;
 }
 
 static bool
 HasLocalSrc(const nsCSSValue::Array *aSrcArr)
 {
@@ -1068,19 +1068,18 @@ FontFaceSet::LogMessage(gfxUserFontEntry
       message.AppendInt(static_cast<uint32_t>(aStatus));
       break;
     }
   }
   message.AppendLiteral(" source: ");
   message.Append(fontURI);
 
 #ifdef PR_LOGGING
-  if (PR_LOG_TEST(gfxUserFontSet::GetUserFontsLog(), PR_LOG_DEBUG)) {
-    PR_LOG(gfxUserFontSet::GetUserFontsLog(), PR_LOG_DEBUG,
-           ("userfonts (%p) %s", mUserFontSet.get(), message.get()));
+  if (LOG_ENABLED()) {
+    LOG(("userfonts (%p) %s", mUserFontSet.get(), message.get()));
   }
 #endif
 
   // try to give the user an indication of where the rule came from
   nsCSSFontFaceRule* rule = FindRuleForUserFontEntry(aUserFontEntry);
   nsString href;
   nsString text;
   nsresult rv;
--- a/layout/style/nsFontFaceLoader.cpp
+++ b/layout/style/nsFontFaceLoader.cpp
@@ -20,30 +20,19 @@
 #include "nsIHttpChannel.h"
 #include "nsIContentPolicy.h"
 #include "nsContentPolicyUtils.h"
 
 #include "mozilla/gfx/2D.h"
 
 using namespace mozilla;
 
-#ifdef PR_LOGGING
-PRLogModuleInfo*
-nsFontFaceLoader::GetFontDownloaderLog()
-{
-  static PRLogModuleInfo* sLog;
-  if (!sLog)
-    sLog = PR_NewLogModule("fontdownloader");
-  return sLog;
-}
-#endif /* PR_LOGGING */
-
-#define LOG(args) PR_LOG(GetFontDownloaderLog(), PR_LOG_DEBUG, args)
-#define LOG_ENABLED() PR_LOG_TEST(GetFontDownloaderLog(), PR_LOG_DEBUG)
-
+#define LOG(args) PR_LOG(gfxUserFontSet::GetUserFontsLog(), PR_LOG_DEBUG, args)
+#define LOG_ENABLED() PR_LOG_TEST(gfxUserFontSet::GetUserFontsLog(), \
+                                  PR_LOG_DEBUG)
 
 nsFontFaceLoader::nsFontFaceLoader(gfxUserFontEntry* aUserFontEntry,
                                    nsIURI* aFontURI,
                                    mozilla::dom::FontFaceSet* aFontFaceSet,
                                    nsIChannel* aChannel)
   : mUserFontEntry(aUserFontEntry),
     mFontURI(aFontURI),
     mFontFaceSet(aFontFaceSet),
@@ -114,31 +103,31 @@ nsFontFaceLoader::LoadTimerCallback(nsIT
       ufe->mFontDataLoadingState = gfxUserFontEntry::LOADING_ALMOST_DONE;
       uint32_t delay;
       loader->mLoadTimer->GetDelay(&delay);
       loader->mLoadTimer->InitWithFuncCallback(LoadTimerCallback,
                                                static_cast<void*>(loader),
                                                delay >> 1,
                                                nsITimer::TYPE_ONE_SHOT);
       updateUserFontSet = false;
-      LOG(("fontdownloader (%p) 75%% done, resetting timer\n", loader));
+      LOG(("userfonts (%p) 75%% done, resetting timer\n", loader));
     }
   }
 
   // If the font is not 75% loaded, or if we've already timed out once
   // before, we mark this entry as "loading slowly", so the fallback
   // font will be used in the meantime, and tell the context to refresh.
   if (updateUserFontSet) {
     ufe->mFontDataLoadingState = gfxUserFontEntry::LOADING_SLOWLY;
     nsPresContext* ctx = loader->mFontFaceSet->GetPresContext();
     NS_ASSERTION(ctx, "userfontset doesn't have a presContext?");
     if (ctx) {
       loader->mFontFaceSet->IncrementGeneration();
       ctx->UserFontSetUpdated();
-      LOG(("fontdownloader (%p) timeout reflow\n", loader));
+      LOG(("userfonts (%p) timeout reflow\n", loader));
     }
   }
 }
 
 NS_IMPL_ISUPPORTS(nsFontFaceLoader, nsIStreamLoaderObserver)
 
 NS_IMETHODIMP
 nsFontFaceLoader::OnStreamComplete(nsIStreamLoader* aLoader,
@@ -154,20 +143,20 @@ nsFontFaceLoader::OnStreamComplete(nsISt
 
   mFontFaceSet->RemoveLoader(this);
 
 #ifdef PR_LOGGING
   if (LOG_ENABLED()) {
     nsAutoCString fontURI;
     mFontURI->GetSpec(fontURI);
     if (NS_SUCCEEDED(aStatus)) {
-      LOG(("fontdownloader (%p) download completed - font uri: (%s)\n", 
+      LOG(("userfonts (%p) download completed - font uri: (%s)\n",
            this, fontURI.get()));
     } else {
-      LOG(("fontdownloader (%p) download failed - font uri: (%s) error: %8.8x\n", 
+      LOG(("userfonts (%p) download failed - font uri: (%s) error: %8.8x\n",
            this, fontURI.get(), aStatus));
     }
   }
 #endif
 
   nsPresContext* ctx = mFontFaceSet->GetPresContext();
   NS_ASSERTION(ctx && !ctx->PresShell()->IsDestroying(),
                "We should have been canceled already");
@@ -200,17 +189,17 @@ nsFontFaceLoader::OnStreamComplete(nsISt
   bool fontUpdate =
     mUserFontEntry->FontDataDownloadComplete(aString, aStringLen, aStatus);
 
   // when new font loaded, need to reflow
   if (fontUpdate) {
     // Update layout for the presence of the new font.  Since this is
     // asynchronous, reflows will coalesce.
     ctx->UserFontSetUpdated();
-    LOG(("fontdownloader (%p) reflow\n", this));
+    LOG(("userfonts (%p) reflow\n", this));
   }
 
   // done with font set
   mFontFaceSet = nullptr;
   if (mLoadTimer) {
     mLoadTimer->Cancel();
     mLoadTimer = nullptr;
   }
--- a/layout/style/nsFontFaceLoader.h
+++ b/layout/style/nsFontFaceLoader.h
@@ -41,20 +41,16 @@ public:
   void StartedLoading(nsIStreamLoader* aStreamLoader);
 
   static void LoadTimerCallback(nsITimer* aTimer, void* aClosure);
 
   static nsresult CheckLoadAllowed(nsIPrincipal* aSourcePrincipal,
                                    nsIURI* aTargetURI,
                                    nsISupports* aContext);
 
-#ifdef PR_LOGGING
-  static PRLogModuleInfo* GetFontDownloaderLog();
-#endif
-
 protected:
   virtual ~nsFontFaceLoader();
 
 private:
   nsRefPtr<gfxUserFontEntry>  mUserFontEntry;
   nsCOMPtr<nsIURI>        mFontURI;
   nsRefPtr<mozilla::dom::FontFaceSet> mFontFaceSet;
   nsCOMPtr<nsIChannel>    mChannel;