Bug 1139804 (Part 2) - Stop accessing private imgRequest members in imgRequestProxy. r=baku
authorSeth Fowler <seth@mozilla.com>
Mon, 23 Mar 2015 19:37:45 -0700
changeset 264075 434182bfb8cc7586f51d7dfd918cc91262ce9f5d
parent 264074 670fa5a3482da7e566217e8716f91802d5420fb6
child 264076 61c1f8d6b44a88781f49075c1d57e8ae1ea6ffbd
push id4718
push userraliiev@mozilla.com
push dateMon, 11 May 2015 18:39:53 +0000
treeherdermozilla-beta@c20c4ef55f08 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1139804
milestone39.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 1139804 (Part 2) - Stop accessing private imgRequest members in imgRequestProxy. r=baku
image/src/imgRequest.h
image/src/imgRequestProxy.cpp
image/src/imgRequestProxy.h
--- a/image/src/imgRequest.h
+++ b/image/src/imgRequest.h
@@ -124,74 +124,78 @@ public:
     return principal.forget();
   }
 
   // Return the ProgressTracker associated with this imgRequest. It may live
   // in |mProgressTracker| or in |mImage.mProgressTracker|, depending on whether
   // mImage has been instantiated yet.
   already_AddRefed<ProgressTracker> GetProgressTracker();
 
+  /// Returns the Image associated with this imgRequest, if it's ready.
+  already_AddRefed<Image> GetImage() const;
+
   // Get the current principal of the image. No AddRefing.
   inline nsIPrincipal* GetPrincipal() const { return mPrincipal.get(); }
 
   // Resize the cache entry to 0 if it exists
   void ResetCacheEntry();
 
   // OK to use on any thread.
   nsresult GetURI(ImageURL **aURI);
   nsresult GetCurrentURI(nsIURI **aURI);
 
   nsresult GetImageErrorCode(void);
 
+  /// Returns true if we've received any data.
+  bool HasTransferredData() const;
+
+  /// Returns a non-owning pointer to this imgRequest's MIME type.
+  const char* GetMimeType() const { return mContentType.get(); }
+
+  /// @return the priority of the underlying network request, or
+  /// PRIORITY_NORMAL if it doesn't support nsISupportsPriority.
+  int32_t Priority() const;
+
+  /// Adjust the priority of the underlying network request by @aDelta on behalf
+  /// of @aProxy.
+  void AdjustPriority(imgRequestProxy* aProxy, int32_t aDelta);
+
+  nsITimedChannel* GetTimedChannel() const { return mTimedChannel; }
+
+  nsresult GetSecurityInfo(nsISupports** aSecurityInfoOut);
+
 private:
   friend class imgCacheEntry;
-  friend class imgRequestProxy;
   friend class imgLoader;
   friend class imgCacheValidator;
   friend class imgCacheExpirationTracker;
   friend class mozilla::image::ProgressTracker;
 
   inline void SetLoadId(void *aLoadId) {
     mLoadId = aLoadId;
   }
   void Cancel(nsresult aStatus);
   void EvictFromCache();
   void RemoveFromCache();
 
-  nsresult GetSecurityInfo(nsISupports **aSecurityInfo);
-
-  inline const char *GetMimeType() const {
-    return mContentType.get();
-  }
   inline nsIProperties *Properties() {
     return mProperties;
   }
 
   // Reset the cache entry after we've dropped our reference to it. Used by the
   // imgLoader when our cache entry is re-requested after we've dropped our
   // reference to it.
   void SetCacheEntry(imgCacheEntry *entry);
 
   // Returns whether we've got a reference to the cache entry.
   bool HasCacheEntry() const;
 
   // Update the cache entry size based on the image container.
   void UpdateCacheEntrySize();
 
-  // Return the priority of the underlying network request, or return
-  // PRIORITY_NORMAL if it doesn't support nsISupportsPriority.
-  int32_t Priority() const;
-
-  // Adjust the priority of the underlying network request by the given delta
-  // on behalf of the given proxy.
-  void AdjustPriority(imgRequestProxy *aProxy, int32_t aDelta);
-
-  // Return whether we've seen some data at this point
-  bool HasTransferredData() const;
-
   // Set whether this request is stored in the cache. If it isn't, regardless
   // of whether this request has a non-null mCacheEntry, this imgRequest won't
   // try to update or modify the image cache.
   void SetIsInCache(bool cacheable);
 
   bool HasConsumers();
 
   /// Returns true if RequestDecode() was called.
@@ -208,18 +212,16 @@ public:
   // Sets properties for this image; will dispatch to main thread if needed.
   void SetProperties(const nsACString& aContentType,
                      const nsACString& aContentDisposition);
 
 private:
   friend class imgMemoryReporter;
   friend class FinishPreparingForNewPartRunnable;
 
-  already_AddRefed<Image> GetImage() const;
-
   void FinishPreparingForNewPart(const NewPartResult& aResult);
 
   // Weak reference to parent loader; this request cannot outlive its owner.
   imgLoader* mLoader;
   nsCOMPtr<nsIRequest> mRequest;
   // The original URI we were loaded with. This is the same as the URI we are
   // keyed on in the cache. We store a string here to avoid off main thread
   // refcounting issues with nsStandardURL.
--- a/image/src/imgRequestProxy.cpp
+++ b/image/src/imgRequestProxy.cpp
@@ -500,23 +500,25 @@ NS_IMETHODIMP imgRequestProxy::GetImage(
 {
   NS_ENSURE_TRUE(aImage, NS_ERROR_NULL_POINTER);
   // It's possible that our owner has an image but hasn't notified us of it -
   // that'll happen if we get Canceled before the owner instantiates its image
   // (because Canceling unregisters us as a listener on mOwner). If we're
   // in that situation, just grab the image off of mOwner.
   nsRefPtr<Image> image = GetImage();
   nsCOMPtr<imgIContainer> imageToReturn;
-  if (image)
+  if (image) {
     imageToReturn = do_QueryInterface(image);
-  if (!imageToReturn && GetOwner())
-    imageToReturn = GetOwner()->mImage;
-
-  if (!imageToReturn)
+  }
+  if (!imageToReturn && GetOwner()) {
+    imageToReturn = GetOwner()->GetImage();
+  }
+  if (!imageToReturn) {
     return NS_ERROR_FAILURE;
+  }
 
   imageToReturn.swap(*aImage);
 
   return NS_OK;
 }
 
 /* readonly attribute unsigned long imageStatus; */
 NS_IMETHODIMP imgRequestProxy::GetImageStatus(uint32_t *aStatus)
--- a/image/src/imgRequestProxy.h
+++ b/image/src/imgRequestProxy.h
@@ -166,19 +166,20 @@ protected:
   // Return the ProgressTracker associated with mOwner and/or mImage. It may
   // live either on mOwner or mImage, depending on whether
   //   (a) we have an mOwner at all
   //   (b) whether mOwner has instantiated its image yet
   already_AddRefed<ProgressTracker> GetProgressTracker() const;
 
   nsITimedChannel* TimedChannel()
   {
-    if (!GetOwner())
+    if (!GetOwner()) {
       return nullptr;
-    return GetOwner()->mTimedChannel;
+    }
+    return GetOwner()->GetTimedChannel();
   }
 
   already_AddRefed<Image> GetImage() const;
   bool HasImage() const;
   imgRequest* GetOwner() const;
 
   nsresult PerformClone(imgINotificationObserver* aObserver,
                         imgRequestProxy* (aAllocFn)(imgRequestProxy*),