Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/netwerk/cache2/CacheEntry.h
Line
Count
Source (jump to first uncovered line)
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/. */
4
5
#ifndef CacheEntry__h__
6
#define CacheEntry__h__
7
8
#include "nsICacheEntry.h"
9
#include "CacheFile.h"
10
11
#include "nsIRunnable.h"
12
#include "nsIOutputStream.h"
13
#include "nsICacheEntryOpenCallback.h"
14
#include "nsICacheEntryDoomCallback.h"
15
16
#include "nsCOMPtr.h"
17
#include "nsRefPtrHashtable.h"
18
#include "nsDataHashtable.h"
19
#include "nsHashKeys.h"
20
#include "nsString.h"
21
#include "nsCOMArray.h"
22
#include "nsThreadUtils.h"
23
#include "mozilla/Attributes.h"
24
#include "mozilla/Mutex.h"
25
#include "mozilla/TimeStamp.h"
26
27
static inline uint32_t
28
PRTimeToSeconds(PRTime t_usec)
29
0
{
30
0
  PRTime usec_per_sec = PR_USEC_PER_SEC;
31
0
  return uint32_t(t_usec /= usec_per_sec);
32
0
}
Unexecuted instantiation: AppCacheStorage.cpp:PRTimeToSeconds(long)
Unexecuted instantiation: CacheStorage.cpp:PRTimeToSeconds(long)
Unexecuted instantiation: Unified_cpp_netwerk_cache20.cpp:PRTimeToSeconds(long)
Unexecuted instantiation: Unified_cpp_netwerk_cache21.cpp:PRTimeToSeconds(long)
33
34
0
#define NowInSeconds() PRTimeToSeconds(PR_Now())
35
36
class nsIOutputStream;
37
class nsIURI;
38
class nsIThread;
39
40
namespace mozilla {
41
namespace net {
42
43
class CacheStorageService;
44
class CacheStorage;
45
class CacheOutputCloseListener;
46
class CacheEntryHandle;
47
48
class CacheEntry final : public nsIRunnable
49
                       , public CacheFileListener
50
{
51
public:
52
  NS_DECL_THREADSAFE_ISUPPORTS
53
  NS_DECL_NSIRUNNABLE
54
55
  static uint64_t GetNextId();
56
57
  CacheEntry(const nsACString& aStorageID, const nsACString& aURI, const nsACString& aEnhanceID,
58
             bool aUseDisk, bool aSkipSizeCheck, bool aPin);
59
60
  void AsyncOpen(nsICacheEntryOpenCallback* aCallback, uint32_t aFlags);
61
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();
66
67
  // Forwarded to from CacheEntryHandle : nsICacheEntry
68
  nsresult GetKey(nsACString & aKey);
69
  nsresult GetCacheEntryId(uint64_t *aCacheEntryId);
70
  nsresult GetPersistent(bool *aPersistent);
71
  nsresult GetFetchCount(int32_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 *aOnStartTime);
77
  nsresult GetOnStopTime(uint64_t *aOnStopTime);
78
  nsresult SetNetworkTimes(uint64_t onStartTime, uint64_t onStopTime);
79
  nsresult ForceValidFor(uint32_t aSecondsToTheFuture);
80
  nsresult GetIsForcedValid(bool *aIsForcedValid);
81
  nsresult OpenInputStream(int64_t offset, nsIInputStream * *_retval);
82
  nsresult OpenOutputStream(int64_t offset, int64_t predictedSize, nsIOutputStream * *_retval);
83
  nsresult GetSecurityInfo(nsISupports * *aSecurityInfo);
84
  nsresult SetSecurityInfo(nsISupports *aSecurityInfo);
85
  nsresult GetStorageDataSize(uint32_t *aStorageDataSize);
86
  nsresult AsyncDoom(nsICacheEntryDoomCallback *listener);
87
  nsresult GetMetaDataElement(const char * key, char * *_retval);
88
  nsresult SetMetaDataElement(const char * key, const char * value);
89
  nsresult VisitMetaData(nsICacheEntryMetaDataVisitor *visitor);
90
  nsresult MetaDataReady(void);
91
  nsresult SetValid(void);
92
  nsresult GetDiskStorageSizeInKB(uint32_t *aDiskStorageSizeInKB);
93
  nsresult Recreate(bool aMemoryOnly, nsICacheEntry * *_retval);
94
  nsresult GetDataSize(int64_t *aDataSize);
95
  nsresult GetAltDataSize(int64_t *aAltDataSize);
96
  nsresult OpenAlternativeOutputStream(const nsACString & type, int64_t predictedSize, nsIOutputStream * *_retval);
97
  nsresult OpenAlternativeInputStream(const nsACString & type, nsIInputStream * *_retval);
98
  nsresult GetLoadContextInfo(nsILoadContextInfo * *aLoadContextInfo);
99
  nsresult Close(void);
100
  nsresult MarkValid(void);
101
  nsresult MaybeMarkValid(void);
102
  nsresult HasWriteAccess(bool aWriteAllowed, bool *_retval);
103
104
public:
105
  uint32_t GetMetadataMemoryConsumption();
106
0
  nsCString const &GetStorageID() const { return mStorageID; }
107
0
  nsCString const &GetEnhanceID() const { return mEnhanceID; }
108
0
  nsCString const &GetURI() const { return mURI; }
109
  // Accessible at any time
110
0
  bool IsUsingDisk() const { return mUseDisk; }
111
  bool IsReferenced() const;
112
  bool IsFileDoomed();
113
0
  bool IsDoomed() const { return mIsDoomed; }
114
0
  bool IsPinned() const { return mPinned; }
115
116
  // Methods for entry management (eviction from memory),
117
  // called only on the management thread.
118
119
  // TODO make these inline
120
  double GetFrecency() const;
121
  uint32_t GetExpirationTime() const;
122
0
  uint32_t UseCount() const { return mUseCount; }
123
124
  bool IsRegistered() const;
125
  bool CanRegister() const;
126
  void SetRegistered(bool aRegistered);
127
128
0
  TimeStamp const& LoadStart() const { return mLoadStart; }
129
130
  enum EPurge {
131
    PURGE_DATA_ONLY_DISK_BACKED,
132
    PURGE_WHOLE_ONLY_DISK_BACKED,
133
    PURGE_WHOLE,
134
  };
135
136
  bool DeferOrBypassRemovalOnPinStatus(bool aPinned);
137
  bool Purge(uint32_t aWhat);
138
  void PurgeAndDoom();
139
  void DoomAlreadyRemoved();
140
141
  nsresult HashingKeyWithStorage(nsACString &aResult) const;
142
  nsresult HashingKey(nsACString &aResult) const;
143
144
  static nsresult HashingKey(const nsACString& aStorageID,
145
                             const nsACString& aEnhanceID,
146
                             nsIURI* aURI,
147
                             nsACString &aResult);
148
149
  static nsresult HashingKey(const nsACString& aStorageID,
150
                             const nsACString& aEnhanceID,
151
                             const nsACString& aURISpec,
152
                             nsACString &aResult);
153
154
  // Accessed only on the service management thread
155
  double mFrecency;
156
  ::mozilla::Atomic<uint32_t, ::mozilla::Relaxed> mSortingExpirationTime;
157
158
  // Memory reporting
159
  size_t SizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const;
160
  size_t SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const;
161
162
private:
163
  virtual ~CacheEntry();
164
165
  // CacheFileListener
166
  NS_IMETHOD OnFileReady(nsresult aResult, bool aIsNew) override;
167
  NS_IMETHOD OnFileDoomed(nsresult aResult) override;
168
169
  // Keep the service alive during life-time of an entry
170
  RefPtr<CacheStorageService> mService;
171
172
  // We must monitor when a cache entry whose consumer is responsible
173
  // for writing it the first time gets released.  We must then invoke
174
  // waiting callbacks to not break the chain.
175
  class Callback
176
  {
177
  public:
178
    Callback(CacheEntry* aEntry,
179
             nsICacheEntryOpenCallback *aCallback,
180
             bool aReadOnly, bool aCheckOnAnyThread, bool aSecret);
181
    // Special constructor for Callback objects added to the chain
182
    // just to ensure proper defer dooming (recreation) of this entry.
183
    Callback(CacheEntry* aEntry, bool aDoomWhenFoundInPinStatus);
184
    Callback(Callback const &aThat);
185
    ~Callback();
186
187
    // Called when this callback record changes it's owning entry,
188
    // mainly during recreation.
189
    void ExchangeEntry(CacheEntry* aEntry);
190
191
    // Returns true when an entry is about to be "defer" doomed and this is
192
    // a "defer" callback.
193
    bool DeferDoom(bool *aDoom) const;
194
195
    // We are raising reference count here to take into account the pending
196
    // callback (that virtually holds a ref to this entry before it gets
197
    // it's pointer).
198
    RefPtr<CacheEntry> mEntry;
199
    nsCOMPtr<nsICacheEntryOpenCallback> mCallback;
200
    nsCOMPtr<nsIEventTarget> mTarget;
201
    bool mReadOnly : 1;
202
    bool mRevalidating : 1;
203
    bool mCheckOnAnyThread : 1;
204
    bool mRecheckAfterWrite : 1;
205
    bool mNotWanted : 1;
206
    bool mSecret : 1;
207
208
    // These are set only for the defer-doomer Callback instance inserted
209
    // to the callback chain.  When any of these is set and also any of
210
    // the corressponding flags on the entry is set, this callback will
211
    // indicate (via DeferDoom()) the entry have to be recreated/doomed.
212
    bool mDoomWhenFoundPinned : 1;
213
    bool mDoomWhenFoundNonPinned : 1;
214
215
    nsresult OnCheckThread(bool *aOnCheckThread) const;
216
    nsresult OnAvailThread(bool *aOnAvailThread) const;
217
  };
218
219
  // Since OnCacheEntryAvailable must be invoked on the main thread
220
  // we need a runnable for it...
221
  class AvailableCallbackRunnable : public Runnable
222
  {
223
  public:
224
    AvailableCallbackRunnable(CacheEntry* aEntry,
225
                              Callback const &aCallback)
226
      : Runnable("CacheEntry::AvailableCallbackRunnable")
227
      , mEntry(aEntry)
228
      , mCallback(aCallback)
229
0
    {}
230
231
  private:
232
    NS_IMETHOD Run() override
233
0
    {
234
0
      mEntry->InvokeAvailableCallback(mCallback);
235
0
      return NS_OK;
236
0
    }
237
238
    RefPtr<CacheEntry> mEntry;
239
    Callback mCallback;
240
  };
241
242
  // Since OnCacheEntryDoomed must be invoked on the main thread
243
  // we need a runnable for it...
244
  class DoomCallbackRunnable : public Runnable
245
  {
246
  public:
247
    DoomCallbackRunnable(CacheEntry* aEntry, nsresult aRv)
248
      : Runnable("net::CacheEntry::DoomCallbackRunnable")
249
      , mEntry(aEntry)
250
      , mRv(aRv)
251
0
    {
252
0
    }
253
254
  private:
255
    NS_IMETHOD Run() override
256
0
    {
257
0
      nsCOMPtr<nsICacheEntryDoomCallback> callback;
258
0
      {
259
0
        mozilla::MutexAutoLock lock(mEntry->mLock);
260
0
        mEntry->mDoomCallback.swap(callback);
261
0
      }
262
0
263
0
      if (callback)
264
0
        callback->OnCacheEntryDoomed(mRv);
265
0
      return NS_OK;
266
0
    }
267
268
    RefPtr<CacheEntry> mEntry;
269
    nsresult mRv;
270
  };
271
272
  // Starts the load or just invokes the callback, bypasses (when required)
273
  // if busy.  Returns true on job done, false on bypass.
274
  bool Open(Callback & aCallback, bool aTruncate, bool aPriority, bool aBypassIfBusy);
275
  // Loads from disk asynchronously
276
  bool Load(bool aTruncate, bool aPriority);
277
278
  void RememberCallback(Callback & aCallback);
279
  void InvokeCallbacksLock();
280
  void InvokeCallbacks();
281
  bool InvokeCallbacks(bool aReadOnly);
282
  bool InvokeCallback(Callback & aCallback);
283
  void InvokeAvailableCallback(Callback const & aCallback);
284
  void OnFetched(Callback const & aCallback);
285
286
  nsresult OpenOutputStreamInternal(int64_t offset, nsIOutputStream * *_retval);
287
  nsresult OpenInputStreamInternal(int64_t offset, const char *aAltDataType, nsIInputStream * *_retval);
288
289
  void OnHandleClosed(CacheEntryHandle const* aHandle);
290
291
private:
292
  friend class CacheEntryHandle;
293
  // Increment/decrements the number of handles keeping this entry.
294
0
  void AddHandleRef() { ++mHandlesCount; }
295
0
  void ReleaseHandleRef() { --mHandlesCount; }
296
  // Current number of handles keeping this entry.
297
0
  uint32_t HandlesCount() const { return mHandlesCount; }
298
299
private:
300
  friend class CacheOutputCloseListener;
301
  void OnOutputClosed();
302
303
private:
304
  // Schedules a background operation on the management thread.
305
  // When executed on the management thread directly, the operation(s)
306
  // is (are) executed immediately.
307
  void BackgroundOp(uint32_t aOperation, bool aForceAsync = false);
308
  void StoreFrecency(double aFrecency);
309
310
  // Called only from DoomAlreadyRemoved()
311
  void DoomFile();
312
  // When this entry is doomed the first time, this method removes
313
  // any force-valid timing info for this entry.
314
  void RemoveForcedValidity();
315
316
  already_AddRefed<CacheEntryHandle> ReopenTruncated(bool aMemoryOnly,
317
                                                     nsICacheEntryOpenCallback* aCallback);
318
  void TransferCallbacks(CacheEntry & aFromEntry);
319
320
  mozilla::Mutex mLock;
321
322
  // Reflects the number of existing handles for this entry
323
  ::mozilla::ThreadSafeAutoRefCnt mHandlesCount;
324
325
  nsTArray<Callback> mCallbacks;
326
  nsCOMPtr<nsICacheEntryDoomCallback> mDoomCallback;
327
328
  RefPtr<CacheFile> mFile;
329
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
  ::mozilla::Atomic<nsresult, ::mozilla::ReleaseAcquire> mFileStatus;
334
  nsCString mURI;
335
  nsCString mEnhanceID;
336
  nsCString mStorageID;
337
338
  // mUseDisk, mSkipSizeCheck, mIsDoomed are plain "bool", not "bool:1",
339
  // so as to avoid bitfield races with the byte containing
340
  // mSecurityInfoLoaded et al.  See bug 1278524.
341
  //
342
  // Whether it's allowed to persist the data to disk
343
  bool const mUseDisk;
344
  // Whether it should skip max size check.
345
  bool const mSkipSizeCheck;
346
  // Set when entry is doomed with AsyncDoom() or DoomAlreadyRemoved().
347
  bool mIsDoomed;
348
349
  // Following flags are all synchronized with the cache entry lock.
350
351
  // Whether security info has already been looked up in metadata.
352
  bool mSecurityInfoLoaded : 1;
353
  // Prevents any callback invocation
354
  bool mPreventCallbacks : 1;
355
  // true: after load and an existing file, or after output stream has been opened.
356
  //       note - when opening an input stream, and this flag is false, output stream
357
  //       is open along ; this makes input streams on new entries behave correctly
358
  //       when EOF is reached (WOULD_BLOCK is returned).
359
  // false: after load and a new file, or dropped to back to false when a writer
360
  //        fails to open an output stream.
361
  bool mHasData : 1;
362
  // The indication of pinning this entry was open with
363
  bool mPinned : 1;
364
  // Whether the pinning state of the entry is known (equals to the actual state
365
  // of the cache file)
366
  bool mPinningKnown : 1;
367
368
  static char const * StateString(uint32_t aState);
369
370
  enum EState {      // transiting to:
371
    NOTLOADED = 0,   // -> LOADING | EMPTY
372
    LOADING = 1,     // -> EMPTY | READY
373
    EMPTY = 2,       // -> WRITING
374
    WRITING = 3,     // -> EMPTY | READY
375
    READY = 4,       // -> REVALIDATING
376
    REVALIDATING = 5 // -> READY
377
  };
378
379
  // State of this entry.
380
  EState mState;
381
382
  enum ERegistration {
383
    NEVERREGISTERED = 0, // The entry has never been registered
384
    REGISTERED = 1,      // The entry is stored in the memory pool index
385
    DEREGISTERED = 2     // The entry has been removed from the pool
386
  };
387
388
  // Accessed only on the management thread.  Records the state of registration
389
  // this entry in the memory pool intermediate cache.
390
  ERegistration mRegistration;
391
392
  // If a new (empty) entry is requested to open an input stream before
393
  // output stream has been opened, we must open output stream internally
394
  // on CacheFile and hold until writer releases the entry or opens the output
395
  // stream for read (then we trade him mOutputStream).
396
  nsCOMPtr<nsIOutputStream> mOutputStream;
397
398
  // Weak reference to the current writter.  There can be more then one
399
  // writer at a time and OnHandleClosed() must be processed only for the
400
  // current one.
401
  CacheEntryHandle* mWriter;
402
403
  // Background thread scheduled operation.  Set (under the lock) one
404
  // of this flags to tell the background thread what to do.
405
  class Ops {
406
  public:
407
    static uint32_t const REGISTER =          1 << 0;
408
    static uint32_t const FRECENCYUPDATE =    1 << 1;
409
    static uint32_t const CALLBACKS =         1 << 2;
410
    static uint32_t const UNREGISTER =        1 << 3;
411
412
0
    Ops() : mFlags(0) { }
413
0
    uint32_t Grab() { uint32_t flags = mFlags; mFlags = 0; return flags; }
414
0
    bool Set(uint32_t aFlags) { if (mFlags & aFlags) return false; mFlags |= aFlags; return true; }
415
  private:
416
    uint32_t mFlags;
417
  } mBackgroundOperations;
418
419
  nsCOMPtr<nsISupports> mSecurityInfo;
420
  mozilla::TimeStamp mLoadStart;
421
  uint32_t mUseCount;
422
423
  const uint64_t mCacheEntryId;
424
};
425
426
427
class CacheEntryHandle final : public nsICacheEntry
428
{
429
public:
430
  explicit CacheEntryHandle(CacheEntry* aEntry);
431
0
  CacheEntry* Entry() const { return mEntry; }
432
433
  NS_DECL_THREADSAFE_ISUPPORTS
434
435
  // Default implementation is simply safely forwarded.
436
0
  NS_IMETHOD GetKey(nsACString & aKey) override { return mEntry->GetKey(aKey); }
437
0
  NS_IMETHOD GetCacheEntryId(uint64_t *aCacheEntryId) override { return mEntry->GetCacheEntryId(aCacheEntryId); }
438
0
  NS_IMETHOD GetPersistent(bool *aPersistent) override { return mEntry->GetPersistent(aPersistent); }
439
0
  NS_IMETHOD GetFetchCount(int32_t *aFetchCount) override { return mEntry->GetFetchCount(aFetchCount); }
440
0
  NS_IMETHOD GetLastFetched(uint32_t *aLastFetched) override { return mEntry->GetLastFetched(aLastFetched); }
441
0
  NS_IMETHOD GetLastModified(uint32_t *aLastModified) override { return mEntry->GetLastModified(aLastModified); }
442
0
  NS_IMETHOD GetExpirationTime(uint32_t *aExpirationTime) override { return mEntry->GetExpirationTime(aExpirationTime); }
443
0
  NS_IMETHOD SetExpirationTime(uint32_t expirationTime) override { return mEntry->SetExpirationTime(expirationTime); }
444
0
  NS_IMETHOD GetOnStartTime(uint64_t *aOnStartTime) override { return mEntry->GetOnStartTime(aOnStartTime); }
445
0
  NS_IMETHOD GetOnStopTime(uint64_t *aOnStopTime) override { return mEntry->GetOnStopTime(aOnStopTime); }
446
0
  NS_IMETHOD SetNetworkTimes(uint64_t onStartTime, uint64_t onStopTime) override { return mEntry->SetNetworkTimes(onStartTime, onStopTime); }
447
0
  NS_IMETHOD ForceValidFor(uint32_t aSecondsToTheFuture) override { return mEntry->ForceValidFor(aSecondsToTheFuture); }
448
0
  NS_IMETHOD GetIsForcedValid(bool *aIsForcedValid) override { return mEntry->GetIsForcedValid(aIsForcedValid); }
449
0
  NS_IMETHOD OpenInputStream(int64_t offset, nsIInputStream * *_retval) override { return mEntry->OpenInputStream(offset, _retval); }
450
0
  NS_IMETHOD OpenOutputStream(int64_t offset, int64_t predictedSize, nsIOutputStream * *_retval) override { return mEntry->OpenOutputStream(offset, predictedSize, _retval); }
451
0
  NS_IMETHOD GetSecurityInfo(nsISupports * *aSecurityInfo) override { return mEntry->GetSecurityInfo(aSecurityInfo); }
452
0
  NS_IMETHOD SetSecurityInfo(nsISupports *aSecurityInfo) override { return mEntry->SetSecurityInfo(aSecurityInfo); }
453
0
  NS_IMETHOD GetStorageDataSize(uint32_t *aStorageDataSize) override { return mEntry->GetStorageDataSize(aStorageDataSize); }
454
0
  NS_IMETHOD AsyncDoom(nsICacheEntryDoomCallback *listener) override { return mEntry->AsyncDoom(listener); }
455
0
  NS_IMETHOD GetMetaDataElement(const char * key, char * *_retval) override { return mEntry->GetMetaDataElement(key, _retval); }
456
0
  NS_IMETHOD SetMetaDataElement(const char * key, const char * value) override { return mEntry->SetMetaDataElement(key, value); }
457
0
  NS_IMETHOD VisitMetaData(nsICacheEntryMetaDataVisitor *visitor) override { return mEntry->VisitMetaData(visitor); }
458
0
  NS_IMETHOD MetaDataReady(void) override { return mEntry->MetaDataReady(); }
459
0
  NS_IMETHOD SetValid(void) override { return mEntry->SetValid(); }
460
0
  NS_IMETHOD GetDiskStorageSizeInKB(uint32_t *aDiskStorageSizeInKB) override { return mEntry->GetDiskStorageSizeInKB(aDiskStorageSizeInKB); }
461
0
  NS_IMETHOD Recreate(bool aMemoryOnly, nsICacheEntry * *_retval) override { return mEntry->Recreate(aMemoryOnly, _retval); }
462
0
  NS_IMETHOD GetDataSize(int64_t *aDataSize) override { return mEntry->GetDataSize(aDataSize); }
463
0
  NS_IMETHOD GetAltDataSize(int64_t *aAltDataSize) override { return mEntry->GetAltDataSize(aAltDataSize); }
464
0
  NS_IMETHOD OpenAlternativeOutputStream(const nsACString & type, int64_t predictedSize, nsIOutputStream * *_retval) override { return mEntry->OpenAlternativeOutputStream(type, predictedSize, _retval); }
465
0
  NS_IMETHOD OpenAlternativeInputStream(const nsACString & type, nsIInputStream * *_retval) override { return mEntry->OpenAlternativeInputStream(type, _retval); }
466
0
  NS_IMETHOD GetLoadContextInfo(nsILoadContextInfo * *aLoadContextInfo) override { return mEntry->GetLoadContextInfo(aLoadContextInfo); }
467
0
  NS_IMETHOD Close(void) override { return mEntry->Close(); }
468
0
  NS_IMETHOD MarkValid(void) override { return mEntry->MarkValid(); }
469
0
  NS_IMETHOD MaybeMarkValid(void) override { return mEntry->MaybeMarkValid(); }
470
0
  NS_IMETHOD HasWriteAccess(bool aWriteAllowed, bool *_retval) override { return mEntry->HasWriteAccess(aWriteAllowed, _retval); }
471
472
  // Specific implementation:
473
  NS_IMETHOD Dismiss() override;
474
475
private:
476
  virtual ~CacheEntryHandle();
477
  RefPtr<CacheEntry> mEntry;
478
479
  // This is |false| until Dismiss() was called and prevents OnHandleClosed
480
  // being called more than once.
481
  Atomic<bool, ReleaseAcquire> mClosed;
482
};
483
484
485
class CacheOutputCloseListener final : public Runnable
486
{
487
public:
488
  void OnOutputClosed();
489
490
private:
491
  friend class CacheEntry;
492
493
0
  virtual ~CacheOutputCloseListener() = default;
494
495
  NS_DECL_NSIRUNNABLE
496
  explicit CacheOutputCloseListener(CacheEntry* aEntry);
497
498
private:
499
  RefPtr<CacheEntry> mEntry;
500
};
501
502
} // namespace net
503
} // namespace mozilla
504
505
#endif