зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1494547: Store actual connection information. r=jdescottes
Depends on D7842 Differential Revision: https://phabricator.services.mozilla.com/D7843 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
cfcc43a224
Коммит
dbf968f31f
|
@ -36,14 +36,13 @@ const {
|
|||
function inspectDebugTarget(type, id) {
|
||||
return async (_, getState) => {
|
||||
const runtime = getCurrentRuntime(getState().runtimes);
|
||||
const runtimeType = runtime.type;
|
||||
const client = runtime.client;
|
||||
const { connection, type: runtimeType } = runtime;
|
||||
|
||||
switch (type) {
|
||||
case DEBUG_TARGETS.TAB: {
|
||||
// Open tab debugger in new window.
|
||||
if (runtime.type === RUNTIMES.NETWORK || runtime.type === RUNTIMES.USB) {
|
||||
const { host, port } = client.transport.connectionSettings;
|
||||
if (runtimeType === RUNTIMES.NETWORK || runtimeType === RUNTIMES.USB) {
|
||||
const { host, port } = connection.transportDetails;
|
||||
window.open(`about:devtools-toolbox?type=tab&id=${id}` +
|
||||
`&host=${host}&port=${port}`);
|
||||
} else if (runtimeType === RUNTIMES.THIS_FIREFOX) {
|
||||
|
@ -53,7 +52,7 @@ function inspectDebugTarget(type, id) {
|
|||
}
|
||||
case DEBUG_TARGETS.EXTENSION: {
|
||||
if (runtimeType === RUNTIMES.NETWORK) {
|
||||
await debugRemoteAddon(id, client);
|
||||
await debugRemoteAddon(id, connection.client);
|
||||
} else if (runtimeType === RUNTIMES.THIS_FIREFOX) {
|
||||
debugLocalAddon(id);
|
||||
}
|
||||
|
@ -61,7 +60,7 @@ function inspectDebugTarget(type, id) {
|
|||
}
|
||||
case DEBUG_TARGETS.WORKER: {
|
||||
// Open worker toolbox in new window.
|
||||
gDevToolsBrowser.openWorkerToolbox(client, id);
|
||||
gDevToolsBrowser.openWorkerToolbox(connection.client, id);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -38,14 +38,15 @@ async function createLocalClient() {
|
|||
DebuggerServer.registerAllActors();
|
||||
const client = new DebuggerClient(DebuggerServer.connectPipe());
|
||||
await client.connect();
|
||||
return client;
|
||||
return { client };
|
||||
}
|
||||
|
||||
async function createNetworkClient(host, port) {
|
||||
const transport = await DebuggerClient.socketConnect({ host, port });
|
||||
const transportDetails = { host, port };
|
||||
const transport = await DebuggerClient.socketConnect(transportDetails);
|
||||
const client = new DebuggerClient(transport);
|
||||
await client.connect();
|
||||
return client;
|
||||
return { client, transportDetails };
|
||||
}
|
||||
|
||||
async function createUSBClient(socketPath) {
|
||||
|
@ -92,15 +93,15 @@ function connectRuntime(id) {
|
|||
dispatch({ type: CONNECT_RUNTIME_START });
|
||||
try {
|
||||
const runtime = findRuntimeById(id, getState().runtimes);
|
||||
const client = await createClientForRuntime(runtime);
|
||||
const { client, transportDetails } = await createClientForRuntime(runtime);
|
||||
const info = await getRuntimeInfo(runtime, client);
|
||||
const connection = { client, info, transportDetails };
|
||||
|
||||
dispatch({
|
||||
type: CONNECT_RUNTIME_SUCCESS,
|
||||
runtime: {
|
||||
id,
|
||||
client,
|
||||
info,
|
||||
connection,
|
||||
type: runtime.type,
|
||||
}
|
||||
});
|
||||
|
@ -115,7 +116,7 @@ function disconnectRuntime(id) {
|
|||
dispatch({ type: DISCONNECT_RUNTIME_START });
|
||||
try {
|
||||
const runtime = findRuntimeById(id, getState().runtimes);
|
||||
const client = runtime.client;
|
||||
const client = runtime.connection.client;
|
||||
|
||||
await client.close();
|
||||
DebuggerServer.destroy();
|
||||
|
|
|
@ -56,10 +56,10 @@ class Sidebar extends PureComponent {
|
|||
|
||||
return runtimes.map(runtime => {
|
||||
const pageId = runtime.type + "-" + runtime.id;
|
||||
const runtimeHasClient = !!runtime.client;
|
||||
const runtimeHasConnection = !!runtime.connection;
|
||||
|
||||
const connectComponent = DeviceSidebarItemAction({
|
||||
connected: runtimeHasClient,
|
||||
connected: runtimeHasConnection,
|
||||
dispatch,
|
||||
runtimeId: runtime.id,
|
||||
});
|
||||
|
@ -73,7 +73,7 @@ class Sidebar extends PureComponent {
|
|||
key: pageId,
|
||||
name: runtime.name,
|
||||
runtimeId: runtime.id,
|
||||
selectable: runtimeHasClient,
|
||||
selectable: runtimeHasConnection,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ function debugTargetListenerMiddleware(store) {
|
|||
return next => action => {
|
||||
switch (action.type) {
|
||||
case WATCH_RUNTIME_SUCCESS: {
|
||||
const { client } = action.runtime;
|
||||
const { client } = action.runtime.connection;
|
||||
client.addListener("tabListChanged", onTabsUpdated);
|
||||
AddonManager.addAddonListener(extensionsListener);
|
||||
client.addListener("workerListChanged", onWorkersUpdated);
|
||||
|
@ -65,7 +65,7 @@ function debugTargetListenerMiddleware(store) {
|
|||
break;
|
||||
}
|
||||
case UNWATCH_RUNTIME_START: {
|
||||
const { client } = action.runtime;
|
||||
const { client } = action.runtime.connection;
|
||||
client.removeListener("tabListChanged", onTabsUpdated);
|
||||
AddonManager.removeAddonListener(extensionsListener);
|
||||
client.removeListener("workerListChanged", onWorkersUpdated);
|
||||
|
|
|
@ -11,13 +11,14 @@ function getCurrentRuntime(runtimesState) {
|
|||
exports.getCurrentRuntime = getCurrentRuntime;
|
||||
|
||||
function getCurrentClient(runtimesState) {
|
||||
return getCurrentRuntime(runtimesState).client;
|
||||
const connection = getCurrentConnection(runtimesState);
|
||||
return connection ? connection.client : null;
|
||||
}
|
||||
exports.getCurrentClient = getCurrentClient;
|
||||
|
||||
function getCurrentRuntimeInfo(runtimesState) {
|
||||
const runtime = getCurrentRuntime(runtimesState);
|
||||
return runtime ? runtime.info : null;
|
||||
const connection = getCurrentConnection(runtimesState);
|
||||
return connection ? connection.info : null;
|
||||
}
|
||||
exports.getCurrentRuntimeInfo = getCurrentRuntimeInfo;
|
||||
|
||||
|
@ -30,3 +31,8 @@ function findRuntimeById(id, runtimesState) {
|
|||
return allRuntimes.find(r => r.id === id);
|
||||
}
|
||||
exports.findRuntimeById = findRuntimeById;
|
||||
|
||||
function getCurrentConnection(runtimesState) {
|
||||
const runtime = getCurrentRuntime(runtimesState);
|
||||
return runtime ? runtime.connection : null;
|
||||
}
|
||||
|
|
|
@ -68,13 +68,13 @@ function _updateRuntimeById(runtimeId, updatedRuntime, state) {
|
|||
function runtimesReducer(state = RuntimesState(), action) {
|
||||
switch (action.type) {
|
||||
case CONNECT_RUNTIME_SUCCESS: {
|
||||
const { id, client, info } = action.runtime;
|
||||
return _updateRuntimeById(id, { client, info }, state);
|
||||
const { id, connection } = action.runtime;
|
||||
return _updateRuntimeById(id, { connection }, state);
|
||||
}
|
||||
|
||||
case DISCONNECT_RUNTIME_SUCCESS: {
|
||||
const { id } = action.runtime;
|
||||
return _updateRuntimeById(id, { client: null, info: null }, state);
|
||||
return _updateRuntimeById(id, { connection: null }, state);
|
||||
}
|
||||
|
||||
case NETWORK_LOCATIONS_UPDATED: {
|
||||
|
|
Загрузка…
Ссылка в новой задаче