Skip to content

Commit

Permalink
Bug 1495382 - Check isMultiE10s from runtime info;r=daisuke,ladybenko
Browse files Browse the repository at this point in the history
Depends on D15081

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

--HG--
rename : devtools/client/shared/multi-e10s-helper.js => devtools/shared/multi-e10s-helper.js
extra : moz-landing-system : lando
  • Loading branch information
juliandescottes committed Jan 9, 2019
1 parent d802ac1 commit fb34f9a
Show file tree
Hide file tree
Showing 20 changed files with 105 additions and 47 deletions.
14 changes: 0 additions & 14 deletions devtools/client/aboutdebugging-new/aboutdebugging.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@ const {
removeUSBRuntimesObserver,
} = require("./src/modules/usb-runtimes");

const {
addMultiE10sListener,
isMultiE10s,
removeMultiE10sListener,
} = require("devtools/client/shared/multi-e10s-helper");

loader.lazyRequireGetter(this, "adbAddon", "devtools/shared/adb/adb-addon", true);

const Router = createFactory(require("devtools/client/shared/vendor/react-router-dom").HashRouter);
Expand All @@ -54,7 +48,6 @@ const AboutDebugging = {
this.onAdbAddonUpdated = this.onAdbAddonUpdated.bind(this);
this.onNetworkLocationsUpdated = this.onNetworkLocationsUpdated.bind(this);
this.onUSBRuntimesUpdated = this.onUSBRuntimesUpdated.bind(this);
this.onMultiE10sUpdated = this.onMultiE10sUpdated.bind(this);

this.store = configureStore();
this.actions = bindActionCreators(actions, this.store.dispatch);
Expand Down Expand Up @@ -90,12 +83,6 @@ const AboutDebugging = {

// Remove deprecated remote debugging extensions.
await adbAddon.uninstallUnsupportedExtensions();

addMultiE10sListener(this.onMultiE10sUpdated);
},

onMultiE10sUpdated() {
this.actions.updateMultiE10sStatus(isMultiE10s());
},

onAdbAddonUpdated() {
Expand Down Expand Up @@ -123,7 +110,6 @@ const AboutDebugging = {
// Remove all client listeners.
this.actions.removeRuntimeListeners();

removeMultiE10sListener(this.onMultiE10sUpdated);
removeNetworkLocationsObserver(this.onNetworkLocationsUpdated);
removeUSBRuntimesObserver(this.onUSBRuntimesUpdated);
adbAddon.off("update", this.onAdbAddonUpdated);
Expand Down
43 changes: 41 additions & 2 deletions devtools/client/aboutdebugging-new/src/actions/runtimes.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,27 @@ const {
UPDATE_CONNECTION_PROMPT_SETTING_FAILURE,
UPDATE_CONNECTION_PROMPT_SETTING_START,
UPDATE_CONNECTION_PROMPT_SETTING_SUCCESS,
UPDATE_RUNTIME_MULTIE10S_FAILURE,
UPDATE_RUNTIME_MULTIE10S_START,
UPDATE_RUNTIME_MULTIE10S_SUCCESS,
WATCH_RUNTIME_FAILURE,
WATCH_RUNTIME_START,
WATCH_RUNTIME_SUCCESS,
} = require("../constants");

async function getRuntimeInfo(runtime, clientWrapper) {
const { type } = runtime;
const { name, channel, deviceName, version } =
const { name, channel, deviceName, isMultiE10s, version } =
await clientWrapper.getDeviceDescription();
const icon =
(channel === "release" || channel === "beta" || channel === "aurora")
? `chrome://devtools/skin/images/aboutdebugging-firefox-${ channel }.svg`
: "chrome://devtools/skin/images/aboutdebugging-firefox-nightly.svg";

return {
icon,
deviceName,
icon,
isMultiE10s,
name,
type,
version,
Expand All @@ -65,22 +69,36 @@ function onUSBDebuggerClientClosed() {
window.AboutDebugging.store.dispatch(Actions.scanUSBRuntimes());
}

function onMultiE10sUpdated() {
window.AboutDebugging.store.dispatch(updateMultiE10s());
}

function connectRuntime(id) {
return async (dispatch, getState) => {
dispatch({ type: CONNECT_RUNTIME_START });
try {
const runtime = findRuntimeById(id, getState().runtimes);
const clientWrapper = await createClientForRuntime(runtime);
const info = await getRuntimeInfo(runtime, clientWrapper);
const { isMultiE10s } = info;
delete info.isMultiE10s;

const promptPrefName = RUNTIME_PREFERENCE.CONNECTION_PROMPT;
const connectionPromptEnabled = await clientWrapper.getPreference(promptPrefName);
const runtimeDetails = {
clientWrapper,
connectionPromptEnabled,
info,
isMultiE10s,
};

clientWrapper.addListener("closed", onUSBDebuggerClientClosed);

const deviceFront = await clientWrapper.getFront("device");
if (deviceFront) {
deviceFront.on("multi-e10s-updated", onMultiE10sUpdated);
}

if (runtime.type === RUNTIMES.USB) {
// `closed` event will be emitted when disabling remote debugging
// on the connected USB runtime.
Expand Down Expand Up @@ -108,6 +126,11 @@ function disconnectRuntime(id) {
const runtime = findRuntimeById(id, getState().runtimes);
const { clientWrapper } = runtime.runtimeDetails;

const deviceFront = await clientWrapper.getFront("device");
if (deviceFront) {
deviceFront.off("multi-e10s-updated", onMultiE10sUpdated);
}

if (runtime.type === RUNTIMES.USB) {
clientWrapper.removeListener("closed", onUSBDebuggerClientClosed);
}
Expand Down Expand Up @@ -146,6 +169,22 @@ function updateConnectionPromptSetting(connectionPromptEnabled) {
};
}

function updateMultiE10s() {
return async (dispatch, getState) => {
dispatch({ type: UPDATE_RUNTIME_MULTIE10S_START });
try {
const runtime = getCurrentRuntime(getState().runtimes);
const { clientWrapper } = runtime.runtimeDetails;
// Re-get actual value from the runtime.
const { isMultiE10s } = await clientWrapper.getDeviceDescription();

dispatch({ type: UPDATE_RUNTIME_MULTIE10S_SUCCESS, runtime, isMultiE10s });
} catch (e) {
dispatch({ type: UPDATE_RUNTIME_MULTIE10S_FAILURE, error: e });
}
};
}

function watchRuntime(id) {
return async (dispatch, getState) => {
dispatch({ type: WATCH_RUNTIME_START });
Expand Down
8 changes: 0 additions & 8 deletions devtools/client/aboutdebugging-new/src/actions/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const {
ADB_ADDON_UNINSTALL_FAILURE,
ADB_ADDON_STATUS_UPDATED,
DEBUG_TARGET_COLLAPSIBILITY_UPDATED,
MULTI_E10S_UPDATED,
NETWORK_LOCATIONS_UPDATED,
PAGE_SELECTED,
PAGE_TYPES,
Expand Down Expand Up @@ -127,12 +126,6 @@ function scanUSBRuntimes() {
};
}

function updateMultiE10sStatus(isMultiE10s) {
return (dispatch, getState) => {
dispatch({ type: MULTI_E10S_UPDATED, isMultiE10s});
};
}

module.exports = {
addNetworkLocation,
installAdbAddon,
Expand All @@ -142,6 +135,5 @@ module.exports = {
uninstallAdbAddon,
updateAdbAddonStatus,
updateDebugTargetCollapsibility,
updateMultiE10sStatus,
updateNetworkLocations,
};
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ const { connect } = require("devtools/client/shared/vendor/react-redux");

const FluentReact = require("devtools/client/shared/vendor/fluent-react");

const { getCurrentRuntimeDetails } = require("../../modules/runtimes-state-helper");

const InspectAction = createFactory(require("./InspectAction"));

const Actions = require("../../actions/index");
Expand All @@ -26,7 +28,7 @@ class ServiceWorkerAction extends PureComponent {
// Provided by wrapping the component with FluentReact.withLocalization.
getString: PropTypes.func.isRequired,
// Provided by redux state
isMultiE10s: PropTypes.bool.isRequired,
runtimeDetails: Types.runtimeDetails.isRequired,
target: Types.debugTarget.isRequired,
};
}
Expand All @@ -42,8 +44,9 @@ class ServiceWorkerAction extends PureComponent {
}

_renderAction() {
const { dispatch, isMultiE10s, target } = this.props;
const { dispatch, runtimeDetails, target } = this.props;
const { isActive, isRunning } = target.details;
const { isMultiE10s } = runtimeDetails;

if (!isRunning) {
const startLabel = this.props.getString("about-debugging-worker-action-start");
Expand Down Expand Up @@ -95,7 +98,7 @@ class ServiceWorkerAction extends PureComponent {

const mapStateToProps = state => {
return {
isMultiE10s: state.ui.isMultiE10s,
runtimeDetails: getCurrentRuntimeDetails(state.runtimes),
};
};

Expand Down
4 changes: 3 additions & 1 deletion devtools/client/aboutdebugging-new/src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const actionTypes = {
DISCONNECT_RUNTIME_FAILURE: "DISCONNECT_RUNTIME_FAILURE",
DISCONNECT_RUNTIME_START: "DISCONNECT_RUNTIME_START",
DISCONNECT_RUNTIME_SUCCESS: "DISCONNECT_RUNTIME_SUCCESS",
MULTI_E10S_UPDATED: "MULTI_E10S_UPDATED",
NETWORK_LOCATIONS_UPDATED: "NETWORK_LOCATIONS_UPDATED",
PAGE_SELECTED: "PAGE_SELECTED",
REMOTE_RUNTIMES_UPDATED: "REMOTE_RUNTIMES_UPDATED",
Expand All @@ -41,6 +40,9 @@ const actionTypes = {
UPDATE_CONNECTION_PROMPT_SETTING_FAILURE: "UPDATE_CONNECTION_PROMPT_SETTING_FAILURE",
UPDATE_CONNECTION_PROMPT_SETTING_START: "UPDATE_CONNECTION_PROMPT_SETTING_START",
UPDATE_CONNECTION_PROMPT_SETTING_SUCCESS: "UPDATE_CONNECTION_PROMPT_SETTING_SUCCESS",
UPDATE_RUNTIME_MULTIE10S_FAILURE: "UPDATE_RUNTIME_MULTIE10S_FAILURE",
UPDATE_RUNTIME_MULTIE10S_START: "UPDATE_RUNTIME_MULTIE10S_START",
UPDATE_RUNTIME_MULTIE10S_SUCCESS: "UPDATE_RUNTIME_MULTIE10S_SUCCESS",
USB_RUNTIMES_SCAN_START: "USB_RUNTIMES_SCAN_START",
USB_RUNTIMES_SCAN_SUCCESS: "USB_RUNTIMES_SCAN_SUCCESS",
WATCH_RUNTIME_FAILURE: "WATCH_RUNTIME_FAILURE",
Expand Down
3 changes: 1 addition & 2 deletions devtools/client/aboutdebugging-new/src/create-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ const Services = require("Services");
const { applyMiddleware, createStore } = require("devtools/client/shared/vendor/redux");
const { thunk } = require("devtools/client/shared/redux/middleware/thunk.js");
const { waitUntilService } = require("devtools/client/shared/redux/middleware/wait-service.js");
const { isMultiE10s } = require("devtools/client/shared/multi-e10s-helper");

const rootReducer = require("./reducers/index");
const { DebugTargetsState } = require("./reducers/debug-targets-state");
Expand Down Expand Up @@ -51,7 +50,7 @@ function getUiState() {
const showSystemAddons = Services.prefs.getBoolPref(PREFERENCES.SHOW_SYSTEM_ADDONS,
false);
return new UiState(locations, collapsibilities, networkEnabled, wifiEnabled,
showSystemAddons, isMultiE10s());
showSystemAddons);
}

exports.configureStore = configureStore;
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,23 @@ class ClientWrapper {
}
}

async getFront(typeName) {
return this.client.mainRoot.getFront(typeName);
}

onFront(typeName, listener) {
this.client.mainRoot.onFront(typeName, listener);
}

async getDeviceDescription() {
const deviceFront = await this.client.mainRoot.getFront("device");
const { brandName, channel, deviceName, version } =
const deviceFront = await this.getFront("device");
const { brandName, channel, deviceName, isMultiE10s, version } =
await deviceFront.getDescription();
// Only expose a specific set of properties.
return {
channel,
deviceName,
isMultiE10s,
name: brandName,
version,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,4 @@ function getCurrentRuntimeDetails(runtimesState) {
const runtime = getCurrentRuntime(runtimesState);
return runtime ? runtime.runtimeDetails : null;
}
exports.getCurrentRuntimeDetails = getCurrentRuntimeDetails;
10 changes: 10 additions & 0 deletions devtools/client/aboutdebugging-new/src/reducers/runtimes-state.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const {
RUNTIMES,
UNWATCH_RUNTIME_SUCCESS,
UPDATE_CONNECTION_PROMPT_SETTING_SUCCESS,
UPDATE_RUNTIME_MULTIE10S_SUCCESS,
REMOTE_RUNTIMES_UPDATED,
WATCH_RUNTIME_SUCCESS,
} = require("../constants");
Expand Down Expand Up @@ -97,6 +98,15 @@ function runtimesReducer(state = RuntimesState(), action) {
return _updateRuntimeById(runtimeId, { runtimeDetails }, state);
}

case UPDATE_RUNTIME_MULTIE10S_SUCCESS: {
const { isMultiE10s } = action;
const { id: runtimeId } = action.runtime;
const runtime = findRuntimeById(runtimeId, state);
const runtimeDetails =
Object.assign({}, runtime.runtimeDetails, { isMultiE10s });
return _updateRuntimeById(runtimeId, { runtimeDetails }, state);
}

case REMOTE_RUNTIMES_UPDATED: {
const { runtimes, runtimeType } = action;
const key = TYPE_TO_RUNTIMES_KEY[runtimeType];
Expand Down
9 changes: 1 addition & 8 deletions devtools/client/aboutdebugging-new/src/reducers/ui-state.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
const {
ADB_ADDON_STATUS_UPDATED,
DEBUG_TARGET_COLLAPSIBILITY_UPDATED,
MULTI_E10S_UPDATED,
NETWORK_LOCATIONS_UPDATED,
PAGE_SELECTED,
TEMPORARY_EXTENSION_INSTALL_FAILURE,
Expand All @@ -18,11 +17,10 @@ const {

function UiState(locations = [], debugTargetCollapsibilities = {},
networkEnabled = false, wifiEnabled = false,
showSystemAddons = false, isMultiE10s = false) {
showSystemAddons = false) {
return {
adbAddonStatus: null,
debugTargetCollapsibilities,
isMultiE10s,
isScanningUsb: false,
networkEnabled,
networkLocations: locations,
Expand All @@ -48,11 +46,6 @@ function uiReducer(state = UiState(), action) {
return Object.assign({}, state, { debugTargetCollapsibilities });
}

case MULTI_E10S_UPDATED: {
const { isMultiE10s } = action;
return Object.assign({}, state, { isMultiE10s });
}

case NETWORK_LOCATIONS_UPDATED: {
const { locations } = action;
return Object.assign({}, state, { networkLocations: locations });
Expand Down
3 changes: 2 additions & 1 deletion devtools/client/aboutdebugging-new/src/types/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
"use strict";

const { debugTarget } = require("./debug-target");
const { runtime } = require("./runtime");
const { runtime, runtimeDetails } = require("./runtime");

module.exports = Object.assign({}, {
debugTarget,
runtime,
runtimeDetails,
});
5 changes: 5 additions & 0 deletions devtools/client/aboutdebugging-new/src/types/runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ const runtimeDetails = {

// runtime information
info: PropTypes.shape(runtimeInfo).isRequired,

// True if this runtime supports multiple content processes
// This might be undefined when connecting to runtimes older than Fx 66
isMultiE10s: PropTypes.bool,
};
exports.runtimeDetails = PropTypes.shape(runtimeDetails);

const networkRuntimeConnectionParameter = {
// host name of debugger server to connect
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ function createClientMock() {
sharedWorkers: [],
}),
// no-op
getFront: () => {},
// no-op
onFront: () => {},
// stores the preference locally (doesn't update about:config)
setPreference: function(prefName, value) {
Expand Down
2 changes: 1 addition & 1 deletion devtools/client/aboutdebugging/components/workers/Panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const {
addMultiE10sListener,
isMultiE10s,
removeMultiE10sListener,
} = require("devtools/client/shared/multi-e10s-helper");
} = require("devtools/shared/multi-e10s-helper");

const PanelHeader = createFactory(require("../PanelHeader"));
const TargetList = createFactory(require("../TargetList"));
Expand Down
1 change: 0 additions & 1 deletion devtools/client/shared/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ DevToolsModules(
'key-shortcuts.js',
'keycodes.js',
'link.js',
'multi-e10s-helper.js',
'natural-sort.js',
'node-attribute-parser.js',
'options-view.js',
Expand Down
Loading

0 comments on commit fb34f9a

Please sign in to comment.