1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #ifndef CacheFileUtils__h__
6 #define CacheFileUtils__h__
13 class nsILoadContextInfo
;
18 namespace CacheFileUtils
{
20 already_AddRefed
<nsILoadContextInfo
>
21 ParseKey(const nsCSubstring
&aKey
,
22 nsCSubstring
*aIdEnhance
= nullptr,
23 nsCSubstring
*aURISpec
= nullptr);
26 AppendKeyPrefix(nsILoadContextInfo
*aInfo
, nsACString
&_retval
);
29 AppendTagWithValue(nsACString
& aTarget
, char const aTag
, nsCSubstring
const & aValue
);
32 KeyMatchesLoadContextInfo(const nsACString
&aKey
,
33 nsILoadContextInfo
*aInfo
,
38 ValidityPair(uint32_t aOffset
, uint32_t aLen
);
40 ValidityPair
& operator=(const ValidityPair
& aOther
);
42 // Returns true when two pairs can be merged, i.e. they do overlap or the one
43 // ends exactly where the other begins.
44 bool CanBeMerged(const ValidityPair
& aOther
) const;
46 // Returns true when aOffset is placed anywhere in the validity interval or
47 // exactly after its end.
48 bool IsInOrFollows(uint32_t aOffset
) const;
50 // Returns true when this pair has lower offset than the other pair. In case
51 // both pairs have the same offset it returns true when this pair has a
53 bool LessThan(const ValidityPair
& aOther
) const;
55 // Merges two pair into one.
56 void Merge(const ValidityPair
& aOther
);
58 uint32_t Offset() const { return mOffset
; }
59 uint32_t Len() const { return mLen
; }
68 // Prints pairs in the map into log.
71 // Returns number of pairs in the map.
72 uint32_t Length() const;
74 // Adds a new pair to the map. It keeps the pairs ordered and merges pairs
76 void AddPair(uint32_t aOffset
, uint32_t aLen
);
78 // Removes all pairs from the map.
81 size_t SizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf
) const;
83 ValidityPair
& operator[](uint32_t aIdx
);
86 nsTArray
<ValidityPair
> mMap
;