[protocol] Extract DevToolsCDPConnection class from SessionRouter [devtools/devtools-frontend : main]

0 views
Skip to first unread message

Simon Zünd (Gerrit)

unread,
4:07 AM (7 hours ago) 4:07 AM
to Devtools-frontend LUCI CQ, Alex Rudenko, devtools-rev...@chromium.org, lighthouse-en...@google.com
Attention needed from Alex Rudenko

Simon Zünd added 1 comment

File front_end/core/protocol_client/InspectorBackend.ts
Line 216, Patchset 1 (Latest): onEvent<T extends Event>(event: CDPEvent<T>): void {
const sessionId = event.sessionId || '';
const session = this.#sessions.get(sessionId);
session?.target.dispatch(event as unknown as EventMessage);
}
Simon Zünd . unresolved

Technically we could get rid of `SessionRouter` alltogether in a follow-up:

The target base class subscribes to `onEvent` and then only dispatches where the session ID matches, i.e.

```
onEvent<T extends Event>(event: CDPEvent<T>): void {
if (event.sessionId === this.sessionId) this.dispatch(event)
}

```

The downside of that is that instead of getting exactly one session and dispatching on that, we call N `onEvent` observers, where N is the number of active sessions.

Not sure if that is a concern, but CDP is rather talkative. Wdyt?

Open in Gerrit

Related details

Attention is currently required from:
  • Alex Rudenko
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: devtools/devtools-frontend
Gerrit-Branch: main
Gerrit-Change-Id: Ie2817bf36b2afd3fb51e0cf6f5a3fbad711fbcf9
Gerrit-Change-Number: 7123819
Gerrit-PatchSet: 1
Gerrit-Owner: Simon Zünd <szu...@chromium.org>
Gerrit-Reviewer: Alex Rudenko <alexr...@chromium.org>
Gerrit-Reviewer: Simon Zünd <szu...@chromium.org>
Gerrit-CC: Devtools-frontend LUCI CQ <devtools-fro...@luci-project-accounts.iam.gserviceaccount.com>
Gerrit-Attention: Alex Rudenko <alexr...@chromium.org>
Gerrit-Comment-Date: Wed, 05 Nov 2025 09:07:00 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Alex Rudenko (Gerrit)

unread,
4:14 AM (6 hours ago) 4:14 AM
to Simon Zünd, Devtools-frontend LUCI CQ, devtools-rev...@chromium.org, lighthouse-en...@google.com
Attention needed from Simon Zünd

Alex Rudenko added 2 comments

File front_end/core/protocol_client/DevToolsCDPConnection.ts
Line 163, Patchset 1 (Latest): window.setTimeout(() => {
Alex Rudenko . unresolved

can we use globalThis or nothing at all?

File front_end/core/protocol_client/InspectorBackend.ts
Line 216, Patchset 1 (Latest): onEvent<T extends Event>(event: CDPEvent<T>): void {
const sessionId = event.sessionId || '';
const session = this.#sessions.get(sessionId);
session?.target.dispatch(event as unknown as EventMessage);
}
Simon Zünd . unresolved

Technically we could get rid of `SessionRouter` alltogether in a follow-up:

The target base class subscribes to `onEvent` and then only dispatches where the session ID matches, i.e.

```
onEvent<T extends Event>(event: CDPEvent<T>): void {
if (event.sessionId === this.sessionId) this.dispatch(event)
}

```

The downside of that is that instead of getting exactly one session and dispatching on that, we call N `onEvent` observers, where N is the number of active sessions.

Not sure if that is a concern, but CDP is rather talkative. Wdyt?

Alex Rudenko

I'd say let's keep SessionRouter

Open in Gerrit

Related details

Attention is currently required from:
  • Simon Zünd
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: devtools/devtools-frontend
Gerrit-Branch: main
Gerrit-Change-Id: Ie2817bf36b2afd3fb51e0cf6f5a3fbad711fbcf9
Gerrit-Change-Number: 7123819
Gerrit-PatchSet: 1
Gerrit-Owner: Simon Zünd <szu...@chromium.org>
Gerrit-Reviewer: Alex Rudenko <alexr...@chromium.org>
Gerrit-Reviewer: Simon Zünd <szu...@chromium.org>
Gerrit-CC: Devtools-frontend LUCI CQ <devtools-fro...@luci-project-accounts.iam.gserviceaccount.com>
Gerrit-Attention: Simon Zünd <szu...@chromium.org>
Gerrit-Comment-Date: Wed, 05 Nov 2025 09:14:08 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Simon Zünd <szu...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Simon Zünd (Gerrit)

unread,
4:25 AM (6 hours ago) 4:25 AM
to Devtools-frontend LUCI CQ, Alex Rudenko, devtools-rev...@chromium.org, lighthouse-en...@google.com
Attention needed from Alex Rudenko

Simon Zünd added 2 comments

File front_end/core/protocol_client/DevToolsCDPConnection.ts
Line 163, Patchset 1: window.setTimeout(() => {
Alex Rudenko . resolved

can we use globalThis or nothing at all?

Simon Zünd

Done

File front_end/core/protocol_client/InspectorBackend.ts
Line 216, Patchset 1: onEvent<T extends Event>(event: CDPEvent<T>): void {

const sessionId = event.sessionId || '';
const session = this.#sessions.get(sessionId);
session?.target.dispatch(event as unknown as EventMessage);
}
Simon Zünd . resolved

Technically we could get rid of `SessionRouter` alltogether in a follow-up:

The target base class subscribes to `onEvent` and then only dispatches where the session ID matches, i.e.

```
onEvent<T extends Event>(event: CDPEvent<T>): void {
if (event.sessionId === this.sessionId) this.dispatch(event)
}

```

The downside of that is that instead of getting exactly one session and dispatching on that, we call N `onEvent` observers, where N is the number of active sessions.

Not sure if that is a concern, but CDP is rather talkative. Wdyt?

Alex Rudenko

I'd say let's keep SessionRouter

Simon Zünd

Acknowledged

Open in Gerrit

Related details

Attention is currently required from:
  • Alex Rudenko
Submit Requirements:
    • requirement satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: devtools/devtools-frontend
    Gerrit-Branch: main
    Gerrit-Change-Id: Ie2817bf36b2afd3fb51e0cf6f5a3fbad711fbcf9
    Gerrit-Change-Number: 7123819
    Gerrit-PatchSet: 2
    Gerrit-Owner: Simon Zünd <szu...@chromium.org>
    Gerrit-Reviewer: Alex Rudenko <alexr...@chromium.org>
    Gerrit-Reviewer: Simon Zünd <szu...@chromium.org>
    Gerrit-CC: Devtools-frontend LUCI CQ <devtools-fro...@luci-project-accounts.iam.gserviceaccount.com>
    Gerrit-Attention: Alex Rudenko <alexr...@chromium.org>
    Gerrit-Comment-Date: Wed, 05 Nov 2025 09:25:49 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Alex Rudenko <alexr...@chromium.org>
    Comment-In-Reply-To: Simon Zünd <szu...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Alex Rudenko (Gerrit)

    unread,
    4:30 AM (6 hours ago) 4:30 AM
    to Simon Zünd, Devtools-frontend LUCI CQ, devtools-rev...@chromium.org, lighthouse-en...@google.com
    Attention needed from Simon Zünd

    Alex Rudenko voted Code-Review+1

    Code-Review+1
    Open in Gerrit

    Related details

    Attention is currently required from:
    • Simon Zünd
    Submit Requirements:
    • requirement satisfiedCode-Owners
    • requirement satisfiedCode-Review
    • requirement satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: devtools/devtools-frontend
    Gerrit-Branch: main
    Gerrit-Change-Id: Ie2817bf36b2afd3fb51e0cf6f5a3fbad711fbcf9
    Gerrit-Change-Number: 7123819
    Gerrit-PatchSet: 2
    Gerrit-Owner: Simon Zünd <szu...@chromium.org>
    Gerrit-Reviewer: Alex Rudenko <alexr...@chromium.org>
    Gerrit-Reviewer: Simon Zünd <szu...@chromium.org>
    Gerrit-CC: Devtools-frontend LUCI CQ <devtools-fro...@luci-project-accounts.iam.gserviceaccount.com>
    Gerrit-Attention: Simon Zünd <szu...@chromium.org>
    Gerrit-Comment-Date: Wed, 05 Nov 2025 09:30:36 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: Yes
    satisfied_requirement
    open
    diffy

    Simon Zünd (Gerrit)

    unread,
    4:33 AM (6 hours ago) 4:33 AM
    to Alex Rudenko, Devtools-frontend LUCI CQ, devtools-rev...@chromium.org, lighthouse-en...@google.com

    Simon Zünd voted Commit-Queue+2

    Commit-Queue+2
    Open in Gerrit

    Related details

    Attention set is empty
    Submit Requirements:
    • requirement satisfiedCode-Owners
    • requirement satisfiedCode-Review
    • requirement satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: devtools/devtools-frontend
    Gerrit-Branch: main
    Gerrit-Change-Id: Ie2817bf36b2afd3fb51e0cf6f5a3fbad711fbcf9
    Gerrit-Change-Number: 7123819
    Gerrit-PatchSet: 2
    Gerrit-Owner: Simon Zünd <szu...@chromium.org>
    Gerrit-Reviewer: Alex Rudenko <alexr...@chromium.org>
    Gerrit-Reviewer: Simon Zünd <szu...@chromium.org>
    Gerrit-CC: Devtools-frontend LUCI CQ <devtools-fro...@luci-project-accounts.iam.gserviceaccount.com>
    Gerrit-Comment-Date: Wed, 05 Nov 2025 09:33:13 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: Yes
    satisfied_requirement
    open
    diffy

    Devtools-frontend LUCI CQ (Gerrit)

    unread,
    4:57 AM (6 hours ago) 4:57 AM
    to Simon Zünd, Alex Rudenko, devtools-rev...@chromium.org, lighthouse-en...@google.com

    Devtools-frontend LUCI CQ submitted the change

    Change information

    Commit message:
    [protocol] Extract DevToolsCDPConnection class from SessionRouter

    This CL is mostly a mechanical change that splits the existing
    "SessionRouter" into a "connection part" and a "session management"
    part.

    R=alexr...@chromium.org
    Bug: 453469270
    Change-Id: Ie2817bf36b2afd3fb51e0cf6f5a3fbad711fbcf9
    Commit-Queue: Simon Zünd <szu...@chromium.org>
    Reviewed-by: Alex Rudenko <alexr...@chromium.org>
    Files:
    • M config/gni/devtools_grd_files.gni
    • M front_end/core/protocol_client/BUILD.gn
    • A front_end/core/protocol_client/DevToolsCDPConnection.ts
    • M front_end/core/protocol_client/InspectorBackend.ts
    • M front_end/core/protocol_client/protocol_client.ts
    • M front_end/entrypoints/lighthouse_worker/LighthouseWorkerService.ts
    • M front_end/panels/lighthouse/LighthouseProtocolService.ts
    • M front_end/panels/recorder/models/RecordingPlayer.ts
    • M test/e2e_non_hosted/puppeteer/puppeteer_test.ts
    Change size: L
    Delta: 9 files changed, 229 insertions(+), 197 deletions(-)
    Branch: refs/heads/main
    Submit Requirements:
    • requirement satisfiedCode-Review: +1 by Alex Rudenko
    Open in Gerrit
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: merged
    Gerrit-Project: devtools/devtools-frontend
    Gerrit-Branch: main
    Gerrit-Change-Id: Ie2817bf36b2afd3fb51e0cf6f5a3fbad711fbcf9
    Gerrit-Change-Number: 7123819
    Gerrit-PatchSet: 3
    Gerrit-Owner: Simon Zünd <szu...@chromium.org>
    Gerrit-Reviewer: Alex Rudenko <alexr...@chromium.org>
    Gerrit-Reviewer: Devtools-frontend LUCI CQ <devtools-fro...@luci-project-accounts.iam.gserviceaccount.com>
    Gerrit-Reviewer: Simon Zünd <szu...@chromium.org>
    open
    diffy
    satisfied_requirement
    Reply all
    Reply to author
    Forward
    0 new messages