Files
palemoon27/services/sync/modules/notifications.js
T
roytam1 b4a9437711 import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1199171 part 0 - Add spewInst function for debugging Jit code. r=lth (12cd32209d)
- Bug 1192786 - support an installed printer, for profiling. r=nbp (59fe21c4a5)
- Bug 1199171 part 1 - Assembler::GetCF32Target: Decode instructions as needed. r=h4writer (b120e75c4f)
- Bug 1192786 - add forgotten ifdeffery on CLOSED TREE. r=me (7ccf2e792c)
- Bug 1195263 - ARM: Instruction::extractCond asserts that the instruction has a condition flag. r=h4writer (fe30c9a6ae)
- Bug 1207449: Conservatively mark MFilterTypeSet with phis as not float32-compatible; r=h4writer (9062bae786)
- revert 1130679 that was never commited (a9c6fcc984)
- Bug 1201793 - correct scratch register scope r=nbp CLOSED TREE (6df1d46059)
- Bug 1202643 - bailout from udiv on nonzero remainder. r=nbp (b001fc7c42)
- Bug 1206650 - Part 1/2 - Clean up load8ZeroExtend(). r=nbp (288a451461)
- Bug 1206650 - Part 2/2 - Use the dest register for scratch in alu_dbl(). r=nbp (4e601cff7f)
- Bug 1201793 - ScratchRegisterScope: ma_alu expect to have scratch register owned by the caller. r=sstangl (6783084545)
- pointer style (04d2b491cc)
- Bug 1202757 - disassemble more instructions. r=sstangl (39e29fbc98)
- Bug 1211832 - Disable functions that can easily cause artificial OOMs. r=jonco (3264e2dcb6)
- Bug 1188390 - Fail when Sprinter in disassemble ooms. r=h4writer (f59e3b00ca)
- Bug 1191635 - Fix stack limit for evalInWorker runtime. r=bhackett (b4b8f37dc1)
- Bug 1209873 - IonMonkey: MIPS: Add AssemblerMIPSShared::as_sync. r=arai (80dbd653b7)
- Bug 1212469 - Fix some OOM handling issues shown up by the previous patch r=jandem (ca7e25d243)
- Bug 1215058 - Fix various OOM handling issues related to off-thread compilation r=jandem (6d95767f75)
- Bug 1207827 - Copy pool data into buffer immediately. r=nbp (d3fcd69e1e)
- Bug 1207827 - Stop perforating AssemblerBuffers. r=nbp (8ac7947355)
- Bug 1207827 - Use a Vector for poolInfo_. r=nbp (d97f814916)
- Bug 1207827 - Switch jit::Pool to a LifoAllocPolicy. r=nbp (caf547349e)
- Bug 1207827 - Eliminate poolSizeBefore(). r=nbp (adad1dfa68)
- Bug 1181612: Hoist codeLabels_ and associated common functions into Assembler-shared; r=luke (5086762e53)
- Bug 1207827 - Remove ARM temporary offset buffers. r=nbp (7bc80ab795)
- Bug 1207827 - Delete Assembler::actualOffset() and transitive closure. r=nbp (34141fde56)
- Bug 1213146 - IonMonkey: MIPS: Remove AssemblerMIPSShared::asAsm. r=arai (8d71e648c9)
- const-var (f860ce4da7)
- Bug 944164 - set the shell variable scriptPath to communicate the currently running script to the debugger, r=jorendorff (5ca9508912)
- align to firefox (f895d43a07)
- Bug 1213146 - IonMonkey: MIPS: Move Assembler::PatchDataWithValueCheck to architecture specific. r=lth (c8a7b478f6)
- Bug 944164 - make the shell actually quit when you call quit(), r=jorendorff (8e737a7450)
2022-10-06 11:43:07 +08:00

132 lines
4.1 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/. */
this.EXPORTED_SYMBOLS = ["Notifications", "Notification", "NotificationButton"];
var Cc = Components.classes;
var Ci = Components.interfaces;
var Cr = Components.results;
var Cu = Components.utils;
Cu.import("resource://services-common/observers.js");
Cu.import("resource://gre/modules/Log.jsm");
Cu.import("resource://services-sync/util.js");
this.Notifications = {
// Match the referenced values in toolkit/content/widgets/notification.xml.
get PRIORITY_INFO() { return 1; }, // PRIORITY_INFO_LOW
get PRIORITY_WARNING() { return 4; }, // PRIORITY_WARNING_LOW
get PRIORITY_ERROR() { return 7; }, // PRIORITY_CRITICAL_LOW
// FIXME: instead of making this public, dress the Notifications object
// to behave like an iterator (using generators?) and have callers access
// this array through the Notifications object.
notifications: [],
_observers: [],
// XXX Should we have a helper method for adding a simple notification?
// I.e. something like |function notify(title, description, priority)|.
add: function Notifications_add(notification) {
this.notifications.push(notification);
Observers.notify("weave:notification:added", notification, null);
},
remove: function Notifications_remove(notification) {
let index = this.notifications.indexOf(notification);
if (index != -1) {
this.notifications.splice(index, 1);
Observers.notify("weave:notification:removed", notification, null);
}
},
/**
* Replace an existing notification.
*/
replace: function Notifications_replace(oldNotification, newNotification) {
let index = this.notifications.indexOf(oldNotification);
if (index != -1)
this.notifications.splice(index, 1, newNotification);
else {
this.notifications.push(newNotification);
// XXX Should we throw because we didn't find the existing notification?
// XXX Should we notify observers about weave:notification:added?
}
// XXX Should we notify observers about weave:notification:replaced?
},
/**
* Remove all notifications that match a title. If no title is provided, all
* notifications are removed.
*
* @param title [optional]
* Title of notifications to remove; falsy value means remove all
*/
removeAll: function Notifications_removeAll(title) {
this.notifications.filter(old => (old.title == title || !title)).
forEach(old => { this.remove(old); }, this);
},
// replaces all existing notifications with the same title as the new one
replaceTitle: function Notifications_replaceTitle(notification) {
this.removeAll(notification.title);
this.add(notification);
}
};
/**
* A basic notification. Subclass this to create more complex notifications.
*/
this.Notification =
function Notification(title, description, iconURL, priority, buttons, link) {
this.title = title;
this.description = description;
if (iconURL)
this.iconURL = iconURL;
if (priority)
this.priority = priority;
if (buttons)
this.buttons = buttons;
if (link)
this.link = link;
}
// We set each prototype property individually instead of redefining
// the entire prototype to avoid blowing away existing properties
// of the prototype like the the "constructor" property, which we use
// to bind notification objects to their XBL representations.
Notification.prototype.priority = Notifications.PRIORITY_INFO;
Notification.prototype.iconURL = null;
Notification.prototype.buttons = [];
/**
* A button to display in a notification.
*/
this.NotificationButton =
function NotificationButton(label, accessKey, callback) {
function callbackWrapper() {
try {
callback.apply(this, arguments);
} catch (e) {
let logger = Log.repository.getLogger("Sync.Notifications");
logger.error("An exception occurred: " + Utils.exceptionStr(e));
logger.info(Utils.stackTrace(e));
throw e;
}
}
this.label = label;
this.accessKey = accessKey;
this.callback = callbackWrapper;
}