2016-05-28 00:54:31 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2013-11-27 11:59:41 +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_ipc_backgroundchildimpl_h__
|
|
|
|
#define mozilla_ipc_backgroundchildimpl_h__
|
|
|
|
|
|
|
|
#include "mozilla/Attributes.h"
|
|
|
|
#include "mozilla/ipc/PBackgroundChild.h"
|
2019-04-26 20:53:07 +03:00
|
|
|
#include "nsRefPtrHashtable.h"
|
2014-10-16 08:56:52 +04:00
|
|
|
#include "nsAutoPtr.h"
|
2014-04-01 06:55:36 +04:00
|
|
|
|
2013-11-27 11:59:41 +04:00
|
|
|
namespace mozilla {
|
2014-09-27 03:21:57 +04:00
|
|
|
namespace dom {
|
2015-09-09 14:15:05 +03:00
|
|
|
|
2017-06-07 13:36:42 +03:00
|
|
|
class IDBFileHandle;
|
2015-09-09 14:15:05 +03:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
namespace indexedDB {
|
|
|
|
|
2014-10-16 08:56:52 +04:00
|
|
|
class ThreadLocal;
|
2014-09-27 03:21:57 +04:00
|
|
|
|
|
|
|
} // namespace indexedDB
|
|
|
|
} // namespace dom
|
|
|
|
|
2013-11-27 11:59:41 +04:00
|
|
|
namespace ipc {
|
|
|
|
|
|
|
|
// Instances of this class should never be created directly. This class is meant
|
|
|
|
// to be inherited in BackgroundImpl.
|
|
|
|
class BackgroundChildImpl : public PBackgroundChild {
|
2014-04-01 06:55:36 +04:00
|
|
|
public:
|
|
|
|
class ThreadLocal;
|
|
|
|
|
|
|
|
// Get the ThreadLocal for the current thread if
|
|
|
|
// BackgroundChild::GetOrCreateForCurrentThread() has been called and true was
|
|
|
|
// returned (e.g. a valid PBackgroundChild actor has been created or is in the
|
|
|
|
// process of being created). Otherwise this function returns null.
|
|
|
|
// This functions is implemented in BackgroundImpl.cpp.
|
|
|
|
static ThreadLocal* GetThreadLocalForCurrentThread();
|
|
|
|
|
2013-11-27 11:59:41 +04:00
|
|
|
protected:
|
|
|
|
BackgroundChildImpl();
|
|
|
|
virtual ~BackgroundChildImpl();
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void ProcessingError(Result aCode, const char* aReason) override;
|
2014-11-20 22:48:18 +03:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void ActorDestroy(ActorDestroyReason aWhy) override;
|
2013-11-27 11:59:41 +04:00
|
|
|
|
|
|
|
virtual PBackgroundTestChild* AllocPBackgroundTestChild(
|
2015-03-21 19:28:04 +03:00
|
|
|
const nsCString& aTestArg) override;
|
2013-11-27 11:59:41 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool DeallocPBackgroundTestChild(
|
|
|
|
PBackgroundTestChild* aActor) override;
|
2014-09-27 03:21:57 +04:00
|
|
|
|
|
|
|
virtual PBackgroundIDBFactoryChild* AllocPBackgroundIDBFactoryChild(
|
2015-03-21 19:28:04 +03:00
|
|
|
const LoggingInfo& aLoggingInfo) override;
|
2014-09-27 03:21:57 +04:00
|
|
|
|
|
|
|
virtual bool DeallocPBackgroundIDBFactoryChild(
|
|
|
|
PBackgroundIDBFactoryChild* aActor) override;
|
|
|
|
|
2015-11-22 12:44:33 +03:00
|
|
|
virtual PBackgroundIndexedDBUtilsChild* AllocPBackgroundIndexedDBUtilsChild()
|
|
|
|
override;
|
|
|
|
|
|
|
|
virtual bool DeallocPBackgroundIndexedDBUtilsChild(
|
|
|
|
PBackgroundIndexedDBUtilsChild* aActor) override;
|
|
|
|
|
2018-08-20 15:33:03 +03:00
|
|
|
virtual PBackgroundSDBConnectionChild* AllocPBackgroundSDBConnectionChild(
|
|
|
|
const PrincipalInfo& aPrincipalInfo) override;
|
|
|
|
|
|
|
|
virtual bool DeallocPBackgroundSDBConnectionChild(
|
|
|
|
PBackgroundSDBConnectionChild* aActor) override;
|
|
|
|
|
2018-11-29 23:48:41 +03:00
|
|
|
virtual PBackgroundLSDatabaseChild* AllocPBackgroundLSDatabaseChild(
|
|
|
|
const PrincipalInfo& aPrincipalInfo, const uint32_t& aPrivateBrowsingId,
|
|
|
|
const uint64_t& aDatastoreId) override;
|
2018-11-29 23:47:20 +03:00
|
|
|
|
2018-11-29 23:48:41 +03:00
|
|
|
virtual bool DeallocPBackgroundLSDatabaseChild(
|
|
|
|
PBackgroundLSDatabaseChild* aActor) override;
|
2018-11-29 23:47:45 +03:00
|
|
|
|
|
|
|
virtual PBackgroundLSObserverChild* AllocPBackgroundLSObserverChild(
|
|
|
|
const uint64_t& aObserverId) override;
|
|
|
|
|
|
|
|
virtual bool DeallocPBackgroundLSObserverChild(
|
|
|
|
PBackgroundLSObserverChild* aActor) override;
|
2018-11-29 23:47:20 +03:00
|
|
|
|
|
|
|
virtual PBackgroundLSRequestChild* AllocPBackgroundLSRequestChild(
|
|
|
|
const LSRequestParams& aParams) override;
|
|
|
|
|
|
|
|
virtual bool DeallocPBackgroundLSRequestChild(
|
|
|
|
PBackgroundLSRequestChild* aActor) override;
|
|
|
|
|
2018-11-29 23:48:15 +03:00
|
|
|
virtual PBackgroundLSSimpleRequestChild* AllocPBackgroundLSSimpleRequestChild(
|
|
|
|
const LSSimpleRequestParams& aParams) override;
|
|
|
|
|
|
|
|
virtual bool DeallocPBackgroundLSSimpleRequestChild(
|
|
|
|
PBackgroundLSSimpleRequestChild* aActor) override;
|
|
|
|
|
2018-07-14 09:34:14 +03:00
|
|
|
virtual PBackgroundLocalStorageCacheChild*
|
|
|
|
AllocPBackgroundLocalStorageCacheChild(
|
|
|
|
const PrincipalInfo& aPrincipalInfo, const nsCString& aOriginKey,
|
|
|
|
const uint32_t& aPrivateBrowsingId) override;
|
|
|
|
|
|
|
|
virtual bool DeallocPBackgroundLocalStorageCacheChild(
|
|
|
|
PBackgroundLocalStorageCacheChild* aActor) override;
|
|
|
|
|
2017-08-08 23:56:49 +03:00
|
|
|
virtual PBackgroundStorageChild* AllocPBackgroundStorageChild(
|
2017-08-09 00:01:52 +03:00
|
|
|
const nsString& aProfilePath) override;
|
2017-08-08 23:56:49 +03:00
|
|
|
|
|
|
|
virtual bool DeallocPBackgroundStorageChild(
|
|
|
|
PBackgroundStorageChild* aActor) override;
|
|
|
|
|
2017-05-09 23:35:27 +03:00
|
|
|
virtual PPendingIPCBlobChild* AllocPPendingIPCBlobChild(
|
|
|
|
const IPCBlob& aBlob) override;
|
|
|
|
|
|
|
|
virtual bool DeallocPPendingIPCBlobChild(
|
|
|
|
PPendingIPCBlobChild* aActor) 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 PIPCBlobInputStreamChild* AllocPIPCBlobInputStreamChild(
|
|
|
|
const nsID& aID, const uint64_t& aSize) override;
|
|
|
|
|
|
|
|
virtual bool DeallocPIPCBlobInputStreamChild(
|
|
|
|
PIPCBlobInputStreamChild* aActor) override;
|
|
|
|
|
2017-10-05 08:41:42 +03:00
|
|
|
virtual PTemporaryIPCBlobChild* AllocPTemporaryIPCBlobChild() override;
|
|
|
|
|
|
|
|
virtual bool DeallocPTemporaryIPCBlobChild(
|
|
|
|
PTemporaryIPCBlobChild* aActor) override;
|
|
|
|
|
2019-04-26 20:53:07 +03:00
|
|
|
virtual PFileCreatorChild* AllocPFileCreatorChild(
|
|
|
|
const nsString& aFullPath, const nsString& aType, const nsString& aName,
|
|
|
|
const Maybe<int64_t>& aLastModified, const bool& aExistenceCheck,
|
|
|
|
const bool& aIsFromNsIFile) override;
|
|
|
|
|
|
|
|
virtual bool DeallocPFileCreatorChild(PFileCreatorChild* aActor) override;
|
|
|
|
|
2018-11-20 02:18:32 +03:00
|
|
|
virtual mozilla::dom::PRemoteWorkerChild* AllocPRemoteWorkerChild(
|
|
|
|
const RemoteWorkerData& aData) override;
|
|
|
|
|
2018-11-20 02:18:33 +03:00
|
|
|
virtual mozilla::ipc::IPCResult RecvPRemoteWorkerConstructor(
|
|
|
|
PRemoteWorkerChild* aActor, const RemoteWorkerData& aData) override;
|
|
|
|
|
2018-11-20 02:18:32 +03:00
|
|
|
virtual bool DeallocPRemoteWorkerChild(
|
|
|
|
mozilla::dom::PRemoteWorkerChild* aActor) override;
|
|
|
|
|
|
|
|
virtual mozilla::dom::PRemoteWorkerServiceChild*
|
|
|
|
AllocPRemoteWorkerServiceChild() override;
|
|
|
|
|
|
|
|
virtual bool DeallocPRemoteWorkerServiceChild(
|
|
|
|
mozilla::dom::PRemoteWorkerServiceChild* aActor) override;
|
|
|
|
|
2018-11-20 02:18:20 +03:00
|
|
|
virtual mozilla::dom::PSharedWorkerChild* AllocPSharedWorkerChild(
|
2018-11-20 02:18:33 +03:00
|
|
|
const mozilla::dom::RemoteWorkerData& aData, const uint64_t& aWindowID,
|
|
|
|
const mozilla::dom::MessagePortIdentifier& aPortIdentifier) override;
|
2018-11-20 02:18:20 +03:00
|
|
|
|
|
|
|
virtual bool DeallocPSharedWorkerChild(
|
|
|
|
mozilla::dom::PSharedWorkerChild* aActor) override;
|
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
virtual PFileDescriptorSetChild* AllocPFileDescriptorSetChild(
|
|
|
|
const FileDescriptor& aFileDescriptor) override;
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool DeallocPFileDescriptorSetChild(
|
|
|
|
PFileDescriptorSetChild* aActor) override;
|
2015-01-14 02:37:00 +03:00
|
|
|
|
2015-08-31 15:51:29 +03:00
|
|
|
virtual PCamerasChild* AllocPCamerasChild() override;
|
|
|
|
|
|
|
|
virtual bool DeallocPCamerasChild(PCamerasChild* aActor) override;
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual PVsyncChild* AllocPVsyncChild() override;
|
2015-01-14 02:37:00 +03:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool DeallocPVsyncChild(PVsyncChild* aActor) override;
|
2015-01-15 19:58:40 +03:00
|
|
|
|
2015-05-29 17:14:14 +03:00
|
|
|
virtual PUDPSocketChild* AllocPUDPSocketChild(
|
2019-03-05 17:41:42 +03:00
|
|
|
const Maybe<PrincipalInfo>& aPrincipalInfo,
|
2015-05-29 17:14:14 +03:00
|
|
|
const nsCString& aFilter) override;
|
|
|
|
virtual bool DeallocPUDPSocketChild(PUDPSocketChild* aActor) override;
|
|
|
|
|
2015-01-15 19:58:40 +03:00
|
|
|
virtual PBroadcastChannelChild* AllocPBroadcastChannelChild(
|
|
|
|
const PrincipalInfo& aPrincipalInfo, const nsCString& aOrigin,
|
2016-06-07 14:50:00 +03:00
|
|
|
const nsString& aChannel) override;
|
2015-01-15 19:58:40 +03:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool DeallocPBroadcastChannelChild(
|
|
|
|
PBroadcastChannelChild* aActor) override;
|
2015-03-02 16:20:00 +03:00
|
|
|
|
2015-06-04 21:51:57 +03:00
|
|
|
virtual PServiceWorkerManagerChild* AllocPServiceWorkerManagerChild()
|
|
|
|
override;
|
|
|
|
|
|
|
|
virtual bool DeallocPServiceWorkerManagerChild(
|
|
|
|
PServiceWorkerManagerChild* aActor) override;
|
|
|
|
|
2015-03-02 16:20:00 +03:00
|
|
|
virtual dom::cache::PCacheStorageChild* AllocPCacheStorageChild(
|
|
|
|
const dom::cache::Namespace& aNamespace,
|
2015-03-21 19:28:04 +03:00
|
|
|
const PrincipalInfo& aPrincipalInfo) override;
|
2015-03-02 16:20:00 +03:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool DeallocPCacheStorageChild(
|
|
|
|
dom::cache::PCacheStorageChild* aActor) override;
|
2015-03-02 16:20:00 +03:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual dom::cache::PCacheChild* AllocPCacheChild() override;
|
2015-03-02 16:20:00 +03:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool DeallocPCacheChild(dom::cache::PCacheChild* aActor) override;
|
2015-03-02 16:20:00 +03:00
|
|
|
|
|
|
|
virtual dom::cache::PCacheStreamControlChild* AllocPCacheStreamControlChild()
|
2015-03-21 19:28:04 +03:00
|
|
|
override;
|
2015-03-02 16:20:00 +03:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool DeallocPCacheStreamControlChild(
|
|
|
|
dom::cache::PCacheStreamControlChild* aActor) override;
|
2015-06-17 13:44:27 +03:00
|
|
|
|
|
|
|
virtual PMessagePortChild* AllocPMessagePortChild(
|
|
|
|
const nsID& aUUID, const nsID& aDestinationUUID,
|
|
|
|
const uint32_t& aSequenceID) override;
|
|
|
|
|
|
|
|
virtual bool DeallocPMessagePortChild(PMessagePortChild* aActor) override;
|
2015-07-31 10:25:27 +03:00
|
|
|
|
2017-03-14 14:28:58 +03:00
|
|
|
virtual PChildToParentStreamChild* AllocPChildToParentStreamChild() override;
|
2016-05-15 20:32:09 +03:00
|
|
|
|
2017-03-14 14:28:58 +03:00
|
|
|
virtual bool DeallocPChildToParentStreamChild(
|
|
|
|
PChildToParentStreamChild* aActor) override;
|
2016-05-15 20:32:09 +03:00
|
|
|
|
2017-03-14 14:29:43 +03:00
|
|
|
virtual PParentToChildStreamChild* AllocPParentToChildStreamChild() override;
|
|
|
|
|
|
|
|
virtual bool DeallocPParentToChildStreamChild(
|
|
|
|
PParentToChildStreamChild* aActor) override;
|
|
|
|
|
2015-11-22 12:43:55 +03:00
|
|
|
virtual PQuotaChild* AllocPQuotaChild() override;
|
|
|
|
|
|
|
|
virtual bool DeallocPQuotaChild(PQuotaChild* aActor) override;
|
2016-04-09 21:17:02 +03:00
|
|
|
|
|
|
|
virtual PFileSystemRequestChild* AllocPFileSystemRequestChild(
|
|
|
|
const FileSystemParams&) override;
|
|
|
|
|
|
|
|
virtual bool DeallocPFileSystemRequestChild(
|
|
|
|
PFileSystemRequestChild*) override;
|
|
|
|
|
2016-06-28 01:25:00 +03:00
|
|
|
// Gamepad API Background IPC
|
|
|
|
virtual PGamepadEventChannelChild* AllocPGamepadEventChannelChild() override;
|
|
|
|
|
|
|
|
virtual bool DeallocPGamepadEventChannelChild(
|
|
|
|
PGamepadEventChannelChild* aActor) override;
|
2016-06-28 01:26:00 +03:00
|
|
|
|
|
|
|
virtual PGamepadTestChannelChild* AllocPGamepadTestChannelChild() override;
|
|
|
|
|
|
|
|
virtual bool DeallocPGamepadTestChannelChild(
|
|
|
|
PGamepadTestChannelChild* aActor) override;
|
2017-05-02 15:10:00 +03:00
|
|
|
|
2017-11-01 20:19:38 +03:00
|
|
|
virtual PClientManagerChild* AllocPClientManagerChild() override;
|
|
|
|
|
|
|
|
virtual bool DeallocPClientManagerChild(PClientManagerChild* aActor) override;
|
|
|
|
|
2017-05-02 15:10:00 +03:00
|
|
|
#ifdef EARLY_BETA_OR_EARLIER
|
|
|
|
virtual void OnChannelReceivedMessage(const Message& aMsg) override;
|
|
|
|
#endif
|
2017-04-20 03:46:08 +03:00
|
|
|
|
|
|
|
virtual PWebAuthnTransactionChild* AllocPWebAuthnTransactionChild() override;
|
|
|
|
|
|
|
|
virtual bool DeallocPWebAuthnTransactionChild(
|
|
|
|
PWebAuthnTransactionChild* aActor) override;
|
2017-05-15 11:01:10 +03:00
|
|
|
|
|
|
|
virtual PHttpBackgroundChannelChild* AllocPHttpBackgroundChannelChild(
|
|
|
|
const uint64_t& aChannelId) override;
|
|
|
|
|
|
|
|
virtual bool DeallocPHttpBackgroundChannelChild(
|
|
|
|
PHttpBackgroundChannelChild* aActor) override;
|
2017-08-09 00:02:28 +03:00
|
|
|
|
2017-11-15 22:18:58 +03:00
|
|
|
virtual PMIDIPortChild* AllocPMIDIPortChild(
|
|
|
|
const MIDIPortInfo& aPortInfo, const bool& aSysexEnabled) override;
|
|
|
|
virtual bool DeallocPMIDIPortChild(PMIDIPortChild*) override;
|
|
|
|
|
|
|
|
virtual PMIDIManagerChild* AllocPMIDIManagerChild() override;
|
|
|
|
virtual bool DeallocPMIDIManagerChild(PMIDIManagerChild*) override;
|
2018-07-10 02:02:39 +03:00
|
|
|
|
|
|
|
virtual PServiceWorkerChild* AllocPServiceWorkerChild(
|
|
|
|
const IPCServiceWorkerDescriptor&) override;
|
|
|
|
|
|
|
|
virtual bool DeallocPServiceWorkerChild(PServiceWorkerChild*) override;
|
|
|
|
|
|
|
|
virtual PServiceWorkerContainerChild* AllocPServiceWorkerContainerChild()
|
|
|
|
override;
|
|
|
|
|
|
|
|
virtual bool DeallocPServiceWorkerContainerChild(
|
|
|
|
PServiceWorkerContainerChild*) override;
|
|
|
|
|
|
|
|
virtual PServiceWorkerRegistrationChild* AllocPServiceWorkerRegistrationChild(
|
|
|
|
const IPCServiceWorkerRegistrationDescriptor&) override;
|
|
|
|
|
|
|
|
virtual bool DeallocPServiceWorkerRegistrationChild(
|
|
|
|
PServiceWorkerRegistrationChild*) override;
|
2018-12-01 23:26:09 +03:00
|
|
|
|
|
|
|
virtual PEndpointForReportChild* AllocPEndpointForReportChild(
|
|
|
|
const nsString& aGroupName, const PrincipalInfo& aPrincipalInfo) override;
|
|
|
|
|
|
|
|
virtual bool DeallocPEndpointForReportChild(
|
|
|
|
PEndpointForReportChild* aActor) override;
|
2013-11-27 11:59:41 +04:00
|
|
|
};
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class BackgroundChildImpl::ThreadLocal final {
|
2014-04-01 06:55:36 +04:00
|
|
|
friend class nsAutoPtr<ThreadLocal>;
|
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
public:
|
2014-10-16 08:56:52 +04:00
|
|
|
nsAutoPtr<mozilla::dom::indexedDB::ThreadLocal> mIndexedDBThreadLocal;
|
2017-06-07 13:36:42 +03:00
|
|
|
mozilla::dom::IDBFileHandle* mCurrentFileHandle;
|
2014-04-01 06:55:36 +04:00
|
|
|
|
|
|
|
public:
|
|
|
|
ThreadLocal();
|
|
|
|
|
|
|
|
private:
|
|
|
|
// Only destroyed by nsAutoPtr<ThreadLocal>.
|
|
|
|
~ThreadLocal();
|
|
|
|
};
|
|
|
|
|
2013-11-27 11:59:41 +04:00
|
|
|
} // namespace ipc
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_ipc_backgroundchildimpl_h__
|