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"
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
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.
31 class WebBrowserPersistRemoteDocument
;
33 class WebBrowserPersistDocumentParent final
34 : public PWebBrowserPersistDocumentParent
{
36 WebBrowserPersistDocumentParent();
37 virtual ~WebBrowserPersistDocumentParent();
39 // Set a callback to be invoked when the actor leaves the START
40 // state. This method must be called exactly once while the actor
41 // is still in the START state (or is unconstructed).
42 void SetOnReady(nsIWebBrowserPersistDocumentReceiver
* aOnReady
);
44 using Attrs
= WebBrowserPersistDocumentAttrs
;
47 mozilla::ipc::IPCResult
RecvAttributes(const Attrs
& aAttrs
,
48 const Maybe
<IPCStream
>& aPostStream
);
49 mozilla::ipc::IPCResult
RecvInitFailure(const nsresult
& aFailure
);
51 PWebBrowserPersistResourcesParent
* AllocPWebBrowserPersistResourcesParent();
52 bool DeallocPWebBrowserPersistResourcesParent(
53 PWebBrowserPersistResourcesParent
* aActor
);
55 PWebBrowserPersistSerializeParent
* AllocPWebBrowserPersistSerializeParent(
56 const WebBrowserPersistURIMap
& aMap
,
57 const nsACString
& aRequestedContentType
, const uint32_t& aEncoderFlags
,
58 const uint32_t& aWrapColumn
);
59 bool DeallocPWebBrowserPersistSerializeParent(
60 PWebBrowserPersistSerializeParent
* aActor
);
62 virtual void ActorDestroy(ActorDestroyReason aWhy
) override
;
65 // This is reset to nullptr when the callback is invoked.
66 nsCOMPtr
<nsIWebBrowserPersistDocumentReceiver
> mOnReady
;
67 WebBrowserPersistRemoteDocument
* mReflection
;
70 } // namespace mozilla
72 #endif // WebBrowserPersistDocumentParent_h__