track async api requests

This commit is contained in:
Robo 2016-02-22 19:30:21 +05:30
parent 2b547bd44a
commit a734326907
8 changed files with 39 additions and 39 deletions

View file

@ -32,17 +32,16 @@ v8Util.setHiddenValue(global, 'ipc', new events.EventEmitter);
const electron = require('electron');
// Call webFrame method.
const asyncWebFrameMethods = [
'executeJavaScript'
];
electron.ipcRenderer.on('ELECTRON_INTERNAL_RENDERER_WEB_FRAME_METHOD', (event, method, args) => {
if (asyncWebFrameMethods.includes(method)) {
const responseCallback = function(result) {
event.sender.send('ELECTRON_INTERNAL_RENDERER_WEB_FRAME_RESPONSE', method, result);
};
args.push(responseCallback);
}
electron.webFrame[method].apply(electron.webFrame, args);
});
electron.ipcRenderer.on('ELECTRON_INTERNAL_RENDERER_ASYNC_WEB_FRAME_METHOD', (event, method, args) => {
let requestId = args.shift();
const responseCallback = function(result) {
event.sender.send('ELECTRON_INTERNAL_RENDERER_ASYNC_WEB_FRAME_RESPONSE', requestId, result);
};
args.push(responseCallback);
electron.webFrame[method].apply(electron.webFrame, args);
});