Bug 782859 - Add e10s support the ContentHandler component [r=vingtetun]

This commit is contained in:
Fabrice Desré 2012-08-15 09:00:02 -07:00
Родитель 4ad387b16d
Коммит 23ce62fbf6
2 изменённых файлов: 29 добавлений и 12 удалений

Просмотреть файл

@ -44,6 +44,11 @@ XPCOMUtils.defineLazyGetter(this, 'DebuggerServer', function() {
return DebuggerServer;
});
XPCOMUtils.defineLazyGetter(this, "ppmm", function() {
return Cc["@mozilla.org/parentprocessmessagemanager;1"]
.getService(Ci.nsIFrameMessageManager);
});
function getContentWindow() {
return shell.contentBrowser.contentWindow;
}
@ -149,6 +154,8 @@ var shell = {
});
this.contentBrowser.src = homeURL;
ppmm.addMessageListener("content-handler", this);
},
stop: function shell_stop() {
@ -159,6 +166,7 @@ var shell = {
window.removeEventListener('mozfullscreenchange', this);
window.removeEventListener('sizemodechange', this);
this.contentBrowser.removeEventListener('mozbrowserloadstart', this, true);
ppmm.removeMessageListener("content-handler", this);
#ifndef MOZ_WIDGET_GONK
delete Services.audioManager;
@ -298,13 +306,29 @@ var shell = {
break;
}
},
sendEvent: function shell_sendEvent(content, type, details) {
let event = content.document.createEvent('CustomEvent');
event.initCustomEvent(type, true, true, details ? details : {});
content.dispatchEvent(event);
},
sendChromeEvent: function shell_sendChromeEvent(details) {
this.sendEvent(getContentWindow(), "mozChromeEvent", details);
},
receiveMessage: function shell_receiveMessage(message) {
if (message.name != 'content-handler') {
return;
}
let handler = message.json;
new MozActivity({
name: 'view',
data: {
type: handler.type,
url: handler.url
}
});
}
};
@ -602,17 +626,6 @@ window.addEventListener('ContentStart', function ss_onContentStart() {
});
});
Services.obs.addObserver(function ContentHandler(subject, topic, data) {
let handler = JSON.parse(data);
new MozActivity({
name: 'view',
data: {
type: handler.type,
url: handler.url
}
});
}, 'content-handler', false);
(function geolocationStatusTracker() {
let gGeolocationActiveCount = 0;

Просмотреть файл

@ -13,6 +13,10 @@ const PDF_CONTENT_TYPE = "application/pdf";
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
XPCOMUtils.defineLazyGetter(this, "cpmm", function() {
return Cc["@mozilla.org/childprocessmessagemanager;1"].getService(Ci.nsIFrameMessageManager);
});
function log(aMsg) {
let msg = "ContentHandler.js: " + (aMsg.join ? aMsg.join("") : aMsg);
Cc["@mozilla.org/consoleservice;1"].getService(Ci.nsIConsoleService)
@ -36,7 +40,7 @@ ContentHandler.prototype = {
"type": aMimetype,
"url": aRequest.URI.spec
};
Services.obs.notifyObservers(this, "content-handler", JSON.stringify(detail));
cpmm.sendAsyncMessage("content-handler", detail);
aRequest.cancel(Cr.NS_BINDING_ABORTED);
},