WebBrowserPersistDocumentParent.h 2.9 KB

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