Skip to content

Commit

Permalink
Bug 1773770: Part 7 - Migrate PowerManagerService to static component…
Browse files Browse the repository at this point in the history
… registration. r=mccr8

Differential Revision: https://phabricator.services.mozilla.com/D149434
  • Loading branch information
kmaglione committed Jun 23, 2022
1 parent 5c8f3b9 commit 48fc593
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 35 deletions.
32 changes: 0 additions & 32 deletions dom/power/PowerManagerService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,35 +136,3 @@ PowerManagerService::NewWakeLock(const nsAString& aTopic,
}

} // namespace mozilla::dom::power

NS_DEFINE_NAMED_CID(NS_POWERMANAGERSERVICE_CID);

NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(
nsIPowerManagerService,
mozilla::dom::power::PowerManagerService::GetInstance)

static const mozilla::Module::CIDEntry kPowerManagerCIDs[] = {
// clang-format off
{ &kNS_POWERMANAGERSERVICE_CID, false, nullptr, nsIPowerManagerServiceConstructor, mozilla::Module::ALLOW_IN_GPU_RDD_AND_SOCKET_PROCESS },
{ nullptr }
// clang-format on
};

static const mozilla::Module::ContractIDEntry kPowerManagerContracts[] = {
// clang-format off
{ POWERMANAGERSERVICE_CONTRACTID, &kNS_POWERMANAGERSERVICE_CID, mozilla::Module::ALLOW_IN_GPU_RDD_AND_SOCKET_PROCESS },
{ nullptr }
// clang-format on
};

// We mark the power module as being available in the GPU process because the
// appshell depends on the power manager service.
extern const mozilla::Module kPowerManagerModule = {
mozilla::Module::kVersion,
kPowerManagerCIDs,
kPowerManagerContracts,
nullptr,
nullptr,
nullptr,
nullptr,
mozilla::Module::ALLOW_IN_GPU_RDD_AND_SOCKET_PROCESS};
17 changes: 17 additions & 0 deletions dom/power/components.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# 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/.

Classes = [
{
'cid': '{18c2e238-3a0a-4153-89fc-166b3b1465a1}',
'contract_ids': ['@mozilla.org/power/powermanagerservice;1'],
'type': 'mozilla::dom::power::PowerManagerService',
'constructor': 'mozilla::dom::power::PowerManagerService::GetInstance',
'headers': ['mozilla/dom/power/PowerManagerService.h'],
'singleton': True,
'processes': ProcessSelector.ALLOW_IN_GPU_RDD_AND_SOCKET_PROCESS,
},
]
4 changes: 4 additions & 0 deletions dom/power/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ XPIDL_SOURCES += [

XPIDL_MODULE = "dom_power"

XPCOM_MANIFESTS += [
"components.conf",
]

EXPORTS.mozilla.dom += [
"WakeLock.h",
]
Expand Down
1 change: 0 additions & 1 deletion dom/power/nsIPowerManagerService.idl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include "nsISupports.idl"

%{C++
#define NS_POWERMANAGERSERVICE_CID { 0x18c2e238, 0x3a0a, 0x4153, {0x89, 0xfc, 0x16, 0x6b, 0x3b, 0x14, 0x65, 0xa1 } }
#define POWERMANAGERSERVICE_CONTRACTID "@mozilla.org/power/powermanagerservice;1"
%}

Expand Down
2 changes: 0 additions & 2 deletions xpcom/components/nsComponentManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,6 @@ nsComponentManagerImpl::nsComponentManagerImpl()
mLock("nsComponentManagerImpl.mLock"),
mStatus(NOT_INITIALIZED) {}

extern const mozilla::Module kPowerManagerModule;
extern const mozilla::Module kContentProcessWidgetModule;
#if defined(MOZ_WIDGET_COCOA) || defined(MOZ_WIDGET_UIKIT)
extern const mozilla::Module kWidgetModule;
Expand Down Expand Up @@ -360,7 +359,6 @@ nsresult nsComponentManagerImpl::Init() {

nsCategoryManager::GetSingleton()->SuppressNotifications(true);

RegisterModule(&kPowerManagerModule);
RegisterModule(&kContentProcessWidgetModule);
#if defined(MOZ_WIDGET_COCOA) || defined(MOZ_WIDGET_UIKIT)
RegisterModule(&kWidgetModule);
Expand Down

0 comments on commit 48fc593

Please sign in to comment.