Bug 1887677: Correctly compute inClass predicate when validating unbound private...
[gecko.git] / netwerk / cache2 / CacheEntry.h
blob0e137d306b84666b840c5c770600ab50a824b571
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 CacheEntry__h__
6 #define CacheEntry__h__
8 #include "mozilla/LinkedList.h"
9 #include "nsICacheEntry.h"
10 #include "CacheFile.h"
12 #include "nsIRunnable.h"
13 #include "nsIOutputStream.h"
14 #include "nsICacheEntryOpenCallback.h"
15 #include "nsICacheEntryDoomCallback.h"
16 #include "nsITransportSecurityInfo.h"
18 #include "nsCOMPtr.h"
19 #include "nsRefPtrHashtable.h"
20 #include "nsHashKeys.h"
21 #include "nsString.h"
22 #include "nsCOMArray.h"
23 #include "nsThreadUtils.h"
24 #include "mozilla/Attributes.h"
25 #include "mozilla/Mutex.h"
26 #include "mozilla/TimeStamp.h"
28 static inline uint32_t PRTimeToSeconds(PRTime t_usec) {
29 return uint32_t(t_usec / PR_USEC_PER_SEC);
32 #define NowInSeconds() PRTimeToSeconds(PR_Now())
34 class nsIOutputStream;
35 class nsIURI;
36 class nsIThread;
38 namespace mozilla {
39 namespace net {
41 class CacheStorageService;
42 class CacheStorage;
43 class CacheOutputCloseListener;
44 class CacheEntryHandle;
46 class CacheEntry final : public nsIRunnable,
47 public CacheFileListener,
48 // Used by CacheStorageService::MemoryPool
49 public LinkedListElement<RefPtr<CacheEntry>> {
50 public:
51 NS_DECL_THREADSAFE_ISUPPORTS
52 NS_DECL_NSIRUNNABLE
54 static uint64_t GetNextId();
56 CacheEntry(const nsACString& aStorageID, const nsACString& aURI,
57 const nsACString& aEnhanceID, bool aUseDisk, bool aSkipSizeCheck,
58 bool aPin);
60 void AsyncOpen(nsICacheEntryOpenCallback* aCallback, uint32_t aFlags);
62 CacheEntryHandle* NewHandle();
63 // For a new and recreated entry w/o a callback, we need to wrap it
64 // with a handle to detect writing consumer is gone.
65 CacheEntryHandle* NewWriteHandle();
67 // Forwarded to from CacheEntryHandle : nsICacheEntry
68 nsresult GetKey(nsACString& aKey);
69 nsresult GetCacheEntryId(uint64_t* aCacheEntryId);
70 nsresult GetPersistent(bool* aPersistToDisk);
71 nsresult GetFetchCount(uint32_t* aFetchCount);
72 nsresult GetLastFetched(uint32_t* aLastFetched);
73 nsresult GetLastModified(uint32_t* aLastModified);
74 nsresult GetExpirationTime(uint32_t* aExpirationTime);
75 nsresult SetExpirationTime(uint32_t expirationTime);
76 nsresult GetOnStartTime(uint64_t* aTime);
77 nsresult GetOnStopTime(uint64_t* aTime);
78 nsresult SetNetworkTimes(uint64_t onStartTime, uint64_t onStopTime);
79 nsresult SetContentType(uint8_t aContentType);
80 nsresult ForceValidFor(uint32_t aSecondsToTheFuture);
81 nsresult GetIsForcedValid(bool* aIsForcedValid);
82 nsresult MarkForcedValidUse();
83 nsresult OpenInputStream(int64_t offset, nsIInputStream** _retval);
84 nsresult OpenOutputStream(int64_t offset, int64_t predictedSize,
85 nsIOutputStream** _retval);
86 nsresult GetSecurityInfo(nsITransportSecurityInfo** aSecurityInfo);
87 nsresult SetSecurityInfo(nsITransportSecurityInfo* aSecurityInfo);
88 nsresult GetStorageDataSize(uint32_t* aStorageDataSize);
89 nsresult AsyncDoom(nsICacheEntryDoomCallback* aCallback);
90 nsresult GetMetaDataElement(const char* key, char** aRetval);
91 nsresult SetMetaDataElement(const char* key, const char* value);
92 nsresult VisitMetaData(nsICacheEntryMetaDataVisitor* visitor);
93 nsresult MetaDataReady(void);
94 nsresult SetValid(void);
95 nsresult GetDiskStorageSizeInKB(uint32_t* aDiskStorageSizeInKB);
96 nsresult Recreate(bool aMemoryOnly, nsICacheEntry** _retval);
97 nsresult GetDataSize(int64_t* aDataSize);
98 nsresult GetAltDataSize(int64_t* aDataSize);
99 nsresult GetAltDataType(nsACString& aAltDataType);
100 nsresult OpenAlternativeOutputStream(const nsACString& type,
101 int64_t predictedSize,
102 nsIAsyncOutputStream** _retval);
103 nsresult OpenAlternativeInputStream(const nsACString& type,
104 nsIInputStream** _retval);
105 nsresult GetLoadContextInfo(nsILoadContextInfo** aInfo);
106 nsresult Close(void);
107 nsresult MarkValid(void);
108 nsresult MaybeMarkValid(void);
109 nsresult HasWriteAccess(bool aWriteAllowed, bool* aWriteAccess);
111 public:
112 uint32_t GetMetadataMemoryConsumption();
113 nsCString const& GetStorageID() const { return mStorageID; }
114 nsCString const& GetEnhanceID() const { return mEnhanceID; }
115 nsCString const& GetURI() const { return mURI; }
116 // Accessible at any time
117 bool IsUsingDisk() const { return mUseDisk; }
118 bool IsReferenced() const MOZ_NO_THREAD_SAFETY_ANALYSIS;
119 bool IsFileDoomed();
120 bool IsDoomed() const { return mIsDoomed; }
121 bool IsPinned() const { return mPinned; }
123 // Methods for entry management (eviction from memory),
124 // called only on the management thread.
126 // TODO make these inline
127 double GetFrecency() const;
128 uint32_t GetExpirationTime() const;
129 uint32_t UseCount() const { return mUseCount; }
131 bool IsRegistered() const;
132 bool CanRegister() const;
133 void SetRegistered(bool aRegistered);
135 TimeStamp const& LoadStart() const { return mLoadStart; }
137 enum EPurge {
138 PURGE_DATA_ONLY_DISK_BACKED,
139 PURGE_WHOLE_ONLY_DISK_BACKED,
140 PURGE_WHOLE,
143 bool DeferOrBypassRemovalOnPinStatus(bool aPinned);
144 bool Purge(uint32_t aWhat);
145 void PurgeAndDoom();
146 void DoomAlreadyRemoved();
148 nsresult HashingKeyWithStorage(nsACString& aResult) const;
149 nsresult HashingKey(nsACString& aResult) const;
151 static nsresult HashingKey(const nsACString& aStorageID,
152 const nsACString& aEnhanceID, nsIURI* aURI,
153 nsACString& aResult);
155 static nsresult HashingKey(const nsACString& aStorageID,
156 const nsACString& aEnhanceID,
157 const nsACString& aURISpec, nsACString& aResult);
159 // Accessed only on the service management thread
160 double mFrecency{0};
161 ::mozilla::Atomic<uint32_t, ::mozilla::Relaxed> mSortingExpirationTime{
162 uint32_t(-1)};
164 // Memory reporting
165 size_t SizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf);
166 size_t SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf);
168 private:
169 virtual ~CacheEntry();
171 // CacheFileListener
172 NS_IMETHOD OnFileReady(nsresult aResult, bool aIsNew) override;
173 NS_IMETHOD OnFileDoomed(nsresult aResult) override;
175 // Keep the service alive during life-time of an entry
176 RefPtr<CacheStorageService> mService;
178 // We must monitor when a cache entry whose consumer is responsible
179 // for writing it the first time gets released. We must then invoke
180 // waiting callbacks to not break the chain.
181 class Callback {
182 public:
183 Callback(CacheEntry* aEntry, nsICacheEntryOpenCallback* aCallback,
184 bool aReadOnly, bool aCheckOnAnyThread, bool aSecret);
185 // Special constructor for Callback objects added to the chain
186 // just to ensure proper defer dooming (recreation) of this entry.
187 Callback(CacheEntry* aEntry, bool aDoomWhenFoundInPinStatus);
188 Callback(Callback const& aThat);
189 ~Callback();
191 // Called when this callback record changes it's owning entry,
192 // mainly during recreation.
193 void ExchangeEntry(CacheEntry* aEntry) MOZ_REQUIRES(aEntry->mLock);
195 // Returns true when an entry is about to be "defer" doomed and this is
196 // a "defer" callback. The caller must hold a lock (this entry is in the
197 // caller's mCallback array)
198 bool DeferDoom(bool* aDoom) const;
200 // We are raising reference count here to take into account the pending
201 // callback (that virtually holds a ref to this entry before it gets
202 // it's pointer).
203 RefPtr<CacheEntry> mEntry;
204 nsCOMPtr<nsICacheEntryOpenCallback> mCallback;
205 nsCOMPtr<nsIEventTarget> mTarget;
206 bool mReadOnly : 1;
207 bool mRevalidating : 1;
208 bool mCheckOnAnyThread : 1;
209 bool mRecheckAfterWrite : 1;
210 bool mNotWanted : 1;
211 bool mSecret : 1;
213 // These are set only for the defer-doomer Callback instance inserted
214 // to the callback chain. When any of these is set and also any of
215 // the corressponding flags on the entry is set, this callback will
216 // indicate (via DeferDoom()) the entry have to be recreated/doomed.
217 bool mDoomWhenFoundPinned : 1;
218 bool mDoomWhenFoundNonPinned : 1;
220 nsresult OnCheckThread(bool* aOnCheckThread) const;
221 nsresult OnAvailThread(bool* aOnAvailThread) const;
224 // Since OnCacheEntryAvailable must be invoked on the main thread
225 // we need a runnable for it...
226 class AvailableCallbackRunnable : public Runnable {
227 public:
228 AvailableCallbackRunnable(CacheEntry* aEntry, Callback const& aCallback)
229 : Runnable("CacheEntry::AvailableCallbackRunnable"),
230 mEntry(aEntry),
231 mCallback(aCallback) {}
233 private:
234 NS_IMETHOD Run() override {
235 mEntry->InvokeAvailableCallback(mCallback);
236 return NS_OK;
239 RefPtr<CacheEntry> mEntry;
240 Callback mCallback;
243 // Since OnCacheEntryDoomed must be invoked on the main thread
244 // we need a runnable for it...
245 class DoomCallbackRunnable : public Runnable {
246 public:
247 DoomCallbackRunnable(CacheEntry* aEntry, nsresult aRv)
248 : Runnable("net::CacheEntry::DoomCallbackRunnable"),
249 mEntry(aEntry),
250 mRv(aRv) {}
252 private:
253 NS_IMETHOD Run() override {
254 nsCOMPtr<nsICacheEntryDoomCallback> callback;
256 mozilla::MutexAutoLock lock(mEntry->mLock);
257 mEntry->mDoomCallback.swap(callback);
260 if (callback) callback->OnCacheEntryDoomed(mRv);
261 return NS_OK;
264 RefPtr<CacheEntry> mEntry;
265 nsresult mRv;
268 // Starts the load or just invokes the callback, bypasses (when required)
269 // if busy. Returns true on job done, false on bypass.
270 bool Open(Callback& aCallback, bool aTruncate, bool aPriority,
271 bool aBypassIfBusy);
272 // Loads from disk asynchronously
273 bool Load(bool aTruncate, bool aPriority);
275 void RememberCallback(Callback& aCallback) MOZ_REQUIRES(mLock);
276 void InvokeCallbacksLock();
277 void InvokeCallbacks();
278 bool InvokeCallbacks(bool aReadOnly);
279 bool InvokeCallback(Callback& aCallback);
280 void InvokeAvailableCallback(Callback const& aCallback);
281 void OnFetched(Callback const& aCallback);
283 nsresult OpenOutputStreamInternal(int64_t offset, nsIOutputStream** _retval);
284 nsresult OpenInputStreamInternal(int64_t offset, const char* aAltDataType,
285 nsIInputStream** _retval);
287 void OnHandleClosed(CacheEntryHandle const* aHandle);
289 private:
290 friend class CacheEntryHandle;
291 // Increment/decrements the number of handles keeping this entry.
292 void AddHandleRef() MOZ_REQUIRES(mLock) { ++mHandlesCount; }
293 void ReleaseHandleRef() MOZ_REQUIRES(mLock) { --mHandlesCount; }
294 // Current number of handles keeping this entry.
295 uint32_t HandlesCount() const MOZ_REQUIRES(mLock) { return mHandlesCount; }
297 private:
298 friend class CacheOutputCloseListener;
299 void OnOutputClosed();
301 private:
302 // Schedules a background operation on the management thread.
303 // When executed on the management thread directly, the operation(s)
304 // is (are) executed immediately.
305 void BackgroundOp(uint32_t aOperation, bool aForceAsync = false);
306 void StoreFrecency(double aFrecency);
308 // Called only from DoomAlreadyRemoved()
309 void DoomFile() MOZ_REQUIRES(mLock);
310 // When this entry is doomed the first time, this method removes
311 // any force-valid timing info for this entry.
312 void RemoveForcedValidity();
314 already_AddRefed<CacheEntryHandle> ReopenTruncated(
315 bool aMemoryOnly, nsICacheEntryOpenCallback* aCallback);
316 void TransferCallbacks(CacheEntry& aFromEntry);
318 mozilla::Mutex mLock{"CacheEntry"};
320 // Reflects the number of existing handles for this entry
321 ::mozilla::ThreadSafeAutoRefCnt mHandlesCount MOZ_GUARDED_BY(mLock);
323 nsTArray<Callback> mCallbacks MOZ_GUARDED_BY(mLock);
324 nsCOMPtr<nsICacheEntryDoomCallback> mDoomCallback;
326 // Set in CacheEntry::Load(), only - shouldn't need to be under lock
327 // XXX FIX? is this correct?
328 RefPtr<CacheFile> mFile;
330 // Using ReleaseAcquire since we only control access to mFile with this.
331 // When mFileStatus is read and found success it is ensured there is mFile and
332 // that it is after a successful call to Init().
333 Atomic<nsresult, ReleaseAcquire> mFileStatus{NS_ERROR_NOT_INITIALIZED};
334 // Set in constructor
335 nsCString const mURI;
336 nsCString const mEnhanceID;
337 nsCString const mStorageID;
339 // mUseDisk, mSkipSizeCheck, mIsDoomed are plain "bool", not "bool:1",
340 // so as to avoid bitfield races with the byte containing
341 // mSecurityInfoLoaded et al. See bug 1278524.
343 // Whether it's allowed to persist the data to disk
344 bool const mUseDisk;
345 // Whether it should skip max size check.
346 bool const mSkipSizeCheck;
347 // Set when entry is doomed with AsyncDoom() or DoomAlreadyRemoved().
348 Atomic<bool, Relaxed> mIsDoomed{false};
349 // The indication of pinning this entry was open with
350 Atomic<bool, Relaxed> mPinned;
352 // Following flags are all synchronized with the cache entry lock.
354 // Whether security info has already been looked up in metadata.
355 bool mSecurityInfoLoaded : 1 MOZ_GUARDED_BY(mLock);
356 // Prevents any callback invocation
357 bool mPreventCallbacks : 1 MOZ_GUARDED_BY(mLock);
358 // true: after load and an existing file, or after output stream has been
359 // opened.
360 // note - when opening an input stream, and this flag is false, output
361 // stream is open along ; this makes input streams on new entries
362 // behave correctly when EOF is reached (WOULD_BLOCK is returned).
363 // false: after load and a new file, or dropped to back to false when a
364 // writer fails to open an output stream.
365 bool mHasData : 1 MOZ_GUARDED_BY(mLock);
366 // Whether the pinning state of the entry is known (equals to the actual state
367 // of the cache file)
368 bool mPinningKnown : 1 MOZ_GUARDED_BY(mLock);
370 static char const* StateString(uint32_t aState);
372 enum EState { // transiting to:
373 NOTLOADED = 0, // -> LOADING | EMPTY
374 LOADING = 1, // -> EMPTY | READY
375 EMPTY = 2, // -> WRITING
376 WRITING = 3, // -> EMPTY | READY
377 READY = 4, // -> REVALIDATING
378 REVALIDATING = 5 // -> READY
381 // State of this entry.
382 EState mState MOZ_GUARDED_BY(mLock){NOTLOADED};
384 enum ERegistration {
385 NEVERREGISTERED = 0, // The entry has never been registered
386 REGISTERED = 1, // The entry is stored in the memory pool index
387 DEREGISTERED = 2 // The entry has been removed from the pool
390 // Accessed only on the management thread. Records the state of registration
391 // this entry in the memory pool intermediate cache.
392 ERegistration mRegistration{NEVERREGISTERED};
394 // If a new (empty) entry is requested to open an input stream before
395 // output stream has been opened, we must open output stream internally
396 // on CacheFile and hold until writer releases the entry or opens the output
397 // stream for read (then we trade him mOutputStream).
398 nsCOMPtr<nsIOutputStream> mOutputStream MOZ_GUARDED_BY(mLock);
400 // Weak reference to the current writter. There can be more then one
401 // writer at a time and OnHandleClosed() must be processed only for the
402 // current one.
403 CacheEntryHandle* mWriter MOZ_GUARDED_BY(mLock){nullptr};
405 // Background thread scheduled operation. Set (under the lock) one
406 // of this flags to tell the background thread what to do.
407 class Ops {
408 public:
409 static uint32_t const REGISTER = 1 << 0;
410 static uint32_t const FRECENCYUPDATE = 1 << 1;
411 static uint32_t const CALLBACKS = 1 << 2;
412 static uint32_t const UNREGISTER = 1 << 3;
414 Ops() = default;
415 uint32_t Grab() {
416 uint32_t flags = mFlags;
417 mFlags = 0;
418 return flags;
420 bool Set(uint32_t aFlags) {
421 if (mFlags & aFlags) return false;
422 mFlags |= aFlags;
423 return true;
426 private:
427 uint32_t mFlags{0};
428 } mBackgroundOperations;
430 nsCOMPtr<nsITransportSecurityInfo> mSecurityInfo;
431 mozilla::TimeStamp mLoadStart;
432 uint32_t mUseCount{0};
434 const uint64_t mCacheEntryId;
437 class CacheEntryHandle final : public nsICacheEntry {
438 public:
439 explicit CacheEntryHandle(CacheEntry* aEntry);
440 CacheEntry* Entry() const { return mEntry; }
442 NS_DECL_THREADSAFE_ISUPPORTS
444 // Default implementation is simply safely forwarded.
445 NS_IMETHOD GetKey(nsACString& aKey) override { return mEntry->GetKey(aKey); }
446 NS_IMETHOD GetCacheEntryId(uint64_t* aCacheEntryId) override {
447 return mEntry->GetCacheEntryId(aCacheEntryId);
449 NS_IMETHOD GetPersistent(bool* aPersistent) override {
450 return mEntry->GetPersistent(aPersistent);
452 NS_IMETHOD GetFetchCount(uint32_t* aFetchCount) override {
453 return mEntry->GetFetchCount(aFetchCount);
455 NS_IMETHOD GetLastFetched(uint32_t* aLastFetched) override {
456 return mEntry->GetLastFetched(aLastFetched);
458 NS_IMETHOD GetLastModified(uint32_t* aLastModified) override {
459 return mEntry->GetLastModified(aLastModified);
461 NS_IMETHOD GetExpirationTime(uint32_t* aExpirationTime) override {
462 return mEntry->GetExpirationTime(aExpirationTime);
464 NS_IMETHOD SetExpirationTime(uint32_t expirationTime) override {
465 return mEntry->SetExpirationTime(expirationTime);
467 NS_IMETHOD GetOnStartTime(uint64_t* aOnStartTime) override {
468 return mEntry->GetOnStartTime(aOnStartTime);
470 NS_IMETHOD GetOnStopTime(uint64_t* aOnStopTime) override {
471 return mEntry->GetOnStopTime(aOnStopTime);
473 NS_IMETHOD SetNetworkTimes(uint64_t onStartTime,
474 uint64_t onStopTime) override {
475 return mEntry->SetNetworkTimes(onStartTime, onStopTime);
477 NS_IMETHOD SetContentType(uint8_t contentType) override {
478 return mEntry->SetContentType(contentType);
480 NS_IMETHOD ForceValidFor(uint32_t aSecondsToTheFuture) override {
481 return mEntry->ForceValidFor(aSecondsToTheFuture);
483 NS_IMETHOD GetIsForcedValid(bool* aIsForcedValid) override {
484 return mEntry->GetIsForcedValid(aIsForcedValid);
486 NS_IMETHOD MarkForcedValidUse() override {
487 return mEntry->MarkForcedValidUse();
489 NS_IMETHOD OpenInputStream(int64_t offset,
490 nsIInputStream** _retval) override {
491 return mEntry->OpenInputStream(offset, _retval);
493 NS_IMETHOD OpenOutputStream(int64_t offset, int64_t predictedSize,
494 nsIOutputStream** _retval) override {
495 return mEntry->OpenOutputStream(offset, predictedSize, _retval);
497 NS_IMETHOD GetSecurityInfo(
498 nsITransportSecurityInfo** aSecurityInfo) override {
499 return mEntry->GetSecurityInfo(aSecurityInfo);
501 NS_IMETHOD SetSecurityInfo(nsITransportSecurityInfo* aSecurityInfo) override {
502 return mEntry->SetSecurityInfo(aSecurityInfo);
504 NS_IMETHOD GetStorageDataSize(uint32_t* aStorageDataSize) override {
505 return mEntry->GetStorageDataSize(aStorageDataSize);
507 NS_IMETHOD AsyncDoom(nsICacheEntryDoomCallback* listener) override {
508 return mEntry->AsyncDoom(listener);
510 NS_IMETHOD GetMetaDataElement(const char* key, char** _retval) override {
511 return mEntry->GetMetaDataElement(key, _retval);
513 NS_IMETHOD SetMetaDataElement(const char* key, const char* value) override {
514 return mEntry->SetMetaDataElement(key, value);
516 NS_IMETHOD VisitMetaData(nsICacheEntryMetaDataVisitor* visitor) override {
517 return mEntry->VisitMetaData(visitor);
519 NS_IMETHOD MetaDataReady(void) override { return mEntry->MetaDataReady(); }
520 NS_IMETHOD SetValid(void) override { return mEntry->SetValid(); }
521 NS_IMETHOD GetDiskStorageSizeInKB(uint32_t* aDiskStorageSizeInKB) override {
522 return mEntry->GetDiskStorageSizeInKB(aDiskStorageSizeInKB);
524 NS_IMETHOD Recreate(bool aMemoryOnly, nsICacheEntry** _retval) override {
525 return mEntry->Recreate(aMemoryOnly, _retval);
527 NS_IMETHOD GetDataSize(int64_t* aDataSize) override {
528 return mEntry->GetDataSize(aDataSize);
530 NS_IMETHOD GetAltDataSize(int64_t* aAltDataSize) override {
531 return mEntry->GetAltDataSize(aAltDataSize);
533 NS_IMETHOD GetAltDataType(nsACString& aType) override {
534 return mEntry->GetAltDataType(aType);
536 NS_IMETHOD OpenAlternativeOutputStream(
537 const nsACString& type, int64_t predictedSize,
538 nsIAsyncOutputStream** _retval) override {
539 return mEntry->OpenAlternativeOutputStream(type, predictedSize, _retval);
541 NS_IMETHOD OpenAlternativeInputStream(const nsACString& type,
542 nsIInputStream** _retval) override {
543 return mEntry->OpenAlternativeInputStream(type, _retval);
545 NS_IMETHOD GetLoadContextInfo(
546 nsILoadContextInfo** aLoadContextInfo) override {
547 return mEntry->GetLoadContextInfo(aLoadContextInfo);
549 NS_IMETHOD Close(void) override { return mEntry->Close(); }
550 NS_IMETHOD MarkValid(void) override { return mEntry->MarkValid(); }
551 NS_IMETHOD MaybeMarkValid(void) override { return mEntry->MaybeMarkValid(); }
552 NS_IMETHOD HasWriteAccess(bool aWriteAllowed, bool* _retval) override {
553 return mEntry->HasWriteAccess(aWriteAllowed, _retval);
556 // Specific implementation:
557 NS_IMETHOD Dismiss() override;
559 private:
560 virtual ~CacheEntryHandle();
561 RefPtr<CacheEntry> mEntry;
563 // This is |false| until Dismiss() was called and prevents OnHandleClosed
564 // being called more than once.
565 Atomic<bool, ReleaseAcquire> mClosed{false};
568 class CacheOutputCloseListener final : public Runnable {
569 public:
570 void OnOutputClosed();
572 private:
573 friend class CacheEntry;
575 virtual ~CacheOutputCloseListener() = default;
577 NS_DECL_NSIRUNNABLE
578 explicit CacheOutputCloseListener(CacheEntry* aEntry);
580 private:
581 RefPtr<CacheEntry> mEntry;
584 } // namespace net
585 } // namespace mozilla
587 #endif