Backed out changeset 2450366cf7ca (bug 1891629) for causing win msix mochitest failures
[gecko.git] / dom / quota / RemoteQuotaObject.cpp
blob3fa3370fc1211e9c6ad70af5c32fcea9da15ee56
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 "RemoteQuotaObject.h"
9 #include "mozilla/dom/quota/RemoteQuotaObjectChild.h"
10 #include "mozilla/ipc/BackgroundParent.h"
12 namespace mozilla::dom::quota {
14 RemoteQuotaObject::RemoteQuotaObject(RefPtr<RemoteQuotaObjectChild> aActor)
15 : QuotaObject(/* aIsRemote */ true), mActor(std::move(aActor)) {
16 MOZ_COUNT_CTOR(RemoteQuotaObject);
18 mActor->SetRemoteQuotaObject(this);
21 RemoteQuotaObject::~RemoteQuotaObject() {
22 MOZ_COUNT_DTOR(RemoteQuotaObject);
24 Close();
27 void RemoteQuotaObject::ClearActor() {
28 MOZ_ASSERT(mActor);
30 mActor = nullptr;
33 void RemoteQuotaObject::Close() {
34 if (!mActor) {
35 return;
38 MOZ_ASSERT(mActor->GetActorEventTarget()->IsOnCurrentThread());
40 mActor->Close();
41 MOZ_ASSERT(!mActor);
44 const nsAString& RemoteQuotaObject::Path() const { return EmptyString(); }
46 bool RemoteQuotaObject::MaybeUpdateSize(int64_t aSize, bool aTruncate) {
47 MOZ_ASSERT(!NS_IsMainThread());
48 MOZ_ASSERT(!mozilla::ipc::IsOnBackgroundThread());
49 MOZ_ASSERT(!GetCurrentThreadWorkerPrivate());
51 if (!mActor) {
52 return false;
55 MOZ_ASSERT(mActor->GetActorEventTarget()->IsOnCurrentThread());
57 bool result;
58 if (!mActor->SendMaybeUpdateSize(aSize, aTruncate, &result)) {
59 return false;
62 return result;
65 } // namespace mozilla::dom::quota