Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/cache/QuotaClient.cpp
Line
Count
Source (jump to first uncovered line)
1
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
3
/* This Source Code Form is subject to the terms of the Mozilla Public
4
 * License, v. 2.0. If a copy of the MPL was not distributed with this
5
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7
#include "mozilla/dom/cache/QuotaClient.h"
8
9
#include "DBAction.h"
10
#include "FileUtils.h"
11
#include "mozilla/dom/cache/Manager.h"
12
#include "mozilla/dom/quota/QuotaManager.h"
13
#include "mozilla/dom/quota/UsageInfo.h"
14
#include "mozilla/ipc/BackgroundParent.h"
15
#include "mozilla/Unused.h"
16
#include "nsIFile.h"
17
#include "nsISimpleEnumerator.h"
18
#include "nsThreadUtils.h"
19
20
namespace {
21
22
using mozilla::Atomic;
23
using mozilla::dom::ContentParentId;
24
using mozilla::dom::cache::DirPaddingFile;
25
using mozilla::dom::cache::Manager;
26
using mozilla::dom::cache::QuotaInfo;
27
using mozilla::dom::quota::AssertIsOnIOThread;
28
using mozilla::dom::quota::Client;
29
using mozilla::dom::quota::PersistenceType;
30
using mozilla::dom::quota::QuotaManager;
31
using mozilla::dom::quota::UsageInfo;
32
using mozilla::ipc::AssertIsOnBackgroundThread;
33
using mozilla::MutexAutoLock;
34
using mozilla::Unused;
35
36
static nsresult
37
GetBodyUsage(nsIFile* aDir, const Atomic<bool>& aCanceled,
38
             UsageInfo* aUsageInfo)
39
0
{
40
0
  AssertIsOnIOThread();
41
0
42
0
  nsCOMPtr<nsIDirectoryEnumerator> entries;
43
0
  nsresult rv = aDir->GetDirectoryEntries(getter_AddRefs(entries));
44
0
  if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
45
0
46
0
  nsCOMPtr<nsIFile> file;
47
0
  while (NS_SUCCEEDED(rv = entries->GetNextFile(getter_AddRefs(file))) &&
48
0
         file && !aCanceled) {
49
0
    bool isDir;
50
0
    rv = file->IsDirectory(&isDir);
51
0
    if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
52
0
53
0
    if (isDir) {
54
0
      rv = GetBodyUsage(file, aCanceled, aUsageInfo);
55
0
      if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
56
0
      continue;
57
0
    }
58
0
59
0
    int64_t fileSize;
60
0
    rv = file->GetFileSize(&fileSize);
61
0
    if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
62
0
    MOZ_DIAGNOSTIC_ASSERT(fileSize >= 0);
63
0
64
0
    aUsageInfo->AppendToFileUsage(fileSize);
65
0
  }
66
0
67
0
  return NS_OK;
68
0
}
69
70
static nsresult
71
LockedGetPaddingSizeFromDB(nsIFile* aDir, const nsACString& aGroup,
72
                           const nsACString& aOrigin, int64_t* aPaddingSizeOut)
73
0
{
74
0
  MOZ_DIAGNOSTIC_ASSERT(aDir);
75
0
  MOZ_DIAGNOSTIC_ASSERT(aPaddingSizeOut);
76
0
77
0
  *aPaddingSizeOut = 0;
78
0
79
0
  nsCOMPtr<mozIStorageConnection> conn;
80
0
  QuotaInfo quotaInfo;
81
0
  quotaInfo.mGroup = aGroup;
82
0
  quotaInfo.mOrigin = aOrigin;
83
0
  nsresult rv = mozilla::dom::cache::
84
0
                OpenDBConnection(quotaInfo, aDir, getter_AddRefs(conn));
85
0
  if (rv == NS_ERROR_FILE_NOT_FOUND ||
86
0
      rv == NS_ERROR_FILE_TARGET_DOES_NOT_EXIST) {
87
0
    // Return NS_OK with size = 0 if both the db and padding file don't exist.
88
0
    // There is no other way to get the overall padding size of an origin.
89
0
    return NS_OK;
90
0
  }
91
0
  if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
92
0
93
0
  int64_t paddingSize = 0;
94
0
  rv = mozilla::dom::cache::
95
0
       LockedDirectoryPaddingRestore(aDir, conn, /* aMustRestore */ false,
96
0
                                     &paddingSize);
97
0
  if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
98
0
99
0
  *aPaddingSizeOut = paddingSize;
100
0
101
0
  return rv;
102
0
}
103
104
class CacheQuotaClient final : public Client
105
{
106
  static CacheQuotaClient* sInstance;
107
108
public:
109
  CacheQuotaClient()
110
  : mDirPaddingFileMutex("DOMCacheQuotaClient.mDirPaddingFileMutex")
111
0
  {
112
0
    AssertIsOnBackgroundThread();
113
0
    MOZ_DIAGNOSTIC_ASSERT(!sInstance);
114
0
    sInstance = this;
115
0
  }
116
117
  static CacheQuotaClient*
118
  Get()
119
0
  {
120
0
    MOZ_DIAGNOSTIC_ASSERT(sInstance);
121
0
    return sInstance;
122
0
  }
123
124
  virtual Type
125
  GetType() override
126
0
  {
127
0
    return DOMCACHE;
128
0
  }
129
130
  virtual nsresult
131
  InitOrigin(PersistenceType aPersistenceType, const nsACString& aGroup,
132
             const nsACString& aOrigin, const AtomicBool& aCanceled,
133
             UsageInfo* aUsageInfo) override
134
0
  {
135
0
    AssertIsOnIOThread();
136
0
137
0
    // The QuotaManager passes a nullptr UsageInfo if there is no quota being
138
0
    // enforced against the origin.
139
0
    if (!aUsageInfo) {
140
0
      return NS_OK;
141
0
    }
142
0
143
0
    return GetUsageForOrigin(aPersistenceType, aGroup, aOrigin, aCanceled,
144
0
                             aUsageInfo);
145
0
  }
146
147
  virtual nsresult
148
  GetUsageForOrigin(PersistenceType aPersistenceType, const nsACString& aGroup,
149
                    const nsACString& aOrigin, const AtomicBool& aCanceled,
150
                    UsageInfo* aUsageInfo) override
151
0
  {
152
0
    AssertIsOnIOThread();
153
0
    MOZ_DIAGNOSTIC_ASSERT(aUsageInfo);
154
0
155
0
    QuotaManager* qm = QuotaManager::Get();
156
0
    MOZ_DIAGNOSTIC_ASSERT(qm);
157
0
158
0
    nsCOMPtr<nsIFile> dir;
159
0
    nsresult rv = qm->GetDirectoryForOrigin(aPersistenceType, aOrigin,
160
0
                                            getter_AddRefs(dir));
161
0
    if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
162
0
163
0
    rv = dir->Append(NS_LITERAL_STRING(DOMCACHE_DIRECTORY_NAME));
164
0
    if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
165
0
166
0
    int64_t paddingSize = 0;
167
0
    {
168
0
      // If the tempoary file still exists after locking, it means the previous
169
0
      // action fails, so restore the padding file.
170
0
      MutexAutoLock lock(mDirPaddingFileMutex);
171
0
172
0
      if (mozilla::dom::cache::
173
0
          DirectoryPaddingFileExists(dir, DirPaddingFile::TMP_FILE) ||
174
0
          NS_WARN_IF(NS_FAILED(mozilla::dom::cache::
175
0
                               LockedDirectoryPaddingGet(dir,
176
0
                                                         &paddingSize)))) {
177
0
        rv = LockedGetPaddingSizeFromDB(dir, aGroup, aOrigin, &paddingSize);
178
0
        if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
179
0
      }
180
0
    }
181
0
182
0
    aUsageInfo->AppendToFileUsage(paddingSize);
183
0
184
0
    nsCOMPtr<nsIDirectoryEnumerator> entries;
185
0
    rv = dir->GetDirectoryEntries(getter_AddRefs(entries));
186
0
    if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
187
0
188
0
    nsCOMPtr<nsIFile> file;
189
0
    while (NS_SUCCEEDED(rv = entries->GetNextFile(getter_AddRefs(file))) &&
190
0
           file && !aCanceled) {
191
0
      nsAutoString leafName;
192
0
      rv = file->GetLeafName(leafName);
193
0
      if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
194
0
195
0
      bool isDir;
196
0
      rv = file->IsDirectory(&isDir);
197
0
      if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
198
0
199
0
      if (isDir) {
200
0
        if (leafName.EqualsLiteral("morgue")) {
201
0
          rv = GetBodyUsage(file, aCanceled, aUsageInfo);
202
0
          if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
203
0
        } else {
204
0
          NS_WARNING("Unknown Cache directory found!");
205
0
        }
206
0
207
0
        continue;
208
0
      }
209
0
210
0
      // Ignore transient sqlite files and marker files
211
0
      if (leafName.EqualsLiteral("caches.sqlite-journal") ||
212
0
          leafName.EqualsLiteral("caches.sqlite-shm") ||
213
0
          leafName.Find(NS_LITERAL_CSTRING("caches.sqlite-mj"), false, 0, 0) == 0 ||
214
0
          leafName.EqualsLiteral("context_open.marker")) {
215
0
        continue;
216
0
      }
217
0
218
0
      if (leafName.EqualsLiteral("caches.sqlite") ||
219
0
          leafName.EqualsLiteral("caches.sqlite-wal")) {
220
0
        int64_t fileSize;
221
0
        rv = file->GetFileSize(&fileSize);
222
0
        if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
223
0
        MOZ_DIAGNOSTIC_ASSERT(fileSize >= 0);
224
0
225
0
        aUsageInfo->AppendToDatabaseUsage(fileSize);
226
0
        continue;
227
0
      }
228
0
229
0
      // Ignore directory padding file
230
0
      if (leafName.EqualsLiteral(PADDING_FILE_NAME) ||
231
0
          leafName.EqualsLiteral(PADDING_TMP_FILE_NAME)) {
232
0
        continue;
233
0
      }
234
0
235
0
      NS_WARNING("Unknown Cache file found!");
236
0
    }
237
0
238
0
    return NS_OK;
239
0
  }
240
241
  virtual void
242
  OnOriginClearCompleted(PersistenceType aPersistenceType,
243
                         const nsACString& aOrigin) override
244
0
  {
245
0
    // Nothing to do here.
246
0
  }
247
248
  virtual void
249
  ReleaseIOThreadObjects() override
250
0
  {
251
0
    // Nothing to do here as the Context handles cleaning everything up
252
0
    // automatically.
253
0
  }
254
255
  virtual void
256
  AbortOperations(const nsACString& aOrigin) override
257
0
  {
258
0
    AssertIsOnBackgroundThread();
259
0
260
0
    Manager::Abort(aOrigin);
261
0
  }
262
263
  virtual void
264
  AbortOperationsForProcess(ContentParentId aContentParentId) override
265
0
  {
266
0
    // The Cache and Context can be shared by multiple client processes.  They
267
0
    // are not exclusively owned by a single process.
268
0
    //
269
0
    // As far as I can tell this is used by QuotaManager to abort operations
270
0
    // when a particular process goes away.  We definitely don't want this
271
0
    // since we are shared.  Also, the Cache actor code already properly
272
0
    // handles asynchronous actor destruction when the child process dies.
273
0
    //
274
0
    // Therefore, do nothing here.
275
0
  }
276
277
  virtual void
278
  StartIdleMaintenance() override
279
0
  { }
280
281
  virtual void
282
  StopIdleMaintenance() override
283
0
  { }
284
285
  virtual void
286
  ShutdownWorkThreads() override
287
0
  {
288
0
    AssertIsOnBackgroundThread();
289
0
290
0
    // spins the event loop and synchronously shuts down all Managers
291
0
    Manager::ShutdownAll();
292
0
  }
293
294
  nsresult
295
  UpgradeStorageFrom2_0To2_1(nsIFile* aDirectory) override
296
0
  {
297
0
    AssertIsOnIOThread();
298
0
    MOZ_DIAGNOSTIC_ASSERT(aDirectory);
299
0
300
0
    MutexAutoLock lock(mDirPaddingFileMutex);
301
0
302
0
    nsresult rv = mozilla::dom::cache::LockedDirectoryPaddingInit(aDirectory);
303
0
    if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
304
0
305
0
    return rv;
306
0
  }
307
308
  // static
309
  template<typename Callable>
310
  nsresult
311
  MaybeUpdatePaddingFileInternal(nsIFile* aBaseDir,
312
                                 mozIStorageConnection* aConn,
313
                                 const int64_t aIncreaseSize,
314
                                 const int64_t aDecreaseSize,
315
                                 Callable aCommitHook)
316
0
  {
317
0
    MOZ_ASSERT(!NS_IsMainThread());
318
0
    MOZ_DIAGNOSTIC_ASSERT(aBaseDir);
319
0
    MOZ_DIAGNOSTIC_ASSERT(aConn);
320
0
    MOZ_DIAGNOSTIC_ASSERT(aIncreaseSize >= 0);
321
0
    MOZ_DIAGNOSTIC_ASSERT(aDecreaseSize >= 0);
322
0
323
0
    nsresult rv;
324
0
325
0
    // Temporary should be removed at the end of each action. If not, it means
326
0
    // the failure happened.
327
0
    bool temporaryPaddingFileExist =
328
0
      mozilla::dom::cache::DirectoryPaddingFileExists(aBaseDir,
329
0
                                                      DirPaddingFile::TMP_FILE);
330
0
331
0
    if (aIncreaseSize == aDecreaseSize && !temporaryPaddingFileExist) {
332
0
      // Early return here, since most cache actions won't modify padding size.
333
0
      rv = aCommitHook();
334
0
      Unused << NS_WARN_IF(NS_FAILED(rv));
335
0
      return rv;
336
0
    }
337
0
338
0
    {
339
0
      MutexAutoLock lock(mDirPaddingFileMutex);
340
0
      rv =
341
0
        mozilla::dom::cache::
342
0
        LockedUpdateDirectoryPaddingFile(aBaseDir, aConn, aIncreaseSize,
343
0
                                         aDecreaseSize,
344
0
                                         temporaryPaddingFileExist);
345
0
      if (NS_WARN_IF(NS_FAILED(rv))) {
346
0
        // Don't delete the temporary padding file here to force the next action
347
0
        // recalculate the padding size.
348
0
        return rv;
349
0
      }
350
0
351
0
      rv = aCommitHook();
352
0
      if (NS_WARN_IF(NS_FAILED(rv))) {
353
0
        // Don't delete the temporary padding file here to force the next action
354
0
        // recalculate the padding size.
355
0
        return rv;
356
0
      }
357
0
358
0
      rv = mozilla::dom::cache::LockedDirectoryPaddingFinalizeWrite(aBaseDir);
359
0
      if (NS_WARN_IF(NS_FAILED(rv))) {
360
0
        // Force restore file next time.
361
0
        Unused << mozilla::dom::cache::
362
0
                  LockedDirectoryPaddingDeleteFile(aBaseDir,
363
0
                                                   DirPaddingFile::FILE);
364
0
365
0
        // Ensure that we are able to force the padding file to be restored.
366
0
        MOZ_ASSERT(
367
0
          mozilla::dom::cache::
368
0
          DirectoryPaddingFileExists(aBaseDir, DirPaddingFile::TMP_FILE));
369
0
370
0
        // Since both the body file and header have been stored in the
371
0
        // file-system, just make the action be resolve and let the padding file
372
0
        // be restored in the next action.
373
0
        rv = NS_OK;
374
0
      }
375
0
    }
376
0
377
0
    return rv;
378
0
  }
Unexecuted instantiation: Unified_cpp_dom_cache1.cpp:nsresult (anonymous namespace)::CacheQuotaClient::MaybeUpdatePaddingFileInternal<mozilla::dom::cache::Manager::DeleteOrphanedCacheAction::RunSyncWithDBOnTarget(mozilla::dom::cache::QuotaInfo const&, nsIFile*, mozIStorageConnection*)::{lambda()#1}>(nsIFile*, mozIStorageConnection*, long, long, mozilla::dom::cache::Manager::DeleteOrphanedCacheAction::RunSyncWithDBOnTarget(mozilla::dom::cache::QuotaInfo const&, nsIFile*, mozIStorageConnection*)::{lambda()#1})
Unexecuted instantiation: Unified_cpp_dom_cache1.cpp:nsresult (anonymous namespace)::CacheQuotaClient::MaybeUpdatePaddingFileInternal<mozilla::dom::cache::Manager::CacheDeleteAction::RunSyncWithDBOnTarget(mozilla::dom::cache::QuotaInfo const&, nsIFile*, mozIStorageConnection*)::{lambda()#1}>(nsIFile*, mozIStorageConnection*, long, long, mozilla::dom::cache::Manager::CacheDeleteAction::RunSyncWithDBOnTarget(mozilla::dom::cache::QuotaInfo const&, nsIFile*, mozIStorageConnection*)::{lambda()#1})
Unexecuted instantiation: Unified_cpp_dom_cache1.cpp:nsresult (anonymous namespace)::CacheQuotaClient::MaybeUpdatePaddingFileInternal<mozilla::dom::cache::Manager::CachePutAllAction::OnAsyncCopyComplete(nsresult)::{lambda()#1}>(nsIFile*, mozIStorageConnection*, long, long, mozilla::dom::cache::Manager::CachePutAllAction::OnAsyncCopyComplete(nsresult)::{lambda()#1})
Unexecuted instantiation: Unified_cpp_dom_cache1.cpp:nsresult (anonymous namespace)::CacheQuotaClient::MaybeUpdatePaddingFileInternal<mozilla::dom::cache::(anonymous namespace)::SetupAction::RunSyncWithDBOnTarget(mozilla::dom::cache::QuotaInfo const&, nsIFile*, mozIStorageConnection*)::{lambda()#1}>(nsIFile*, mozIStorageConnection*, long, long, mozilla::dom::cache::(anonymous namespace)::SetupAction::RunSyncWithDBOnTarget(mozilla::dom::cache::QuotaInfo const&, nsIFile*, mozIStorageConnection*)::{lambda()#1})
379
380
  // static
381
  nsresult
382
  RestorePaddingFileInternal(nsIFile* aBaseDir, mozIStorageConnection* aConn)
383
0
  {
384
0
    MOZ_ASSERT(!NS_IsMainThread());
385
0
    MOZ_DIAGNOSTIC_ASSERT(aBaseDir);
386
0
    MOZ_DIAGNOSTIC_ASSERT(aConn);
387
0
388
0
    int64_t dummyPaddingSize;
389
0
390
0
    MutexAutoLock lock(mDirPaddingFileMutex);
391
0
392
0
    nsresult rv =
393
0
      mozilla::dom::cache::
394
0
      LockedDirectoryPaddingRestore(aBaseDir, aConn, /* aMustRestore */ true,
395
0
                                    &dummyPaddingSize);
396
0
    Unused << NS_WARN_IF(NS_FAILED(rv));
397
0
398
0
    return rv;
399
0
  }
400
401
  // static
402
  nsresult
403
  WipePaddingFileInternal(const QuotaInfo& aQuotaInfo, nsIFile* aBaseDir)
404
0
  {
405
0
    MOZ_ASSERT(!NS_IsMainThread());
406
0
    MOZ_DIAGNOSTIC_ASSERT(aBaseDir);
407
0
408
0
    MutexAutoLock lock(mDirPaddingFileMutex);
409
0
410
0
    MOZ_ASSERT(mozilla::dom::cache::
411
0
               DirectoryPaddingFileExists(aBaseDir, DirPaddingFile::FILE));
412
0
413
0
    int64_t paddingSize = 0;
414
0
    bool temporaryPaddingFileExist =
415
0
      mozilla::dom::cache::
416
0
      DirectoryPaddingFileExists(aBaseDir, DirPaddingFile::TMP_FILE);
417
0
418
0
    if (temporaryPaddingFileExist ||
419
0
        NS_WARN_IF(NS_FAILED(
420
0
          mozilla::dom::cache::
421
0
          LockedDirectoryPaddingGet(aBaseDir, &paddingSize)))) {
422
0
      // XXXtt: Maybe have a method in the QuotaManager to clean the usage under
423
0
      // the quota client and the origin.
424
0
      // There is nothing we can do to recover the file.
425
0
      NS_WARNING("Cannnot read padding size from file!");
426
0
      paddingSize = 0;
427
0
    }
428
0
429
0
    if (paddingSize > 0) {
430
0
      mozilla::dom::cache::DecreaseUsageForQuotaInfo(aQuotaInfo, paddingSize);
431
0
    }
432
0
433
0
    nsresult rv =
434
0
      mozilla::dom::cache::
435
0
      LockedDirectoryPaddingDeleteFile(aBaseDir, DirPaddingFile::FILE);
436
0
    if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
437
0
438
0
    // Remove temporary file if we have one.
439
0
    rv = mozilla::dom::cache::
440
0
         LockedDirectoryPaddingDeleteFile(aBaseDir, DirPaddingFile::TMP_FILE);
441
0
    if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
442
0
443
0
    rv = mozilla::dom::cache::LockedDirectoryPaddingInit(aBaseDir);
444
0
    Unused << NS_WARN_IF(NS_FAILED(rv));
445
0
446
0
    return rv;
447
0
  }
448
449
private:
450
  ~CacheQuotaClient()
451
0
  {
452
0
    AssertIsOnBackgroundThread();
453
0
    MOZ_DIAGNOSTIC_ASSERT(sInstance == this);
454
0
455
0
    sInstance = nullptr;
456
0
  }
457
458
  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(CacheQuotaClient, override)
459
460
  // Mutex lock to protect directroy padding files. It should only be acquired
461
  // in DOM Cache IO threads and Quota IO thread.
462
  mozilla::Mutex mDirPaddingFileMutex;
463
};
464
465
// static
466
CacheQuotaClient* CacheQuotaClient::sInstance = nullptr;
467
468
} // namespace
469
470
namespace mozilla {
471
namespace dom {
472
namespace cache {
473
474
// static
475
already_AddRefed<quota::Client> CreateQuotaClient()
476
0
{
477
0
  AssertIsOnBackgroundThread();
478
0
479
0
  RefPtr<CacheQuotaClient> ref = new CacheQuotaClient();
480
0
  return ref.forget();
481
0
}
482
483
// static
484
template<typename Callable>
485
nsresult
486
MaybeUpdatePaddingFile(nsIFile* aBaseDir,
487
                       mozIStorageConnection* aConn,
488
                       const int64_t aIncreaseSize,
489
                       const int64_t aDecreaseSize,
490
                       Callable aCommitHook)
491
0
{
492
0
  MOZ_ASSERT(!NS_IsMainThread());
493
0
  MOZ_DIAGNOSTIC_ASSERT(aBaseDir);
494
0
  MOZ_DIAGNOSTIC_ASSERT(aConn);
495
0
  MOZ_DIAGNOSTIC_ASSERT(aIncreaseSize >= 0);
496
0
  MOZ_DIAGNOSTIC_ASSERT(aDecreaseSize >= 0);
497
0
498
0
  RefPtr<CacheQuotaClient> cacheQuotaClient = CacheQuotaClient::Get();
499
0
  MOZ_DIAGNOSTIC_ASSERT(cacheQuotaClient);
500
0
501
0
  nsresult rv =
502
0
    cacheQuotaClient->MaybeUpdatePaddingFileInternal(aBaseDir, aConn,
503
0
                                                     aIncreaseSize,
504
0
                                                     aDecreaseSize,
505
0
                                                     aCommitHook);
506
0
  Unused << NS_WARN_IF(NS_FAILED(rv));
507
0
508
0
  return rv;
509
0
}
Unexecuted instantiation: nsresult mozilla::dom::cache::MaybeUpdatePaddingFile<mozilla::dom::cache::Manager::DeleteOrphanedCacheAction::RunSyncWithDBOnTarget(mozilla::dom::cache::QuotaInfo const&, nsIFile*, mozIStorageConnection*)::{lambda()#1}>(nsIFile*, mozIStorageConnection*, long, long, mozilla::dom::cache::Manager::DeleteOrphanedCacheAction::RunSyncWithDBOnTarget(mozilla::dom::cache::QuotaInfo const&, nsIFile*, mozIStorageConnection*)::{lambda()#1})
Unexecuted instantiation: nsresult mozilla::dom::cache::MaybeUpdatePaddingFile<mozilla::dom::cache::Manager::CacheDeleteAction::RunSyncWithDBOnTarget(mozilla::dom::cache::QuotaInfo const&, nsIFile*, mozIStorageConnection*)::{lambda()#1}>(nsIFile*, mozIStorageConnection*, long, long, mozilla::dom::cache::Manager::CacheDeleteAction::RunSyncWithDBOnTarget(mozilla::dom::cache::QuotaInfo const&, nsIFile*, mozIStorageConnection*)::{lambda()#1})
Unexecuted instantiation: nsresult mozilla::dom::cache::MaybeUpdatePaddingFile<mozilla::dom::cache::Manager::CachePutAllAction::OnAsyncCopyComplete(nsresult)::{lambda()#1}>(nsIFile*, mozIStorageConnection*, long, long, mozilla::dom::cache::Manager::CachePutAllAction::OnAsyncCopyComplete(nsresult)::{lambda()#1})
Unexecuted instantiation: Unified_cpp_dom_cache1.cpp:nsresult mozilla::dom::cache::MaybeUpdatePaddingFile<mozilla::dom::cache::(anonymous namespace)::SetupAction::RunSyncWithDBOnTarget(mozilla::dom::cache::QuotaInfo const&, nsIFile*, mozIStorageConnection*)::{lambda()#1}>(nsIFile*, mozIStorageConnection*, long, long, mozilla::dom::cache::(anonymous namespace)::SetupAction::RunSyncWithDBOnTarget(mozilla::dom::cache::QuotaInfo const&, nsIFile*, mozIStorageConnection*)::{lambda()#1})
510
511
// static
512
nsresult
513
RestorePaddingFile(nsIFile* aBaseDir, mozIStorageConnection* aConn)
514
0
{
515
0
  MOZ_ASSERT(!NS_IsMainThread());
516
0
  MOZ_DIAGNOSTIC_ASSERT(aBaseDir);
517
0
  MOZ_DIAGNOSTIC_ASSERT(aConn);
518
0
519
0
  RefPtr<CacheQuotaClient> cacheQuotaClient = CacheQuotaClient::Get();
520
0
  MOZ_DIAGNOSTIC_ASSERT(cacheQuotaClient);
521
0
522
0
  nsresult rv =
523
0
    cacheQuotaClient->RestorePaddingFileInternal(aBaseDir, aConn);
524
0
  Unused << NS_WARN_IF(NS_FAILED(rv));
525
0
526
0
  return rv;
527
0
}
528
529
// static
530
nsresult
531
WipePaddingFile(const QuotaInfo& aQuotaInfo, nsIFile* aBaseDir)
532
0
{
533
0
  MOZ_ASSERT(!NS_IsMainThread());
534
0
  MOZ_DIAGNOSTIC_ASSERT(aBaseDir);
535
0
536
0
  RefPtr<CacheQuotaClient> cacheQuotaClient = CacheQuotaClient::Get();
537
0
  MOZ_DIAGNOSTIC_ASSERT(cacheQuotaClient);
538
0
539
0
  nsresult rv =
540
0
    cacheQuotaClient->WipePaddingFileInternal(aQuotaInfo, aBaseDir);
541
0
  Unused << NS_WARN_IF(NS_FAILED(rv));
542
0
543
0
  return rv;
544
0
}
545
} // namespace cache
546
} // namespace dom
547
} // namespace mozilla