Files
palemoon27/toolkit/components/places/PlacesCategoriesStarter.js
T
roytam1 cc9fb3b5bf import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1152454 - Made liveregions responsive to name/value change events. r=yzen (056df463ef)
- Bug 1166321 - [AccessFu] adding support for role='switch'. r=eeejay (540831bb6a)
- Bug 1179284 - using explicit label for accessible with role 'status' instead of subtree. r=eeejay (919f0b93e7)
- Bug 1163374 - Basic MathML Accessibility support in AccessFu. r=yzen (cddbfee120)
- Bug 1199884 - Keep match roles empty in BaseTraversalRules that don't provide roles. r=yzen (b80ff3c892)
- Bug 1200836 - Land on first atomic object in container traversal. r=yzen (0243a695af)
- Bug 1206491 - Fix a JavaScript error in about:cache page. r=mayhemmer (5eaa374c84)
- Bug 1142174 - Normalize omni.ja! paths when diffing about:memory reports. r=njn (bf046c4958)
- let-var (5e9cf0b098)
- Bug 1205364 part 1. Make createAttribute in an HTML document lowercase the passed-in attribute name. r=smaug (0b8a9f0f60)
- Bug 647621 - Implement document.charset and update document.inputEncoding to the latest spec. r=bz (e31fd9f567)
- Bug 647621 - Remove document.charset from historical.html because it was eventually added to the spec. r=Ms2ger (506ecf3238)
- Bug 1201798 part 1 - Move PropagateScrollToViewport() from nsCSSFrameConstructor to nsPresContext as a public method. r=roc (5d33acfa26)
- Bug 1201798 part 2 - Update viewport scrollbar override for fullscreen and remove the leagcy css rule. r=roc (852d3d181f)
- Bug 1201798 part 3 - Add test for viewport scrollbar on fullscreen. r=roc (88ad5560ae)
- Bug 1048622 - Fix 'assignment to undefined variable' warnings in nsBrowserContentHandler.js. r=gavin (55edf093ce)
- Bug 1205328: undef min/max at the top of irregexp/RegExpAST.h if they're already defined; r=ehsan (2a5daa48a9)
- Bug 773687 - Fix assertion pattern in RegExp with sticky flag. r=till (0f1643690b)
- Bug 1084248 - add a cast<> method, remove the casting constructor as requested. r=waldo (3fb0619085)
- cleanup (705296cc44)
- Bug 1143512 - Remove unused declaration of regexp_flags. r=jandem (79f538a4c8)
- bit of 1198193 and pointer styles (6bec08ca9e)
- Bug 1146580 - Make FinalizationWitnessService listen for xpcom shutdown. r=bholley (6a4093bf23)
- Bug 1199578 - include SharedTypedArray in a type test. r=waldo (94b943eb91)
- Bug 1203791 - Fix LazyLink issue with Debugger::onIonCompilation. r=h4writer (3d5c4ee130)
- pointer style (f24eb566fd)
- Bug 1204726 - Make sure that the MacroAssembler is no longer rooted when onIonCompilation is called. r=h4writer (f697b11f6d)
- Bug 1206418 - Fix origin of animations and scissors for preserves3d. r=roc (1813cc2c21)
2022-09-07 10:25:03 +08:00

113 lines
4.0 KiB
JavaScript

/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*-
* vim: sw=2 ts=2 sts=2 expandtab
* 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/. */
////////////////////////////////////////////////////////////////////////////////
//// Constants
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cu = Components.utils;
// Fired by TelemetryPing when async telemetry data should be collected.
const TOPIC_GATHER_TELEMETRY = "gather-telemetry";
// Seconds between maintenance runs.
const MAINTENANCE_INTERVAL_SECONDS = 7 * 86400;
////////////////////////////////////////////////////////////////////////////////
//// Imports
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
Components.utils.import("resource://gre/modules/Services.jsm");
Components.utils.import("resource://gre/modules/PlacesUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "PlacesDBUtils",
"resource://gre/modules/PlacesDBUtils.jsm");
/**
* This component can be used as a starter for modules that have to run when
* certain categories are invoked.
*/
function PlacesCategoriesStarter()
{
Services.obs.addObserver(this, TOPIC_GATHER_TELEMETRY, false);
Services.obs.addObserver(this, PlacesUtils.TOPIC_SHUTDOWN, false);
// nsINavBookmarkObserver implementation.
let notify = (function () {
if (!this._notifiedBookmarksSvcReady) {
// For perf reasons unregister from the category, since no further
// notifications are needed.
Cc["@mozilla.org/categorymanager;1"]
.getService(Ci.nsICategoryManager)
.deleteCategoryEntry("bookmarks-observer", this, false);
// Directly notify PlacesUtils, to ensure it catches the notification.
PlacesUtils.observe(null, "bookmarks-service-ready", null);
}
}).bind(this);
[ "onItemAdded", "onItemRemoved", "onItemChanged", "onBeginUpdateBatch",
"onEndUpdateBatch", "onItemVisited",
"onItemMoved" ].forEach(function(aMethod) {
this[aMethod] = notify;
}, this);
}
PlacesCategoriesStarter.prototype = {
//////////////////////////////////////////////////////////////////////////////
//// nsIObserver
observe: function PCS_observe(aSubject, aTopic, aData)
{
switch (aTopic) {
case PlacesUtils.TOPIC_SHUTDOWN:
Services.obs.removeObserver(this, PlacesUtils.TOPIC_SHUTDOWN);
Services.obs.removeObserver(this, TOPIC_GATHER_TELEMETRY);
let globalObj =
Cu.getGlobalForObject(PlacesCategoriesStarter.prototype);
let descriptor =
Object.getOwnPropertyDescriptor(globalObj, "PlacesDBUtils");
if (descriptor.value !== undefined) {
PlacesDBUtils.shutdown();
}
break;
case TOPIC_GATHER_TELEMETRY:
PlacesDBUtils.telemetry();
break;
case "idle-daily":
// Once a week run places.sqlite maintenance tasks.
let lastMaintenance = 0;
try {
lastMaintenance =
Services.prefs.getIntPref("places.database.lastMaintenance");
} catch (ex) {}
let nowSeconds = parseInt(Date.now() / 1000);
if (lastMaintenance < nowSeconds - MAINTENANCE_INTERVAL_SECONDS) {
PlacesDBUtils.maintenanceOnIdle();
}
break;
default:
throw new Error("Trying to handle an unknown category.");
}
},
//////////////////////////////////////////////////////////////////////////////
//// nsISupports
classID: Components.ID("803938d5-e26d-4453-bf46-ad4b26e41114"),
_xpcom_factory: XPCOMUtils.generateSingletonFactory(PlacesCategoriesStarter),
QueryInterface: XPCOMUtils.generateQI([
Ci.nsIObserver
, Ci.nsINavBookmarkObserver
])
};
////////////////////////////////////////////////////////////////////////////////
//// Module Registration
var components = [PlacesCategoriesStarter];
this.NSGetFactory = XPCOMUtils.generateNSGetFactory(components);