2014-06-11 09:44:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2015-05-03 22:32:37 +03:00
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2014-06-11 09:44:13 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_dom_ContentBridgeParent_h
|
|
|
|
#define mozilla_dom_ContentBridgeParent_h
|
|
|
|
|
|
|
|
#include "mozilla/dom/PContentBridgeParent.h"
|
|
|
|
#include "mozilla/dom/nsIContentParent.h"
|
2014-10-24 04:28:00 +04:00
|
|
|
#include "mozilla/dom/ipc/IdType.h"
|
2015-03-10 14:10:00 +03:00
|
|
|
#include "nsIObserver.h"
|
2014-06-11 09:44:13 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
class ContentBridgeParent : public PContentBridgeParent
|
|
|
|
, public nsIContentParent
|
2015-03-10 14:10:00 +03:00
|
|
|
, public nsIObserver
|
2014-06-11 09:44:13 +04:00
|
|
|
{
|
|
|
|
public:
|
2017-01-27 02:05:36 +03:00
|
|
|
explicit ContentBridgeParent();
|
2014-06-11 09:44:13 +04:00
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
2015-03-10 14:10:00 +03:00
|
|
|
NS_DECL_NSIOBSERVER
|
2014-06-11 09:44:13 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void ActorDestroy(ActorDestroyReason aWhy) override;
|
2014-06-11 09:44:13 +04:00
|
|
|
void DeferredDestroy();
|
2016-01-05 12:59:30 +03:00
|
|
|
virtual bool IsContentBridgeParent() const override { return true; }
|
2015-08-31 08:53:00 +03:00
|
|
|
void NotifyTabDestroyed();
|
2014-06-11 09:44:13 +04:00
|
|
|
|
|
|
|
static ContentBridgeParent*
|
2017-01-27 01:40:17 +03:00
|
|
|
Create(Endpoint<PContentBridgeParent>&& aEndpoint);
|
2014-06-11 09:44:13 +04:00
|
|
|
|
|
|
|
virtual PBrowserParent*
|
|
|
|
SendPBrowserConstructor(PBrowserParent* aActor,
|
2014-10-29 21:11:00 +03:00
|
|
|
const TabId& aTabId,
|
2017-04-07 02:46:18 +03:00
|
|
|
const TabId& aSameTabGroupAs,
|
2014-06-11 09:44:13 +04:00
|
|
|
const IPCTabContext& aContext,
|
|
|
|
const uint32_t& aChromeFlags,
|
2014-10-24 04:28:00 +04:00
|
|
|
const ContentParentId& aCpID,
|
2015-03-21 19:28:04 +03:00
|
|
|
const bool& aIsForBrowser) override;
|
2014-06-11 09:44:13 +04:00
|
|
|
|
2017-03-14 14:29:43 +03:00
|
|
|
virtual PFileDescriptorSetParent*
|
|
|
|
SendPFileDescriptorSetConstructor(const FileDescriptor&) override;
|
|
|
|
|
2016-06-15 19:57:46 +03:00
|
|
|
FORWARD_SHMEM_ALLOCATOR_TO(PContentBridgeParent)
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
jsipc::CPOWManager* GetCPOWManager() override;
|
2014-06-11 09:44:13 +04:00
|
|
|
|
2016-01-05 12:59:30 +03:00
|
|
|
virtual ContentParentId ChildID() const override
|
2014-06-11 09:44:13 +04:00
|
|
|
{
|
|
|
|
return mChildID;
|
|
|
|
}
|
2016-01-05 12:59:30 +03:00
|
|
|
virtual bool IsForBrowser() const override
|
2014-06-11 09:44:13 +04:00
|
|
|
{
|
|
|
|
return mIsForBrowser;
|
|
|
|
}
|
2016-08-01 13:26:48 +03:00
|
|
|
virtual int32_t Pid() const override
|
|
|
|
{
|
|
|
|
// XXX: do we need this for ContentBridgeParent?
|
|
|
|
return -1;
|
|
|
|
}
|
2017-05-29 13:38:46 +03:00
|
|
|
virtual bool IsForJSPlugin() const override
|
|
|
|
{
|
|
|
|
return mIsForJSPlugin;
|
|
|
|
}
|
|
|
|
|
2014-06-11 09:44:13 +04:00
|
|
|
|
2017-03-14 14:29:43 +03:00
|
|
|
virtual mozilla::ipc::PParentToChildStreamParent*
|
|
|
|
SendPParentToChildStreamConstructor(mozilla::ipc::PParentToChildStreamParent*) override;
|
|
|
|
|
2017-03-15 04:00:00 +03:00
|
|
|
virtual bool SendActivate(PBrowserParent* aTab) override
|
|
|
|
{
|
|
|
|
return PContentBridgeParent::SendActivate(aTab);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool SendDeactivate(PBrowserParent* aTab) override
|
|
|
|
{
|
|
|
|
return PContentBridgeParent::SendDeactivate(aTab);
|
|
|
|
}
|
|
|
|
|
2014-06-11 09:44:13 +04:00
|
|
|
protected:
|
2014-06-23 23:56:07 +04:00
|
|
|
virtual ~ContentBridgeParent();
|
|
|
|
|
2014-10-24 04:28:00 +04:00
|
|
|
void SetChildID(ContentParentId aId)
|
2014-06-11 09:44:13 +04:00
|
|
|
{
|
|
|
|
mChildID = aId;
|
|
|
|
}
|
2016-01-05 12:59:30 +03:00
|
|
|
|
2014-06-11 09:44:13 +04:00
|
|
|
void SetIsForBrowser(bool aIsForBrowser)
|
|
|
|
{
|
|
|
|
mIsForBrowser = aIsForBrowser;
|
|
|
|
}
|
2017-05-29 13:38:46 +03:00
|
|
|
void SetIsForJSPlugin(bool aIsForJSPlugin)
|
|
|
|
{
|
|
|
|
mIsForJSPlugin = aIsForJSPlugin;
|
|
|
|
}
|
2014-06-11 09:44:13 +04:00
|
|
|
|
2016-05-05 11:45:00 +03:00
|
|
|
void Close()
|
|
|
|
{
|
2016-05-05 11:45:00 +03:00
|
|
|
// Trick NewRunnableMethod
|
2016-05-05 11:45:00 +03:00
|
|
|
PContentBridgeParent::Close();
|
|
|
|
}
|
|
|
|
|
2014-06-11 09:44:13 +04:00
|
|
|
protected:
|
2016-11-15 06:26:00 +03:00
|
|
|
virtual mozilla::ipc::IPCResult
|
2016-01-05 12:59:30 +03:00
|
|
|
RecvSyncMessage(const nsString& aMsg,
|
|
|
|
const ClonedMessageData& aData,
|
|
|
|
InfallibleTArray<jsipc::CpowEntry>&& aCpows,
|
|
|
|
const IPC::Principal& aPrincipal,
|
|
|
|
nsTArray<StructuredCloneData>* aRetvals) override;
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
virtual mozilla::ipc::IPCResult RecvAsyncMessage(const nsString& aMsg,
|
|
|
|
InfallibleTArray<jsipc::CpowEntry>&& aCpows,
|
|
|
|
const IPC::Principal& aPrincipal,
|
|
|
|
const ClonedMessageData& aData) override;
|
2014-06-11 09:44:13 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual jsipc::PJavaScriptParent* AllocPJavaScriptParent() override;
|
2016-01-05 12:59:30 +03:00
|
|
|
|
2014-06-11 09:44:13 +04:00
|
|
|
virtual bool
|
2015-03-21 19:28:04 +03:00
|
|
|
DeallocPJavaScriptParent(jsipc::PJavaScriptParent*) override;
|
2014-06-11 09:44:13 +04:00
|
|
|
|
|
|
|
virtual PBrowserParent*
|
2014-10-29 21:11:00 +03:00
|
|
|
AllocPBrowserParent(const TabId& aTabId,
|
2017-04-07 02:46:18 +03:00
|
|
|
const TabId& aSameTabGroupAs,
|
2014-10-29 21:11:00 +03:00
|
|
|
const IPCTabContext &aContext,
|
2014-06-11 09:44:13 +04:00
|
|
|
const uint32_t& aChromeFlags,
|
2014-10-24 04:28:00 +04:00
|
|
|
const ContentParentId& aCpID,
|
2015-03-21 19:28:04 +03:00
|
|
|
const bool& aIsForBrowser) override;
|
2016-01-05 12:59:30 +03:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool DeallocPBrowserParent(PBrowserParent*) override;
|
2014-06-11 09:44:13 +04:00
|
|
|
|
2017-03-21 10:44:12 +03:00
|
|
|
virtual mozilla::ipc::IPCResult
|
|
|
|
RecvPBrowserConstructor(PBrowserParent* actor,
|
|
|
|
const TabId& tabId,
|
|
|
|
const TabId& sameTabGroupAs,
|
|
|
|
const IPCTabContext& context,
|
|
|
|
const uint32_t& chromeFlags,
|
|
|
|
const ContentParentId& cpId,
|
|
|
|
const bool& isForBrowser) override;
|
|
|
|
|
Bug 1353629 - PBlob refactoring - part 4 - IPCBlobInputStream, r=smaug
IPCBlobInputStream is a new type of nsIInputStream that is used only in content
process when a Blob is sent from parent to child. This inputStream is for now,
just cloneable.
When the parent process sends a Blob to a content process, it has the Blob and
its inputStream. With its inputStream it creates a IPCBlobInputStreamParent
actor. This actor keeps the inputStream alive for following uses (not part of
this patch).
On the child side we will have, of course, a IPCBlobInputStreamChild actor.
This actor is able to create a IPCBlobInputStream when CreateStream() is
called. This means that 1 IPCBlobInputStreamChild can manage multiple
IPCBlobInputStreams each time one of them is cloned. When the last one of this
stream is released, the child actor sends a __delete__ request to the parent
side; the parent will be deleted, and the original inputStream, on the parent
side, will be released as well.
IPCBlobInputStream is a special inputStream because each method, except for
Available() fails. Basically, this inputStream cannot be used on the content
process for nothing else than knowing the size of the original stream.
In the following patches, I'll introduce an async way to use it.
2017-04-24 13:09:40 +03:00
|
|
|
virtual PIPCBlobInputStreamParent*
|
|
|
|
SendPIPCBlobInputStreamConstructor(PIPCBlobInputStreamParent* aActor,
|
|
|
|
const nsID& aID,
|
|
|
|
const uint64_t& aSize) override;
|
|
|
|
|
|
|
|
virtual PIPCBlobInputStreamParent*
|
|
|
|
AllocPIPCBlobInputStreamParent(const nsID& aID,
|
|
|
|
const uint64_t& aSize) override;
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
DeallocPIPCBlobInputStreamParent(PIPCBlobInputStreamParent*) override;
|
|
|
|
|
2017-03-14 14:28:58 +03:00
|
|
|
virtual PChildToParentStreamParent* AllocPChildToParentStreamParent() override;
|
2016-09-21 13:27:26 +03:00
|
|
|
|
2017-03-14 14:28:58 +03:00
|
|
|
virtual bool
|
|
|
|
DeallocPChildToParentStreamParent(PChildToParentStreamParent* aActor) override;
|
2016-09-21 13:27:26 +03:00
|
|
|
|
2017-03-14 14:29:43 +03:00
|
|
|
virtual mozilla::ipc::PParentToChildStreamParent*
|
|
|
|
AllocPParentToChildStreamParent() override;
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
DeallocPParentToChildStreamParent(mozilla::ipc::PParentToChildStreamParent* aActor) override;
|
|
|
|
|
2016-09-21 13:27:26 +03:00
|
|
|
virtual PFileDescriptorSetParent*
|
|
|
|
AllocPFileDescriptorSetParent(const mozilla::ipc::FileDescriptor&) override;
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
DeallocPFileDescriptorSetParent(PFileDescriptorSetParent*) override;
|
|
|
|
|
2014-06-11 09:44:13 +04:00
|
|
|
DISALLOW_EVIL_CONSTRUCTORS(ContentBridgeParent);
|
|
|
|
|
|
|
|
protected: // members
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<ContentBridgeParent> mSelfRef;
|
2014-10-24 04:28:00 +04:00
|
|
|
ContentParentId mChildID;
|
2014-06-11 09:44:13 +04:00
|
|
|
bool mIsForBrowser;
|
2017-05-29 13:38:46 +03:00
|
|
|
bool mIsForJSPlugin;
|
2014-06-11 09:44:13 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
friend class ContentParent;
|
|
|
|
};
|
|
|
|
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
2014-06-11 09:44:13 +04:00
|
|
|
|
|
|
|
#endif // mozilla_dom_ContentBridgeParent_h
|