tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

FileSystemAccessHandleControlChild.h (1617B)


      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
      5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #ifndef DOM_FS_CHILD_FILESYSTEMACCESSHANDLECONTROLCHILD_H_
      8 #define DOM_FS_CHILD_FILESYSTEMACCESSHANDLECONTROLCHILD_H_
      9 
     10 #include "mozilla/dom/PFileSystemAccessHandleControlChild.h"
     11 #include "nsISupportsImpl.h"
     12 
     13 namespace mozilla::dom {
     14 
     15 class FileSystemSyncAccessHandle;
     16 
     17 class FileSystemAccessHandleControlChild
     18    : public PFileSystemAccessHandleControlChild {
     19 public:
     20  NS_INLINE_DECL_REFCOUNTING_WITH_DESTROY(FileSystemAccessHandleControlChild,
     21                                          Destroy(), override)
     22 
     23  void SetAccessHandle(FileSystemSyncAccessHandle* aAccessHandle);
     24 
     25  void Shutdown();
     26 
     27  void ActorDestroy(ActorDestroyReason aWhy) override;
     28 
     29 protected:
     30  virtual ~FileSystemAccessHandleControlChild() = default;
     31 
     32  // This is called when the object's refcount drops to zero. We use this custom
     33  // callback to close the top level actor if it hasn't been explicitly closed
     34  // yet. For example when `FileSystemSyncAccessHandle::Create` fails after
     35  // creating and binding the top level actor.
     36  virtual void Destroy() {
     37    Shutdown();
     38    delete this;
     39  }
     40 
     41  // The weak reference is cleared in ActorDestroy.
     42  FileSystemSyncAccessHandle* MOZ_NON_OWNING_REF mAccessHandle;
     43 };
     44 
     45 }  // namespace mozilla::dom
     46 
     47 #endif  // DOM_FS_CHILD_FILESYSTEMACCESSHANDLECONTROLCHILD_H_