Bug 840850 - Fix missing include guard and style issues in ImageFactory. r=joe
authorSeth Fowler <seth@mozilla.com>
Wed, 13 Feb 2013 13:53:42 -0800
changeset 131712 c89635394bdb2789e98f60a49b0bbd95483d413b
parent 131711 e1f096c747dfb93a4f692bdbb7ed364f9d8a9a82
child 131713 77a7ce6cbf81a95efe53339a51b540f0bec90e34
push id2323
push userbbajaj@mozilla.com
push dateMon, 01 Apr 2013 19:47:02 +0000
treeherdermozilla-beta@7712be144d91 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjoe
bugs840850
milestone21.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 840850 - Fix missing include guard and style issues in ImageFactory. r=joe
image/src/ImageFactory.cpp
image/src/ImageFactory.h
image/src/imgRequest.cpp
image/src/imgTools.cpp
--- a/image/src/ImageFactory.cpp
+++ b/image/src/ImageFactory.cpp
@@ -1,26 +1,32 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  *
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+#include <algorithm>
+
 #include "mozilla/Preferences.h"
 #include "mozilla/Likely.h"
 
 #include "nsIHttpChannel.h"
 #include "nsSimpleURI.h"
 #include "nsMimeTypes.h"
+#include "nsIURI.h"
+#include "nsIRequest.h"
 
+#include "imgIContainer.h"
+#include "imgStatusTracker.h"
 #include "RasterImage.h"
 #include "VectorImage.h"
+#include "Image.h"
 
 #include "ImageFactory.h"
-#include <algorithm>
 
 namespace mozilla {
 namespace image {
 
 // Global preferences related to image containers.
 static bool gInitializedPrefCaches = false;
 static bool gDecodeOnDraw = false;
 static bool gDiscardable = false;
@@ -33,22 +39,22 @@ InitPrefCaches()
   gInitializedPrefCaches = true;
 }
 
 static uint32_t
 ComputeImageFlags(nsIURI* uri, bool isMultiPart)
 {
   nsresult rv;
 
-  // We default to the static globals
+  // We default to the static globals.
   bool isDiscardable = gDiscardable;
   bool doDecodeOnDraw = gDecodeOnDraw;
 
   // We want UI to be as snappy as possible and not to flicker. Disable discarding
-  // and decode-on-draw for chrome URLS
+  // and decode-on-draw for chrome URLS.
   bool isChrome = false;
   rv = uri->SchemeIs("chrome", &isChrome);
   if (NS_SUCCEEDED(rv) && isChrome)
     isDiscardable = doDecodeOnDraw = false;
 
   // We don't want resources like the "loading" icon to be discardable or
   // decode-on-draw either.
   bool isResource = false;
@@ -56,17 +62,17 @@ ComputeImageFlags(nsIURI* uri, bool isMu
   if (NS_SUCCEEDED(rv) && isResource)
     isDiscardable = doDecodeOnDraw = false;
 
   // For multipart/x-mixed-replace, we basically want a direct channel to the
   // decoder. Disable both for this case as well.
   if (isMultiPart)
     isDiscardable = doDecodeOnDraw = false;
 
-  // We have all the information we need
+  // We have all the information we need.
   uint32_t imageFlags = Image::INIT_FLAG_NONE;
   if (isDiscardable)
     imageFlags |= Image::INIT_FLAG_DISCARDABLE;
   if (doDecodeOnDraw)
     imageFlags |= Image::INIT_FLAG_DECODE_ON_DRAW;
   if (isMultiPart)
     imageFlags |= Image::INIT_FLAG_MULTIPART;
 
@@ -118,17 +124,16 @@ ImageFactory::CreateAnonymousImage(const
 
   rv = newImage->Init(nullptr, aMimeType.get(), Image::INIT_FLAG_NONE);
   NS_ENSURE_SUCCESS(rv, BadImage(newImage));
 
   return newImage.forget();
 }
 
 /* static */ already_AddRefed<Image>
-
 ImageFactory::CreateRasterImage(nsIRequest* aRequest,
                                 imgStatusTracker* aStatusTracker,
                                 const nsCString& aMimeType,
                                 nsIURI* aURI,
                                 uint32_t aImageFlags,
                                 uint32_t aInnerWindowId)
 {
   nsresult rv;
@@ -146,26 +151,26 @@ ImageFactory::CreateRasterImage(nsIReque
   if (httpChannel) {
     nsAutoCString contentLength;
     rv = httpChannel->GetResponseHeader(NS_LITERAL_CSTRING("content-length"),
                                         contentLength);
     if (NS_SUCCEEDED(rv)) {
       int32_t len = contentLength.ToInteger(&rv);
 
       // Pass anything usable on so that the RasterImage can preallocate
-      // its source buffer
+      // its source buffer.
       if (len > 0) {
         uint32_t sizeHint = (uint32_t) len;
         sizeHint = std::min<uint32_t>(sizeHint, 20000000); // Bound by something reasonable
         rv = newImage->SetSourceSizeHint(sizeHint);
         if (NS_FAILED(rv)) {
-          // Flush memory, try to get some back, and try again
+          // Flush memory, try to get some back, and try again.
           rv = nsMemory::HeapMinimize(true);
           nsresult rv2 = newImage->SetSourceSizeHint(sizeHint);
-          // If we've still failed at this point, things are going downhill
+          // If we've still failed at this point, things are going downhill.
           if (NS_FAILED(rv) || NS_FAILED(rv2)) {
             NS_WARNING("About to hit OOM in imagelib!");
           }
         }
       }
     }
   }
 
--- a/image/src/ImageFactory.h
+++ b/image/src/ImageFactory.h
@@ -1,25 +1,26 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  *
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#include "nsIURI.h"
-#include "nsIRequest.h"
+#ifndef MOZILLA_IMAGELIB_IMAGEFACTORY_H_
+#define MOZILLA_IMAGELIB_IMAGEFACTORY_H_
 
-#include "imgIContainer.h"
-#include "imgStatusTracker.h"
-
-#include "Image.h"
+class nsIRequest;
+class nsIURI;
+class imgStatusTracker;
 
 namespace mozilla {
 namespace image {
 
+class Image;
+
 class ImageFactory
 {
 public:
   /**
    * Creates a new image with the given properties.
    *
    * @param aRequest       The associated request.
    * @param aStatusTracker A status tracker for the image to use.
@@ -60,8 +61,10 @@ private:
                                                    uint32_t aInnerWindowId);
 
   // This is a static factory class, so disallow instantiation.
   virtual ~ImageFactory() = 0;
 };
 
 } // namespace image
 } // namespace mozilla
+
+#endif // MOZILLA_IMAGELIB_IMAGEFACTORY_H_
--- a/image/src/imgRequest.cpp
+++ b/image/src/imgRequest.cpp
@@ -12,17 +12,19 @@
  * gets changed.
  * This #undef needs to be in multiple places because we don't always pull
  * headers in in the same order.
  */
 #undef LoadImage
 
 #include "imgLoader.h"
 #include "imgRequestProxy.h"
+#include "imgStatusTracker.h"
 #include "ImageFactory.h"
+#include "Image.h"
 
 #include "imgILoader.h"
 
 #include "netCore.h"
 
 #include "nsIChannel.h"
 #include "nsICachingChannel.h"
 #include "nsILoadGroup.h"
--- a/image/src/imgTools.cpp
+++ b/image/src/imgTools.cpp
@@ -16,16 +16,17 @@
 #include "nsStringStream.h"
 #include "nsComponentManagerUtils.h"
 #include "nsWeakReference.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsStreamUtils.h"
 #include "nsNetUtil.h"
 #include "nsContentUtils.h"
 #include "ImageFactory.h"
+#include "Image.h"
 #include "ScriptedNotificationObserver.h"
 #include "imgIScriptedNotificationObserver.h"
 
 using namespace mozilla::image;
 
 class nsIDOMDocument;
 class nsIDocument;