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"
|
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();
|
|
|
|
|
2014-11-20 22:48:18 +03:00
|
|
|
virtual void
|
2015-03-21 19:28:04 +03:00
|
|
|
ProcessingError(Result aCode, const char* aReason) override;
|
2014-11-20 22:48:18 +03:00
|
|
|
|
2013-11-27 11:59:41 +04:00
|
|
|
virtual void
|
2015-03-21 19:28:04 +03:00
|
|
|
ActorDestroy(ActorDestroyReason aWhy) override;
|
2013-11-27 11:59:41 +04:00
|
|
|
|
|
|
|
virtual PBackgroundTestChild*
|
2015-03-21 19:28:04 +03:00
|
|
|
AllocPBackgroundTestChild(const nsCString& aTestArg) override;
|
2013-11-27 11:59:41 +04:00
|
|
|
|
|
|
|
virtual bool
|
2015-03-21 19:28:04 +03:00
|
|
|
DeallocPBackgroundTestChild(PBackgroundTestChild* aActor) override;
|
2014-09-27 03:21:57 +04:00
|
|
|
|
|
|
|
virtual PBackgroundIDBFactoryChild*
|
2015-03-21 19:28:04 +03:00
|
|
|
AllocPBackgroundIDBFactoryChild(const LoggingInfo& aLoggingInfo) override;
|
2014-09-27 03:21:57 +04:00
|
|
|
|
|
|
|
virtual bool
|
|
|
|
DeallocPBackgroundIDBFactoryChild(PBackgroundIDBFactoryChild* aActor)
|
2015-03-21 19:28:04 +03:00
|
|
|
override;
|
2014-09-27 03:21:57 +04:00
|
|
|
|
2015-11-22 12:44:33 +03:00
|
|
|
virtual PBackgroundIndexedDBUtilsChild*
|
|
|
|
AllocPBackgroundIndexedDBUtilsChild() override;
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
DeallocPBackgroundIndexedDBUtilsChild(PBackgroundIndexedDBUtilsChild* aActor)
|
|
|
|
override;
|
|
|
|
|
2017-08-08 23:56:49 +03:00
|
|
|
virtual PBackgroundStorageChild*
|
2017-08-09 00:01:52 +03:00
|
|
|
AllocPBackgroundStorageChild(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;
|
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
virtual PFileDescriptorSetChild*
|
|
|
|
AllocPFileDescriptorSetChild(const FileDescriptor& aFileDescriptor)
|
2015-03-21 19:28:04 +03:00
|
|
|
override;
|
2014-09-27 03:21:57 +04:00
|
|
|
|
|
|
|
virtual bool
|
2015-03-21 19:28:04 +03:00
|
|
|
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-01-14 02:37:00 +03:00
|
|
|
virtual PVsyncChild*
|
2015-03-21 19:28:04 +03:00
|
|
|
AllocPVsyncChild() override;
|
2015-01-14 02:37:00 +03:00
|
|
|
|
|
|
|
virtual bool
|
2015-03-21 19:28:04 +03:00
|
|
|
DeallocPVsyncChild(PVsyncChild* aActor) override;
|
2015-01-15 19:58:40 +03:00
|
|
|
|
2015-05-29 17:14:14 +03:00
|
|
|
virtual PUDPSocketChild*
|
|
|
|
AllocPUDPSocketChild(const OptionalPrincipalInfo& aPrincipalInfo,
|
|
|
|
const nsCString& aFilter) override;
|
|
|
|
virtual bool
|
|
|
|
DeallocPUDPSocketChild(PUDPSocketChild* aActor) override;
|
|
|
|
|
2015-01-15 19:58:40 +03:00
|
|
|
virtual PBroadcastChannelChild*
|
|
|
|
AllocPBroadcastChannelChild(const PrincipalInfo& aPrincipalInfo,
|
2015-07-06 21:28:41 +03:00
|
|
|
const nsCString& aOrigin,
|
2016-06-07 14:50:00 +03:00
|
|
|
const nsString& aChannel) override;
|
2015-01-15 19:58:40 +03:00
|
|
|
|
|
|
|
virtual bool
|
2015-03-21 19:28:04 +03:00
|
|
|
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
|
|
|
|
|
|
|
virtual bool
|
2015-03-21 19:28:04 +03:00
|
|
|
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
|
|
|
|
|
|
|
virtual bool
|
2015-03-21 19:28:04 +03:00
|
|
|
DeallocPCacheChild(dom::cache::PCacheChild* aActor) override;
|
2015-03-02 16:20:00 +03:00
|
|
|
|
|
|
|
virtual dom::cache::PCacheStreamControlChild*
|
2015-03-21 19:28:04 +03:00
|
|
|
AllocPCacheStreamControlChild() override;
|
2015-03-02 16:20:00 +03:00
|
|
|
|
|
|
|
virtual bool
|
2015-03-21 19:28:04 +03:00
|
|
|
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
|
|
|
|
|
|
|
virtual bool
|
2017-03-14 14:28:58 +03:00
|
|
|
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-08-29 08:45:04 +03:00
|
|
|
virtual PAsmJSCacheEntryChild*
|
|
|
|
AllocPAsmJSCacheEntryChild(const dom::asmjscache::OpenMode& aOpenMode,
|
|
|
|
const dom::asmjscache::WriteParams& aWriteParams,
|
|
|
|
const PrincipalInfo& aPrincipalInfo) override;
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
DeallocPAsmJSCacheEntryChild(PAsmJSCacheEntryChild* 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
|
|
|
|
|
|
|
virtual mozilla::ipc::IPCResult
|
|
|
|
RecvDispatchLocalStorageChange(const nsString& aDocumentURI,
|
|
|
|
const nsString& aKey,
|
|
|
|
const nsString& aOldValue,
|
|
|
|
const nsString& aNewValue,
|
|
|
|
const PrincipalInfo& aPrincipalInfo,
|
|
|
|
const bool& aIsPrivate) override;
|
2017-07-20 02:23:01 +03:00
|
|
|
|
|
|
|
bool
|
2017-09-13 06:59:35 +03:00
|
|
|
GetMessageSchedulerGroups(const Message& aMsg, SchedulerGroupSet& aGroups) override;
|
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;
|
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__
|