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 {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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);
|
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
|
|
|
|
2018-06-20 18:57:50 +03:00
|
|
|
/// A weak pointer to the URI.
|
2018-06-06 03:42:56 +03:00
|
|
|
nsIURI* URI() const { return mURI; }
|
2015-05-20 20:21:09 +03:00
|
|
|
|
2018-06-20 18:57:50 +03:00
|
|
|
const OriginAttributes& OriginAttributesRef() const { return mOriginAttributes; }
|
|
|
|
|
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:
|
2018-06-06 03:42:56 +03:00
|
|
|
bool SchemeIs(const char* aScheme);
|
2016-04-11 12:00:03 +03:00
|
|
|
static void* GetControlledDocumentToken(nsIDocument* aDocument);
|
2015-05-20 20:21:09 +03:00
|
|
|
|
2018-06-06 03:42:56 +03:00
|
|
|
nsCOMPtr<nsIURI> mURI;
|
2015-05-21 04:49:53 +03:00
|
|
|
Maybe<uint64_t> mBlobSerial;
|
2018-06-06 03:42:56 +03:00
|
|
|
nsCString mBlobRef;
|
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;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace image
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_image_src_ImageCacheKey_h
|