Bug 1645982 - Rename some service getters in `Services.py` to better match the types. r=froydnj

Differential Revision: https://phabricator.services.mozilla.com/D79791
This commit is contained in:
Nicholas Nethercote 2020-06-16 23:32:21 +00:00
Родитель 5ae8a2d95b
Коммит a8f5f49b8a
29 изменённых файлов: 51 добавлений и 49 удалений

Просмотреть файл

@ -119,8 +119,7 @@ nsChromeProtocolHandler::NewChannel(nsIURI* aURI, nsILoadInfo* aLoadInfo,
if (!nsChromeRegistry::gChromeRegistry) {
// We don't actually want this ref, we just want the service to
// initialize if it hasn't already.
nsCOMPtr<nsIChromeRegistry> reg =
mozilla::services::GetChromeRegistryService();
nsCOMPtr<nsIChromeRegistry> reg = mozilla::services::GetChromeRegistry();
NS_ENSURE_TRUE(nsChromeRegistry::gChromeRegistry, NS_ERROR_FAILURE);
}

Просмотреть файл

@ -11104,7 +11104,7 @@ void nsDocShell::SaveLastVisit(nsIChannel* aChannel, nsIURI* aURI,
return;
}
nsCOMPtr<IHistory> history = services::GetHistoryService();
nsCOMPtr<IHistory> history = services::GetHistory();
if (history) {
uint32_t visitURIFlags = 0;
@ -12241,7 +12241,7 @@ void nsDocShell::UpdateGlobalHistoryTitle(nsIURI* aURI) {
return;
}
if (nsCOMPtr<IHistory> history = services::GetHistoryService()) {
if (nsCOMPtr<IHistory> history = services::GetHistory()) {
history->SetURITitle(aURI, mTitle);
}
}

Просмотреть файл

@ -15417,7 +15417,7 @@ class UserIntractionTimer final : public Runnable,
}
static already_AddRefed<nsIAsyncShutdownClient> GetShutdownPhase() {
nsCOMPtr<nsIAsyncShutdownService> svc = services::GetAsyncShutdown();
nsCOMPtr<nsIAsyncShutdownService> svc = services::GetAsyncShutdownService();
NS_ENSURE_TRUE(!!svc, nullptr);
nsCOMPtr<nsIAsyncShutdownClient> phase;

Просмотреть файл

@ -140,7 +140,7 @@ EventStates Link::LinkState() const {
// Make sure the href attribute has a valid link (bug 23209).
// If we have a good href, register with History if available.
if (mHistory && hrefURI) {
if (nsCOMPtr<IHistory> history = services::GetHistoryService()) {
if (nsCOMPtr<IHistory> history = services::GetHistory()) {
self->mRegistered = true;
history->RegisterVisitedCallback(hrefURI, self);
// And make sure we are in the document's link map.
@ -552,7 +552,7 @@ void Link::UnregisterFromHistory() {
// And tell History to stop tracking us.
if (mHistory && mCachedURI) {
if (nsCOMPtr<IHistory> history = services::GetHistoryService()) {
if (nsCOMPtr<IHistory> history = services::GetHistory()) {
history->UnregisterVisitedCallback(mCachedURI, this);
mRegistered = false;
}

Просмотреть файл

@ -75,7 +75,8 @@ RefPtr<GenericPromise> OnShutdown() {
nsCOMPtr<nsIRunnable> r =
NS_NewRunnableFunction("ClientManagerServer::OnShutdown", [ref]() {
nsCOMPtr<nsIAsyncShutdownService> svc = services::GetAsyncShutdown();
nsCOMPtr<nsIAsyncShutdownService> svc =
services::GetAsyncShutdownService();
if (!svc) {
ref->Resolve(true, __func__);
return;

Просмотреть файл

@ -492,7 +492,7 @@ class ReleasingTimerHolder final : public Runnable,
}
static nsCOMPtr<nsIAsyncShutdownClient> GetShutdownPhase() {
nsCOMPtr<nsIAsyncShutdownService> svc = services::GetAsyncShutdown();
nsCOMPtr<nsIAsyncShutdownService> svc = services::GetAsyncShutdownService();
NS_ENSURE_TRUE(!!svc, nullptr);
nsCOMPtr<nsIAsyncShutdownClient> phase;

Просмотреть файл

@ -3963,7 +3963,7 @@ mozilla::ipc::IPCResult BrowserParent::RecvVisitURI(nsIURI* aURI,
if (NS_WARN_IF(!widget)) {
return IPC_OK();
}
nsCOMPtr<IHistory> history = services::GetHistoryService();
nsCOMPtr<IHistory> history = services::GetHistory();
if (history) {
Unused << history->VisitURI(widget, aURI, aLastVisitedURI, aFlags);
}
@ -3973,7 +3973,7 @@ mozilla::ipc::IPCResult BrowserParent::RecvVisitURI(nsIURI* aURI,
mozilla::ipc::IPCResult BrowserParent::RecvQueryVisitedState(
const nsTArray<RefPtr<nsIURI>>&& aURIs) {
#ifdef MOZ_ANDROID_HISTORY
nsCOMPtr<IHistory> history = services::GetHistoryService();
nsCOMPtr<IHistory> history = services::GetHistory();
if (NS_WARN_IF(!history)) {
return IPC_OK();
}

Просмотреть файл

@ -2282,7 +2282,7 @@ mozilla::ipc::IPCResult ContentChild::RecvNotifyAlertsObserver(
// touch pages. See GetSpecificMessageEventTarget.
mozilla::ipc::IPCResult ContentChild::RecvNotifyVisited(
nsTArray<VisitedQueryResult>&& aURIs) {
nsCOMPtr<IHistory> history = services::GetHistoryService();
nsCOMPtr<IHistory> history = services::GetHistory();
if (!history) {
return IPC_OK();
}

Просмотреть файл

@ -3122,7 +3122,7 @@ static StaticRefPtr<nsIAsyncShutdownClient> sProfileBeforeChangeClient;
static void InitClients() {
if (!sXPCOMShutdownClient) {
nsresult rv;
nsCOMPtr<nsIAsyncShutdownService> svc = services::GetAsyncShutdown();
nsCOMPtr<nsIAsyncShutdownService> svc = services::GetAsyncShutdownService();
nsCOMPtr<nsIAsyncShutdownClient> client;
rv = svc->GetXpcomWillShutdown(getter_AddRefs(client));
@ -3934,7 +3934,7 @@ mozilla::ipc::IPCResult ContentParent::RecvPSpeechSynthesisConstructor(
mozilla::ipc::IPCResult ContentParent::RecvStartVisitedQueries(
const nsTArray<RefPtr<nsIURI>>& aUris) {
nsCOMPtr<IHistory> history = services::GetHistoryService();
nsCOMPtr<IHistory> history = services::GetHistory();
if (!history) {
return IPC_OK();
}
@ -3952,7 +3952,7 @@ mozilla::ipc::IPCResult ContentParent::RecvSetURITitle(nsIURI* uri,
if (!uri) {
return IPC_FAIL_NO_REASON(this);
}
nsCOMPtr<IHistory> history = services::GetHistoryService();
nsCOMPtr<IHistory> history = services::GetHistory();
if (history) {
history->SetURITitle(uri, title);
}

Просмотреть файл

@ -47,7 +47,7 @@ MediaShutdownManager& MediaShutdownManager::Instance() {
}
static nsCOMPtr<nsIAsyncShutdownClient> GetShutdownBarrier() {
nsCOMPtr<nsIAsyncShutdownService> svc = services::GetAsyncShutdown();
nsCOMPtr<nsIAsyncShutdownService> svc = services::GetAsyncShutdownService();
MOZ_RELEASE_ASSERT(svc);
nsCOMPtr<nsIAsyncShutdownClient> barrier;

Просмотреть файл

@ -1499,7 +1499,7 @@ static bool IsNodeIdValid(GMPParent* aParent) {
}
static nsCOMPtr<nsIAsyncShutdownClient> GetShutdownBarrier() {
nsCOMPtr<nsIAsyncShutdownService> svc = services::GetAsyncShutdown();
nsCOMPtr<nsIAsyncShutdownService> svc = services::GetAsyncShutdownService();
MOZ_RELEASE_ASSERT(svc);
nsCOMPtr<nsIAsyncShutdownClient> barrier;

Просмотреть файл

@ -221,7 +221,7 @@ nsString MediaStatusManager::GetDefaultFaviconURL() const {
// Convert URI from `chrome://XXX` to `file://XXX` because we would like to
// let OS related frameworks, such as SMTC and MPRIS, handle this URL in order
// to show the icon on virtual controller interface.
nsCOMPtr<nsIChromeRegistry> regService = services::GetChromeRegistryService();
nsCOMPtr<nsIChromeRegistry> regService = services::GetChromeRegistry();
if (!regService) {
return EmptyString();
}

Просмотреть файл

@ -10,7 +10,7 @@ namespace mozilla {
namespace media {
RefPtr<nsIAsyncShutdownClient> GetShutdownBarrier() {
nsCOMPtr<nsIAsyncShutdownService> svc = services::GetAsyncShutdown();
nsCOMPtr<nsIAsyncShutdownService> svc = services::GetAsyncShutdownService();
MOZ_RELEASE_ASSERT(svc);
RefPtr<nsIAsyncShutdownClient> barrier;

Просмотреть файл

@ -1851,7 +1851,7 @@ static void WatchRegKey(uint32_t aRoot, nsCOMPtr<nsIWindowsRegKey>& aKey) {
already_AddRefed<nsIAsyncShutdownClient> GetProfileChangeTeardownPhase() {
nsCOMPtr<nsIAsyncShutdownService> asyncShutdownSvc =
services::GetAsyncShutdown();
services::GetAsyncShutdownService();
MOZ_ASSERT(asyncShutdownSvc);
if (NS_WARN_IF(!asyncShutdownSvc)) {
return nullptr;

Просмотреть файл

@ -255,7 +255,7 @@ already_AddRefed<nsIAsyncShutdownClient> GetAsyncShutdownBarrier() {
return nullptr;
}
nsCOMPtr<nsIAsyncShutdownService> svc = services::GetAsyncShutdown();
nsCOMPtr<nsIAsyncShutdownService> svc = services::GetAsyncShutdownService();
MOZ_ASSERT(svc);
nsCOMPtr<nsIAsyncShutdownClient> barrier;

Просмотреть файл

@ -122,7 +122,7 @@ Result<Ok, nsresult> URLPreloader::InitInternal() {
mResProto = do_QueryInterface(ph, &rv);
MOZ_TRY(rv);
mChromeReg = services::GetChromeRegistryService();
mChromeReg = services::GetChromeRegistry();
if (!mChromeReg) {
return Err(NS_ERROR_UNEXPECTED);
}

Просмотреть файл

@ -352,7 +352,7 @@ mozilla::ipc::IPCResult
SocketProcessChild::RecvOnHttpActivityDistributorActivated(
const bool& aIsActivated) {
if (nsCOMPtr<nsIHttpActivityObserver> distributor =
services::GetActivityDistributor()) {
services::GetHttpActivityDistributor()) {
distributor->SetIsActive(aIsActivated);
}
return IPC_OK();

Просмотреть файл

@ -256,7 +256,7 @@ mozilla::ipc::IPCResult SocketProcessParent::RecvObserveHttpActivity(
const uint32_t& aActivitySubtype, const PRTime& aTimestamp,
const uint64_t& aExtraSizeData, const nsCString& aExtraStringData) {
nsCOMPtr<nsIHttpActivityDistributor> activityDistributor =
services::GetActivityDistributor();
services::GetHttpActivityDistributor();
MOZ_ASSERT(activityDistributor);
Unused << activityDistributor->ObserveActivityWithArgs(

Просмотреть файл

@ -272,7 +272,7 @@ nsresult nsHttpTransaction::Init(
mTrafficCategory = trafficCategory;
mActivityDistributor = services::GetActivityDistributor();
mActivityDistributor = services::GetHttpActivityDistributor();
if (!mActivityDistributor) {
return NS_ERROR_NOT_AVAILABLE;
}

Просмотреть файл

@ -1033,7 +1033,7 @@ fn do_construct_cert_storage(
}
fn read_int_pref(name: &str) -> Result<u32, SecurityStateError> {
let pref_service = match xpcom::services::get_PreferencesService() {
let pref_service = match xpcom::services::get_PrefService() {
Some(ps) => ps,
_ => {
return Err(SecurityStateError::from(
@ -1213,7 +1213,7 @@ impl CertStorage {
];
// Fetch add observers for relevant prefs
let pref_service = xpcom::services::get_PreferencesService().unwrap();
let pref_service = xpcom::services::get_PrefService().unwrap();
let prefs: RefPtr<nsIPrefBranch> = match (*pref_service).query_interface() {
Some(pb) => pb,
_ => return Err(SecurityStateError::from("could not QI to nsIPrefBranch")),

Просмотреть файл

@ -156,7 +156,7 @@ nsresult ResolveURI(nsIURI* in, nsIURI** out) {
return ioService->NewURI(spec, nullptr, nullptr, out);
} else if (in->SchemeIs("chrome")) {
nsCOMPtr<nsIChromeRegistry> chromeReg =
mozilla::services::GetChromeRegistryService();
mozilla::services::GetChromeRegistry();
if (!chromeReg) return NS_ERROR_UNEXPECTED;
return chromeReg->ConvertChromeURL(in, out);

Просмотреть файл

@ -126,7 +126,7 @@ struct InitUploadPrefObserver {}
#[allow(non_snake_case)]
impl UploadPrefObserver {
unsafe fn begin_observing(&self) -> Result<(), nsresult> {
let pref_service = xpcom::services::get_PreferencesService().ok_or(NS_ERROR_FAILURE)?;
let pref_service = xpcom::services::get_PrefService().ok_or(NS_ERROR_FAILURE)?;
let pref_branch: RefPtr<nsIPrefBranch> =
(*pref_service).query_interface().ok_or(NS_ERROR_FAILURE)?;
let pref_nscstr = &nsCStr::from("datareporting.healthreport.uploadEnabled") as &nsACString;

Просмотреть файл

@ -378,7 +378,7 @@ Database::Database()
already_AddRefed<nsIAsyncShutdownClient>
Database::GetProfileChangeTeardownPhase() {
nsCOMPtr<nsIAsyncShutdownService> asyncShutdownSvc =
services::GetAsyncShutdown();
services::GetAsyncShutdownService();
MOZ_ASSERT(asyncShutdownSvc);
if (NS_WARN_IF(!asyncShutdownSvc)) {
return nullptr;
@ -395,7 +395,7 @@ Database::GetProfileChangeTeardownPhase() {
already_AddRefed<nsIAsyncShutdownClient>
Database::GetProfileBeforeChangePhase() {
nsCOMPtr<nsIAsyncShutdownService> asyncShutdownSvc =
services::GetAsyncShutdown();
services::GetAsyncShutdownService();
MOZ_ASSERT(asyncShutdownSvc);
if (NS_WARN_IF(!asyncShutdownSvc)) {
return nullptr;

Просмотреть файл

@ -1738,7 +1738,7 @@ History* History::GetService() {
return gService;
}
nsCOMPtr<IHistory> service = services::GetHistoryService();
nsCOMPtr<IHistory> service = services::GetHistory();
if (service) {
NS_ASSERTION(gService, "Our constructor was not run?!");
}

Просмотреть файл

@ -23,7 +23,7 @@ PlacesShutdownBlocker::PlacesShutdownBlocker(const nsString& aName)
// Create a barrier that will be exposed to clients through GetClient(), so
// they can block Places shutdown.
nsCOMPtr<nsIAsyncShutdownService> asyncShutdown =
services::GetAsyncShutdown();
services::GetAsyncShutdownService();
MOZ_ASSERT(asyncShutdown);
if (asyncShutdown) {
nsCOMPtr<nsIAsyncShutdownBarrier> barrier;

Просмотреть файл

@ -164,10 +164,10 @@ fn observe_profile_change() {
}
fn in_safe_mode() -> XULStoreResult<bool> {
let app_info_svc = xpcom::services::get_AppInfoService().ok_or(XULStoreError::Unavailable)?;
let xul_runtime = xpcom::services::get_XULRuntime().ok_or(XULStoreError::Unavailable)?;
let mut in_safe_mode = false;
unsafe {
app_info_svc.GetInSafeMode(&mut in_safe_mode).to_result()?;
xul_runtime.GetInSafeMode(&mut in_safe_mode).to_result()?;
}
Ok(in_safe_mode)
}

Просмотреть файл

@ -13,11 +13,15 @@ def service(name, iface, contractid):
services.append((name, iface, contractid))
service('ChromeRegistryService', 'nsIChromeRegistry',
# The `name` parameter is derived from the `iface` by removing the `nsI`
# prefix. (This often matches the `contractid`, but not always.) The only
# exceptions are when that would result in a misleading name, e.g. for
# "@mozilla.org/file/directory_service;1".
service('ChromeRegistry', 'nsIChromeRegistry',
"@mozilla.org/chrome/chrome-registry;1")
service('ToolkitChromeRegistryService', 'nsIToolkitChromeRegistry',
service('ToolkitChromeRegistry', 'nsIToolkitChromeRegistry',
"@mozilla.org/chrome/chrome-registry;1")
service('XULChromeRegistryService', 'nsIXULChromeRegistry',
service('XULChromeRegistry', 'nsIXULChromeRegistry',
"@mozilla.org/chrome/chrome-registry;1")
service('DirectoryService', 'nsIProperties',
"@mozilla.org/file/directory_service;1"),
@ -29,11 +33,11 @@ service('StringBundleService', 'nsIStringBundleService',
"@mozilla.org/intl/stringbundle;1")
service('PermissionManager', 'nsIPermissionManager',
"@mozilla.org/permissionmanager;1")
service('PreferencesService', 'nsIPrefService',
service('PrefService', 'nsIPrefService',
"@mozilla.org/preferences-service;1")
service('ServiceWorkerManager', 'nsIServiceWorkerManager',
"@mozilla.org/serviceworkers/manager;1")
service('AsyncShutdown', 'nsIAsyncShutdownService',
service('AsyncShutdownService', 'nsIAsyncShutdownService',
"@mozilla.org/async-shutdown-service;1")
service('UUIDGenerator', 'nsIUUIDGenerator',
"@mozilla.org/uuid-generator;1")
@ -47,9 +51,9 @@ service('CacheStorageService', 'nsICacheStorageService',
"@mozilla.org/netwerk/cache-storage-service;1")
service('URIClassifier', 'nsIURIClassifier',
"@mozilla.org/uriclassifierservice")
service('ActivityDistributor', 'nsIHttpActivityDistributor',
service('HttpActivityDistributor', 'nsIHttpActivityDistributor',
"@mozilla.org/network/http-activity-distributor;1")
service('HistoryService', 'mozilla::IHistory',
service('History', 'mozilla::IHistory',
"@mozilla.org/browser/history;1")
service('ThirdPartyUtil', 'mozIThirdPartyUtil',
"@mozilla.org/thirdpartyutil;1")
@ -59,17 +63,17 @@ service('Bits', 'nsIBits',
"@mozilla.org/bits;1")
# If you want nsIXULAppInfo, as returned by Services.jsm, you need to call:
#
# nsCOMPtr<nsIXULRuntime> runtime = mozilla::services::GetAppInfoService();
# nsCOMPtr<nsIXULRuntime> runtime = mozilla::services::GetXULRuntime();
# nsCOMPtr<nsIXULAppInfo> appInfo = do_QueryInterface(runtime);
#
# for C++ or:
#
# let appInfo =
# get_AppInfoService().and_then(|p| p.query_interface::<nsIXULAppInfo>());
# get_XULRuntime().and_then(|p| p.query_interface::<nsIXULAppInfo>());
#
# for Rust. Note that not all applications (e.g. xpcshell) implement
# nsIXULAppInfo.
service('AppInfoService', 'nsIXULRuntime',
service('XULRuntime', 'nsIXULRuntime',
"@mozilla.org/xre/app-info;1")
if buildconfig.substs.get('ENABLE_REMOTE_AGENT'):

Просмотреть файл

@ -642,8 +642,7 @@ void ParseManifest(NSLocationType aType, FileLocation& aFile, char* aBuf,
}
if (!nsChromeRegistry::gChromeRegistry) {
nsCOMPtr<nsIChromeRegistry> cr =
mozilla::services::GetChromeRegistryService();
nsCOMPtr<nsIChromeRegistry> cr = mozilla::services::GetChromeRegistry();
if (!nsChromeRegistry::gChromeRegistry) {
LogMessageWithContext(aFile, line,
"Chrome registry isn't available yet.");

Просмотреть файл

@ -1933,8 +1933,7 @@ NS_IMETHODIMP
nsComponentManagerImpl::RemoveBootstrappedManifestLocation(nsIFile* aLocation) {
NS_ENSURE_ARG_POINTER(aLocation);
nsCOMPtr<nsIChromeRegistry> cr =
mozilla::services::GetChromeRegistryService();
nsCOMPtr<nsIChromeRegistry> cr = mozilla::services::GetChromeRegistry();
if (!cr) {
return NS_ERROR_FAILURE;
}