forked from mirrors/gecko-dev
Bug 920630 - Part 4. Change rest of imagelib to use nsIURI directly instead of ImageURL. r=tnikkel
This commit is contained in:
parent
ce228623ab
commit
594cd79ec7
7 changed files with 36 additions and 98 deletions
|
|
@ -178,16 +178,8 @@ ProgressTracker::Notify(IProgressObserver* aObserver)
|
|||
|
||||
if (MOZ_LOG_TEST(gImgLog, LogLevel::Debug)) {
|
||||
RefPtr<Image> image = GetImage();
|
||||
if (image && image->GetURI()) {
|
||||
RefPtr<ImageURL> uri(image->GetURI());
|
||||
nsAutoCString spec;
|
||||
uri->GetSpec(spec);
|
||||
LOG_FUNC_WITH_PARAM(gImgLog,
|
||||
"ProgressTracker::Notify async", "uri", spec.get());
|
||||
} else {
|
||||
LOG_FUNC_WITH_PARAM(gImgLog,
|
||||
"ProgressTracker::Notify async", "uri", "<unknown>");
|
||||
}
|
||||
LOG_FUNC_WITH_PARAM(gImgLog,
|
||||
"ProgressTracker::Notify async", "uri", image);
|
||||
}
|
||||
|
||||
aObserver->MarkPendingNotify();
|
||||
|
|
@ -253,12 +245,8 @@ ProgressTracker::NotifyCurrentState(IProgressObserver* aObserver)
|
|||
|
||||
if (MOZ_LOG_TEST(gImgLog, LogLevel::Debug)) {
|
||||
RefPtr<Image> image = GetImage();
|
||||
nsAutoCString spec;
|
||||
if (image && image->GetURI()) {
|
||||
image->GetURI()->GetSpec(spec);
|
||||
}
|
||||
LOG_FUNC_WITH_PARAM(gImgLog,
|
||||
"ProgressTracker::NotifyCurrentState", "uri", spec.get());
|
||||
"ProgressTracker::NotifyCurrentState", "uri", image);
|
||||
}
|
||||
|
||||
aObserver->MarkPendingNotify();
|
||||
|
|
@ -401,13 +389,8 @@ ProgressTracker::SyncNotify(IProgressObserver* aObserver)
|
|||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
RefPtr<Image> image = GetImage();
|
||||
|
||||
nsAutoCString spec;
|
||||
if (image && image->GetURI()) {
|
||||
image->GetURI()->GetSpec(spec);
|
||||
}
|
||||
LOG_SCOPE_WITH_PARAM(gImgLog,
|
||||
"ProgressTracker::SyncNotify", "uri", spec.get());
|
||||
"ProgressTracker::SyncNotify", "uri", image);
|
||||
|
||||
nsIntRect rect;
|
||||
if (image) {
|
||||
|
|
@ -596,11 +579,7 @@ ProgressTracker::FireFailureNotification()
|
|||
RefPtr<Image> image = GetImage();
|
||||
if (image) {
|
||||
// Should be on main thread, so ok to create a new nsIURI.
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
{
|
||||
RefPtr<ImageURL> threadsafeUriData = image->GetURI();
|
||||
uri = threadsafeUriData ? threadsafeUriData->ToIURI() : nullptr;
|
||||
}
|
||||
nsCOMPtr<nsIURI> uri = image->GetURI();
|
||||
if (uri) {
|
||||
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
|
||||
if (os) {
|
||||
|
|
|
|||
|
|
@ -994,10 +994,10 @@ imgCacheEntry::SetHasNoProxies(bool hasNoProxies)
|
|||
if (MOZ_LOG_TEST(gImgLog, LogLevel::Debug)) {
|
||||
if (hasNoProxies) {
|
||||
LOG_FUNC_WITH_PARAM(gImgLog, "imgCacheEntry::SetHasNoProxies true",
|
||||
"uri", mRequest->CacheKey().Spec());
|
||||
"uri", mRequest->CacheKey().URI());
|
||||
} else {
|
||||
LOG_FUNC_WITH_PARAM(gImgLog, "imgCacheEntry::SetHasNoProxies false",
|
||||
"uri", mRequest->CacheKey().Spec());
|
||||
"uri", mRequest->CacheKey().URI());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1172,7 +1172,7 @@ imgLoader::CreateNewProxyForRequest(imgRequest* aRequest,
|
|||
*/
|
||||
proxyRequest->SetLoadFlags(aLoadFlags);
|
||||
|
||||
RefPtr<ImageURL> uri;
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
aRequest->GetURI(getter_AddRefs(uri));
|
||||
|
||||
// init adds itself to imgRequest's list of observers
|
||||
|
|
@ -1215,7 +1215,7 @@ imgCacheExpirationTracker::NotifyExpired(imgCacheEntry* entry)
|
|||
if (req) {
|
||||
LOG_FUNC_WITH_PARAM(gImgLog,
|
||||
"imgCacheExpirationTracker::NotifyExpired",
|
||||
"entry", req->CacheKey().Spec());
|
||||
"entry", req->CacheKey().URI());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1580,7 +1580,7 @@ imgLoader::PutIntoCache(const ImageCacheKey& aKey, imgCacheEntry* entry)
|
|||
imgCacheTable& cache = GetCache(aKey);
|
||||
|
||||
LOG_STATIC_FUNC_WITH_PARAM(gImgLog,
|
||||
"imgLoader::PutIntoCache", "uri", aKey.Spec());
|
||||
"imgLoader::PutIntoCache", "uri", aKey.URI());
|
||||
|
||||
// Check to see if this request already exists in the cache. If so, we'll
|
||||
// replace the old version.
|
||||
|
|
@ -1638,7 +1638,7 @@ imgLoader::SetHasNoProxies(imgRequest* aRequest, imgCacheEntry* aEntry)
|
|||
{
|
||||
LOG_STATIC_FUNC_WITH_PARAM(gImgLog,
|
||||
"imgLoader::SetHasNoProxies", "uri",
|
||||
aRequest->CacheKey().Spec());
|
||||
aRequest->CacheKey().URI());
|
||||
|
||||
aEntry->SetHasNoProxies(true);
|
||||
|
||||
|
|
@ -1673,7 +1673,7 @@ imgLoader::SetHasProxies(imgRequest* aRequest)
|
|||
imgCacheTable& cache = GetCache(key);
|
||||
|
||||
LOG_STATIC_FUNC_WITH_PARAM(gImgLog,
|
||||
"imgLoader::SetHasProxies", "uri", key.Spec());
|
||||
"imgLoader::SetHasProxies", "uri", key.URI());
|
||||
|
||||
RefPtr<imgCacheEntry> entry;
|
||||
if (cache.Get(key, getter_AddRefs(entry)) && entry) {
|
||||
|
|
@ -1729,7 +1729,7 @@ imgLoader::CheckCacheLimits(imgCacheTable& cache, imgCacheQueue& queue)
|
|||
if (req) {
|
||||
LOG_STATIC_FUNC_WITH_PARAM(gImgLog,
|
||||
"imgLoader::CheckCacheLimits",
|
||||
"entry", req->CacheKey().Spec());
|
||||
"entry", req->CacheKey().URI());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2004,7 +2004,7 @@ bool
|
|||
imgLoader::RemoveFromCache(const ImageCacheKey& aKey)
|
||||
{
|
||||
LOG_STATIC_FUNC_WITH_PARAM(gImgLog,
|
||||
"imgLoader::RemoveFromCache", "uri", aKey.Spec());
|
||||
"imgLoader::RemoveFromCache", "uri", aKey.URI());
|
||||
|
||||
imgCacheTable& cache = GetCache(aKey);
|
||||
imgCacheQueue& queue = GetCacheQueue(aKey);
|
||||
|
|
@ -2046,7 +2046,7 @@ imgLoader::RemoveFromCache(imgCacheEntry* entry, QueueState aQueueState)
|
|||
|
||||
LOG_STATIC_FUNC_WITH_PARAM(gImgLog,
|
||||
"imgLoader::RemoveFromCache", "entry's uri",
|
||||
key.Spec());
|
||||
key.URI());
|
||||
|
||||
cache.Remove(key);
|
||||
|
||||
|
|
@ -2214,8 +2214,7 @@ imgLoader::LoadImage(nsIURI* aURI,
|
|||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
LOG_SCOPE_WITH_PARAM(gImgLog, "imgLoader::LoadImage", "aURI",
|
||||
aURI->GetSpecOrDefault().get());
|
||||
LOG_SCOPE_WITH_PARAM(gImgLog, "imgLoader::LoadImage", "aURI", aURI);
|
||||
|
||||
*_retval = nullptr;
|
||||
|
||||
|
|
@ -2310,7 +2309,7 @@ imgLoader::LoadImage(nsIURI* aURI,
|
|||
// entry.
|
||||
if (entry->HasNoProxies()) {
|
||||
LOG_FUNC_WITH_PARAM(gImgLog,
|
||||
"imgLoader::LoadImage() adding proxyless entry", "uri", key.Spec());
|
||||
"imgLoader::LoadImage() adding proxyless entry", "uri", key.URI());
|
||||
MOZ_ASSERT(!request->HasCacheEntry(),
|
||||
"Proxyless entry's request has cache entry!");
|
||||
request->SetCacheEntry(entry);
|
||||
|
|
@ -2598,7 +2597,7 @@ imgLoader::LoadImageWithChannel(nsIChannel* channel,
|
|||
if (entry->HasNoProxies()) {
|
||||
LOG_FUNC_WITH_PARAM(gImgLog,
|
||||
"imgLoader::LoadImageWithChannel() adding proxyless entry",
|
||||
"uri", key.Spec());
|
||||
"uri", key.URI());
|
||||
MOZ_ASSERT(!request->HasCacheEntry(),
|
||||
"Proxyless entry's request has cache entry!");
|
||||
request->SetCacheEntry(entry);
|
||||
|
|
@ -3067,17 +3066,11 @@ imgCacheValidator::OnStartRequest(nsIRequest* aRequest, nsISupports* ctxt)
|
|||
// We can't load out of cache. We have to create a whole new request for the
|
||||
// data that's coming in off the channel.
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
{
|
||||
RefPtr<ImageURL> imageURL;
|
||||
mRequest->GetURI(getter_AddRefs(imageURL));
|
||||
uri = imageURL->ToIURI();
|
||||
}
|
||||
mRequest->GetURI(getter_AddRefs(uri));
|
||||
|
||||
if (MOZ_LOG_TEST(gImgLog, LogLevel::Debug)) {
|
||||
LOG_MSG_WITH_PARAM(gImgLog,
|
||||
"imgCacheValidator::OnStartRequest creating new request",
|
||||
"uri", uri->GetSpecOrDefault().get());
|
||||
}
|
||||
LOG_MSG_WITH_PARAM(gImgLog,
|
||||
"imgCacheValidator::OnStartRequest creating new request",
|
||||
"uri", uri);
|
||||
|
||||
int32_t corsmode = mRequest->GetCORSMode();
|
||||
ReferrerPolicy refpol = mRequest->GetReferrerPolicy();
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@ class imgMemoryReporter;
|
|||
|
||||
namespace mozilla {
|
||||
namespace image {
|
||||
class ImageURL;
|
||||
} // namespace image
|
||||
} // namespace mozilla
|
||||
|
||||
|
|
@ -234,7 +233,6 @@ class imgLoader final : public imgILoader,
|
|||
|
||||
public:
|
||||
typedef mozilla::image::ImageCacheKey ImageCacheKey;
|
||||
typedef mozilla::image::ImageURL ImageURL;
|
||||
typedef nsRefPtrHashtable<nsGenericHashKey<ImageCacheKey>,
|
||||
imgCacheEntry> imgCacheTable;
|
||||
typedef nsTHashtable<nsPtrHashKey<imgRequest>> imgSet;
|
||||
|
|
|
|||
|
|
@ -80,10 +80,8 @@ imgRequest::~imgRequest()
|
|||
mLoader->RemoveFromUncachedImages(this);
|
||||
}
|
||||
if (mURI) {
|
||||
nsAutoCString spec;
|
||||
mURI->GetSpec(spec);
|
||||
LOG_FUNC_WITH_PARAM(gImgLog, "imgRequest::~imgRequest()",
|
||||
"keyuri", spec.get());
|
||||
"keyuri", mURI);
|
||||
} else
|
||||
LOG_FUNC(gImgLog, "imgRequest::~imgRequest()");
|
||||
}
|
||||
|
|
@ -111,17 +109,11 @@ imgRequest::Init(nsIURI *aURI,
|
|||
MOZ_ASSERT(aChannel, "No channel");
|
||||
|
||||
mProperties = do_CreateInstance("@mozilla.org/properties;1");
|
||||
|
||||
// Use ImageURL to ensure access to URI data off main thread.
|
||||
nsresult rv;
|
||||
mURI = new ImageURL(aURI, rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mURI = aURI;
|
||||
mFinalURI = aFinalURI;
|
||||
mRequest = aRequest;
|
||||
mChannel = aChannel;
|
||||
mTimedChannel = do_QueryInterface(mChannel);
|
||||
|
||||
mTriggeringPrincipal = aTriggeringPrincipal;
|
||||
mCORSMode = aCORSMode;
|
||||
mReferrerPolicy = aReferrerPolicy;
|
||||
|
|
@ -265,12 +257,10 @@ imgRequest::RemoveProxy(imgRequestProxy* proxy, nsresult aStatus)
|
|||
if (mLoader) {
|
||||
mLoader->SetHasNoProxies(this, mCacheEntry);
|
||||
}
|
||||
} else if (MOZ_LOG_TEST(gImgLog, LogLevel::Debug)) {
|
||||
nsAutoCString spec;
|
||||
mURI->GetSpec(spec);
|
||||
} else {
|
||||
LOG_MSG_WITH_PARAM(gImgLog,
|
||||
"imgRequest::RemoveProxy no cache entry",
|
||||
"uri", spec.get());
|
||||
"uri", mURI);
|
||||
}
|
||||
|
||||
/* If |aStatus| is a failure code, then cancel the load if it is still in
|
||||
|
|
@ -422,7 +412,7 @@ imgRequest::IsDecodeRequested() const
|
|||
return mDecodeRequested;
|
||||
}
|
||||
|
||||
nsresult imgRequest::GetURI(ImageURL** aURI)
|
||||
nsresult imgRequest::GetURI(nsIURI** aURI)
|
||||
{
|
||||
MOZ_ASSERT(aURI);
|
||||
|
||||
|
|
@ -988,7 +978,7 @@ struct NewPartResult final
|
|||
|
||||
static NewPartResult
|
||||
PrepareForNewPart(nsIRequest* aRequest, nsIInputStream* aInStr, uint32_t aCount,
|
||||
ImageURL* aURI, bool aIsMultipart, image::Image* aExistingImage,
|
||||
nsIURI* aURI, bool aIsMultipart, image::Image* aExistingImage,
|
||||
ProgressTracker* aProgressTracker, uint32_t aInnerWindowId)
|
||||
{
|
||||
NewPartResult result(aExistingImage);
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@ class nsIURI;
|
|||
namespace mozilla {
|
||||
namespace image {
|
||||
class Image;
|
||||
class ImageURL;
|
||||
class ProgressTracker;
|
||||
} // namespace image
|
||||
} // namespace mozilla
|
||||
|
|
@ -50,7 +49,6 @@ class imgRequest final : public nsIStreamListener,
|
|||
{
|
||||
typedef mozilla::image::Image Image;
|
||||
typedef mozilla::image::ImageCacheKey ImageCacheKey;
|
||||
typedef mozilla::image::ImageURL ImageURL;
|
||||
typedef mozilla::image::ProgressTracker ProgressTracker;
|
||||
typedef mozilla::net::ReferrerPolicy ReferrerPolicy;
|
||||
|
||||
|
|
@ -151,7 +149,7 @@ public:
|
|||
void ResetCacheEntry();
|
||||
|
||||
// OK to use on any thread.
|
||||
nsresult GetURI(ImageURL** aURI);
|
||||
nsresult GetURI(nsIURI** aURI);
|
||||
nsresult GetFinalURI(nsIURI** aURI);
|
||||
bool IsScheme(const char* aScheme) const;
|
||||
bool IsChrome() const;
|
||||
|
|
@ -235,7 +233,7 @@ private:
|
|||
// 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.
|
||||
RefPtr<ImageURL> mURI;
|
||||
nsCOMPtr<nsIURI> mURI;
|
||||
// The URI of the resource we ended up loading after all redirects, etc.
|
||||
nsCOMPtr<nsIURI> mFinalURI;
|
||||
// The principal which triggered the load of this image. Generally either
|
||||
|
|
|
|||
|
|
@ -180,7 +180,7 @@ nsresult
|
|||
imgRequestProxy::Init(imgRequest* aOwner,
|
||||
nsILoadGroup* aLoadGroup,
|
||||
nsIDocument* aLoadingDocument,
|
||||
ImageURL* aURI,
|
||||
nsIURI* aURI,
|
||||
imgINotificationObserver* aObserver)
|
||||
{
|
||||
MOZ_ASSERT(!GetOwner() && !mListener,
|
||||
|
|
@ -772,7 +772,7 @@ NS_IMETHODIMP
|
|||
imgRequestProxy::GetURI(nsIURI** aURI)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread(), "Must be on main thread to convert URI");
|
||||
nsCOMPtr<nsIURI> uri = mURI->ToIURI();
|
||||
nsCOMPtr<nsIURI> uri = mURI;
|
||||
uri.forget(aURI);
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
@ -787,18 +787,6 @@ imgRequestProxy::GetFinalURI(nsIURI** aURI)
|
|||
return GetOwner()->GetFinalURI(aURI);
|
||||
}
|
||||
|
||||
nsresult
|
||||
imgRequestProxy::GetURI(ImageURL** aURI)
|
||||
{
|
||||
if (!mURI) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_ADDREF(*aURI = mURI);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
imgRequestProxy::GetNotificationObserver(imgINotificationObserver** aObserver)
|
||||
{
|
||||
|
|
@ -1095,12 +1083,8 @@ imgRequestProxy::Notify(int32_t aType, const mozilla::gfx::IntRect* aRect)
|
|||
void
|
||||
imgRequestProxy::OnLoadComplete(bool aLastPart)
|
||||
{
|
||||
if (MOZ_LOG_TEST(gImgLog, LogLevel::Debug)) {
|
||||
nsAutoCString name;
|
||||
GetName(name);
|
||||
LOG_FUNC_WITH_PARAM(gImgLog, "imgRequestProxy::OnLoadComplete",
|
||||
"name", name.get());
|
||||
}
|
||||
LOG_FUNC_WITH_PARAM(gImgLog, "imgRequestProxy::OnLoadComplete",
|
||||
"uri", mURI);
|
||||
|
||||
// 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
|
||||
|
|
|
|||
|
|
@ -42,7 +42,6 @@ class TabGroup;
|
|||
|
||||
namespace image {
|
||||
class Image;
|
||||
class ImageURL;
|
||||
class ProgressTracker;
|
||||
} // namespace image
|
||||
} // namespace mozilla
|
||||
|
|
@ -58,7 +57,6 @@ protected:
|
|||
|
||||
public:
|
||||
typedef mozilla::image::Image Image;
|
||||
typedef mozilla::image::ImageURL ImageURL;
|
||||
typedef mozilla::image::ProgressTracker ProgressTracker;
|
||||
|
||||
MOZ_DECLARE_REFCOUNTED_TYPENAME(imgRequestProxy)
|
||||
|
|
@ -76,7 +74,7 @@ public:
|
|||
nsresult Init(imgRequest* aOwner,
|
||||
nsILoadGroup* aLoadGroup,
|
||||
nsIDocument* aLoadingDocument,
|
||||
ImageURL* aURI,
|
||||
nsIURI* aURI,
|
||||
imgINotificationObserver* aObserver);
|
||||
|
||||
nsresult ChangeOwner(imgRequest* aNewOwner); // this will change mOwner.
|
||||
|
|
@ -150,8 +148,6 @@ public:
|
|||
nsresult GetStaticRequest(nsIDocument* aLoadingDocument,
|
||||
imgRequestProxy** aReturn);
|
||||
|
||||
nsresult GetURI(ImageURL** aURI);
|
||||
|
||||
protected:
|
||||
friend class mozilla::image::ProgressTracker;
|
||||
friend class imgStatusNotifyRunnable;
|
||||
|
|
@ -230,7 +226,7 @@ private:
|
|||
void DispatchWithTarget(already_AddRefed<nsIRunnable> aEvent);
|
||||
|
||||
// The URI of our request.
|
||||
RefPtr<ImageURL> mURI;
|
||||
nsCOMPtr<nsIURI> mURI;
|
||||
|
||||
// mListener is only promised to be a weak ref (see imgILoader.idl),
|
||||
// but we actually keep a strong ref to it until we've seen our
|
||||
|
|
|
|||
Loading…
Reference in a new issue