tor-browser

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

WebBrowserPersistDocumentParent.h (2863B)


      1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
      2 *
      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 WebBrowserPersistDocumentParent_h__
      8 #define WebBrowserPersistDocumentParent_h__
      9 
     10 #include "mozilla/Maybe.h"
     11 #include "mozilla/PWebBrowserPersistDocumentParent.h"
     12 #include "nsCOMPtr.h"
     13 #include "nsIWebBrowserPersistDocument.h"
     14 
     15 // This class is the IPC half of the glue between the
     16 // nsIWebBrowserPersistDocument interface and a remote document.  When
     17 // (and if) it receives the Attributes message it constructs an
     18 // WebBrowserPersistRemoteDocument and releases it into the XPCOM
     19 // universe; otherwise, it invokes the document receiver's error
     20 // callback.
     21 //
     22 // This object's lifetime is the normal IPC lifetime; on destruction,
     23 // it calls its XPCOM reflection (if it exists yet) to remove that
     24 // reference.  Normal deletion occurs when the XPCOM object is being
     25 // destroyed or after an InitFailure is received and handled.
     26 //
     27 // See also: BrowserParent::StartPersistence.
     28 
     29 namespace mozilla {
     30 
     31 class WebBrowserPersistRemoteDocument;
     32 
     33 class WebBrowserPersistDocumentParent final
     34    : public PWebBrowserPersistDocumentParent {
     35 public:
     36  NS_INLINE_DECL_REFCOUNTING(WebBrowserPersistDocumentParent, override)
     37 
     38  WebBrowserPersistDocumentParent();
     39 
     40  // Set a callback to be invoked when the actor leaves the START
     41  // state.  This method must be called exactly once while the actor
     42  // is still in the START state (or is unconstructed).
     43  void SetOnReady(nsIWebBrowserPersistDocumentReceiver* aOnReady);
     44 
     45  using Attrs = WebBrowserPersistDocumentAttrs;
     46 
     47  // IPDL methods:
     48  mozilla::ipc::IPCResult RecvAttributes(const Attrs& aAttrs,
     49                                         const Maybe<IPCStream>& aPostStream);
     50  mozilla::ipc::IPCResult RecvInitFailure(const nsresult& aFailure);
     51 
     52  PWebBrowserPersistResourcesParent* AllocPWebBrowserPersistResourcesParent();
     53  bool DeallocPWebBrowserPersistResourcesParent(
     54      PWebBrowserPersistResourcesParent* aActor);
     55 
     56  PWebBrowserPersistSerializeParent* AllocPWebBrowserPersistSerializeParent(
     57      const WebBrowserPersistURIMap& aMap,
     58      const nsACString& aRequestedContentType, const uint32_t& aEncoderFlags,
     59      const uint32_t& aWrapColumn);
     60  bool DeallocPWebBrowserPersistSerializeParent(
     61      PWebBrowserPersistSerializeParent* aActor);
     62 
     63  virtual void ActorDestroy(ActorDestroyReason aWhy) override;
     64 
     65 private:
     66  virtual ~WebBrowserPersistDocumentParent();
     67 
     68  // This is reset to nullptr when the callback is invoked.
     69  nsCOMPtr<nsIWebBrowserPersistDocumentReceiver> mOnReady;
     70  WebBrowserPersistRemoteDocument* mReflection;
     71 };
     72 
     73 }  // namespace mozilla
     74 
     75 #endif  // WebBrowserPersistDocumentParent_h__