Bug 943686 - Add imgRequest.cpp to unified sources. r=? draft
authorEric Rahm <erahm@mozilla.com>
Mon, 20 Mar 2017 13:19:06 -0700
changeset 501687 536eaa12e9524ebaf4e9865eaa7414006cff0740
parent 501686 adb7e01afb0850b3c4937d0a72a54799e3f2519c
child 501688 679aff7940bb6b6bdf1594f261c8ac77628f9e75
push id50078
push usererahm@mozilla.com
push dateMon, 20 Mar 2017 20:21:34 +0000
bugs943686
milestone55.0a1
Bug 943686 - Add imgRequest.cpp to unified sources. r=? MozReview-Commit-ID: B87v26HNtBn
image/imgRequest.cpp
image/moz.build
--- a/image/imgRequest.cpp
+++ b/image/imgRequest.cpp
@@ -504,21 +504,21 @@ imgRequest::RemoveFromCache()
 
 bool
 imgRequest::HasConsumers() const
 {
   RefPtr<ProgressTracker> progressTracker = GetProgressTracker();
   return progressTracker && progressTracker->ObserverCount() > 0;
 }
 
-already_AddRefed<Image>
+already_AddRefed<image::Image>
 imgRequest::GetImage() const
 {
   MutexAutoLock lock(mMutex);
-  RefPtr<Image> image = mImage;
+  RefPtr<image::Image> image = mImage;
   return image.forget();
 }
 
 int32_t imgRequest::Priority() const
 {
   int32_t priority = nsISupportsPriority::PRIORITY_NORMAL;
   nsCOMPtr<nsISupportsPriority> p = do_QueryInterface(mRequest);
   if (p) {
@@ -900,34 +900,34 @@ imgRequest::CheckListenerChain()
   NS_ASSERTION(NS_IsMainThread(), "Should be on the main thread!");
   return NS_OK;
 }
 
 /** nsIStreamListener methods **/
 
 struct NewPartResult final
 {
-  explicit NewPartResult(Image* aExistingImage)
+  explicit NewPartResult(image::Image* aExistingImage)
     : mImage(aExistingImage)
     , mIsFirstPart(!aExistingImage)
     , mSucceeded(false)
     , mShouldResetCacheEntry(false)
   { }
 
   nsAutoCString mContentType;
   nsAutoCString mContentDisposition;
-  RefPtr<Image> mImage;
+  RefPtr<image::Image> mImage;
   const bool mIsFirstPart;
   bool mSucceeded;
   bool mShouldResetCacheEntry;
 };
 
 static NewPartResult
 PrepareForNewPart(nsIRequest* aRequest, nsIInputStream* aInStr, uint32_t aCount,
-                  ImageURL* aURI, bool aIsMultipart, Image* aExistingImage,
+                  ImageURL* aURI, bool aIsMultipart, image::Image* aExistingImage,
                   ProgressTracker* aProgressTracker, uint32_t aInnerWindowId)
 {
   NewPartResult result(aExistingImage);
 
   if (aInStr) {
     mimetype_closure closure;
     closure.newType = &result.mContentType;
 
@@ -962,44 +962,46 @@ PrepareForNewPart(nsIRequest* aRequest, 
   // XXX If server lied about mimetype and it's SVG, we may need to copy
   // the data and dispatch back to the main thread, AND tell the channel to
   // dispatch there in the future.
 
   // Create the new image and give it ownership of our ProgressTracker.
   if (aIsMultipart) {
     // Create the ProgressTracker and image for this part.
     RefPtr<ProgressTracker> progressTracker = new ProgressTracker();
-    RefPtr<Image> partImage =
-      ImageFactory::CreateImage(aRequest, progressTracker, result.mContentType,
-                                aURI, /* aIsMultipart = */ true,
-                                aInnerWindowId);
+    RefPtr<image::Image> partImage =
+      image::ImageFactory::CreateImage(aRequest, progressTracker,
+                                       result.mContentType,
+                                       aURI, /* aIsMultipart = */ true,
+                                       aInnerWindowId);
 
     if (result.mIsFirstPart) {
       // First part for a multipart channel. Create the MultipartImage wrapper.
       MOZ_ASSERT(aProgressTracker, "Shouldn't have given away tracker yet");
       aProgressTracker->SetIsMultipart();
       result.mImage =
-        ImageFactory::CreateMultipartImage(partImage, aProgressTracker);
+        image::ImageFactory::CreateMultipartImage(partImage, aProgressTracker);
     } else {
       // Transition to the new part.
       auto multipartImage = static_cast<MultipartImage*>(aExistingImage);
       multipartImage->BeginTransitionToPart(partImage);
 
       // Reset our cache entry size so it doesn't keep growing without bound.
       result.mShouldResetCacheEntry = true;
     }
   } else {
     MOZ_ASSERT(!aExistingImage, "New part for non-multipart channel?");
     MOZ_ASSERT(aProgressTracker, "Shouldn't have given away tracker yet");
 
     // Create an image using our progress tracker.
     result.mImage =
-      ImageFactory::CreateImage(aRequest, aProgressTracker, result.mContentType,
-                                aURI, /* aIsMultipart = */ false,
-                                aInnerWindowId);
+      image::ImageFactory::CreateImage(aRequest, aProgressTracker,
+                                       result.mContentType,
+                                       aURI, /* aIsMultipart = */ false,
+                                       aInnerWindowId);
   }
 
   MOZ_ASSERT(result.mImage);
   if (!result.mImage->HasError() || aIsMultipart) {
     // We allow multipart images to fail to initialize (which generally
     // indicates a bad content type) without cancelling the load, because
     // subsequent parts might be fine.
     result.mSucceeded = true;
--- a/image/moz.build
+++ b/image/moz.build
@@ -62,16 +62,17 @@ UNIFIED_SOURCES += [
     'IDecodingTask.cpp',
     'Image.cpp',
     'ImageCacheKey.cpp',
     'ImageFactory.cpp',
     'ImageOps.cpp',
     'ImageWrapper.cpp',
     'imgFrame.cpp',
     'imgLoader.cpp',
+    'imgRequest.cpp',
     'imgTools.cpp',
     'MultipartImage.cpp',
     'OrientedImage.cpp',
     'ScriptedNotificationObserver.cpp',
     'ShutdownTracker.cpp',
     'SourceBuffer.cpp',
     'SurfaceCache.cpp',
     'SurfaceCacheUtils.cpp',
@@ -79,17 +80,16 @@ UNIFIED_SOURCES += [
     'SVGDocumentWrapper.cpp',
     'VectorImage.cpp',
 ]
 if CONFIG['MOZ_ENABLE_SKIA']:
     UNIFIED_SOURCES += [ 'Downscaler.cpp']
 
 # These files can't be unified because of ImageLogging.h #include order issues.
 SOURCES += [
-    'imgRequest.cpp',
     'imgRequestProxy.cpp',
     'ProgressTracker.cpp',
     'RasterImage.cpp',
 ]
 
 include('/ipc/chromium/chromium-config.mozbuild')
 
 FINAL_LIBRARY = 'xul'