RemoteQuotaObject.cpp (1623B)
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/. */ 6 7 #include "RemoteQuotaObject.h" 8 9 #include "mozilla/dom/quota/RemoteQuotaObjectChild.h" 10 #include "mozilla/ipc/BackgroundParent.h" 11 12 namespace mozilla::dom::quota { 13 14 RemoteQuotaObject::RemoteQuotaObject(RefPtr<RemoteQuotaObjectChild> aActor) 15 : QuotaObject(/* aIsRemote */ true), mActor(std::move(aActor)) { 16 MOZ_COUNT_CTOR(RemoteQuotaObject); 17 18 mActor->SetRemoteQuotaObject(this); 19 } 20 21 RemoteQuotaObject::~RemoteQuotaObject() { 22 MOZ_COUNT_DTOR(RemoteQuotaObject); 23 24 Close(); 25 } 26 27 void RemoteQuotaObject::ClearActor() { 28 MOZ_ASSERT(mActor); 29 30 mActor = nullptr; 31 } 32 33 void RemoteQuotaObject::Close() { 34 if (!mActor) { 35 return; 36 } 37 38 MOZ_ASSERT(mActor->GetActorEventTarget()->IsOnCurrentThread()); 39 40 mActor->Close(); 41 MOZ_ASSERT(!mActor); 42 } 43 44 const nsAString& RemoteQuotaObject::Path() const { return EmptyString(); } 45 46 bool RemoteQuotaObject::MaybeUpdateSize(int64_t aSize, bool aTruncate) { 47 MOZ_ASSERT(!NS_IsMainThread()); 48 MOZ_ASSERT(!mozilla::ipc::IsOnBackgroundThread()); 49 MOZ_ASSERT(!GetCurrentThreadWorkerPrivate()); 50 51 if (!mActor) { 52 return false; 53 } 54 55 MOZ_ASSERT(mActor->GetActorEventTarget()->IsOnCurrentThread()); 56 57 bool result; 58 if (!mActor->SendMaybeUpdateSize(aSize, aTruncate, &result)) { 59 return false; 60 } 61 62 return result; 63 } 64 65 } // namespace mozilla::dom::quota