Bug 1162751 - Part 1: Remove instances of #ifdef PR_LOGGING in image. r=froydnj
authorEric Rahm <erahm@mozilla.com>
Mon, 11 May 2015 13:42:20 -0700
changeset 243291 6983be82c92b4a569c65b0f65d8a0a29a5729580
parent 243290 c6ea21c091e997452df40133ee33839e75bf5ee0
child 243292 37f361e463b3ea5246eb313cb0a4c065a2a05937
push id59639
push usererahm@mozilla.com
push dateMon, 11 May 2015 20:46:10 +0000
treeherdermozilla-inbound@f9af70b6e6de [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1162751
milestone40.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 1162751 - Part 1: Remove instances of #ifdef PR_LOGGING in image. r=froydnj PR_LOGGING is now always defined, we can remove #ifdefs checking for it.
image/ImageLogging.h
image/decoders/nsBMPDecoder.cpp
image/decoders/nsJPEGDecoder.cpp
image/decoders/nsPNGDecoder.cpp
image/encoders/png/nsPNGEncoder.cpp
image/src/ProgressTracker.cpp
image/src/imgLoader.cpp
image/src/imgRequest.cpp
image/src/imgRequestProxy.cpp
--- a/image/ImageLogging.h
+++ b/image/ImageLogging.h
@@ -6,17 +6,16 @@
 
 #ifndef mozilla_image_ImageLogging_h
 #define mozilla_image_ImageLogging_h
 
 #include "prlog.h"
 #include "prinrval.h"
 #include "nsString.h"
 
-#if defined(PR_LOGGING)
 // Declared in imgRequest.cpp.
 extern PRLogModuleInfo* GetImgLog();
 
 #define GIVE_ME_MS_NOW() PR_IntervalToMilliseconds(PR_IntervalNow())
 
 class LogScope {
 public:
 
@@ -152,23 +151,11 @@ public:
 #define LOG_FUNC_WITH_PARAM(l, s, pn, pv) LogFunc(l, this, s, pn, pv)
 
 #define LOG_STATIC_FUNC(l, s) LogFunc(l, nullptr, s)
 
 #define LOG_STATIC_FUNC_WITH_PARAM(l, s, pn, pv) LogFunc(l, nullptr, s, pn, pv)
 
 #define LOG_MSG(l, s, m) LogMessage(l, this, s, m)
 
-#else
-
-#define LOG_SCOPE(l, s)
-#define LOG_SCOPE_WITH_PARAM(l, s, pn, pv)
-#define LOG_FUNC(l, s)
-#define LOG_FUNC_WITH_PARAM(l, s, pn, pv)
-#define LOG_STATIC_FUNC(l, s)
-#define LOG_STATIC_FUNC_WITH_PARAM(l, s, pn, pv)
-#define LOG_MSG(l, s, m)
-
-#endif // if defined(PR_LOGGING)
-
 #define LOG_MSG_WITH_PARAM LOG_FUNC_WITH_PARAM
 
 #endif // mozilla_image_ImageLogging_h
--- a/image/decoders/nsBMPDecoder.cpp
+++ b/image/decoders/nsBMPDecoder.cpp
@@ -17,27 +17,25 @@
 
 #include "nsIInputStream.h"
 #include "RasterImage.h"
 #include <algorithm>
 
 namespace mozilla {
 namespace image {
 
-#ifdef PR_LOGGING
 static PRLogModuleInfo*
 GetBMPLog()
 {
   static PRLogModuleInfo* sBMPLog;
   if (!sBMPLog) {
     sBMPLog = PR_NewLogModule("BMPDecoder");
   }
   return sBMPLog;
 }
-#endif
 
 // Convert from row (1..height) to absolute line (0..height-1)
 #define LINE(row) ((mBIH.height < 0) ? (-mBIH.height - (row)) : ((row) - 1))
 #define PIXEL_OFFSET(row, col) (LINE(row) * mBIH.width + col)
 
 nsBMPDecoder::nsBMPDecoder(RasterImage* aImage)
   : Decoder(aImage)
   , mPos(0)
--- a/image/decoders/nsJPEGDecoder.cpp
+++ b/image/decoders/nsJPEGDecoder.cpp
@@ -31,17 +31,16 @@ extern "C" {
 #define MOZ_JCS_EXT_NATIVE_ENDIAN_XRGB JCS_EXT_BGRX
 #endif
 
 static void cmyk_convert_rgb(JSAMPROW row, JDIMENSION width);
 
 namespace mozilla {
 namespace image {
 
-#if defined(PR_LOGGING)
 static PRLogModuleInfo*
 GetJPEGLog()
 {
   static PRLogModuleInfo* sJPEGLog;
   if (!sJPEGLog) {
     sJPEGLog = PR_NewLogModule("JPEGDecoder");
   }
   return sJPEGLog;
@@ -51,20 +50,16 @@ static PRLogModuleInfo*
 GetJPEGDecoderAccountingLog()
 {
   static PRLogModuleInfo* sJPEGDecoderAccountingLog;
   if (!sJPEGDecoderAccountingLog) {
     sJPEGDecoderAccountingLog = PR_NewLogModule("JPEGDecoderAccounting");
   }
   return sJPEGDecoderAccountingLog;
 }
-#else
-#define GetJPEGLog()
-#define GetJPEGDecoderAccountingLog()
-#endif
 
 static qcms_profile*
 GetICCProfile(struct jpeg_decompress_struct& info)
 {
   JOCTET* profilebuf;
   uint32_t profileLength;
   qcms_profile* profile = nullptr;
 
--- a/image/decoders/nsPNGDecoder.cpp
+++ b/image/decoders/nsPNGDecoder.cpp
@@ -17,17 +17,16 @@
 #include "RasterImage.h"
 #include "mozilla/Telemetry.h"
 
 #include <algorithm>
 
 namespace mozilla {
 namespace image {
 
-#ifdef PR_LOGGING
 static PRLogModuleInfo*
 GetPNGLog()
 {
   static PRLogModuleInfo* sPNGLog;
   if (!sPNGLog) {
     sPNGLog = PR_NewLogModule("PNGDecoder");
   }
   return sPNGLog;
@@ -37,17 +36,16 @@ static PRLogModuleInfo*
 GetPNGDecoderAccountingLog()
 {
   static PRLogModuleInfo* sPNGDecoderAccountingLog;
   if (!sPNGDecoderAccountingLog) {
     sPNGDecoderAccountingLog = PR_NewLogModule("PNGDecoderAccounting");
   }
   return sPNGDecoderAccountingLog;
 }
-#endif
 
 // Limit image dimensions (bug #251381, #591822, and #967656)
 #ifndef MOZ_PNG_MAX_DIMENSION
 #  define MOZ_PNG_MAX_DIMENSION 32767
 #endif
 
 // For size decodes
 #define WIDTH_OFFSET 16
--- a/image/encoders/png/nsPNGEncoder.cpp
+++ b/image/encoders/png/nsPNGEncoder.cpp
@@ -7,27 +7,25 @@
 #include "nsCRT.h"
 #include "nsPNGEncoder.h"
 #include "nsStreamUtils.h"
 #include "nsString.h"
 #include "prprf.h"
 
 using namespace mozilla;
 
-#ifdef PR_LOGGING
 static PRLogModuleInfo*
 GetPNGEncoderLog()
 {
   static PRLogModuleInfo* sPNGEncoderLog;
   if (!sPNGEncoderLog) {
     sPNGEncoderLog = PR_NewLogModule("PNGEncoder");
   }
   return sPNGEncoderLog;
 }
-#endif
 
 NS_IMPL_ISUPPORTS(nsPNGEncoder, imgIEncoder, nsIInputStream,
                   nsIAsyncInputStream)
 
 nsPNGEncoder::nsPNGEncoder() : mPNG(nullptr), mPNGinfo(nullptr),
                                mIsAnimation(false),
                                mFinished(false),
                                mImageBuffer(nullptr), mImageBufferSize(0),
--- a/image/src/ProgressTracker.cpp
+++ b/image/src/ProgressTracker.cpp
@@ -159,29 +159,27 @@ class AsyncNotifyRunnable : public nsRun
     nsTArray<nsRefPtr<IProgressObserver>> mObservers;
 };
 
 void
 ProgressTracker::Notify(IProgressObserver* aObserver)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
-#ifdef PR_LOGGING
   nsRefPtr<Image> image = GetImage();
   if (image && image->GetURI()) {
     nsRefPtr<ImageURL> uri(image->GetURI());
     nsAutoCString spec;
     uri->GetSpec(spec);
     LOG_FUNC_WITH_PARAM(GetImgLog(),
                         "ProgressTracker::Notify async", "uri", spec.get());
   } else {
     LOG_FUNC_WITH_PARAM(GetImgLog(),
                         "ProgressTracker::Notify async", "uri", "<unknown>");
   }
-#endif
 
   aObserver->SetNotificationsDeferred(true);
 
   // If we have an existing runnable that we can use, we just append this
   // observer to its list of observers to be notified. This ensures we don't
   // unnecessarily delay onload.
   AsyncNotifyRunnable* runnable =
     static_cast<AsyncNotifyRunnable*>(mRunnable.get());
@@ -228,25 +226,23 @@ class AsyncNotifyCurrentStateRunnable : 
     nsRefPtr<Image> mImage;
 };
 
 void
 ProgressTracker::NotifyCurrentState(IProgressObserver* aObserver)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
-#ifdef PR_LOGGING
   nsRefPtr<Image> image = GetImage();
   nsAutoCString spec;
   if (image && image->GetURI()) {
     image->GetURI()->GetSpec(spec);
   }
   LOG_FUNC_WITH_PARAM(GetImgLog(),
                       "ProgressTracker::NotifyCurrentState", "uri", spec.get());
-#endif
 
   aObserver->SetNotificationsDeferred(true);
 
   nsCOMPtr<nsIRunnable> ev = new AsyncNotifyCurrentStateRunnable(this,
                                                                  aObserver);
   NS_DispatchToCurrentThread(ev);
 }
 
@@ -360,24 +356,22 @@ ProgressTracker::SyncNotifyProgress(Prog
 
 void
 ProgressTracker::SyncNotify(IProgressObserver* aObserver)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   nsRefPtr<Image> image = GetImage();
 
-#ifdef PR_LOGGING
   nsAutoCString spec;
   if (image && image->GetURI()) {
     image->GetURI()->GetSpec(spec);
   }
   LOG_SCOPE_WITH_PARAM(GetImgLog(),
                        "ProgressTracker::SyncNotify", "uri", spec.get());
-#endif
 
   nsIntRect rect;
   if (image) {
     if (NS_FAILED(image->GetWidth(&rect.width)) ||
         NS_FAILED(image->GetHeight(&rect.height))) {
       // Either the image has no intrinsic size, or it has an error.
       rect = GetMaxSizedIntRect();
     }
--- a/image/src/imgLoader.cpp
+++ b/image/src/imgLoader.cpp
@@ -888,31 +888,29 @@ imgCacheEntry::UpdateCache(int32_t diff 
   if (!Evicted() && HasNoProxies()) {
     mLoader->CacheEntriesChanged(mRequest->IsChrome(), diff);
   }
 }
 
 void
 imgCacheEntry::SetHasNoProxies(bool hasNoProxies)
 {
-#if defined(PR_LOGGING)
   nsRefPtr<ImageURL> uri;
   mRequest->GetURI(getter_AddRefs(uri));
   nsAutoCString spec;
   if (uri) {
     uri->GetSpec(spec);
   }
   if (hasNoProxies) {
     LOG_FUNC_WITH_PARAM(GetImgLog(), "imgCacheEntry::SetHasNoProxies true",
                         "uri", spec.get());
   } else {
     LOG_FUNC_WITH_PARAM(GetImgLog(), "imgCacheEntry::SetHasNoProxies false",
                         "uri", spec.get());
   }
-#endif
 
   mHasNoProxies = hasNoProxies;
 }
 
 imgCacheQueue::imgCacheQueue()
  : mDirty(false),
    mSize(0)
 { }
@@ -1072,28 +1070,26 @@ imgCacheExpirationTracker::imgCacheExpir
 
 void
 imgCacheExpirationTracker::NotifyExpired(imgCacheEntry* entry)
 {
   // Hold on to a reference to this entry, because the expiration tracker
   // mechanism doesn't.
   nsRefPtr<imgCacheEntry> kungFuDeathGrip(entry);
 
-#if defined(PR_LOGGING)
   nsRefPtr<imgRequest> req(entry->GetRequest());
   if (req) {
     nsRefPtr<ImageURL> uri;
     req->GetURI(getter_AddRefs(uri));
     nsAutoCString spec;
     uri->GetSpec(spec);
     LOG_FUNC_WITH_PARAM(GetImgLog(),
                        "imgCacheExpirationTracker::NotifyExpired",
                        "entry", spec.get());
   }
-#endif
 
   // We can be called multiple times on the same entry. Don't do work multiple
   // times.
   if (!entry->Evicted()) {
     entry->Loader()->RemoveFromCache(entry);
   }
 
   entry->Loader()->VerifyCacheSizes();
@@ -1508,25 +1504,23 @@ imgLoader::PutIntoCache(const ImageCache
   RemoveFromUncachedImages(request);
 
   return true;
 }
 
 bool
 imgLoader::SetHasNoProxies(imgRequest* aRequest, imgCacheEntry* aEntry)
 {
-#if defined(PR_LOGGING)
   nsRefPtr<ImageURL> uri;
   aRequest->GetURI(getter_AddRefs(uri));
   nsAutoCString spec;
   uri->GetSpec(spec);
 
   LOG_STATIC_FUNC_WITH_PARAM(GetImgLog(),
                              "imgLoader::SetHasNoProxies", "uri", spec.get());
-#endif
 
   aEntry->SetHasNoProxies(true);
 
   if (aEntry->Evicted()) {
     return false;
   }
 
   imgCacheQueue& queue = GetCacheQueue(aRequest->IsChrome());
@@ -1600,28 +1594,26 @@ imgLoader::CheckCacheLimits(imgCacheTabl
 
   // Remove entries from the cache until we're back at our desired max size.
   while (queue.GetSize() > sCacheMaxSize) {
     // Remove the first entry in the queue.
     nsRefPtr<imgCacheEntry> entry(queue.Pop());
 
     NS_ASSERTION(entry, "imgLoader::CheckCacheLimits -- NULL entry pointer");
 
-#if defined(PR_LOGGING)
     nsRefPtr<imgRequest> req(entry->GetRequest());
     if (req) {
       nsRefPtr<ImageURL> uri;
       req->GetURI(getter_AddRefs(uri));
       nsAutoCString spec;
       uri->GetSpec(spec);
       LOG_STATIC_FUNC_WITH_PARAM(GetImgLog(),
                                  "imgLoader::CheckCacheLimits",
                                  "entry", spec.get());
     }
-#endif
 
     if (entry) {
       RemoveFromCache(entry);
     }
   }
 }
 
 bool
@@ -1840,25 +1832,23 @@ imgLoader::ValidateEntry(imgCacheEntry* 
     }
 
     // Determine whether the cache aEntry must be revalidated...
     validateRequest = ShouldRevalidateEntry(aEntry, aLoadFlags, hasExpired);
 
     PR_LOG(GetImgLog(), PR_LOG_DEBUG,
            ("imgLoader::ValidateEntry validating cache entry. "
             "validateRequest = %d", validateRequest));
-#if defined(PR_LOGGING)
   } else if (!key) {
     nsAutoCString spec;
     aURI->GetSpec(spec);
 
     PR_LOG(GetImgLog(), PR_LOG_DEBUG,
            ("imgLoader::ValidateEntry BYPASSING cache validation for %s "
             "because of NULL LoadID", spec.get()));
-#endif
   }
 
   // We can't use a cached request if it comes from a different
   // application cache than this load is expecting.
   nsCOMPtr<nsIApplicationCacheContainer> appCacheContainer;
   nsCOMPtr<nsIApplicationCache> requestAppCache;
   nsCOMPtr<nsIApplicationCache> groupAppCache;
   if ((appCacheContainer = do_GetInterface(request->GetRequest()))) {
@@ -2113,21 +2103,19 @@ imgLoader::LoadImage(nsIURI* aURI,
   VerifyCacheSizes();
 
   NS_ASSERTION(aURI, "imgLoader::LoadImage -- NULL URI pointer");
 
   if (!aURI) {
     return NS_ERROR_NULL_POINTER;
   }
 
-#ifdef PR_LOGGING
   nsAutoCString spec;
   aURI->GetSpec(spec);
   LOG_SCOPE_WITH_PARAM(GetImgLog(), "imgLoader::LoadImage", "aURI", spec.get());
-#endif
 
   *_retval = nullptr;
 
   nsRefPtr<imgRequest> request;
 
   nsresult rv;
   nsLoadFlags requestFlags = nsIRequest::LOAD_NORMAL;
 
@@ -2871,23 +2859,21 @@ imgCacheValidator::OnStartRequest(nsIReq
   // data that's coming in off the channel.
   nsCOMPtr<nsIURI> uri;
   {
     nsRefPtr<ImageURL> imageURL;
     mRequest->GetURI(getter_AddRefs(imageURL));
     uri = imageURL->ToIURI();
   }
 
-#if defined(PR_LOGGING)
   nsAutoCString spec;
   uri->GetSpec(spec);
   LOG_MSG_WITH_PARAM(GetImgLog(),
                      "imgCacheValidator::OnStartRequest creating new request",
                      "uri", spec.get());
-#endif
 
   int32_t corsmode = mRequest->GetCORSMode();
   ReferrerPolicy refpol = mRequest->GetReferrerPolicy();
   nsCOMPtr<nsIPrincipal> loadingPrincipal = mRequest->GetLoadingPrincipal();
 
   // Doom the old request's cache entry
   mRequest->RemoveFromCache();
 
--- a/image/src/imgRequest.cpp
+++ b/image/src/imgRequest.cpp
@@ -37,30 +37,26 @@
 #include "plstr.h" // PL_strcasestr(...)
 #include "nsNetUtil.h"
 #include "nsIProtocolHandler.h"
 #include "imgIRequest.h"
 
 using namespace mozilla;
 using namespace mozilla::image;
 
-#if defined(PR_LOGGING)
 PRLogModuleInfo*
 GetImgLog()
 {
   static PRLogModuleInfo* sImgLog;
   if (!sImgLog) {
     sImgLog = PR_NewLogModule("imgRequest");
   }
   return sImgLog;
 }
 #define LOG_TEST(level) (GetImgLog() && PR_LOG_TEST(GetImgLog(), (level)))
-#else
-#define LOG_TEST(level) false
-#endif
 
 NS_IMPL_ISUPPORTS(imgRequest,
                   nsIStreamListener, nsIRequestObserver,
                   nsIThreadRetargetableStreamListener,
                   nsIChannelEventSink,
                   nsIInterfaceRequestor,
                   nsIAsyncVerifyRedirectCallback)
 
@@ -258,25 +254,23 @@ imgRequest::RemoveProxy(imgRequestProxy*
     // we can be evicted from the cache.
     if (mCacheEntry) {
       MOZ_ASSERT(mURI, "Removing last observer without key uri.");
 
       if (mLoader) {
         mLoader->SetHasNoProxies(this, mCacheEntry);
       }
     }
-#if defined(PR_LOGGING)
     else {
       nsAutoCString spec;
       mURI->GetSpec(spec);
       LOG_MSG_WITH_PARAM(GetImgLog(),
                          "imgRequest::RemoveProxy no cache entry",
                          "uri", spec.get());
     }
-#endif
 
     /* If |aStatus| is a failure code, then cancel the load if it is still in
        progress.  Otherwise, let the load continue, keeping 'this' in the cache
        with no observers.  This way, if a proxy is destroyed without calling
        cancel on it, it won't leak and won't leave a bad pointer in the observer
        list.
      */
     if (!(progressTracker->GetProgress() & FLAG_LAST_PART_COMPLETE) &&
--- a/image/src/imgRequestProxy.cpp
+++ b/image/src/imgRequestProxy.cpp
@@ -856,22 +856,20 @@ imgRequestProxy::Notify(int32_t aType, c
   nsCOMPtr<imgINotificationObserver> listener(mListener);
 
   mListener->Notify(this, aType, aRect);
 }
 
 void
 imgRequestProxy::OnLoadComplete(bool aLastPart)
 {
-#ifdef PR_LOGGING
   nsAutoCString name;
   GetName(name);
   LOG_FUNC_WITH_PARAM(GetImgLog(), "imgRequestProxy::OnLoadComplete",
                       "name", name.get());
-#endif
   // There's all sorts of stuff here that could kill us (the OnStopRequest call
   // on the listener, the removal from the loadgroup, the release of the
   // listener, etc).  Don't let them do it.
   nsCOMPtr<imgIRequest> kungFuDeathGrip(this);
 
   if (mListener && !mCanceled) {
     // Hold a ref to the listener while we call it, just in case.
     nsCOMPtr<imgINotificationObserver> kungFuDeathGrip(mListener);
@@ -901,38 +899,34 @@ imgRequestProxy::OnLoadComplete(bool aLa
     mListenerIsStrongRef = false;
     NS_RELEASE(obs);
   }
 }
 
 void
 imgRequestProxy::BlockOnload()
 {
-#ifdef PR_LOGGING
   nsAutoCString name;
   GetName(name);
   LOG_FUNC_WITH_PARAM(GetImgLog(), "imgRequestProxy::BlockOnload",
                       "name", name.get());
-#endif
 
   nsCOMPtr<imgIOnloadBlocker> blocker = do_QueryInterface(mListener);
   if (blocker) {
     blocker->BlockOnload(this);
   }
 }
 
 void
 imgRequestProxy::UnblockOnload()
 {
-#ifdef PR_LOGGING
   nsAutoCString name;
   GetName(name);
   LOG_FUNC_WITH_PARAM(GetImgLog(), "imgRequestProxy::UnblockOnload",
                       "name", name.get());
-#endif
 
   nsCOMPtr<imgIOnloadBlocker> blocker = do_QueryInterface(mListener);
   if (blocker) {
     blocker->UnblockOnload(this);
   }
 }
 
 void