Files
palemoon27/image/ImageCacheKey.cpp
T
roytam1 b4e0096456 import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1147555 - Implement logging for MediaTimer. r=mattwoodrow (5cf479784)
- Bug 1160064 - Explicitly initialize logging at the right time. r=jww (fd87f4aa4)
- Bug 1163196 - Part 1: Remove instances of #ifdef PR_LOGGING in dom/security. r=froydnj (889db2d96)
- Bug 1163196 - Part 2: Wrap expensive calls in PR_LOG_TEST. r=froydnj (caefa9db6)
- Bug 1148203 - Fix build errors with combinations of enable/disable of ffmp4/ffmpeg/eme - r=cpearce,ted (27308aa76)
- Bug 1164622 - Part 1: Remove instances of #ifdef PR_LOGGING in media. r=froydnj (302eb552e)
- Bug 1164622 - Part 2: Wrap expensive calls in PR_LOG_TEST. r=ekr (808824402)
- Bug 1164556 - Part 1: Remove instances of #ifdef PR_LOGGING in toolkit. r=froydnj (2b056c1bf)
- Bug 1143197 part.1 Use current IM context at handling key events rather than active IM context r=m_kato (f4c677871)
- Bug 1143197 part.2 Assume that composition is committed if a call of gtk_im_context_reset() causes composition string becomes empty r=m_kato (59cb6d378)
- Bug 1162242 - Part 2: Remove DEBUG_TIMERS. r=froydnj (792376073)
- Bug 1162242 - Part 3: Clean up usage of PR_LOG_TEST. r=froydnj (ebab31690)
- Bug 1157343 - Protect ProgressTracker::mImage with a mutex. r=tn (5e4be06c4)
- Bug 1162751 - Part 1: Remove instances of #ifdef PR_LOGGING in image. r=froydnj (124c81181)
- Bug 1162751 - Part 2: Always disable pallete index checking. r=seth (a914e4e31)
- Bug 1155429 - Add an explicit ImageCacheKey type for the ImageLib cache. r=baku (be1d56940)
- Bug 1162751 - Part 3: Wrap expensive calls in PR_LOG_TEST. r=seth (c2af68bb8)
- Bug 1164620 - Part 2: Wrap expensive calls in PR_LOG_TEST. r=froydnj (b0470b57f)
- Bug 1163192 - Part 1: Remove instances of #ifdef PR_LOGGING in dom/xslt. r=froydnj (5f8441bd8)
- Bug 1163192 - Part 2: Wrap expensive calls in PR_LOG_TEST. r=froydnj (1ee241448)
- Bug 1160703 (Part 1) - Move ImageCacheKey out of imgLoader.h. r=baku (22f0c6e93)
- Bug 1160703 (Part 2) - Store an ImageURL pointer instead of a URI spec string in ImageCacheKey. r=baku (e36657b1e)
2021-02-25 10:48:11 +08:00

79 lines
1.7 KiB
C++

/* -*- 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 "ImageCacheKey.h"
#include "mozilla/Move.h"
#include "File.h"
#include "ImageURL.h"
#include "nsHostObjectProtocolHandler.h"
#include "nsString.h"
namespace mozilla {
using namespace dom;
namespace image {
ImageCacheKey::ImageCacheKey(nsIURI* aURI)
: mURI(new ImageURL(aURI))
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(mURI);
bool isChrome;
mIsChrome = NS_SUCCEEDED(aURI->SchemeIs("chrome", &isChrome)) && isChrome;
mHash = ComputeHash(mURI);
}
ImageCacheKey::ImageCacheKey(ImageURL* aURI)
: mURI(aURI)
{
MOZ_ASSERT(mURI);
bool isChrome;
mIsChrome = NS_SUCCEEDED(aURI->SchemeIs("chrome", &isChrome)) && isChrome;
mHash = ComputeHash(mURI);
}
ImageCacheKey::ImageCacheKey(const ImageCacheKey& aOther)
: mURI(aOther.mURI)
, mHash(aOther.mHash)
, mIsChrome(aOther.mIsChrome)
{ }
ImageCacheKey::ImageCacheKey(ImageCacheKey&& aOther)
: mURI(Move(aOther.mURI))
, mHash(aOther.mHash)
, mIsChrome(aOther.mIsChrome)
{ }
bool
ImageCacheKey::operator==(const ImageCacheKey& aOther) const
{
return *mURI == *aOther.mURI;
}
const char*
ImageCacheKey::Spec() const
{
return mURI->Spec();
}
/* static */ uint32_t
ImageCacheKey::ComputeHash(ImageURL* aURI)
{
// Since we frequently call Hash() several times in a row on the same
// ImageCacheKey, as an optimization we compute our hash once and store it.
nsAutoCString spec;
aURI->GetSpec(spec);
return HashString(spec);
}
} // namespace image
} // namespace mozilla