LCOV - code coverage report
Current view: top level - image - ImageCacheKey.h (source / functions) Hit Total Coverage
Test: output.info Lines: 3 4 75.0 %
Date: 2017-07-14 16:53:18 Functions: 3 4 75.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2             : /* This Source Code Form is subject to the terms of the Mozilla Public
       3             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       4             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       5             : 
       6             : /**
       7             :  * ImageCacheKey is the key type for the image cache (see imgLoader.h).
       8             :  */
       9             : 
      10             : #ifndef mozilla_image_src_ImageCacheKey_h
      11             : #define mozilla_image_src_ImageCacheKey_h
      12             : 
      13             : #include "mozilla/BasePrincipal.h"
      14             : #include "mozilla/Maybe.h"
      15             : #include "mozilla/RefPtr.h"
      16             : 
      17             : class nsIDocument;
      18             : class nsIURI;
      19             : 
      20             : namespace mozilla {
      21             : namespace image {
      22             : 
      23             : class ImageURL;
      24             : 
      25             : /**
      26             :  * An ImageLib cache entry key.
      27             :  *
      28             :  * We key the cache on the initial URI (before any redirects), with some
      29             :  * canonicalization applied. See ComputeHash() for the details.
      30             :  * Controlled documents do not share their cache entries with
      31             :  * non-controlled documents, or other controlled documents.
      32             :  */
      33          47 : class ImageCacheKey final
      34             : {
      35             : public:
      36             :   ImageCacheKey(nsIURI* aURI, const OriginAttributes& aAttrs,
      37             :                 nsIDocument* aDocument, nsresult& aRv);
      38             :   ImageCacheKey(ImageURL* aURI, const OriginAttributes& aAttrs,
      39             :                 nsIDocument* aDocument);
      40             : 
      41             :   ImageCacheKey(const ImageCacheKey& aOther);
      42             :   ImageCacheKey(ImageCacheKey&& aOther);
      43             : 
      44             :   bool operator==(const ImageCacheKey& aOther) const;
      45         165 :   PLDHashNumber Hash() const { return mHash; }
      46             : 
      47             :   /// A weak pointer to the URI spec for this cache entry. For logging only.
      48             :   const char* Spec() const;
      49             : 
      50             :   /// Is this cache entry for a chrome image?
      51         211 :   bool IsChrome() const { return mIsChrome; }
      52             : 
      53             :   /// A token indicating which service worker controlled document this entry
      54             :   /// belongs to, if any.
      55           0 :   void* ControlledDocument() const { return mControlledDocument; }
      56             : 
      57             : private:
      58             :   static PLDHashNumber ComputeHash(ImageURL* aURI,
      59             :                                    const Maybe<uint64_t>& aBlobSerial,
      60             :                                    const OriginAttributes& aAttrs,
      61             :                                    void* aControlledDocument);
      62             :   static void* GetControlledDocumentToken(nsIDocument* aDocument);
      63             : 
      64             :   RefPtr<ImageURL> mURI;
      65             :   Maybe<uint64_t> mBlobSerial;
      66             :   OriginAttributes mOriginAttributes;
      67             :   void* mControlledDocument;
      68             :   PLDHashNumber mHash;
      69             :   bool mIsChrome;
      70             : };
      71             : 
      72             : } // namespace image
      73             : } // namespace mozilla
      74             : 
      75             : #endif // mozilla_image_src_ImageCacheKey_h

Generated by: LCOV version 1.13