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 file,
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "mozilla/dom/quota/NotifyUtils.h"
9 #include "mozilla/RefPtr.h"
10 #include "mozilla/StaticPrefs_dom.h"
11 #include "mozilla/dom/quota/NotifyUtilsCommon.h"
12 #include "mozilla/dom/quota/QuotaManager.h"
14 #include "nsSupportsPrimitives.h"
16 namespace mozilla::dom::quota
{
18 void NotifyStoragePressure(QuotaManager
& aQuotaManager
, uint64_t aUsage
) {
19 aQuotaManager
.AssertNotCurrentThreadOwnsQuotaMutex();
21 auto subjectGetter
= [usage
= aUsage
]() {
22 auto wrapper
= MakeRefPtr
<nsSupportsPRUint64
>();
24 MOZ_ALWAYS_SUCCEEDS(wrapper
->SetData(usage
));
26 return wrapper
.forget();
29 NotifyObserversOnMainThread("QuotaManager::StoragePressure",
30 std::move(subjectGetter
));
33 void NotifyMaintenanceStarted(QuotaManager
& aQuotaManager
) {
34 aQuotaManager
.AssertIsOnOwningThread();
36 if (!StaticPrefs::dom_quotaManager_testing()) {
40 NotifyObserversOnMainThread("QuotaManager::MaintenanceStarted");
43 void NotifyClientDirectoryOpeningStarted(QuotaManager
& aQuotaManager
) {
44 aQuotaManager
.AssertIsOnOwningThread();
46 if (!StaticPrefs::dom_quotaManager_testing()) {
50 NotifyObserversOnMainThread("QuotaManager::ClientDirectoryOpeningStarted");
53 } // namespace mozilla::dom::quota