Bug 1919824 - Make `NativeKey::GetFollowingCharMessage` return `false` when removed...
[gecko.git] / dom / quota / QuotaObject.h
blob96397faf66e30d17dd15f16638bed041f24f197d
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 #ifndef DOM_QUOTA_QUOTAOBJECT_H_
8 #define DOM_QUOTA_QUOTAOBJECT_H_
10 #include "nsISupportsImpl.h"
12 class nsIInterfaceRequestor;
14 namespace mozilla::dom::quota {
16 class CanonicalQuotaObject;
17 class IPCQuotaObject;
18 class RemoteQuotaObject;
20 // QuotaObject type is serializable, but only in a restricted manner. The type
21 // is only safe to serialize in the parent process and only when the type
22 // hasn't been previously deserialized. So the type can be serialized in the
23 // parent process and deserialized in a child process or it can be serialized
24 // in the parent process and deserialized in the parent process as well
25 // (non-e10s mode). The same type can never be serialized/deserialized more
26 // than once.
27 // The deserialized type (remote variant) can only be used on the thread it was
28 // deserialized on and it will stop working if the thread it was sent from is
29 // shutdown (consumers should make sure that the originating thread is kept
30 // alive for the necessary time).
31 class QuotaObject {
32 public:
33 NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING
35 CanonicalQuotaObject* AsCanonicalQuotaObject();
37 RemoteQuotaObject* AsRemoteQuotaObject();
39 // Serialize this QuotaObject. This method works only in the parent process
40 // and only with objects which haven't been previously deserialized.
41 // The serial event target where this method is called should be highly
42 // available, as it will be used to process requests from the remote variant.
43 IPCQuotaObject Serialize(nsIInterfaceRequestor* aCallbacks);
45 // Deserialize a QuotaObject. This method works in both the child and parent.
46 // The deserialized QuotaObject can only be used on the calling serial event
47 // target.
48 static RefPtr<QuotaObject> Deserialize(IPCQuotaObject& aQuotaObject);
50 virtual const nsAString& Path() const = 0;
52 [[nodiscard]] virtual bool MaybeUpdateSize(int64_t aSize, bool aTruncate) = 0;
54 virtual bool IncreaseSize(int64_t aDelta) = 0;
56 virtual void DisableQuotaCheck() = 0;
58 virtual void EnableQuotaCheck() = 0;
60 protected:
61 QuotaObject(bool aIsRemote) : mIsRemote(aIsRemote) {}
63 virtual ~QuotaObject() = default;
65 const bool mIsRemote;
68 } // namespace mozilla::dom::quota
70 #endif // DOM_QUOTA_QUOTAOBJECT_H_