Use // for multi-line comments
This commit is contained in:
parent
f4af744519
commit
990dc30e8d
15 changed files with 65 additions and 138 deletions
|
@ -62,11 +62,8 @@ AutoUpdater = (function(superClass) {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/*
|
// Private: Emit both error object and message, this is to keep compatibility
|
||||||
Private: Emit both error object and message, this is to keep compatibility
|
// with Old APIs.
|
||||||
with Old APIs.
|
|
||||||
*/
|
|
||||||
|
|
||||||
AutoUpdater.prototype.emitError = function(message) {
|
AutoUpdater.prototype.emitError = function(message) {
|
||||||
return this.emit('error', new Error(message), message);
|
return this.emit('error', new Error(message), message);
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,24 +6,16 @@ path = require('path');
|
||||||
|
|
||||||
spawn = require('child_process').spawn;
|
spawn = require('child_process').spawn;
|
||||||
|
|
||||||
|
|
||||||
// i.e. my-app/app-0.1.13/
|
// i.e. my-app/app-0.1.13/
|
||||||
|
|
||||||
appFolder = path.dirname(process.execPath);
|
appFolder = path.dirname(process.execPath);
|
||||||
|
|
||||||
|
|
||||||
// i.e. my-app/Update.exe
|
// i.e. my-app/Update.exe
|
||||||
|
|
||||||
updateExe = path.resolve(appFolder, '..', 'Update.exe');
|
updateExe = path.resolve(appFolder, '..', 'Update.exe');
|
||||||
|
|
||||||
exeName = path.basename(process.execPath);
|
exeName = path.basename(process.execPath);
|
||||||
|
|
||||||
|
// Spawn a command and invoke the callback when it completes with an error
|
||||||
/*
|
// and the output from standard out.
|
||||||
Spawn a command and invoke the callback when it completes with an error
|
|
||||||
and the output from standard out.
|
|
||||||
*/
|
|
||||||
|
|
||||||
spawnUpdate = function(args, detached, callback) {
|
spawnUpdate = function(args, detached, callback) {
|
||||||
var error, error1, errorEmitted, spawnedProcess, stderr, stdout;
|
var error, error1, errorEmitted, spawnedProcess, stderr, stdout;
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -33,10 +33,8 @@ BrowserWindow.prototype._init = function() {
|
||||||
return ipcMain.emit('ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_OPEN', event, url, frameName, options);
|
return ipcMain.emit('ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_OPEN', event, url, frameName, options);
|
||||||
});
|
});
|
||||||
|
|
||||||
/*
|
// window.resizeTo(...)
|
||||||
window.resizeTo(...)
|
// window.moveTo(...)
|
||||||
window.moveTo(...)
|
|
||||||
*/
|
|
||||||
this.webContents.on('move', (function(_this) {
|
this.webContents.on('move', (function(_this) {
|
||||||
return function(event, size) {
|
return function(event, size) {
|
||||||
return _this.setBounds(size);
|
return _this.setBounds(size);
|
||||||
|
@ -69,14 +67,12 @@ BrowserWindow.prototype._init = function() {
|
||||||
};
|
};
|
||||||
})(this));
|
})(this));
|
||||||
|
|
||||||
/*
|
// Sometimes the webContents doesn't get focus when window is shown, so we have
|
||||||
Sometimes the webContents doesn't get focus when window is shown, so we have
|
// to force focusing on webContents in this case. The safest way is to focus it
|
||||||
to force focusing on webContents in this case. The safest way is to focus it
|
// when we first start to load URL, if we do it earlier it won't have effect,
|
||||||
when we first start to load URL, if we do it earlier it won't have effect,
|
// if we do it later we might move focus in the page.
|
||||||
if we do it later we might move focus in the page.
|
// Though this hack is only needed on OS X when the app is launched from
|
||||||
Though this hack is only needed on OS X when the app is launched from
|
// Finder, we still do it on all platforms in case of other bugs we don't know.
|
||||||
Finder, we still do it on all platforms in case of other bugs we don't know.
|
|
||||||
*/
|
|
||||||
this.webContents.once('load-url', function() {
|
this.webContents.once('load-url', function() {
|
||||||
return this.focus();
|
return this.focus();
|
||||||
});
|
});
|
||||||
|
|
|
@ -18,15 +18,11 @@ ipcMain.on('ATOM_SHELL_SYNC_NAVIGATION_CONTROLLER', function() {
|
||||||
return event.returnValue = (ref = event.sender)[method].apply(ref, args);
|
return event.returnValue = (ref = event.sender)[method].apply(ref, args);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// JavaScript implementation of Chromium's NavigationController.
|
||||||
/*
|
// Instead of relying on Chromium for history control, we compeletely do history
|
||||||
JavaScript implementation of Chromium's NavigationController.
|
// control on user land, and only rely on WebContents.loadURL for navigation.
|
||||||
Instead of relying on Chromium for history control, we compeletely do history
|
// This helps us avoid Chromium's various optimizations so we can ensure renderer
|
||||||
control on user land, and only rely on WebContents.loadURL for navigation.
|
// process is restarted everytime.
|
||||||
This helps us avoid Chromium's various optimizations so we can ensure renderer
|
|
||||||
process is restarted everytime.
|
|
||||||
*/
|
|
||||||
|
|
||||||
NavigationController = (function() {
|
NavigationController = (function() {
|
||||||
function NavigationController(webContents) {
|
function NavigationController(webContents) {
|
||||||
this.webContents = webContents;
|
this.webContents = webContents;
|
||||||
|
|
|
@ -138,10 +138,8 @@ wrapWebContents = function(webContents) {
|
||||||
var args;
|
var args;
|
||||||
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
|
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
|
||||||
|
|
||||||
/*
|
// Calling loadURL during this event might cause crash, so delay the event
|
||||||
Calling loadURL during this event might cause crash, so delay the event
|
// until next tick.
|
||||||
until next tick.
|
|
||||||
*/
|
|
||||||
return setImmediate((function(_this) {
|
return setImmediate((function(_this) {
|
||||||
return function() {
|
return function() {
|
||||||
return _this.emit.apply(_this, ['did-fail-load'].concat(slice.call(args)));
|
return _this.emit.apply(_this, ['did-fail-load'].concat(slice.call(args)));
|
||||||
|
|
|
@ -36,10 +36,8 @@ getExtensionInfoFromPath = function(srcDirectory) {
|
||||||
manifest = JSON.parse(fs.readFileSync(path.join(srcDirectory, 'manifest.json')));
|
manifest = JSON.parse(fs.readFileSync(path.join(srcDirectory, 'manifest.json')));
|
||||||
if (extensionInfoMap[manifest.name] == null) {
|
if (extensionInfoMap[manifest.name] == null) {
|
||||||
|
|
||||||
/*
|
// We can not use 'file://' directly because all resources in the extension
|
||||||
We can not use 'file://' directly because all resources in the extension
|
// will be treated as relative to the root in Chrome.
|
||||||
will be treated as relative to the root in Chrome.
|
|
||||||
*/
|
|
||||||
page = url.format({
|
page = url.format({
|
||||||
protocol: 'chrome-extension',
|
protocol: 'chrome-extension',
|
||||||
slashes: true,
|
slashes: true,
|
||||||
|
|
|
@ -29,10 +29,8 @@ ipcMain.on('ATOM_BROWSER_DESKTOP_CAPTURER_GET_SOURCES', function(event, captureW
|
||||||
desktopCapturer.startHandling(captureWindow, captureScreen, thumbnailSize);
|
desktopCapturer.startHandling(captureWindow, captureScreen, thumbnailSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// If the WebContents is destroyed before receiving result, just remove the
|
||||||
If the WebContents is destroyed before receiving result, just remove the
|
// reference from requestsQueue to make the module not send the result to it.
|
||||||
reference from requestsQueue to make the module not send the result to it.
|
|
||||||
*/
|
|
||||||
return event.sender.once('destroyed', function() {
|
return event.sender.once('destroyed', function() {
|
||||||
return request.webContents = null;
|
return request.webContents = null;
|
||||||
});
|
});
|
||||||
|
@ -60,10 +58,8 @@ desktopCapturer.emit = function(event, name, sources) {
|
||||||
ref.send("ATOM_RENDERER_DESKTOP_CAPTURER_RESULT_" + handledRequest.id, result);
|
ref.send("ATOM_RENDERER_DESKTOP_CAPTURER_RESULT_" + handledRequest.id, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// Check the queue to see whether there is other same request. If has, handle
|
||||||
Check the queue to see whether there is other same request. If has, handle
|
// it for reducing redunplicated `desktopCaptuer.startHandling` calls.
|
||||||
it for reducing redunplicated `desktopCaptuer.startHandling` calls.
|
|
||||||
*/
|
|
||||||
unhandledRequestsQueue = [];
|
unhandledRequestsQueue = [];
|
||||||
for (i = 0, len = requestsQueue.length; i < len; i++) {
|
for (i = 0, len = requestsQueue.length; i < len; i++) {
|
||||||
request = requestsQueue[i];
|
request = requestsQueue[i];
|
||||||
|
|
|
@ -62,11 +62,9 @@ createGuest = function(embedder, params) {
|
||||||
event = destroyEvents[i];
|
event = destroyEvents[i];
|
||||||
embedder.once(event, destroy);
|
embedder.once(event, destroy);
|
||||||
|
|
||||||
/*
|
// Users might also listen to the crashed event, so We must ensure the guest
|
||||||
Users might also listen to the crashed event, so We must ensure the guest
|
// is destroyed before users' listener gets called. It is done by moving our
|
||||||
is destroyed before users' listener gets called. It is done by moving our
|
// listener to the first one in queue.
|
||||||
listener to the first one in queue.
|
|
||||||
*/
|
|
||||||
listeners = embedder._events[event];
|
listeners = embedder._events[event];
|
||||||
if (Array.isArray(listeners)) {
|
if (Array.isArray(listeners)) {
|
||||||
moveLastToFirst(listeners);
|
moveLastToFirst(listeners);
|
||||||
|
|
|
@ -65,11 +65,9 @@ createGuest = function(embedder, url, frameName, options) {
|
||||||
guest = new BrowserWindow(options);
|
guest = new BrowserWindow(options);
|
||||||
guest.loadURL(url);
|
guest.loadURL(url);
|
||||||
|
|
||||||
/*
|
// When |embedder| is destroyed we should also destroy attached guest, and if
|
||||||
When |embedder| is destroyed we should also destroy attached guest, and if
|
// guest is closed by user then we should prevent |embedder| from double
|
||||||
guest is closed by user then we should prevent |embedder| from double
|
// closing guest.
|
||||||
closing guest.
|
|
||||||
*/
|
|
||||||
guestId = guest.id;
|
guestId = guest.id;
|
||||||
closedByEmbedder = function() {
|
closedByEmbedder = function() {
|
||||||
guest.removeListener('closed', closedByUser);
|
guest.removeListener('closed', closedByUser);
|
||||||
|
|
|
@ -17,14 +17,10 @@ Module = require('module');
|
||||||
|
|
||||||
process.argv.splice(1, 1);
|
process.argv.splice(1, 1);
|
||||||
|
|
||||||
|
|
||||||
// Clear search paths.
|
// Clear search paths.
|
||||||
|
|
||||||
require(path.resolve(__dirname, '..', '..', 'common', 'lib', 'reset-search-paths'));
|
require(path.resolve(__dirname, '..', '..', 'common', 'lib', 'reset-search-paths'));
|
||||||
|
|
||||||
|
|
||||||
// Import common settings.
|
// Import common settings.
|
||||||
|
|
||||||
require(path.resolve(__dirname, '..', '..', 'common', 'lib', 'init'));
|
require(path.resolve(__dirname, '..', '..', 'common', 'lib', 'init'));
|
||||||
|
|
||||||
globalPaths = Module.globalPaths;
|
globalPaths = Module.globalPaths;
|
||||||
|
@ -33,17 +29,12 @@ if (!process.env.ELECTRON_HIDE_INTERNAL_MODULES) {
|
||||||
globalPaths.push(path.resolve(__dirname, '..', 'api', 'lib'));
|
globalPaths.push(path.resolve(__dirname, '..', 'api', 'lib'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Expose public APIs.
|
// Expose public APIs.
|
||||||
|
|
||||||
globalPaths.push(path.resolve(__dirname, '..', 'api', 'lib', 'exports'));
|
globalPaths.push(path.resolve(__dirname, '..', 'api', 'lib', 'exports'));
|
||||||
|
|
||||||
if (process.platform === 'win32') {
|
if (process.platform === 'win32') {
|
||||||
|
// Redirect node's console to use our own implementations, since node can not
|
||||||
/*
|
// handle console output when running as GUI program.
|
||||||
Redirect node's console to use our own implementations, since node can not
|
|
||||||
handle console output when running as GUI program.
|
|
||||||
*/
|
|
||||||
consoleLog = function() {
|
consoleLog = function() {
|
||||||
var args;
|
var args;
|
||||||
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
|
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
|
||||||
|
|
|
@ -13,25 +13,17 @@ ObjectsRegistry = (function(superClass) {
|
||||||
this.setMaxListeners(Number.MAX_VALUE);
|
this.setMaxListeners(Number.MAX_VALUE);
|
||||||
this.nextId = 0;
|
this.nextId = 0;
|
||||||
|
|
||||||
/*
|
// Stores all objects by ref-counting.
|
||||||
Stores all objects by ref-counting.
|
// (id) => {object, count}
|
||||||
(id) => {object, count}
|
|
||||||
*/
|
|
||||||
this.storage = {};
|
this.storage = {};
|
||||||
|
|
||||||
/*
|
// Stores the IDs of objects referenced by WebContents.
|
||||||
Stores the IDs of objects referenced by WebContents.
|
// (webContentsId) => {(id) => (count)}
|
||||||
(webContentsId) => {(id) => (count)}
|
|
||||||
*/
|
|
||||||
this.owners = {};
|
this.owners = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Register a new object, the object would be kept referenced until you release
|
||||||
/*
|
// it explicitly.
|
||||||
Register a new object, the object would be kept referenced until you release
|
|
||||||
it explicitly.
|
|
||||||
*/
|
|
||||||
|
|
||||||
ObjectsRegistry.prototype.add = function(webContentsId, obj) {
|
ObjectsRegistry.prototype.add = function(webContentsId, obj) {
|
||||||
var base, base1, id;
|
var base, base1, id;
|
||||||
id = this.saveToStorage(obj);
|
id = this.saveToStorage(obj);
|
||||||
|
@ -51,7 +43,6 @@ ObjectsRegistry = (function(superClass) {
|
||||||
|
|
||||||
|
|
||||||
// Get an object according to its ID.
|
// Get an object according to its ID.
|
||||||
|
|
||||||
ObjectsRegistry.prototype.get = function(id) {
|
ObjectsRegistry.prototype.get = function(id) {
|
||||||
var ref;
|
var ref;
|
||||||
return (ref = this.storage[id]) != null ? ref.object : void 0;
|
return (ref = this.storage[id]) != null ? ref.object : void 0;
|
||||||
|
@ -59,7 +50,6 @@ ObjectsRegistry = (function(superClass) {
|
||||||
|
|
||||||
|
|
||||||
// Dereference an object according to its ID.
|
// Dereference an object according to its ID.
|
||||||
|
|
||||||
ObjectsRegistry.prototype.remove = function(webContentsId, id) {
|
ObjectsRegistry.prototype.remove = function(webContentsId, id) {
|
||||||
var pointer;
|
var pointer;
|
||||||
this.dereference(id, 1);
|
this.dereference(id, 1);
|
||||||
|
@ -77,7 +67,6 @@ ObjectsRegistry = (function(superClass) {
|
||||||
|
|
||||||
|
|
||||||
// Clear all references to objects refrenced by the WebContents.
|
// Clear all references to objects refrenced by the WebContents.
|
||||||
|
|
||||||
ObjectsRegistry.prototype.clear = function(webContentsId) {
|
ObjectsRegistry.prototype.clear = function(webContentsId) {
|
||||||
var count, id, ref;
|
var count, id, ref;
|
||||||
this.emit("clear-" + webContentsId);
|
this.emit("clear-" + webContentsId);
|
||||||
|
@ -94,7 +83,6 @@ ObjectsRegistry = (function(superClass) {
|
||||||
|
|
||||||
|
|
||||||
// Private: Saves the object into storage and assigns an ID for it.
|
// Private: Saves the object into storage and assigns an ID for it.
|
||||||
|
|
||||||
ObjectsRegistry.prototype.saveToStorage = function(object) {
|
ObjectsRegistry.prototype.saveToStorage = function(object) {
|
||||||
var id;
|
var id;
|
||||||
id = v8Util.getHiddenValue(object, 'atomId');
|
id = v8Util.getHiddenValue(object, 'atomId');
|
||||||
|
@ -112,7 +100,6 @@ ObjectsRegistry = (function(superClass) {
|
||||||
|
|
||||||
|
|
||||||
// Private: Dereference the object from store.
|
// Private: Dereference the object from store.
|
||||||
|
|
||||||
ObjectsRegistry.prototype.dereference = function(id, count) {
|
ObjectsRegistry.prototype.dereference = function(id, count) {
|
||||||
var pointer;
|
var pointer;
|
||||||
pointer = this.storage[id];
|
pointer = this.storage[id];
|
||||||
|
|
|
@ -61,11 +61,9 @@ valueToMeta = function(sender, value, optimizeSimpleObject) {
|
||||||
} else if (meta.type === 'object' || meta.type === 'function') {
|
} else if (meta.type === 'object' || meta.type === 'function') {
|
||||||
meta.name = value.constructor.name;
|
meta.name = value.constructor.name;
|
||||||
|
|
||||||
/*
|
// Reference the original value if it's an object, because when it's
|
||||||
Reference the original value if it's an object, because when it's
|
// passed to renderer we would assume the renderer keeps a reference of
|
||||||
passed to renderer we would assume the renderer keeps a reference of
|
// it.
|
||||||
it.
|
|
||||||
*/
|
|
||||||
meta.id = objectsRegistry.add(sender.getId(), value);
|
meta.id = objectsRegistry.add(sender.getId(), value);
|
||||||
meta.members = (function() {
|
meta.members = (function() {
|
||||||
var results;
|
var results;
|
||||||
|
@ -196,12 +194,8 @@ unwrapArgs = function(sender, args) {
|
||||||
return args.map(metaToValue);
|
return args.map(metaToValue);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Call a function and send reply asynchronously if it's a an asynchronous
|
||||||
/*
|
// style function and the caller didn't pass a callback.
|
||||||
Call a function and send reply asynchronously if it's a an asynchronous
|
|
||||||
style function and the caller didn't pass a callback.
|
|
||||||
*/
|
|
||||||
|
|
||||||
callFunction = function(event, func, caller, args) {
|
callFunction = function(event, func, caller, args) {
|
||||||
var e, error1, funcMarkedAsync, funcName, funcPassedCallback, ref, ret;
|
var e, error1, funcMarkedAsync, funcName, funcPassedCallback, ref, ret;
|
||||||
funcMarkedAsync = v8Util.getHiddenValue(func, 'asynchronous');
|
funcMarkedAsync = v8Util.getHiddenValue(func, 'asynchronous');
|
||||||
|
@ -219,11 +213,9 @@ callFunction = function(event, func, caller, args) {
|
||||||
} catch (error1) {
|
} catch (error1) {
|
||||||
e = error1;
|
e = error1;
|
||||||
|
|
||||||
/*
|
// Catch functions thrown further down in function invocation and wrap
|
||||||
Catch functions thrown further down in function invocation and wrap
|
// them with the function name so it's easier to trace things like
|
||||||
them with the function name so it's easier to trace things like
|
// `Error processing argument -1.`
|
||||||
`Error processing argument -1.`
|
|
||||||
*/
|
|
||||||
funcName = (ref = func.name) != null ? ref : "anonymous";
|
funcName = (ref = func.name) != null ? ref : "anonymous";
|
||||||
throw new Error("Could not call remote function `" + funcName + "`. Check that the function signature is correct. Underlying error: " + e.message);
|
throw new Error("Could not call remote function `" + funcName + "`. Check that the function signature is correct. Underlying error: " + e.message);
|
||||||
}
|
}
|
||||||
|
@ -231,7 +223,6 @@ callFunction = function(event, func, caller, args) {
|
||||||
|
|
||||||
|
|
||||||
// Send by BrowserWindow when its render view is deleted.
|
// Send by BrowserWindow when its render view is deleted.
|
||||||
|
|
||||||
process.on('ATOM_BROWSER_RELEASE_RENDER_VIEW', function(id) {
|
process.on('ATOM_BROWSER_RELEASE_RENDER_VIEW', function(id) {
|
||||||
return objectsRegistry.clear(id);
|
return objectsRegistry.clear(id);
|
||||||
});
|
});
|
||||||
|
@ -286,10 +277,8 @@ ipcMain.on('ATOM_BROWSER_CONSTRUCTOR', function(event, id, args) {
|
||||||
args = unwrapArgs(event.sender, args);
|
args = unwrapArgs(event.sender, args);
|
||||||
constructor = objectsRegistry.get(id);
|
constructor = objectsRegistry.get(id);
|
||||||
|
|
||||||
/*
|
// Call new with array of arguments.
|
||||||
Call new with array of arguments.
|
// http://stackoverflow.com/questions/1606797/use-of-apply-with-new-operator-is-this-possible
|
||||||
http://stackoverflow.com/questions/1606797/use-of-apply-with-new-operator-is-this-possible
|
|
||||||
*/
|
|
||||||
obj = new (Function.prototype.bind.apply(constructor, [null].concat(args)));
|
obj = new (Function.prototype.bind.apply(constructor, [null].concat(args)));
|
||||||
return event.returnValue = valueToMeta(event.sender, obj);
|
return event.returnValue = valueToMeta(event.sender, obj);
|
||||||
} catch (error1) {
|
} catch (error1) {
|
||||||
|
|
|
@ -19,10 +19,8 @@ module.exports = CallbacksRegistry = (function() {
|
||||||
}
|
}
|
||||||
id = ++this.nextId;
|
id = ++this.nextId;
|
||||||
|
|
||||||
/*
|
// Capture the location of the function and put it in the ID string,
|
||||||
Capture the location of the function and put it in the ID string,
|
// so that release errors can be tracked down easily.
|
||||||
so that release errors can be tracked down easily.
|
|
||||||
*/
|
|
||||||
regexp = /at (.*)/gi;
|
regexp = /at (.*)/gi;
|
||||||
stackString = (new Error).stack;
|
stackString = (new Error).stack;
|
||||||
while ((match = regexp.exec(stackString)) !== null) {
|
while ((match = regexp.exec(stackString)) !== null) {
|
||||||
|
|
|
@ -571,12 +571,10 @@ exports.wrapFsWithAsar = function(fs) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
// Calling mkdir for directory inside asar archive should throw ENOTDIR
|
||||||
Calling mkdir for directory inside asar archive should throw ENOTDIR
|
// error, but on Windows it throws ENOENT.
|
||||||
error, but on Windows it throws ENOENT.
|
// This is to work around the recursive looping bug of mkdirp since it is
|
||||||
This is to work around the recursive looping bug of mkdirp since it is
|
// widely used.
|
||||||
widely used.
|
|
||||||
*/
|
|
||||||
if (process.platform === 'win32') {
|
if (process.platform === 'win32') {
|
||||||
mkdir = fs.mkdir;
|
mkdir = fs.mkdir;
|
||||||
fs.mkdir = function(p, mode, callback) {
|
fs.mkdir = function(p, mode, callback) {
|
||||||
|
|
|
@ -27,15 +27,12 @@ if (!process.env.ELECTRON_HIDE_INTERNAL_MODULES) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
// setImmediate and process.nextTick makes use of uv_check and uv_prepare to
|
||||||
setImmediate and process.nextTick makes use of uv_check and uv_prepare to
|
// run the callbacks, however since we only run uv loop on requests, the
|
||||||
run the callbacks, however since we only run uv loop on requests, the
|
// callbacks wouldn't be called until something else activated the uv loop,
|
||||||
callbacks wouldn't be called until something else activated the uv loop,
|
// which would delay the callbacks for arbitrary long time. So we should
|
||||||
which would delay the callbacks for arbitrary long time. So we should
|
// initiatively activate the uv loop once setImmediate and process.nextTick is
|
||||||
initiatively activate the uv loop once setImmediate and process.nextTick is
|
// called.
|
||||||
called.
|
|
||||||
*/
|
|
||||||
|
|
||||||
wrapWithActivateUvLoop = function(func) {
|
wrapWithActivateUvLoop = function(func) {
|
||||||
return function() {
|
return function() {
|
||||||
process.activateUvLoop();
|
process.activateUvLoop();
|
||||||
|
@ -51,12 +48,10 @@ global.clearImmediate = timers.clearImmediate;
|
||||||
|
|
||||||
if (process.type === 'browser') {
|
if (process.type === 'browser') {
|
||||||
|
|
||||||
/*
|
// setTimeout needs to update the polling timeout of the event loop, when
|
||||||
setTimeout needs to update the polling timeout of the event loop, when
|
// called under Chromium's event loop the node's event loop won't get a chance
|
||||||
called under Chromium's event loop the node's event loop won't get a chance
|
// to update the timeout, so we have to force the node's event loop to
|
||||||
to update the timeout, so we have to force the node's event loop to
|
// recalculate the timeout in browser process.
|
||||||
recalculate the timeout in browser process.
|
|
||||||
*/
|
|
||||||
global.setTimeout = wrapWithActivateUvLoop(timers.setTimeout);
|
global.setTimeout = wrapWithActivateUvLoop(timers.setTimeout);
|
||||||
global.setInterval = wrapWithActivateUvLoop(timers.setInterval);
|
global.setInterval = wrapWithActivateUvLoop(timers.setInterval);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue