Bug 1524687: Part 4 - Convert Places module to static registration. r=mak

Differential Revision: https://phabricator.services.mozilla.com/D18399

--HG--
extra : rebase_source : c9e4273be9cfccb3588d82878a4b6e4aecce59b5
extra : source : c58caf41bb942d24efb5e108cdb7811be2930498
This commit is contained in:
Kris Maglione 2019-01-24 15:46:19 -08:00
Родитель 6575c46659
Коммит aaf5a4acba
8 изменённых файлов: 78 добавлений и 73 удалений

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

@ -23,12 +23,11 @@ var newClassID = Cc["@mozilla.org/uuid-generator;1"].getService(Ci.nsIUUIDGenera
var registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
var oldClassID = registrar.contractIDToCID(CONTRACT_ID);
var oldFactory = Components.manager.getClassObject(Cc[CONTRACT_ID], Ci.nsIFactory);
registrar.unregisterFactory(oldClassID, oldFactory);
registrar.registerFactory(newClassID, "", CONTRACT_ID, factory);
function cleanupFactory() {
registrar.unregisterFactory(newClassID, factory);
registrar.registerFactory(oldClassID, "", CONTRACT_ID, oldFactory);
registrar.registerFactory(oldClassID, "", CONTRACT_ID, null);
}
function GetPermissionsFile(profile)

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

@ -1241,7 +1241,7 @@ nsresult FetchAndConvertUnsupportedPayloads::ConvertPayload(
// For non-square images, pick the largest side.
int32_t originalSize = std::max(width, height);
int32_t size = originalSize;
for (uint16_t supportedSize : sFaviconSizes) {
for (uint16_t supportedSize : gFaviconSizes) {
if (supportedSize <= originalSize) {
size = supportedSize;
break;

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

@ -0,0 +1,55 @@
# -*- 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': '{0937a705-91a6-417a-8292-b22eb10da86c}',
'contract_ids': ['@mozilla.org/browser/history;1'],
'singleton': True,
'type': 'mozilla::places::History',
'headers': ['mozilla/places/History.h'],
'constructor': 'mozilla::places::History::GetSingleton',
},
{
'cid': '{e8b8bdb7-c96c-4d82-9c6f-2b3c585ec7ea}',
'contract_ids': ['@mozilla.org/network/protocol;1?name=moz-anno'],
'type': 'nsAnnoProtocolHandler',
'headers': ['/toolkit/components/places/nsAnnoProtocolHandler.h'],
},
{
'cid': '{5e8d4751-1852-434b-a992-2c6d2a25fa46}',
'contract_ids': ['@mozilla.org/browser/annotation-service;1'],
'singleton': True,
'type': 'nsAnnotationService',
'headers': ['/toolkit/components/places/nsAnnotationService.h'],
'constructor': 'nsAnnotationService::GetSingleton',
},
{
'cid': '{984e3259-9266-49cf-b605-60b022a00756}',
'contract_ids': ['@mozilla.org/browser/favicon-service;1'],
'singleton': True,
'type': 'nsFaviconService',
'headers': ['/toolkit/components/places/nsFaviconService.h'],
'constructor': 'nsFaviconService::GetSingleton',
},
{
'cid': '{9de95a0c-39a4-4d64-9a53-17940dd7cabb}',
'contract_ids': ['@mozilla.org/browser/nav-bookmarks-service;1'],
'singleton': True,
'type': 'nsNavBookmarks',
'headers': ['/toolkit/components/places/nsNavBookmarks.h'],
'constructor': 'nsNavBookmarks::GetSingleton',
},
{
'cid': '{88cecbb7-6c63-4b3b-8cd4-84f3b8228c69}',
'contract_ids': ['@mozilla.org/browser/nav-history-service;1'],
'singleton': True,
'type': 'nsNavHistory',
'headers': ['/toolkit/components/places/nsNavHistory.h'],
'constructor': 'nsNavHistory::GetSingleton',
'categories': {'vacuum-participant': 'Places'},
},
]

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

@ -44,7 +44,6 @@ if CONFIG['MOZ_PLACES']:
'nsNavHistory.cpp',
'nsNavHistoryQuery.cpp',
'nsNavHistoryResult.cpp',
'nsPlacesModule.cpp',
'PlaceInfo.cpp',
'Shutdown.cpp',
'SQLFunctions.cpp',
@ -84,6 +83,10 @@ if CONFIG['MOZ_PLACES']:
'UnifiedComplete.js',
]
XPCOM_MANIFESTS += [
'components.conf',
]
FINAL_LIBRARY = 'xul'
include('/ipc/chromium/chromium-config.mozbuild')

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

@ -16,8 +16,18 @@
#include "nsString.h"
#include "mozilla/Attributes.h"
namespace mozilla {
namespace places {
struct BookmarkData;
} // namespace places
} // namespace mozilla
class nsAnnotationService final : public nsIAnnotationService,
public nsSupportsWeakReference {
using BookmarkData = mozilla::places::BookmarkData;
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIANNOTATIONSERVICE

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

@ -43,6 +43,8 @@
using namespace mozilla;
using namespace mozilla::places;
const uint16_t gFaviconSizes[7] = {192, 144, 96, 64, 48, 32, 16};
/**
* Used to notify a topic to system observers on async execute completion.
* Will throw on error.
@ -77,9 +79,9 @@ nsresult GetFramesInfoForContainer(imgIContainer* aContainer,
continue;
}
// Check if it's one of the sizes we care about.
auto end = std::end(sFaviconSizes);
uint16_t* matchingSize =
std::find(std::begin(sFaviconSizes), end, nativeSize.width);
auto end = std::end(gFaviconSizes);
const uint16_t* matchingSize =
std::find(std::begin(gFaviconSizes), end, nativeSize.width);
if (matchingSize != end) {
// We must avoid duped sizes, an image could contain multiple frames
// of the same size, but we can only store one. We could use an
@ -727,7 +729,7 @@ nsresult nsFaviconService::OptimizeIconSizes(IconData& aIcon) {
IconPayload newPayload;
newPayload.mimeType = NS_LITERAL_CSTRING(PNG_MIME_TYPE);
newPayload.width = frameInfo.width;
for (uint16_t size : sFaviconSizes) {
for (uint16_t size : gFaviconSizes) {
// The icon could be smaller than 16, that is our minimum.
// Icons smaller than 16px are kept as-is.
if (frameInfo.width >= 16) {

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

@ -27,7 +27,7 @@
// The target dimension in pixels for favicons we store, in reverse order.
// When adding/removing sizes from here, make sure to update the vector size.
static uint16_t sFaviconSizes[7] = {192, 144, 96, 64, 48, 32, 16};
extern const uint16_t gFaviconSizes[7];
// forward class definitions
class mozIStorageStatementCallback;

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

@ -1,64 +0,0 @@
/* 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 "mozilla/ModuleUtils.h"
#include "nsIClassInfoImpl.h"
#include "nsAnnoProtocolHandler.h"
#include "nsAnnotationService.h"
#include "nsNavHistory.h"
#include "nsNavBookmarks.h"
#include "nsFaviconService.h"
#include "History.h"
#include "nsDocShellCID.h"
using namespace mozilla::places;
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsNavHistory,
nsNavHistory::GetSingleton)
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsAnnotationService,
nsAnnotationService::GetSingleton)
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsNavBookmarks,
nsNavBookmarks::GetSingleton)
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsFaviconService,
nsFaviconService::GetSingleton)
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(History, History::GetSingleton)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAnnoProtocolHandler)
NS_DEFINE_NAMED_CID(NS_NAVHISTORYSERVICE_CID);
NS_DEFINE_NAMED_CID(NS_ANNOTATIONSERVICE_CID);
NS_DEFINE_NAMED_CID(NS_ANNOPROTOCOLHANDLER_CID);
NS_DEFINE_NAMED_CID(NS_NAVBOOKMARKSSERVICE_CID);
NS_DEFINE_NAMED_CID(NS_FAVICONSERVICE_CID);
NS_DEFINE_NAMED_CID(NS_HISTORYSERVICE_CID);
const mozilla::Module::CIDEntry kPlacesCIDs[] = {
{&kNS_NAVHISTORYSERVICE_CID, false, nullptr, nsNavHistoryConstructor},
{&kNS_ANNOTATIONSERVICE_CID, false, nullptr,
nsAnnotationServiceConstructor},
{&kNS_ANNOPROTOCOLHANDLER_CID, false, nullptr,
nsAnnoProtocolHandlerConstructor},
{&kNS_NAVBOOKMARKSSERVICE_CID, false, nullptr, nsNavBookmarksConstructor},
{&kNS_FAVICONSERVICE_CID, false, nullptr, nsFaviconServiceConstructor},
{&kNS_HISTORYSERVICE_CID, false, nullptr, HistoryConstructor},
{nullptr}};
const mozilla::Module::ContractIDEntry kPlacesContracts[] = {
{NS_NAVHISTORYSERVICE_CONTRACTID, &kNS_NAVHISTORYSERVICE_CID},
{NS_ANNOTATIONSERVICE_CONTRACTID, &kNS_ANNOTATIONSERVICE_CID},
{NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "moz-anno",
&kNS_ANNOPROTOCOLHANDLER_CID},
{NS_NAVBOOKMARKSSERVICE_CONTRACTID, &kNS_NAVBOOKMARKSSERVICE_CID},
{NS_FAVICONSERVICE_CONTRACTID, &kNS_FAVICONSERVICE_CID},
{NS_IHISTORY_CONTRACTID, &kNS_HISTORYSERVICE_CID},
{nullptr}};
const mozilla::Module::CategoryEntry kPlacesCategories[] = {
{"vacuum-participant", "Places", NS_NAVHISTORYSERVICE_CONTRACTID},
{nullptr}};
const mozilla::Module kPlacesModule = {mozilla::Module::kVersion, kPlacesCIDs,
kPlacesContracts, kPlacesCategories};
NSMODULE_DEFN(nsPlacesModule) = &kPlacesModule;