2015-05-20 20:21:09 +03:00
|
|
|
/* -*- 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/. */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ImageCacheKey is the key type for the image cache (see imgLoader.h).
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef mozilla_image_src_ImageCacheKey_h
|
|
|
|
#define mozilla_image_src_ImageCacheKey_h
|
|
|
|
|
2016-08-04 21:22:00 +03:00
|
|
|
#include "mozilla/BasePrincipal.h"
|
2015-05-21 04:49:53 +03:00
|
|
|
#include "mozilla/Maybe.h"
|
2016-06-30 20:24:27 +03:00
|
|
|
#include "mozilla/RefPtr.h"
|
2017-10-25 01:22:55 +03:00
|
|
|
#include "PLDHashTable.h"
|
2015-05-21 04:49:53 +03:00
|
|
|
|
2016-04-11 12:00:03 +03:00
|
|
|
class nsIDocument;
|
2015-05-20 20:21:09 +03:00
|
|
|
class nsIURI;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace image {
|
|
|
|
|
|
|
|
class ImageURL;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* An ImageLib cache entry key.
|
|
|
|
*
|
|
|
|
* We key the cache on the initial URI (before any redirects), with some
|
|
|
|
* canonicalization applied. See ComputeHash() for the details.
|
2015-10-27 21:12:46 +03:00
|
|
|
* Controlled documents do not share their cache entries with
|
|
|
|
* non-controlled documents, or other controlled documents.
|
2015-05-20 20:21:09 +03:00
|
|
|
*/
|
|
|
|
class ImageCacheKey final
|
|
|
|
{
|
|
|
|
public:
|
2017-01-12 19:38:48 +03:00
|
|
|
ImageCacheKey(nsIURI* aURI, const OriginAttributes& aAttrs,
|
2016-08-29 08:34:32 +03:00
|
|
|
nsIDocument* aDocument, nsresult& aRv);
|
2017-01-12 19:38:48 +03:00
|
|
|
ImageCacheKey(ImageURL* aURI, const OriginAttributes& aAttrs,
|
2016-08-04 21:22:00 +03:00
|
|
|
nsIDocument* aDocument);
|
2015-05-20 20:21:09 +03:00
|
|
|
|
|
|
|
ImageCacheKey(const ImageCacheKey& aOther);
|
|
|
|
ImageCacheKey(ImageCacheKey&& aOther);
|
|
|
|
|
|
|
|
bool operator==(const ImageCacheKey& aOther) const;
|
2017-07-04 08:05:04 +03:00
|
|
|
PLDHashNumber Hash() const { return mHash; }
|
2015-05-20 20:21:09 +03:00
|
|
|
|
|
|
|
/// A weak pointer to the URI spec for this cache entry. For logging only.
|
2015-05-20 20:21:11 +03:00
|
|
|
const char* Spec() const;
|
2015-05-20 20:21:09 +03:00
|
|
|
|
|
|
|
/// Is this cache entry for a chrome image?
|
|
|
|
bool IsChrome() const { return mIsChrome; }
|
|
|
|
|
2015-10-28 23:01:07 +03:00
|
|
|
/// A token indicating which service worker controlled document this entry
|
|
|
|
/// belongs to, if any.
|
|
|
|
void* ControlledDocument() const { return mControlledDocument; }
|
|
|
|
|
2015-05-20 20:21:09 +03:00
|
|
|
private:
|
2017-07-04 08:05:04 +03:00
|
|
|
static PLDHashNumber ComputeHash(ImageURL* aURI,
|
|
|
|
const Maybe<uint64_t>& aBlobSerial,
|
|
|
|
const OriginAttributes& aAttrs,
|
2017-07-24 06:51:20 +03:00
|
|
|
void* aControlledDocument,
|
|
|
|
bool aIsStyloEnabled);
|
2016-04-11 12:00:03 +03:00
|
|
|
static void* GetControlledDocumentToken(nsIDocument* aDocument);
|
2015-05-20 20:21:09 +03:00
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<ImageURL> mURI;
|
2015-05-21 04:49:53 +03:00
|
|
|
Maybe<uint64_t> mBlobSerial;
|
2017-01-12 19:38:48 +03:00
|
|
|
OriginAttributes mOriginAttributes;
|
2015-10-27 21:12:46 +03:00
|
|
|
void* mControlledDocument;
|
2017-07-04 08:05:04 +03:00
|
|
|
PLDHashNumber mHash;
|
2015-05-20 20:21:09 +03:00
|
|
|
bool mIsChrome;
|
2017-07-24 06:51:20 +03:00
|
|
|
// To prevent the reftests of styloVsGecko taking the same image cache after
|
|
|
|
// refreshing, we need to store different caches of stylo and gecko. So, we
|
|
|
|
// also consider the info of StyloEnabled() in ImageCacheKey.
|
|
|
|
bool mIsStyloEnabled;
|
2015-05-20 20:21:09 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace image
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_image_src_ImageCacheKey_h
|