ContentBridgeParent.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  4. * You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #ifndef mozilla_dom_ContentBridgeParent_h
  6. #define mozilla_dom_ContentBridgeParent_h
  7. #include "mozilla/dom/PContentBridgeParent.h"
  8. #include "mozilla/dom/nsIContentParent.h"
  9. #include "mozilla/dom/ipc/IdType.h"
  10. #include "nsIObserver.h"
  11. namespace mozilla {
  12. namespace dom {
  13. class ContentBridgeParent : public PContentBridgeParent
  14. , public nsIContentParent
  15. , public nsIObserver
  16. {
  17. public:
  18. explicit ContentBridgeParent(Transport* aTransport);
  19. NS_DECL_ISUPPORTS
  20. NS_DECL_NSIOBSERVER
  21. virtual void ActorDestroy(ActorDestroyReason aWhy) override;
  22. void DeferredDestroy();
  23. virtual bool IsContentBridgeParent() const override { return true; }
  24. void NotifyTabDestroyed();
  25. static ContentBridgeParent*
  26. Create(Transport* aTransport, ProcessId aOtherProcess);
  27. virtual PBlobParent*
  28. SendPBlobConstructor(PBlobParent* actor,
  29. const BlobConstructorParams& params) override;
  30. virtual PBrowserParent*
  31. SendPBrowserConstructor(PBrowserParent* aActor,
  32. const TabId& aTabId,
  33. const IPCTabContext& aContext,
  34. const uint32_t& aChromeFlags,
  35. const ContentParentId& aCpID,
  36. const bool& aIsForApp,
  37. const bool& aIsForBrowser) override;
  38. FORWARD_SHMEM_ALLOCATOR_TO(PContentBridgeParent)
  39. jsipc::CPOWManager* GetCPOWManager() override;
  40. virtual ContentParentId ChildID() const override
  41. {
  42. return mChildID;
  43. }
  44. virtual bool IsForApp() const override
  45. {
  46. return mIsForApp;
  47. }
  48. virtual bool IsForBrowser() const override
  49. {
  50. return mIsForBrowser;
  51. }
  52. virtual int32_t Pid() const override
  53. {
  54. // XXX: do we need this for ContentBridgeParent?
  55. return -1;
  56. }
  57. protected:
  58. virtual ~ContentBridgeParent();
  59. void SetChildID(ContentParentId aId)
  60. {
  61. mChildID = aId;
  62. }
  63. void SetIsForApp(bool aIsForApp)
  64. {
  65. mIsForApp = aIsForApp;
  66. }
  67. void SetIsForBrowser(bool aIsForBrowser)
  68. {
  69. mIsForBrowser = aIsForBrowser;
  70. }
  71. void Close()
  72. {
  73. // Trick NewRunnableMethod
  74. PContentBridgeParent::Close();
  75. }
  76. protected:
  77. virtual bool
  78. RecvSyncMessage(const nsString& aMsg,
  79. const ClonedMessageData& aData,
  80. InfallibleTArray<jsipc::CpowEntry>&& aCpows,
  81. const IPC::Principal& aPrincipal,
  82. nsTArray<StructuredCloneData>* aRetvals) override;
  83. virtual bool RecvAsyncMessage(const nsString& aMsg,
  84. InfallibleTArray<jsipc::CpowEntry>&& aCpows,
  85. const IPC::Principal& aPrincipal,
  86. const ClonedMessageData& aData) override;
  87. virtual jsipc::PJavaScriptParent* AllocPJavaScriptParent() override;
  88. virtual bool
  89. DeallocPJavaScriptParent(jsipc::PJavaScriptParent*) override;
  90. virtual PBrowserParent*
  91. AllocPBrowserParent(const TabId& aTabId,
  92. const IPCTabContext &aContext,
  93. const uint32_t& aChromeFlags,
  94. const ContentParentId& aCpID,
  95. const bool& aIsForApp,
  96. const bool& aIsForBrowser) override;
  97. virtual bool DeallocPBrowserParent(PBrowserParent*) override;
  98. virtual PBlobParent*
  99. AllocPBlobParent(const BlobConstructorParams& aParams) override;
  100. virtual bool DeallocPBlobParent(PBlobParent*) override;
  101. virtual PSendStreamParent* AllocPSendStreamParent() override;
  102. virtual bool DeallocPSendStreamParent(PSendStreamParent* aActor) override;
  103. virtual PFileDescriptorSetParent*
  104. AllocPFileDescriptorSetParent(const mozilla::ipc::FileDescriptor&) override;
  105. virtual bool
  106. DeallocPFileDescriptorSetParent(PFileDescriptorSetParent*) override;
  107. DISALLOW_EVIL_CONSTRUCTORS(ContentBridgeParent);
  108. protected: // members
  109. RefPtr<ContentBridgeParent> mSelfRef;
  110. Transport* mTransport; // owned
  111. ContentParentId mChildID;
  112. bool mIsForApp;
  113. bool mIsForBrowser;
  114. private:
  115. friend class ContentParent;
  116. };
  117. } // namespace dom
  118. } // namespace mozilla
  119. #endif // mozilla_dom_ContentBridgeParent_h