Bug 1507324 - 1. Keep current remote type if possible; r=geckoview-reviewers,snorp

Some pages can be either remote or non-remote depending on the current
remote type, so we need to take that into account when updating the
remote type.

Differential Revision: https://phabricator.services.mozilla.com/D11951

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Jim Chen 2018-11-14 23:39:21 +00:00
Родитель 69a08335b4
Коммит 376d2464a2
2 изменённых файлов: 23 добавлений и 21 удалений

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

@ -107,23 +107,28 @@ var ModuleManager = {
this._modules.forEach(aCallback, this);
},
updateRemoteType(aRemoteType) {
debug `updateRemoteType remoteType=${aRemoteType}`;
updateRemoteTypeForURI(aURI) {
const currentType =
this.browser.getAttribute("remoteType") || E10SUtils.NOT_REMOTE;
const remoteType = E10SUtils.getRemoteTypeForURI(
aURI, this.settings.useMultiprocess,
currentType, this.browser.currentURI);
const currentRemoteType = this.browser.getAttribute("remoteType") || E10SUtils.NOT_REMOTE;
debug `updateRemoteType: uri=${aURI} currentType=${currentType}
remoteType=${remoteType}`;
if (aRemoteType && !this.settings.useMultiprocess) {
warn `Tried to create a remote browser in multiprocess mode`;
return false;
}
if (currentRemoteType === aRemoteType) {
if (currentType === remoteType) {
// We're already using a child process of the correct type.
return false;
}
if (remoteType !== E10SUtils.NOT_REMOTE &&
!this.settings.useMultiprocess) {
warn `Tried to create a remote browser in non-multiprocess mode`;
return false;
}
// Now we're switching the remoteness (value of "remote" attr).
debug `updateRemoteType: changing from '${currentRemoteType}' to '${aRemoteType}'`;
this.forEach(module => {
if (module.enabled && module.impl) {
@ -139,9 +144,9 @@ var ModuleManager = {
const parent = this.browser.parentNode;
this.browser.remove();
if (aRemoteType) {
if (remoteType) {
this.browser.setAttribute("remote", "true");
this.browser.setAttribute("remoteType", aRemoteType);
this.browser.setAttribute("remoteType", remoteType);
} else {
this.browser.setAttribute("remote", "false");
this.browser.removeAttribute("remoteType");

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

@ -10,7 +10,6 @@ ChromeUtils.import("resource://gre/modules/GeckoViewModule.jsm");
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyModuleGetters(this, {
E10SUtils: "resource://gre/modules/E10SUtils.jsm",
Utils: "resource://gre/modules/sessionstore/Utils.jsm",
LoadURIDelegate: "resource://gre/modules/LoadURIDelegate.jsm",
Services: "resource://gre/modules/Services.jsm",
@ -78,9 +77,7 @@ class GeckoViewNavigation extends GeckoViewModule {
}
if (this.settings.useMultiprocess) {
const remoteType =
E10SUtils.getRemoteTypeForURI(uri, true);
this.moduleManager.updateRemoteType(remoteType);
this.moduleManager.updateRemoteTypeForURI(uri);
}
let parsedUri;
@ -123,12 +120,12 @@ class GeckoViewNavigation extends GeckoViewModule {
// we may need to change the remoteness of our browser and
// load the URI.
const { uri, flags, referrer, triggeringPrincipal } = aMsg.data.loadOptions;
const remoteType =
E10SUtils.getRemoteTypeForURI(uri, this.settings.useMultiprocess);
this.moduleManager.updateRemoteType(remoteType);
this.browser.loadURI(aMsg.data.loadOptions.uri, {
flags, referrerURI: referrer,
this.moduleManager.updateRemoteTypeForURI(uri);
this.browser.loadURI(uri, {
flags,
referrerURI: referrer,
triggeringPrincipal: Utils.deserializePrincipal(triggeringPrincipal),
});
break;