Use // for multi-line comments
This commit is contained in:
parent
f4af744519
commit
990dc30e8d
15 changed files with 65 additions and 138 deletions
|
@ -36,10 +36,8 @@ getExtensionInfoFromPath = function(srcDirectory) {
|
|||
manifest = JSON.parse(fs.readFileSync(path.join(srcDirectory, 'manifest.json')));
|
||||
if (extensionInfoMap[manifest.name] == null) {
|
||||
|
||||
/*
|
||||
We can not use 'file://' directly because all resources in the extension
|
||||
will be treated as relative to the root in Chrome.
|
||||
*/
|
||||
// We can not use 'file://' directly because all resources in the extension
|
||||
// will be treated as relative to the root in Chrome.
|
||||
page = url.format({
|
||||
protocol: 'chrome-extension',
|
||||
slashes: true,
|
||||
|
|
|
@ -29,10 +29,8 @@ ipcMain.on('ATOM_BROWSER_DESKTOP_CAPTURER_GET_SOURCES', function(event, captureW
|
|||
desktopCapturer.startHandling(captureWindow, captureScreen, thumbnailSize);
|
||||
}
|
||||
|
||||
/*
|
||||
If the WebContents is destroyed before receiving result, just remove the
|
||||
reference from requestsQueue to make the module not send the result to it.
|
||||
*/
|
||||
// If the WebContents is destroyed before receiving result, just remove the
|
||||
// reference from requestsQueue to make the module not send the result to it.
|
||||
return event.sender.once('destroyed', function() {
|
||||
return request.webContents = null;
|
||||
});
|
||||
|
@ -60,10 +58,8 @@ desktopCapturer.emit = function(event, name, sources) {
|
|||
ref.send("ATOM_RENDERER_DESKTOP_CAPTURER_RESULT_" + handledRequest.id, result);
|
||||
}
|
||||
|
||||
/*
|
||||
Check the queue to see whether there is other same request. If has, handle
|
||||
it for reducing redunplicated `desktopCaptuer.startHandling` calls.
|
||||
*/
|
||||
// Check the queue to see whether there is other same request. If has, handle
|
||||
// it for reducing redunplicated `desktopCaptuer.startHandling` calls.
|
||||
unhandledRequestsQueue = [];
|
||||
for (i = 0, len = requestsQueue.length; i < len; i++) {
|
||||
request = requestsQueue[i];
|
||||
|
|
|
@ -62,11 +62,9 @@ createGuest = function(embedder, params) {
|
|||
event = destroyEvents[i];
|
||||
embedder.once(event, destroy);
|
||||
|
||||
/*
|
||||
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
|
||||
listener to the first one in queue.
|
||||
*/
|
||||
// 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
|
||||
// listener to the first one in queue.
|
||||
listeners = embedder._events[event];
|
||||
if (Array.isArray(listeners)) {
|
||||
moveLastToFirst(listeners);
|
||||
|
|
|
@ -65,11 +65,9 @@ createGuest = function(embedder, url, frameName, options) {
|
|||
guest = new BrowserWindow(options);
|
||||
guest.loadURL(url);
|
||||
|
||||
/*
|
||||
When |embedder| is destroyed we should also destroy attached guest, and if
|
||||
guest is closed by user then we should prevent |embedder| from double
|
||||
closing guest.
|
||||
*/
|
||||
// When |embedder| is destroyed we should also destroy attached guest, and if
|
||||
// guest is closed by user then we should prevent |embedder| from double
|
||||
// closing guest.
|
||||
guestId = guest.id;
|
||||
closedByEmbedder = function() {
|
||||
guest.removeListener('closed', closedByUser);
|
||||
|
|
|
@ -17,14 +17,10 @@ Module = require('module');
|
|||
|
||||
process.argv.splice(1, 1);
|
||||
|
||||
|
||||
// Clear search paths.
|
||||
|
||||
require(path.resolve(__dirname, '..', '..', 'common', 'lib', 'reset-search-paths'));
|
||||
|
||||
|
||||
// Import common settings.
|
||||
|
||||
require(path.resolve(__dirname, '..', '..', 'common', 'lib', 'init'));
|
||||
|
||||
globalPaths = Module.globalPaths;
|
||||
|
@ -33,17 +29,12 @@ if (!process.env.ELECTRON_HIDE_INTERNAL_MODULES) {
|
|||
globalPaths.push(path.resolve(__dirname, '..', 'api', 'lib'));
|
||||
}
|
||||
|
||||
|
||||
// Expose public APIs.
|
||||
|
||||
globalPaths.push(path.resolve(__dirname, '..', 'api', 'lib', 'exports'));
|
||||
|
||||
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() {
|
||||
var args;
|
||||
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
|
||||
|
|
|
@ -13,25 +13,17 @@ ObjectsRegistry = (function(superClass) {
|
|||
this.setMaxListeners(Number.MAX_VALUE);
|
||||
this.nextId = 0;
|
||||
|
||||
/*
|
||||
Stores all objects by ref-counting.
|
||||
(id) => {object, count}
|
||||
*/
|
||||
// Stores all objects by ref-counting.
|
||||
// (id) => {object, count}
|
||||
this.storage = {};
|
||||
|
||||
/*
|
||||
Stores the IDs of objects referenced by WebContents.
|
||||
(webContentsId) => {(id) => (count)}
|
||||
*/
|
||||
// Stores the IDs of objects referenced by WebContents.
|
||||
// (webContentsId) => {(id) => (count)}
|
||||
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) {
|
||||
var base, base1, id;
|
||||
id = this.saveToStorage(obj);
|
||||
|
@ -51,7 +43,6 @@ ObjectsRegistry = (function(superClass) {
|
|||
|
||||
|
||||
// Get an object according to its ID.
|
||||
|
||||
ObjectsRegistry.prototype.get = function(id) {
|
||||
var ref;
|
||||
return (ref = this.storage[id]) != null ? ref.object : void 0;
|
||||
|
@ -59,7 +50,6 @@ ObjectsRegistry = (function(superClass) {
|
|||
|
||||
|
||||
// Dereference an object according to its ID.
|
||||
|
||||
ObjectsRegistry.prototype.remove = function(webContentsId, id) {
|
||||
var pointer;
|
||||
this.dereference(id, 1);
|
||||
|
@ -77,7 +67,6 @@ ObjectsRegistry = (function(superClass) {
|
|||
|
||||
|
||||
// Clear all references to objects refrenced by the WebContents.
|
||||
|
||||
ObjectsRegistry.prototype.clear = function(webContentsId) {
|
||||
var count, id, ref;
|
||||
this.emit("clear-" + webContentsId);
|
||||
|
@ -94,7 +83,6 @@ ObjectsRegistry = (function(superClass) {
|
|||
|
||||
|
||||
// Private: Saves the object into storage and assigns an ID for it.
|
||||
|
||||
ObjectsRegistry.prototype.saveToStorage = function(object) {
|
||||
var id;
|
||||
id = v8Util.getHiddenValue(object, 'atomId');
|
||||
|
@ -112,7 +100,6 @@ ObjectsRegistry = (function(superClass) {
|
|||
|
||||
|
||||
// Private: Dereference the object from store.
|
||||
|
||||
ObjectsRegistry.prototype.dereference = function(id, count) {
|
||||
var pointer;
|
||||
pointer = this.storage[id];
|
||||
|
|
|
@ -61,11 +61,9 @@ valueToMeta = function(sender, value, optimizeSimpleObject) {
|
|||
} else if (meta.type === 'object' || meta.type === 'function') {
|
||||
meta.name = value.constructor.name;
|
||||
|
||||
/*
|
||||
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
|
||||
it.
|
||||
*/
|
||||
// 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
|
||||
// it.
|
||||
meta.id = objectsRegistry.add(sender.getId(), value);
|
||||
meta.members = (function() {
|
||||
var results;
|
||||
|
@ -196,12 +194,8 @@ unwrapArgs = function(sender, args) {
|
|||
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) {
|
||||
var e, error1, funcMarkedAsync, funcName, funcPassedCallback, ref, ret;
|
||||
funcMarkedAsync = v8Util.getHiddenValue(func, 'asynchronous');
|
||||
|
@ -219,11 +213,9 @@ callFunction = function(event, func, caller, args) {
|
|||
} catch (error1) {
|
||||
e = error1;
|
||||
|
||||
/*
|
||||
Catch functions thrown further down in function invocation and wrap
|
||||
them with the function name so it's easier to trace things like
|
||||
`Error processing argument -1.`
|
||||
*/
|
||||
// Catch functions thrown further down in function invocation and wrap
|
||||
// them with the function name so it's easier to trace things like
|
||||
// `Error processing argument -1.`
|
||||
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);
|
||||
}
|
||||
|
@ -231,7 +223,6 @@ callFunction = function(event, func, caller, args) {
|
|||
|
||||
|
||||
// Send by BrowserWindow when its render view is deleted.
|
||||
|
||||
process.on('ATOM_BROWSER_RELEASE_RENDER_VIEW', function(id) {
|
||||
return objectsRegistry.clear(id);
|
||||
});
|
||||
|
@ -286,10 +277,8 @@ ipcMain.on('ATOM_BROWSER_CONSTRUCTOR', function(event, id, args) {
|
|||
args = unwrapArgs(event.sender, args);
|
||||
constructor = objectsRegistry.get(id);
|
||||
|
||||
/*
|
||||
Call new with array of arguments.
|
||||
http://stackoverflow.com/questions/1606797/use-of-apply-with-new-operator-is-this-possible
|
||||
*/
|
||||
// Call new with array of arguments.
|
||||
// http://stackoverflow.com/questions/1606797/use-of-apply-with-new-operator-is-this-possible
|
||||
obj = new (Function.prototype.bind.apply(constructor, [null].concat(args)));
|
||||
return event.returnValue = valueToMeta(event.sender, obj);
|
||||
} catch (error1) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue