mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
Bug 1517456 - Remove remaining production code references to Task.jsm. r=florian
Differential Revision: https://phabricator.services.mozilla.com/D15646 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
b616e2a125
commit
d1705a170b
@ -43,8 +43,6 @@ ChromeUtils.import("resource://gre/modules/Services.jsm", this);
|
||||
|
||||
ChromeUtils.defineModuleGetter(this, "PromiseUtils",
|
||||
"resource://gre/modules/PromiseUtils.jsm");
|
||||
ChromeUtils.defineModuleGetter(this, "Task",
|
||||
"resource://gre/modules/Task.jsm");
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "gDebug",
|
||||
"@mozilla.org/xpcom/debug;1", "nsIDebug2");
|
||||
Object.defineProperty(this, "gCrashReporter", {
|
||||
@ -313,17 +311,11 @@ function getOrigin(topFrame, filename = null, lineNumber = null, stack = null) {
|
||||
if (stack == null) {
|
||||
// Now build the rest of the stack as a string, using Task.jsm's rewriting
|
||||
// to ensure that we do not lose information at each call to `Task.spawn`.
|
||||
let frames = [];
|
||||
stack = [];
|
||||
while (frame != null) {
|
||||
frames.push(frame.filename + ":" + frame.name + ":" + frame.lineNumber);
|
||||
stack.push(frame.filename + ":" + frame.name + ":" + frame.lineNumber);
|
||||
frame = frame.caller;
|
||||
}
|
||||
stack = frames.join("\n");
|
||||
// Avoid loading Task.jsm if there's no task on the stack.
|
||||
if (stack.includes("/Task.jsm:")) {
|
||||
stack = Task.Debugging.generateReadableStack(stack);
|
||||
}
|
||||
stack = stack.split("\n");
|
||||
}
|
||||
|
||||
return {
|
||||
|
@ -48,8 +48,6 @@ ChromeUtils.import("resource://gre/modules/osfile/ospath.jsm", Path);
|
||||
// The library of promises.
|
||||
ChromeUtils.defineModuleGetter(this, "PromiseUtils",
|
||||
"resource://gre/modules/PromiseUtils.jsm");
|
||||
ChromeUtils.defineModuleGetter(this, "Task",
|
||||
"resource://gre/modules/Task.jsm");
|
||||
|
||||
// The implementation of communications
|
||||
ChromeUtils.import("resource://gre/modules/PromiseWorker.jsm", this);
|
||||
@ -313,9 +311,6 @@ var Scheduler = this.Scheduler = {
|
||||
|
||||
Scheduler.latestReceived = [];
|
||||
let stack = new Error().stack;
|
||||
// Avoid loading Task.jsm if there's no task on the stack.
|
||||
if (stack.includes("/Task.jsm:"))
|
||||
stack = Task.Debugging.generateReadableStack(stack);
|
||||
Scheduler.latestSent = [Date.now(), stack, ...message];
|
||||
|
||||
// Wait for result
|
||||
|
@ -47,7 +47,7 @@ XPCOMUtils.defineLazyServiceGetter(this, "PageThumbsStorageService",
|
||||
"@mozilla.org/thumbnails/pagethumbs-service;1", "nsIPageThumbsStorageService");
|
||||
|
||||
/**
|
||||
* Utilities for dealing with promises and Task.jsm
|
||||
* Utilities for dealing with promises.
|
||||
*/
|
||||
const TaskUtils = {
|
||||
/**
|
||||
|
@ -7,10 +7,8 @@
|
||||
var EXPORTED_SYMBOLS = ["Log"];
|
||||
|
||||
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetters(this, {
|
||||
Services: "resource://gre/modules/Services.jsm",
|
||||
Task: "resource://gre/modules/Task.jsm",
|
||||
});
|
||||
ChromeUtils.defineModuleGetter(this, "Services",
|
||||
"resource://gre/modules/Services.jsm");
|
||||
const INTERNAL_FIELDS = new Set(["_level", "_message", "_time", "_namespace"]);
|
||||
|
||||
|
||||
@ -129,9 +127,6 @@ var Log = {
|
||||
// Standard JS exception
|
||||
if (e.stack) {
|
||||
let stack = e.stack;
|
||||
// Avoid loading Task.jsm if there's no task on the stack.
|
||||
if (stack.includes("/Task.jsm:"))
|
||||
stack = Task.Debugging.generateReadableStack(stack);
|
||||
return "JS Stack trace: " + stack.trim()
|
||||
.replace(/@[^@]*?([^\/\.]+\.\w+:)/g, "@$1");
|
||||
}
|
||||
|
@ -75,7 +75,6 @@ outstanding operations before FooService shuts down.
|
||||
// Module FooService
|
||||
|
||||
Components.utils.import("resource://gre/modules/AsyncShutdown.jsm", this);
|
||||
Components.utils.import("resource://gre/modules/Task.jsm", this);
|
||||
|
||||
this.exports = ["FooService"];
|
||||
|
||||
@ -84,12 +83,12 @@ outstanding operations before FooService shuts down.
|
||||
// Export the `client` capability, to let clients register shutdown blockers
|
||||
FooService.shutdown = shutdown.client;
|
||||
|
||||
// This Task should be triggered at some point during shutdown, generally
|
||||
// as a client to another Barrier or Phase. Triggering this Task is not covered
|
||||
// This function should be triggered at some point during shutdown, generally
|
||||
// as a client to another Barrier or Phase. Triggering this function is not covered
|
||||
// in this snippet.
|
||||
let onshutdown = Task.async(function*() {
|
||||
let onshutdown = async function() {
|
||||
// Wait for all registered clients to have lifted the barrier
|
||||
yield shutdown.wait();
|
||||
await shutdown.wait();
|
||||
|
||||
// Now deactivate FooService itself.
|
||||
// ...
|
||||
@ -121,7 +120,7 @@ The following snippet presents FooClient2, a more sophisticated client of FooSer
|
||||
// It can be any JSON serializable object.
|
||||
state: "Not started",
|
||||
|
||||
wait: Task.async(function*() {
|
||||
async wait() {
|
||||
// This method is called once FooService starts informing its clients that
|
||||
// FooService wishes to shut down.
|
||||
|
||||
@ -130,19 +129,19 @@ The following snippet presents FooClient2, a more sophisticated client of FooSer
|
||||
// to shutdown properly.
|
||||
this.state = "Starting";
|
||||
|
||||
let data = yield collectSomeData();
|
||||
let data = await collectSomeData();
|
||||
this.state = "Data collection complete";
|
||||
|
||||
try {
|
||||
yield writeSomeDataToDisk(data);
|
||||
await writeSomeDataToDisk(data);
|
||||
this.state = "Data successfully written to disk";
|
||||
} catch (ex) {
|
||||
this.state = "Writing data to disk failed, proceeding with shutdown: " + ex;
|
||||
}
|
||||
|
||||
yield FooService.oneLastCall();
|
||||
await FooService.oneLastCall();
|
||||
this.state = "Ready";
|
||||
}.bind(this)
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -154,7 +153,6 @@ Example 4: A service with both internal and external dependencies
|
||||
// Module FooService2
|
||||
|
||||
Components.utils.import("resource://gre/modules/AsyncShutdown.jsm", this);
|
||||
Components.utils.import("resource://gre/modules/Task.jsm", this);
|
||||
Components.utils.import("resource://gre/modules/Promise.jsm", this);
|
||||
|
||||
this.exports = ["FooService2"];
|
||||
@ -199,19 +197,19 @@ Example 4: A service with both internal and external dependencies
|
||||
};
|
||||
|
||||
|
||||
// This Task should be triggered at some point during shutdown, generally
|
||||
// as a client to another Barrier. Triggering this Task is not covered
|
||||
// This function should be triggered at some point during shutdown, generally
|
||||
// as a client to another Barrier. Triggering this function is not covered
|
||||
// in this snippet.
|
||||
let onshutdown = Task.async(function*() {
|
||||
let onshutdown = async function() {
|
||||
// Wait for all registered clients to have lifted the barrier.
|
||||
// These clients may open instances of FooConnection if they need to.
|
||||
yield shutdown.wait();
|
||||
await shutdown.wait();
|
||||
|
||||
// Now stop accepting any other connection request.
|
||||
isClosed = true;
|
||||
|
||||
// Wait for all instances of FooConnection to be closed.
|
||||
yield connections.wait();
|
||||
await connections.wait();
|
||||
|
||||
// Now finish shutting down FooService2
|
||||
// ...
|
||||
|
Loading…
Reference in New Issue
Block a user