Backed out changeset 2450366cf7ca (bug 1891629) for causing win msix mochitest failures
[gecko.git] / dom / webbrowserpersist / WebBrowserPersistDocumentParent.h
blob20b77927ea2ed780f1cd22a32a18e0ff48e27af4
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 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/. */
7 #ifndef WebBrowserPersistDocumentParent_h__
8 #define WebBrowserPersistDocumentParent_h__
10 #include "mozilla/Maybe.h"
11 #include "mozilla/PWebBrowserPersistDocumentParent.h"
12 #include "nsCOMPtr.h"
13 #include "nsIWebBrowserPersistDocument.h"
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.
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.
27 // See also: BrowserParent::StartPersistence.
29 namespace mozilla {
31 class WebBrowserPersistRemoteDocument;
33 class WebBrowserPersistDocumentParent final
34 : public PWebBrowserPersistDocumentParent {
35 public:
36 NS_INLINE_DECL_REFCOUNTING(WebBrowserPersistDocumentParent, override)
38 WebBrowserPersistDocumentParent();
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);
45 using Attrs = WebBrowserPersistDocumentAttrs;
47 // IPDL methods:
48 mozilla::ipc::IPCResult RecvAttributes(const Attrs& aAttrs,
49 const Maybe<IPCStream>& aPostStream);
50 mozilla::ipc::IPCResult RecvInitFailure(const nsresult& aFailure);
52 PWebBrowserPersistResourcesParent* AllocPWebBrowserPersistResourcesParent();
53 bool DeallocPWebBrowserPersistResourcesParent(
54 PWebBrowserPersistResourcesParent* aActor);
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);
63 virtual void ActorDestroy(ActorDestroyReason aWhy) override;
65 private:
66 virtual ~WebBrowserPersistDocumentParent();
68 // This is reset to nullptr when the callback is invoked.
69 nsCOMPtr<nsIWebBrowserPersistDocumentReceiver> mOnReady;
70 WebBrowserPersistRemoteDocument* mReflection;
73 } // namespace mozilla
75 #endif // WebBrowserPersistDocumentParent_h__