mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-20 00:35:44 +00:00
Bug 1415779
P2 Add ClientManagerService and reference it from parent actors. r=baku
This commit is contained in:
parent
b0316788f6
commit
4641badb26
@ -7,6 +7,7 @@
|
||||
#include "ClientHandleParent.h"
|
||||
|
||||
#include "ClientHandleOpParent.h"
|
||||
#include "ClientManagerService.h"
|
||||
#include "ClientSourceParent.h"
|
||||
#include "mozilla/dom/ClientIPCTypes.h"
|
||||
#include "mozilla/Unused.h"
|
||||
@ -51,6 +52,7 @@ ClientHandleParent::RecvPClientHandleOpConstructor(PClientHandleOpParent* aActor
|
||||
}
|
||||
|
||||
ClientHandleParent::ClientHandleParent()
|
||||
: mService(ClientManagerService::GetOrCreateInstance())
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -11,8 +11,12 @@
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class ClientManagerService;
|
||||
|
||||
class ClientHandleParent final : public PClientHandleParent
|
||||
{
|
||||
RefPtr<ClientManagerService> mService;
|
||||
|
||||
// PClientHandleParent interface
|
||||
mozilla::ipc::IPCResult
|
||||
RecvTeardown() override;
|
||||
|
@ -14,6 +14,12 @@ ClientManagerOpParent::ActorDestroy(ActorDestroyReason aReason)
|
||||
{
|
||||
}
|
||||
|
||||
ClientManagerOpParent::ClientManagerOpParent(ClientManagerService* aService)
|
||||
: mService(aService)
|
||||
{
|
||||
MOZ_DIAGNOSTIC_ASSERT(mService);
|
||||
}
|
||||
|
||||
void
|
||||
ClientManagerOpParent::Init(const ClientOpConstructorArgs& aArgs)
|
||||
{
|
||||
|
@ -15,12 +15,14 @@ class ClientManagerService;
|
||||
|
||||
class ClientManagerOpParent final : public PClientManagerOpParent
|
||||
{
|
||||
RefPtr<ClientManagerService> mService;
|
||||
|
||||
// PClientManagerOpParent interface
|
||||
void
|
||||
ActorDestroy(ActorDestroyReason aReason) override;
|
||||
|
||||
public:
|
||||
ClientManagerOpParent() = default;
|
||||
explicit ClientManagerOpParent(ClientManagerService* aService);
|
||||
~ClientManagerOpParent() = default;
|
||||
|
||||
void
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
#include "ClientHandleParent.h"
|
||||
#include "ClientManagerOpParent.h"
|
||||
#include "ClientManagerService.h"
|
||||
#include "ClientSourceParent.h"
|
||||
#include "mozilla/dom/PClientNavigateOpParent.h"
|
||||
#include "mozilla/Unused.h"
|
||||
@ -54,7 +55,7 @@ ClientManagerParent::RecvPClientHandleConstructor(PClientHandleParent* aActor,
|
||||
PClientManagerOpParent*
|
||||
ClientManagerParent::AllocPClientManagerOpParent(const ClientOpConstructorArgs& aArgs)
|
||||
{
|
||||
return new ClientManagerOpParent();
|
||||
return new ClientManagerOpParent(mService);
|
||||
}
|
||||
|
||||
bool
|
||||
@ -101,6 +102,7 @@ ClientManagerParent::DeallocPClientSourceParent(PClientSourceParent* aActor)
|
||||
}
|
||||
|
||||
ClientManagerParent::ClientManagerParent()
|
||||
: mService(ClientManagerService::GetOrCreateInstance())
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -11,8 +11,12 @@
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class ClientManagerService;
|
||||
|
||||
class ClientManagerParent final : public PClientManagerParent
|
||||
{
|
||||
RefPtr<ClientManagerService> mService;
|
||||
|
||||
// PClientManagerParent interface
|
||||
mozilla::ipc::IPCResult
|
||||
RecvTeardown() override;
|
||||
|
50
dom/clients/manager/ClientManagerService.cpp
Normal file
50
dom/clients/manager/ClientManagerService.cpp
Normal file
@ -0,0 +1,50 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* 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/. */
|
||||
|
||||
#include "ClientManagerService.h"
|
||||
|
||||
#include "mozilla/ipc/BackgroundParent.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
using mozilla::ipc::AssertIsOnBackgroundThread;
|
||||
|
||||
namespace {
|
||||
|
||||
ClientManagerService* sClientManagerServiceInstance = nullptr;
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
ClientManagerService::ClientManagerService()
|
||||
{
|
||||
AssertIsOnBackgroundThread();
|
||||
}
|
||||
|
||||
ClientManagerService::~ClientManagerService()
|
||||
{
|
||||
AssertIsOnBackgroundThread();
|
||||
|
||||
MOZ_DIAGNOSTIC_ASSERT(sClientManagerServiceInstance == this);
|
||||
sClientManagerServiceInstance = nullptr;
|
||||
}
|
||||
|
||||
// static
|
||||
already_AddRefed<ClientManagerService>
|
||||
ClientManagerService::GetOrCreateInstance()
|
||||
{
|
||||
AssertIsOnBackgroundThread();
|
||||
|
||||
if (!sClientManagerServiceInstance) {
|
||||
sClientManagerServiceInstance = new ClientManagerService();
|
||||
}
|
||||
|
||||
RefPtr<ClientManagerService> ref(sClientManagerServiceInstance);
|
||||
return ref.forget();
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
31
dom/clients/manager/ClientManagerService.h
Normal file
31
dom/clients/manager/ClientManagerService.h
Normal file
@ -0,0 +1,31 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* 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_ClientManagerService_h
|
||||
#define _mozilla_dom_ClientManagerService_h
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
namespace dom {
|
||||
|
||||
// Define a singleton service to manage client activity throughout the
|
||||
// browser. This service runs on the PBackground thread. To interact
|
||||
// it with it please use the ClientManager and ClientHandle classes.
|
||||
class ClientManagerService final
|
||||
{
|
||||
ClientManagerService();
|
||||
~ClientManagerService();
|
||||
|
||||
public:
|
||||
static already_AddRefed<ClientManagerService>
|
||||
GetOrCreateInstance();
|
||||
|
||||
NS_INLINE_DECL_REFCOUNTING(mozilla::dom::ClientManagerService)
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // _mozilla_dom_ClientManagerService_h
|
@ -7,6 +7,7 @@
|
||||
#include "ClientSourceParent.h"
|
||||
|
||||
#include "ClientHandleParent.h"
|
||||
#include "ClientManagerService.h"
|
||||
#include "ClientSourceOpParent.h"
|
||||
#include "mozilla/dom/ClientIPCTypes.h"
|
||||
#include "mozilla/Unused.h"
|
||||
@ -44,6 +45,7 @@ ClientSourceParent::DeallocPClientSourceOpParent(PClientSourceOpParent* aActor)
|
||||
}
|
||||
|
||||
ClientSourceParent::ClientSourceParent(const ClientSourceConstructorArgs& aArgs)
|
||||
: mService(ClientManagerService::GetOrCreateInstance())
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -11,8 +11,12 @@
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class ClientManagerService;
|
||||
|
||||
class ClientSourceParent final : public PClientSourceParent
|
||||
{
|
||||
RefPtr<ClientManagerService> mService;
|
||||
|
||||
// PClientSourceParent
|
||||
IPCResult
|
||||
RecvTeardown() override;
|
||||
|
@ -27,6 +27,7 @@ UNIFIED_SOURCES += [
|
||||
'ClientManagerOpChild.cpp',
|
||||
'ClientManagerOpParent.cpp',
|
||||
'ClientManagerParent.cpp',
|
||||
'ClientManagerService.cpp',
|
||||
'ClientNavigateOpChild.cpp',
|
||||
'ClientNavigateOpParent.cpp',
|
||||
'ClientOpenWindowOpActors.cpp',
|
||||
|
Loading…
Reference in New Issue
Block a user