Files
roytam1 f38f996411 import changes from `dev' branch of rmottola/Arctic-Fox:
- bug 1249738 - make sWakeLockObservers a function static r=dhylands (a606893142)
- bug 1249738 - make sSystemClockChangeObservers a function static r=dhylands (c994867638)
- bug 1249738 - make sSystemTimezoneChangeObservers a function static r=dhylands (d053417e69)
- Bug 1184285 - Stop warning if RemoveObserver() is called for unregistered observer. r=dhylands (5119547e11)
- Bug 1244754 - part 1 - backport zero-length gradient interval fix from Skia upstream. r=jrmuizel (c1ae572de9)
- Bug 1229975 - backport fix for Skia's GrConvexPolyEffect. r=mchang (80aba4e282)
- Bug 1206961 - Use channel->AsyncOpen2() in image/imgLoader.cpp; removing security checks from the callsite reveals that we have to pass the accurate contentPolicyType to ValidateEntry (r=seth,bz) (0d771560b6)
- Bug 1266615 - Fix C4334 in imgFrame.cpp. r=padenot (2d8227a6cc)
- Bug 1230907 - mPixelRowSize added to constructor with 0 value. r=seth (5681184935)
- Bug 1249550 (part 1) - Flip BMPs with negative height when downscaling. r=tn. (ca5978c766)
- Bug 1249550 (part 2) - Add a test. r=tn. (d3c61944de)
- Bug 1255675. SurfacePipe handles removing the frame rect, so pass the frame rect directly. (ef71f57a9a)
- Bug 1255104 - Use SurfacePipe in nsIconDecoder. r=njn (e10c6c8a29)
- Bug 1120141. Don't use surface with alpha for first frames of all pngs. r=edwin (5e5ffc4465)
- Bug 1265631 - patch 1 - Add line-break data from Unicode's LineBreak.txt to nsUnicodeProperties for builds without ICU. r=masayuki (9873992421)
- Bug 1265631 - patch 2 - Implement GetLineBreakClass() accessor to get Unicode line-break class from ICU or nsUnicodeProperties data. r=masayuki (fe7fcbf270)
- Bug 1265631 - Reftests for line-breaking with supplementary-plane characters. r=masayuki (55e1974356)
- Bug 1265631 - patch 3 - Add surrogate support to nsJISx4051LineBreaker so that supplementary-plane characters get correct line-breaking behavior. r=masayuki (ef24e8efc5)
- Bug 1265631 - followup with adjustments for review comments on patch 3. no_r=me (4fbc8d5a98)
- Bug 1128454 - Fix IPDL test (r=jimm) (82cb7e77fa)
- Bug 1254373: Make TestDemon build on Windows; r=billm (11eeb63019)
- Bug 1227327 - Use regular background image display items for painting button backgrounds. r=mattwoodrow (7a36d30032)
- Bug 1255022 - Make the test_transformed_scrolling_repaints* tests mochitest-plain instead of mochitest-chrome. r=mstange (3d150690e7)
- Bug 1268195 - When restoring a scroll position outside of incremental load, don't keep trying in a loop - just do it once and stop. r=tnikkel (ab9f4f57ab)
- Bug 1265256 - Use the canvas positioning area when computing the background-attachment:fixed rect for canvas frames. r=mstange (3dda1b8beb)
- Bug 623432 part 1 - When the target scroll point is at the screen edge and no scrolling occured, then try to scroll 10px in that direction anyway. r=tn (f9952f107d)
- Bug 623432 part 2 - Ignore scrollbars while drag-selecting content. r=tn (ca26f1145e)
- Bug 623432 part 3 - Check nsFrameSelection::GetDragState() earlier to optimize away some more expensive calls. r=tn (6d540874e2)
- Bug 1269539 - Ensure that the scroll position is restored properly on reloading a page which loads incrementally. r=tnikkel (1e018dca29)
- Bug 1239808 - Fix mozharness mach command for test_packages.json retrieval. r=jlund (9639ec1459)
- Bug 1248097, part 1 - Fix indentation in SpecialPowersObserver.jsm. r=jmaher (75ed8bf7b9)
- Bug 1248097, part 2 - If no name is specified for createFiles, use createUnique to create one. r=jmaher (aa9b8b60f7)
- Bug 1248097, part 3 - Add file creation support for options. r=jmaher (9086ae5f9c)
- Bug 1248097, part 4 - Don't throw away the _createdFiles array every time. r=jmaher (4a7732a4d4)
- Bug 1241576 - Convert testing/ to use channel.open2() (r=sicking) (ecadf38f7b)
- Bug 1251139 - Support running a function in the parent with loadChromeScript. r=jmaher (50377424bb)
- Bug 1153128 - Add sendSyncMessage to SpecialPowers.loadChromeScript. =jmaher (f53c487b0c)
- bug 1254091 convert test_mousecapture.xul to mochitest-plain so we can run it in e10s, r=enndeakin (900bce80cf)
- Bug 1254091 - part 2: fix focus messaging from SpecialPowers to refer to the right window, r=enndeakin (4ec66a9b8f)
- Bug 1258534 - Port test_bug599295.html to mochitest-plain so that it can be turned on in e10s mode; r=mrbkap (2a669777de)
- Bug 1260076 - [Mochitest] implement SpecialPowers.loadPrivilegedScript, r=bholley (8e2076f952)
- Bug 1252750 - Part 1: Create a helper function on SpecialPowersAPI which creates a nested event queue and spins it for a bit. r=mrbkap (fdefa1a3d6)
- Bug 1205358 - Fix up nsUrlClassifierPrefixSet memory reporting. r=gcp. (1c9d78607d)
- Bug 1244259 - Limit PrefixSet read and write buffer sizes to file size. r=froydnj (0906574833)
- Bug 1247615 - Fix off-by-one error in PrefixSet Delta storage compaction. r=froydnj (b72f052289)
- Bug 1219482: Replace PRLogModuleInfo with LazyLogModule in toolkit subdirectory.r=erahm (9d00df5d13)
- Bug 1213400 - Fix crash in broken Safe Browsing list updates. r=gcp (a073ec1a8f)
- Bug 1160263: Don't allow add-ons to override the periodic XPI signature check. r=rstrong (1ef54384cc)
- Bug 1180273 - Adding missing 'this' pointer when forwarding newChannel2 calls (r=gijs,sicking) (b173efdff4)
- Bug 1147562 - Update remaining callsites of newChannel before landing the shim in b2g/ (r=sicking) (10ab6df542)
- Bug 1194087 - MailtoProtocolHandler, SmsProtocolHandler, and TelProtocolHandler will all fire twice after introduction of newChannel2 r=asuth (ff7cc15c67)
- Bug 1204703 - Add AsyncOpen2 to channels in toolkit/ and b2g/ (r=sicking) (8d4b8ad5c6)
- Bug 1264383 - makeFilteringListener breaks eventremoval with shims. r=mconley (6a9d6d5079)
- Bug 1256468 - sessionHistory shim should QI DocShell to nsIWebNavigation automatically. r=krizsa (9a111454cb)
- Bug 1164011 - Test for CPOW shims. r=mconley (bbf7880955)
- Bug 1236409 - Remove toolkit impl of XUL prompt for nsICookiePromptService r=margaret (9f620ba65a)
- Bug 1236259 - Quote MOZ_APP_ID; r=gps (58b8e287b8)
- Bug 1174036 - Handle dynamically-removed textareas gracefully. r=mikedeboer r=ehsan (0797d45e3b)
- Bug 1259531 - [e10s] Fix test_bug451286.xul to run in e10s by converting to a mochitest-browser test. r=mikedeboer (00539d564c)
- Bug 1237798 - Use correct Components object inside CommonJS. r=Yoric (895beb28e2)
- Bug 1188158 - Move nsIPrivateBrowsingTrackingProtectionWhitelist to its own component in toolkit; r=jdm (6c75ab641b)
- Bug 1221537 - Provide a flash.bat script for Windows to device image builds (especially aries). r=fabrice (3eb8a25c0a)
- Bug 1232285 - The Terminator's notion of ticks is incorrect. r=Yoric (bc2688343c)
- Bug 1252382 - Get rid of PR_Sleep in the terminator;r=froydnj (a76de950df)
- Bug 1242084 - nsTerminator::UpdateTelemetry() leaks 8 byte nsStringBuffer when app.update.channel gets set to Beta. r=gfritzsche (56902dc11b)
- align some tests (e5179f8158)
- Bug 1260908 - Allow keyed histograms to accumulate early in startup (r=gfritzsche) (1852efe810)
- Bug 1254550 - Make Telemetry configuration consistent across builds. r=gfritzsche (16dcbf9a83)
2024-09-20 11:27:24 +08:00

322 lines
12 KiB
JavaScript

/* 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/. */
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm", this);
Components.utils.import("resource://gre/modules/Services.jsm", this);
const Cc = Components.classes;
const Ci = Components.interfaces;
const PREF_APP_UPDATE_LASTUPDATETIME_FMT = "app.update.lastUpdateTime.%ID%";
const PREF_APP_UPDATE_TIMERMINIMUMDELAY = "app.update.timerMinimumDelay";
const PREF_APP_UPDATE_TIMERFIRSTINTERVAL = "app.update.timerFirstInterval";
const PREF_APP_UPDATE_LOG = "app.update.log";
const CATEGORY_UPDATE_TIMER = "update-timer";
XPCOMUtils.defineLazyGetter(this, "gLogEnabled", function tm_gLogEnabled() {
return getPref("getBoolPref", PREF_APP_UPDATE_LOG, false);
});
/**
* Gets a preference value, handling the case where there is no default.
* @param func
* The name of the preference function to call, on nsIPrefBranch
* @param preference
* The name of the preference
* @param defaultValue
* The default value to return in the event the preference has
* no setting
* @returns The value of the preference, or undefined if there was no
* user or default value.
*/
function getPref(func, preference, defaultValue) {
try {
return Services.prefs[func](preference);
}
catch (e) {
}
return defaultValue;
}
/**
* Logs a string to the error console.
* @param string
* The string to write to the error console.
*/
function LOG(string) {
if (gLogEnabled) {
dump("*** UTM:SVC " + string + "\n");
Services.console.logStringMessage("UTM:SVC " + string);
}
}
/**
* A manager for timers. Manages timers that fire over long periods of time
* (e.g. days, weeks, months).
* @constructor
*/
function TimerManager() {
Services.obs.addObserver(this, "xpcom-shutdown", false);
}
TimerManager.prototype = {
/**
* The Checker Timer
*/
_timer: null,
/**
* The Checker Timer minimum delay interval as specified by the
* app.update.timerMinimumDelay pref. If the app.update.timerMinimumDelay
* pref doesn't exist this will default to 120000.
*/
_timerMinimumDelay: null,
/**
* The set of registered timers.
*/
_timers: { },
/**
* See nsIObserver.idl
*/
observe: function TM_observe(aSubject, aTopic, aData) {
// Prevent setting the timer interval to a value of less than 30 seconds.
var minInterval = 30000;
// Prevent setting the first timer interval to a value of less than 10
// seconds.
var minFirstInterval = 10000;
switch (aTopic) {
case "utm-test-init":
// Enforce a minimum timer interval of 500 ms for tests and fall through
// to profile-after-change to initialize the timer.
minInterval = 500;
minFirstInterval = 500;
case "profile-after-change":
// Cancel the timer if it has already been initialized. This is primarily
// for tests.
this._timerMinimumDelay = Math.max(1000 * getPref("getIntPref", PREF_APP_UPDATE_TIMERMINIMUMDELAY, 120),
minInterval);
let firstInterval = Math.max(getPref("getIntPref", PREF_APP_UPDATE_TIMERFIRSTINTERVAL,
this._timerMinimumDelay), minFirstInterval);
this._canEnsureTimer = true;
this._ensureTimer(firstInterval);
break;
case "xpcom-shutdown":
Services.obs.removeObserver(this, "xpcom-shutdown");
// Release everything we hold onto.
this._cancelTimer();
for (var timerID in this._timers)
delete this._timers[timerID];
this._timers = null;
break;
}
},
/**
* Called when the checking timer fires.
*
* We only fire one notification each time, so that the operations are
* staggered. We don't want too many to happen at once, which could
* negatively impact responsiveness.
*
* @param timer
* The checking timer that fired.
*/
notify: function TM_notify(timer) {
var nextDelay = null;
function updateNextDelay(delay) {
if (nextDelay === null || delay < nextDelay)
nextDelay = delay;
}
// Each timer calls tryFire(), which figures out which is the one that
// wanted to be called earliest. That one will be fired; the others are
// skipped and will be done later.
var now = Math.round(Date.now() / 1000);
var callbackToFire = null;
var earliestIntendedTime = null;
var skippedFirings = false;
var lastUpdateTime = null;
function tryFire(callback, intendedTime) {
var selected = false;
if (intendedTime <= now) {
if (intendedTime < earliestIntendedTime ||
earliestIntendedTime === null) {
callbackToFire = callback;
earliestIntendedTime = intendedTime;
selected = true;
}
else if (earliestIntendedTime !== null)
skippedFirings = true;
}
// We do not need to updateNextDelay for the timer that actually fires;
// we'll update right after it fires, with the proper intended time.
// Note that we might select one, then select another later (with an
// earlier intended time); it is still ok that we did not update for
// the first one, since if we have skipped firings, the next delay
// will be the minimum delay anyhow.
if (!selected)
updateNextDelay(intendedTime - now);
}
var catMan = Cc["@mozilla.org/categorymanager;1"].
getService(Ci.nsICategoryManager);
var entries = catMan.enumerateCategory(CATEGORY_UPDATE_TIMER);
while (entries.hasMoreElements()) {
let entry = entries.getNext().QueryInterface(Ci.nsISupportsCString).data;
let value = catMan.getCategoryEntry(CATEGORY_UPDATE_TIMER, entry);
let [cid, method, timerID, prefInterval, defaultInterval] = value.split(",");
defaultInterval = parseInt(defaultInterval);
// cid and method are validated below when calling notify.
if (!timerID || !defaultInterval || isNaN(defaultInterval)) {
LOG("TimerManager:notify - update-timer category registered" +
(cid ? " for " + cid : "") + " without required parameters - " +
"skipping");
continue;
}
let interval = getPref("getIntPref", prefInterval, defaultInterval);
let prefLastUpdate = PREF_APP_UPDATE_LASTUPDATETIME_FMT.replace(/%ID%/,
timerID);
// Initialize the last update time to 0 when the preference isn't set so
// the timer will be notified soon after a new profile's first use.
lastUpdateTime = getPref("getIntPref", prefLastUpdate, 0);
// If the last update time is greater than the current time then reset
// it to 0 and the timer manager will correct the value when it fires
// next for this consumer.
if (lastUpdateTime > now)
lastUpdateTime = 0;
if (lastUpdateTime == 0)
Services.prefs.setIntPref(prefLastUpdate, lastUpdateTime);
tryFire(function() {
try {
Components.classes[cid][method](Ci.nsITimerCallback).notify(timer);
LOG("TimerManager:notify - notified " + cid);
}
catch (e) {
LOG("TimerManager:notify - error notifying component id: " +
cid + " ,error: " + e);
}
lastUpdateTime = now;
Services.prefs.setIntPref(prefLastUpdate, lastUpdateTime);
updateNextDelay(lastUpdateTime + interval - now);
}, lastUpdateTime + interval);
}
for (let _timerID in this._timers) {
let timerID = _timerID; // necessary for the closure to work properly
let timerData = this._timers[timerID];
// If the last update time is greater than the current time then reset
// it to 0 and the timer manager will correct the value when it fires
// next for this consumer.
if (timerData.lastUpdateTime > now) {
let prefLastUpdate = PREF_APP_UPDATE_LASTUPDATETIME_FMT.replace(/%ID%/, timerID);
timerData.lastUpdateTime = 0;
Services.prefs.setIntPref(prefLastUpdate, timerData.lastUpdateTime);
}
tryFire(function() {
if (timerData.callback && timerData.callback.notify) {
try {
timerData.callback.notify(timer);
LOG("TimerManager:notify - notified timerID: " + timerID);
}
catch (e) {
LOG("TimerManager:notify - error notifying timerID: " + timerID +
", error: " + e);
}
}
else {
LOG("TimerManager:notify - timerID: " + timerID + " doesn't " +
"implement nsITimerCallback - skipping");
}
lastUpdateTime = now;
timerData.lastUpdateTime = lastUpdateTime;
let prefLastUpdate = PREF_APP_UPDATE_LASTUPDATETIME_FMT.replace(/%ID%/, timerID);
Services.prefs.setIntPref(prefLastUpdate, lastUpdateTime);
updateNextDelay(timerData.lastUpdateTime + timerData.interval - now);
}, timerData.lastUpdateTime + timerData.interval);
}
if (callbackToFire)
callbackToFire();
if (nextDelay !== null) {
if (skippedFirings)
timer.delay = this._timerMinimumDelay;
else
timer.delay = Math.max(nextDelay * 1000, this._timerMinimumDelay);
this.lastTimerReset = Date.now();
} else {
this._cancelTimer();
}
},
/**
* Starts the timer, if necessary, and ensures that it will fire soon enough
* to happen after time |interval| (in milliseconds).
*/
_ensureTimer: function(interval) {
if (!this._canEnsureTimer)
return;
if (!this._timer) {
this._timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
this._timer.initWithCallback(this, interval,
Ci.nsITimer.TYPE_REPEATING_SLACK);
this.lastTimerReset = Date.now();
} else {
if (Date.now() + interval < this.lastTimerReset + this._timer.delay)
this._timer.delay = Math.max(this.lastTimerReset + interval - Date.now(), 0);
}
},
/**
* Stops the timer, if it is running.
*/
_cancelTimer: function() {
if (this._timer) {
this._timer.cancel();
this._timer = null;
}
},
/**
* See nsIUpdateTimerManager.idl
*/
registerTimer: function TM_registerTimer(id, callback, interval) {
LOG("TimerManager:registerTimer - id: " + id);
if (id in this._timers && callback != this._timers[id].callback) {
LOG("TimerManager:registerTimer - Ignoring second registration for " + id);
return;
}
let prefLastUpdate = PREF_APP_UPDATE_LASTUPDATETIME_FMT.replace(/%ID%/, id);
// Initialize the last update time to 0 when the preference isn't set so
// the timer will be notified soon after a new profile's first use.
let lastUpdateTime = getPref("getIntPref", prefLastUpdate, 0);
let now = Math.round(Date.now() / 1000);
if (lastUpdateTime > now)
lastUpdateTime = 0;
if (lastUpdateTime == 0)
Services.prefs.setIntPref(prefLastUpdate, lastUpdateTime);
this._timers[id] = { callback : callback,
interval : interval,
lastUpdateTime : lastUpdateTime };
this._ensureTimer(interval * 1000);
},
classID: Components.ID("{B322A5C0-A419-484E-96BA-D7182163899F}"),
QueryInterface: XPCOMUtils.generateQI([Ci.nsIUpdateTimerManager,
Ci.nsITimerCallback,
Ci.nsIObserver])
};
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([TimerManager]);