Bug 1941046 - Part 4: Send a callback request for impression and clicks of MARS Top...
[gecko.git] / dom / quota / NotifyUtils.cpp
blobdc7abc641893046d6cea5d05f18ab5012c351ec6
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"
13 #include "nsError.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()) {
37 return;
40 NotifyObserversOnMainThread("QuotaManager::MaintenanceStarted");
43 void NotifyClientDirectoryOpeningStarted(QuotaManager& aQuotaManager) {
44 aQuotaManager.AssertIsOnOwningThread();
46 if (!StaticPrefs::dom_quotaManager_testing()) {
47 return;
50 NotifyObserversOnMainThread("QuotaManager::ClientDirectoryOpeningStarted");
53 } // namespace mozilla::dom::quota