diff --git a/atom/browser/api/lib/auto-updater/auto-updater-win.js b/atom/browser/api/lib/auto-updater/auto-updater-win.js index 7d62809a56ce..61b1911e232e 100644 --- a/atom/browser/api/lib/auto-updater/auto-updater-win.js +++ b/atom/browser/api/lib/auto-updater/auto-updater-win.js @@ -62,11 +62,8 @@ AutoUpdater = (function(superClass) { }; - /* - Private: Emit both error object and message, this is to keep compatibility - with Old APIs. - */ - + // Private: Emit both error object and message, this is to keep compatibility + // with Old APIs. AutoUpdater.prototype.emitError = function(message) { return this.emit('error', new Error(message), message); }; diff --git a/atom/browser/api/lib/auto-updater/squirrel-update-win.js b/atom/browser/api/lib/auto-updater/squirrel-update-win.js index 78c127eae46b..2f68c1dace46 100644 --- a/atom/browser/api/lib/auto-updater/squirrel-update-win.js +++ b/atom/browser/api/lib/auto-updater/squirrel-update-win.js @@ -6,24 +6,16 @@ path = require('path'); spawn = require('child_process').spawn; - // i.e. my-app/app-0.1.13/ - appFolder = path.dirname(process.execPath); - // i.e. my-app/Update.exe - updateExe = path.resolve(appFolder, '..', 'Update.exe'); 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) { var error, error1, errorEmitted, spawnedProcess, stderr, stdout; try { diff --git a/atom/browser/api/lib/browser-window.js b/atom/browser/api/lib/browser-window.js index f3b297ebbaf2..79395250f823 100644 --- a/atom/browser/api/lib/browser-window.js +++ b/atom/browser/api/lib/browser-window.js @@ -33,10 +33,8 @@ BrowserWindow.prototype._init = function() { return ipcMain.emit('ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_OPEN', event, url, frameName, options); }); - /* - window.resizeTo(...) - window.moveTo(...) - */ + // window.resizeTo(...) + // window.moveTo(...) this.webContents.on('move', (function(_this) { return function(event, size) { return _this.setBounds(size); @@ -69,14 +67,12 @@ BrowserWindow.prototype._init = function() { }; })(this)); - /* - 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 - 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. - 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. - */ + // 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 + // 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. + // 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. this.webContents.once('load-url', function() { return this.focus(); }); diff --git a/atom/browser/api/lib/navigation-controller.js b/atom/browser/api/lib/navigation-controller.js index ff9b440a9164..5e613f416f4e 100644 --- a/atom/browser/api/lib/navigation-controller.js +++ b/atom/browser/api/lib/navigation-controller.js @@ -18,15 +18,11 @@ ipcMain.on('ATOM_SHELL_SYNC_NAVIGATION_CONTROLLER', function() { 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 - control on user land, and only rely on WebContents.loadURL for navigation. - This helps us avoid Chromium's various optimizations so we can ensure renderer - process is restarted everytime. - */ - +// JavaScript implementation of Chromium's NavigationController. +// Instead of relying on Chromium for history control, we compeletely do history +// control on user land, and only rely on WebContents.loadURL for navigation. +// This helps us avoid Chromium's various optimizations so we can ensure renderer +// process is restarted everytime. NavigationController = (function() { function NavigationController(webContents) { this.webContents = webContents; diff --git a/atom/browser/api/lib/web-contents.js b/atom/browser/api/lib/web-contents.js index c7d6786b17b2..b1d7ee4febd9 100644 --- a/atom/browser/api/lib/web-contents.js +++ b/atom/browser/api/lib/web-contents.js @@ -138,10 +138,8 @@ wrapWebContents = function(webContents) { var args; args = 1 <= arguments.length ? slice.call(arguments, 0) : []; - /* - Calling loadURL during this event might cause crash, so delay the event - until next tick. - */ + // Calling loadURL during this event might cause crash, so delay the event + // until next tick. return setImmediate((function(_this) { return function() { return _this.emit.apply(_this, ['did-fail-load'].concat(slice.call(args))); diff --git a/atom/browser/lib/chrome-extension.js b/atom/browser/lib/chrome-extension.js index 80b3e0e644dd..a6bb44e33823 100644 --- a/atom/browser/lib/chrome-extension.js +++ b/atom/browser/lib/chrome-extension.js @@ -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, diff --git a/atom/browser/lib/desktop-capturer.js b/atom/browser/lib/desktop-capturer.js index 2ebb3d2fa227..68da4e27f1e4 100644 --- a/atom/browser/lib/desktop-capturer.js +++ b/atom/browser/lib/desktop-capturer.js @@ -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]; diff --git a/atom/browser/lib/guest-view-manager.js b/atom/browser/lib/guest-view-manager.js index 2560c8e0a641..fa409f89c41b 100644 --- a/atom/browser/lib/guest-view-manager.js +++ b/atom/browser/lib/guest-view-manager.js @@ -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); diff --git a/atom/browser/lib/guest-window-manager.js b/atom/browser/lib/guest-window-manager.js index 302a6530df01..df129b4a0928 100644 --- a/atom/browser/lib/guest-window-manager.js +++ b/atom/browser/lib/guest-window-manager.js @@ -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); diff --git a/atom/browser/lib/init.js b/atom/browser/lib/init.js index 34f780852f59..9ce4e55ee3be 100644 --- a/atom/browser/lib/init.js +++ b/atom/browser/lib/init.js @@ -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) : []; diff --git a/atom/browser/lib/objects-registry.js b/atom/browser/lib/objects-registry.js index 5f134e8e9ef3..082f1ef3441d 100644 --- a/atom/browser/lib/objects-registry.js +++ b/atom/browser/lib/objects-registry.js @@ -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]; diff --git a/atom/browser/lib/rpc-server.js b/atom/browser/lib/rpc-server.js index ab7dee85f6ee..13405b8ed96d 100644 --- a/atom/browser/lib/rpc-server.js +++ b/atom/browser/lib/rpc-server.js @@ -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) { diff --git a/atom/common/api/lib/callbacks-registry.js b/atom/common/api/lib/callbacks-registry.js index 018301825302..5c74388ec409 100644 --- a/atom/common/api/lib/callbacks-registry.js +++ b/atom/common/api/lib/callbacks-registry.js @@ -19,10 +19,8 @@ module.exports = CallbacksRegistry = (function() { } id = ++this.nextId; - /* - Capture the location of the function and put it in the ID string, - so that release errors can be tracked down easily. - */ + // Capture the location of the function and put it in the ID string, + // so that release errors can be tracked down easily. regexp = /at (.*)/gi; stackString = (new Error).stack; while ((match = regexp.exec(stackString)) !== null) { diff --git a/atom/common/lib/asar.js b/atom/common/lib/asar.js index c90b59ddb764..843b6d75aa7f 100644 --- a/atom/common/lib/asar.js +++ b/atom/common/lib/asar.js @@ -571,12 +571,10 @@ exports.wrapFsWithAsar = function(fs) { } }; - /* - Calling mkdir for directory inside asar archive should throw ENOTDIR - error, but on Windows it throws ENOENT. - This is to work around the recursive looping bug of mkdirp since it is - widely used. - */ + // Calling mkdir for directory inside asar archive should throw ENOTDIR + // error, but on Windows it throws ENOENT. + // This is to work around the recursive looping bug of mkdirp since it is + // widely used. if (process.platform === 'win32') { mkdir = fs.mkdir; fs.mkdir = function(p, mode, callback) { diff --git a/atom/common/lib/init.js b/atom/common/lib/init.js index 44291ff45262..dca836c7db81 100644 --- a/atom/common/lib/init.js +++ b/atom/common/lib/init.js @@ -27,15 +27,12 @@ if (!process.env.ELECTRON_HIDE_INTERNAL_MODULES) { } -/* - 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 - callbacks wouldn't be called until something else activated the uv loop, - which would delay the callbacks for arbitrary long time. So we should - initiatively activate the uv loop once setImmediate and process.nextTick is - called. - */ - +// 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 +// callbacks wouldn't be called until something else activated the uv loop, +// which would delay the callbacks for arbitrary long time. So we should +// initiatively activate the uv loop once setImmediate and process.nextTick is +// called. wrapWithActivateUvLoop = function(func) { return function() { process.activateUvLoop(); @@ -51,12 +48,10 @@ global.clearImmediate = timers.clearImmediate; if (process.type === 'browser') { - /* - 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 - to update the timeout, so we have to force the node's event loop to - recalculate the timeout in browser process. - */ + // 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 + // to update the timeout, so we have to force the node's event loop to + // recalculate the timeout in browser process. global.setTimeout = wrapWithActivateUvLoop(timers.setTimeout); global.setInterval = wrapWithActivateUvLoop(timers.setInterval); }