[Extensions] Resolve per-context webRequest blocking dispatch targets [chromium/src : main]

0 views
Skip to first unread message

Andrea Orru (Gerrit)

unread,
Jul 22, 2026, 1:27:53 AM (3 days ago) Jul 22
to Devlin Cronin, Chromium LUCI CQ, chromium...@chromium.org, chromium-a...@chromium.org, extension...@chromium.org
Attention needed from Devlin Cronin

New activity on the change

Open in Gerrit

Related details

Attention is currently required from:
  • Devlin Cronin
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • 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: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Ic809ceb2b09718c14a754673e6246f8c9aab08d4
Gerrit-Change-Number: 8120467
Gerrit-PatchSet: 10
Gerrit-Owner: Andrea Orru <andre...@chromium.org>
Gerrit-Reviewer: Andrea Orru <andre...@chromium.org>
Gerrit-Reviewer: Devlin Cronin <rdevlin...@chromium.org>
Gerrit-Attention: Devlin Cronin <rdevlin...@chromium.org>
Gerrit-Comment-Date: Wed, 22 Jul 2026 05:27:41 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Devlin Cronin (Gerrit)

unread,
Jul 22, 2026, 2:46:07 PM (3 days ago) Jul 22
to Andrea Orru, Devlin Cronin, Chromium LUCI CQ, chromium...@chromium.org, chromium-a...@chromium.org, extension...@chromium.org
Attention needed from Andrea Orru

Devlin Cronin added 11 comments

Patchset-level comments
File-level comment, Patchset 10 (Latest):
Devlin Cronin . resolved

Thanks, Andrea!

Commit Message
Line 16, Patchset 10 (Latest): "webRequestInternal.eventHandled". Each response is clamped to the
Devlin Cronin . unresolved

nitty nit: maybe add "as they do today" to indicate this flow isn't new.

File extensions/browser/api/web_request/extension_web_request_event_router.h
Line 768, Patchset 10 (Latest): content::BrowserContext* browser_context,
Devlin Cronin . unresolved

same comments re ref, ChildProcessId

Line 519, Patchset 10 (Latest): int render_process_id,
Devlin Cronin . unresolved

nit: ChildProcessId?

Line 517, Patchset 10 (Latest): content::BrowserContext* browser_context,
Devlin Cronin . unresolved

nit: pass by ref

File extensions/browser/api/web_request/extension_web_request_event_router.cc
Line 1763, Patchset 10 (Latest): !key.IsLazy() && key.web_view_instance_id != 0;
Devlin Cronin . unresolved

is there such a thing as a lazy webview listener? I feel like there shouldn't be. Can we make this a CHECK somewhere (or multiple places)?

Line 1943, Patchset 10 (Latest): if (!responding_target) {
Devlin Cronin . unresolved

when do we expect this? (Add a comment)

Line 2004, Patchset 10 (Latest): // If no exact match exists, check if this is a newly started context
// operating under a concrete identity for an event dispatched under its lazy
// key. In that case, fall back to matching the existing lazy target for the
// same browser context, extension, and webview instance.
return std::ranges::find_if(
blocked_request.pending_targets, [&key](const auto& entry) {
const DispatchTargetKey& candidate_key = entry.first;
return candidate_key.IsLazy() &&
candidate_key.listener_context_id == key.listener_context_id &&
candidate_key.extension_id == key.extension_id &&
candidate_key.web_view_instance_id == key.web_view_instance_id;
});
Devlin Cronin . unresolved

hmm... is this / should this be possible?

A lazy context starts. There are only lazy listeners.

  • Context adds listeners before the event gets there. This means we'll have gone through the IPC to add the event listener, which should happen on the same associated message channel and thus the listener should be active (right?)
  • Or, context doesn't add listeners in time (unsupported async registration). The listeners aren't registered, so they can't get the event.

Is there a scenario in which the listener gets the event, but we haven't received the message that it's been added?

Line 2044, Patchset 10 (Latest): return RespondingTarget{blocked_request, it};
Devlin Cronin . unresolved

passing iterators into maps from methods is, to me, a bit of a code smell -- it's very easy to accidentally have the iterator become stale without easily noticing it.

It also doesn't look like we ever use the returned iterator _as an iterator_. Could we instead have this return the blocked request and extra info flags?

Line 2069, Patchset 10 (Latest): // completion signal that arrived before this deferred task executed).
Devlin Cronin . unresolved

if the event couldn't dispatch, how could we get a completion signal?

Or should this instead be something like the process going away? (I guess in some ways that's a "completion signal", but isn't what I'd normally think of)

Line 2762, Patchset 10 (Latest): // Requests may be missing if already completed or canceled, or blocked on
// a different event stage if the request advanced past `event_name` before
// a delayed response arrived.
Devlin Cronin . unresolved

how would this happen?

Open in Gerrit

Related details

Attention is currently required from:
  • Andrea Orru
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • 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: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Ic809ceb2b09718c14a754673e6246f8c9aab08d4
    Gerrit-Change-Number: 8120467
    Gerrit-PatchSet: 10
    Gerrit-Owner: Andrea Orru <andre...@chromium.org>
    Gerrit-Reviewer: Andrea Orru <andre...@chromium.org>
    Gerrit-Reviewer: Devlin Cronin <rdevlin...@chromium.org>
    Gerrit-Attention: Andrea Orru <andre...@chromium.org>
    Gerrit-Comment-Date: Wed, 22 Jul 2026 18:45:53 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Andrea Orru (Gerrit)

    unread,
    Jul 22, 2026, 5:15:49 PM (2 days ago) Jul 22
    to Devlin Cronin, Chromium LUCI CQ, chromium...@chromium.org, chromium-a...@chromium.org, extension...@chromium.org
    Attention needed from Devlin Cronin

    Andrea Orru added 4 comments

    Patchset-level comments
    Andrea Orru . unresolved

    Answering a few of the core questions before I make more code changes.

    File extensions/browser/api/web_request/extension_web_request_event_router.cc
    Line 1763, Patchset 10 (Latest): !key.IsLazy() && key.web_view_instance_id != 0;
    Devlin Cronin . unresolved

    is there such a thing as a lazy webview listener? I feel like there shouldn't be. Can we make this a CHECK somewhere (or multiple places)?

    Andrea Orru

    Acknowledged. There's no such thing as a lazy webview listener and we can add CHECKs.

    Line 2004, Patchset 10 (Latest): // If no exact match exists, check if this is a newly started context
    // operating under a concrete identity for an event dispatched under its lazy
    // key. In that case, fall back to matching the existing lazy target for the
    // same browser context, extension, and webview instance.
    return std::ranges::find_if(
    blocked_request.pending_targets, [&key](const auto& entry) {
    const DispatchTargetKey& candidate_key = entry.first;
    return candidate_key.IsLazy() &&
    candidate_key.listener_context_id == key.listener_context_id &&
    candidate_key.extension_id == key.extension_id &&
    candidate_key.web_view_instance_id == key.web_view_instance_id;
    });
    Devlin Cronin . unresolved

    hmm... is this / should this be possible?

    A lazy context starts. There are only lazy listeners.

    • Context adds listeners before the event gets there. This means we'll have gone through the IPC to add the event listener, which should happen on the same associated message channel and thus the listener should be active (right?)
    • Or, context doesn't add listeners in time (unsupported async registration). The listeners aren't registered, so they can't get the event.

    Is there a scenario in which the listener gets the event, but we haven't received the message that it's been added?

    Andrea Orru

    To answer your question first... There's no scenario where the listener gets the event before we've received the registration. That's not why this code is here.

    This is actually the "normal" path, not an edge case. Probably the comments don't make it clear.

    The pending target is written at dispatch time using the lazy key, because a sleeping context has no other identity at that point. But once awake, the context always answers under its concrete identity (actual process ID, worker version etc.). So for any event dispatched while the context was sleeping, the answer's key can never equal the lazy key in the map.

    Line 2069, Patchset 10 (Latest): // completion signal that arrived before this deferred task executed).
    Devlin Cronin . unresolved

    if the event couldn't dispatch, how could we get a completion signal?

    Or should this instead be something like the process going away? (I guess in some ways that's a "completion signal", but isn't what I'd normally think of)

    Andrea Orru

    The "process going away" case is not handled in the current CL, but in a follow-up (it's mentioned in the commit description, although perhaps just in passing).

    A process/worker can be torn down, in which case a real `eventHandlingDone` cannot be issued, and the browser needs to manage the equivalent of a "completion signal".

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Devlin Cronin
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • 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: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Ic809ceb2b09718c14a754673e6246f8c9aab08d4
    Gerrit-Change-Number: 8120467
    Gerrit-PatchSet: 10
    Gerrit-Owner: Andrea Orru <andre...@chromium.org>
    Gerrit-Reviewer: Andrea Orru <andre...@chromium.org>
    Gerrit-Reviewer: Devlin Cronin <rdevlin...@chromium.org>
    Gerrit-Attention: Devlin Cronin <rdevlin...@chromium.org>
    Gerrit-Comment-Date: Wed, 22 Jul 2026 21:15:34 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Devlin Cronin <rdevlin...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Andrea Orru (Gerrit)

    unread,
    Jul 23, 2026, 6:33:08 PM (2 days ago) Jul 23
    to Devlin Cronin, Chromium LUCI CQ, chromium...@chromium.org, chromium-a...@chromium.org, extension...@chromium.org
    Attention needed from Devlin Cronin

    Andrea Orru voted and added 4 comments

    Votes added by Andrea Orru

    Commit-Queue+1

    4 comments

    Commit Message
    Line 16, Patchset 10: "webRequestInternal.eventHandled". Each response is clamped to the
    Devlin Cronin . resolved

    nitty nit: maybe add "as they do today" to indicate this flow isn't new.

    Andrea Orru

    Done

    File extensions/browser/api/web_request/extension_web_request_event_router.h
    Line 768, Patchset 10: content::BrowserContext* browser_context,
    Devlin Cronin . resolved

    same comments re ref, ChildProcessId

    Andrea Orru

    Done

    Line 519, Patchset 10: int render_process_id,
    Devlin Cronin . resolved

    nit: ChildProcessId?

    Andrea Orru

    Done

    Line 517, Patchset 10: content::BrowserContext* browser_context,
    Devlin Cronin . resolved

    nit: pass by ref

    Andrea Orru

    Done

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Devlin Cronin
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • 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: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Ic809ceb2b09718c14a754673e6246f8c9aab08d4
    Gerrit-Change-Number: 8120467
    Gerrit-PatchSet: 12
    Gerrit-Owner: Andrea Orru <andre...@chromium.org>
    Gerrit-Reviewer: Andrea Orru <andre...@chromium.org>
    Gerrit-Reviewer: Devlin Cronin <rdevlin...@chromium.org>
    Gerrit-Attention: Devlin Cronin <rdevlin...@chromium.org>
    Gerrit-Comment-Date: Thu, 23 Jul 2026 22:32:57 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    Comment-In-Reply-To: Devlin Cronin <rdevlin...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Devlin Cronin (Gerrit)

    unread,
    Jul 23, 2026, 6:51:34 PM (2 days ago) Jul 23
    to Andrea Orru, Devlin Cronin, Chromium LUCI CQ, chromium...@chromium.org, chromium-a...@chromium.org, extension...@chromium.org
    Attention needed from Andrea Orru

    Devlin Cronin added 2 comments

    File extensions/browser/api/web_request/extension_web_request_event_router.cc
    Line 2004, Patchset 10: // If no exact match exists, check if this is a newly started context

    // operating under a concrete identity for an event dispatched under its lazy
    // key. In that case, fall back to matching the existing lazy target for the
    // same browser context, extension, and webview instance.
    return std::ranges::find_if(
    blocked_request.pending_targets, [&key](const auto& entry) {
    const DispatchTargetKey& candidate_key = entry.first;
    return candidate_key.IsLazy() &&
    candidate_key.listener_context_id == key.listener_context_id &&
    candidate_key.extension_id == key.extension_id &&
    candidate_key.web_view_instance_id == key.web_view_instance_id;
    });
    Devlin Cronin . unresolved

    hmm... is this / should this be possible?

    A lazy context starts. There are only lazy listeners.

    • Context adds listeners before the event gets there. This means we'll have gone through the IPC to add the event listener, which should happen on the same associated message channel and thus the listener should be active (right?)
    • Or, context doesn't add listeners in time (unsupported async registration). The listeners aren't registered, so they can't get the event.

    Is there a scenario in which the listener gets the event, but we haven't received the message that it's been added?

    Andrea Orru

    To answer your question first... There's no scenario where the listener gets the event before we've received the registration. That's not why this code is here.

    This is actually the "normal" path, not an edge case. Probably the comments don't make it clear.

    The pending target is written at dispatch time using the lazy key, because a sleeping context has no other identity at that point. But once awake, the context always answers under its concrete identity (actual process ID, worker version etc.). So for any event dispatched while the context was sleeping, the answer's key can never equal the lazy key in the map.

    Devlin Cronin

    Got it; thanks for the details. This makes sense.

    It's probably worth updating the comment to explain this a bit more thoroughly, but the general code flow makes sense.

    Line 2069, Patchset 10: // completion signal that arrived before this deferred task executed).
    Devlin Cronin . unresolved

    if the event couldn't dispatch, how could we get a completion signal?

    Or should this instead be something like the process going away? (I guess in some ways that's a "completion signal", but isn't what I'd normally think of)

    Andrea Orru

    The "process going away" case is not handled in the current CL, but in a follow-up (it's mentioned in the commit description, although perhaps just in passing).

    A process/worker can be torn down, in which case a real `eventHandlingDone` cannot be issued, and the browser needs to manage the equivalent of a "completion signal".

    Devlin Cronin

    got it -- but then we should still document when another completion signal could arrive : )

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Andrea Orru
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • 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: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Ic809ceb2b09718c14a754673e6246f8c9aab08d4
    Gerrit-Change-Number: 8120467
    Gerrit-PatchSet: 12
    Gerrit-Owner: Andrea Orru <andre...@chromium.org>
    Gerrit-Reviewer: Andrea Orru <andre...@chromium.org>
    Gerrit-Reviewer: Devlin Cronin <rdevlin...@chromium.org>
    Gerrit-Attention: Andrea Orru <andre...@chromium.org>
    Gerrit-Comment-Date: Thu, 23 Jul 2026 22:51:10 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Devlin Cronin <rdevlin...@chromium.org>
    Comment-In-Reply-To: Andrea Orru <andre...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Andrea Orru (Gerrit)

    unread,
    Jul 23, 2026, 7:29:33 PM (2 days ago) Jul 23
    to Devlin Cronin, Chromium LUCI CQ, chromium...@chromium.org, chromium-a...@chromium.org, extension...@chromium.org

    Andrea Orru added 1 comment

    File extensions/browser/api/web_request/extension_web_request_event_router.cc
    Line 2044, Patchset 10: return RespondingTarget{blocked_request, it};
    Devlin Cronin . resolved

    passing iterators into maps from methods is, to me, a bit of a code smell -- it's very easy to accidentally have the iterator become stale without easily noticing it.

    It also doesn't look like we ever use the returned iterator _as an iterator_. Could we instead have this return the blocked request and extra info flags?

    Andrea Orru

    Done

    Open in Gerrit

    Related details

    Attention set is empty
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • 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: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Ic809ceb2b09718c14a754673e6246f8c9aab08d4
    Gerrit-Change-Number: 8120467
    Gerrit-PatchSet: 13
    Gerrit-Owner: Andrea Orru <andre...@chromium.org>
    Gerrit-Reviewer: Andrea Orru <andre...@chromium.org>
    Gerrit-Reviewer: Devlin Cronin <rdevlin...@chromium.org>
    Gerrit-Comment-Date: Thu, 23 Jul 2026 23:28:59 +0000
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Andrea Orru (Gerrit)

    unread,
    Jul 24, 2026, 4:58:34 PM (11 hours ago) Jul 24
    to Devlin Cronin, Chromium LUCI CQ, chromium...@chromium.org, chromium-a...@chromium.org, extension...@chromium.org

    Andrea Orru added 5 comments

    File extensions/browser/api/web_request/extension_web_request_event_router.cc
    Line 1763, Patchset 10: !key.IsLazy() && key.web_view_instance_id != 0;
    Devlin Cronin . resolved

    is there such a thing as a lazy webview listener? I feel like there shouldn't be. Can we make this a CHECK somewhere (or multiple places)?

    Andrea Orru

    Acknowledged. There's no such thing as a lazy webview listener and we can add CHECKs.

    Andrea Orru

    Done

    Line 1943, Patchset 10: if (!responding_target) {
    Devlin Cronin . resolved

    when do we expect this? (Add a comment)

    Andrea Orru

    Done

    Line 2004, Patchset 10: // If no exact match exists, check if this is a newly started context
    // operating under a concrete identity for an event dispatched under its lazy
    // key. In that case, fall back to matching the existing lazy target for the
    // same browser context, extension, and webview instance.
    return std::ranges::find_if(
    blocked_request.pending_targets, [&key](const auto& entry) {
    const DispatchTargetKey& candidate_key = entry.first;
    return candidate_key.IsLazy() &&
    candidate_key.listener_context_id == key.listener_context_id &&
    candidate_key.extension_id == key.extension_id &&
    candidate_key.web_view_instance_id == key.web_view_instance_id;
    });
    Devlin Cronin . resolved

    hmm... is this / should this be possible?

    A lazy context starts. There are only lazy listeners.

    • Context adds listeners before the event gets there. This means we'll have gone through the IPC to add the event listener, which should happen on the same associated message channel and thus the listener should be active (right?)
    • Or, context doesn't add listeners in time (unsupported async registration). The listeners aren't registered, so they can't get the event.

    Is there a scenario in which the listener gets the event, but we haven't received the message that it's been added?

    Andrea Orru

    To answer your question first... There's no scenario where the listener gets the event before we've received the registration. That's not why this code is here.

    This is actually the "normal" path, not an edge case. Probably the comments don't make it clear.

    The pending target is written at dispatch time using the lazy key, because a sleeping context has no other identity at that point. But once awake, the context always answers under its concrete identity (actual process ID, worker version etc.). So for any event dispatched while the context was sleeping, the answer's key can never equal the lazy key in the map.

    Devlin Cronin

    Got it; thanks for the details. This makes sense.

    It's probably worth updating the comment to explain this a bit more thoroughly, but the general code flow makes sense.

    Andrea Orru

    Done

    Line 2069, Patchset 10: // completion signal that arrived before this deferred task executed).
    Devlin Cronin . resolved

    if the event couldn't dispatch, how could we get a completion signal?

    Or should this instead be something like the process going away? (I guess in some ways that's a "completion signal", but isn't what I'd normally think of)

    Andrea Orru

    The "process going away" case is not handled in the current CL, but in a follow-up (it's mentioned in the commit description, although perhaps just in passing).

    A process/worker can be torn down, in which case a real `eventHandlingDone` cannot be issued, and the browser needs to manage the equivalent of a "completion signal".

    Devlin Cronin

    got it -- but then we should still document when another completion signal could arrive : )

    Andrea Orru

    Done

    Line 2762, Patchset 10: // Requests may be missing if already completed or canceled, or blocked on

    // a different event stage if the request advanced past `event_name` before
    // a delayed response arrived.
    Devlin Cronin . resolved

    how would this happen?

    Andrea Orru

    Done

    Open in Gerrit

    Related details

    Attention set is empty
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • 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: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Ic809ceb2b09718c14a754673e6246f8c9aab08d4
    Gerrit-Change-Number: 8120467
    Gerrit-PatchSet: 14
    Gerrit-Owner: Andrea Orru <andre...@chromium.org>
    Gerrit-Reviewer: Andrea Orru <andre...@chromium.org>
    Gerrit-Reviewer: Devlin Cronin <rdevlin...@chromium.org>
    Gerrit-Comment-Date: Fri, 24 Jul 2026 20:58:23 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Devlin Cronin <rdevlin...@chromium.org>
    Comment-In-Reply-To: Andrea Orru <andre...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Andrea Orru (Gerrit)

    unread,
    Jul 24, 2026, 5:01:03 PM (11 hours ago) Jul 24
    to Devlin Cronin, Chromium LUCI CQ, chromium...@chromium.org, chromium-a...@chromium.org, extension...@chromium.org
    Attention needed from Devlin Cronin

    Andrea Orru voted Commit-Queue+1

    Commit-Queue+1
    Open in Gerrit

    Related details

    Attention is currently required from:
    • Devlin Cronin
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • 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: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Ic809ceb2b09718c14a754673e6246f8c9aab08d4
    Gerrit-Change-Number: 8120467
    Gerrit-PatchSet: 14
    Gerrit-Owner: Andrea Orru <andre...@chromium.org>
    Gerrit-Reviewer: Andrea Orru <andre...@chromium.org>
    Gerrit-Reviewer: Devlin Cronin <rdevlin...@chromium.org>
    Gerrit-Attention: Devlin Cronin <rdevlin...@chromium.org>
    Gerrit-Comment-Date: Fri, 24 Jul 2026 21:00:53 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: Yes
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Andrea Orru (Gerrit)

    unread,
    Jul 24, 2026, 5:01:20 PM (11 hours ago) Jul 24
    to Devlin Cronin, Chromium LUCI CQ, chromium...@chromium.org, chromium-a...@chromium.org, extension...@chromium.org
    Attention needed from Devlin Cronin

    Andrea Orru added 1 comment

    Patchset-level comments
    File-level comment, Patchset 10:
    Andrea Orru . resolved

    Answering a few of the core questions before I make more code changes.

    Andrea Orru

    Done

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Devlin Cronin
    Submit Requirements:
      • requirement satisfiedCode-Coverage
      • 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: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: Ic809ceb2b09718c14a754673e6246f8c9aab08d4
      Gerrit-Change-Number: 8120467
      Gerrit-PatchSet: 14
      Gerrit-Owner: Andrea Orru <andre...@chromium.org>
      Gerrit-Reviewer: Andrea Orru <andre...@chromium.org>
      Gerrit-Reviewer: Devlin Cronin <rdevlin...@chromium.org>
      Gerrit-Attention: Devlin Cronin <rdevlin...@chromium.org>
      Gerrit-Comment-Date: Fri, 24 Jul 2026 21:01:09 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      Comment-In-Reply-To: Andrea Orru <andre...@chromium.org>
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Devlin Cronin (Gerrit)

      unread,
      Jul 24, 2026, 6:57:14 PM (9 hours ago) Jul 24
      to Andrea Orru, Devlin Cronin, Chromium LUCI CQ, chromium...@chromium.org, chromium-a...@chromium.org, extension...@chromium.org
      Attention needed from Andrea Orru

      Devlin Cronin voted and added 3 comments

      Votes added by Devlin Cronin

      Code-Review+1

      3 comments

      Patchset-level comments
      File-level comment, Patchset 14 (Latest):
      Devlin Cronin . resolved

      LGTM; thanks, Andrea!

      File extensions/browser/api/web_request/extension_web_request_event_router.h
      Line 756, Patchset 14 (Latest): GroupListenersByDispatchTarget(const RawListeners& listeners);
      Devlin Cronin . unresolved

      Is the only reason this is a static method (as opposed to an anonymous namespace method in the .cc file) because it returns a DispatchTargetKey, which is a private type? If so, maybe put a comment? (In most cases, private statics are kind of a code smell)

      File extensions/browser/api/web_request/extension_web_request_event_router.cc
      Line 2077, Patchset 14 (Latest): if (blocked_request.pending_targets.erase(target_key) == 0) {
      // The target was already resolved. Several independent triggers can
      // resolve a pending target, in any order:
      // - Renderer completion signals: renderer-controlled IPCs, which a
      // misbehaving renderer can send unsolicited.
      // - `OnTargetCannotDispatch()`, which runs from a posted task.
      // - Teardown of the target's renderer context.
      // A trigger that runs after the target is resolved must do nothing; in
      // particular, it must not decrement the block count again.
      return;
      }
      Devlin Cronin . unresolved

      this... still seems like we should be able to be stricter here (e.g. maybe renderer kills).
      1) Misbehaving renderer: should terminate the renderer
      2) "CannotDispatch". This should only happen as a "second" signal if the renderer context was eliminated. We should never get a "cannot dispatch" for a live renderer as the second signal, since if we can't dispatch, we shouldn't get that first signal.
      3) Renderer teardown should probably only enter here if the renderer is being tracked as a pending target.

      This is probably okay for this CL, but I wonder if we should add a TODO to tighten it up? WDYT?

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Andrea Orru
      Submit Requirements:
        • requirement satisfiedCode-Coverage
        • requirement satisfiedCode-Owners
        • requirement satisfiedCode-Review
        • requirement is not satisfiedNo-Unresolved-Comments
        • requirement satisfiedReview-Enforcement
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: chromium/src
        Gerrit-Branch: main
        Gerrit-Change-Id: Ic809ceb2b09718c14a754673e6246f8c9aab08d4
        Gerrit-Change-Number: 8120467
        Gerrit-PatchSet: 14
        Gerrit-Owner: Andrea Orru <andre...@chromium.org>
        Gerrit-Reviewer: Andrea Orru <andre...@chromium.org>
        Gerrit-Reviewer: Devlin Cronin <rdevlin...@chromium.org>
        Gerrit-Attention: Andrea Orru <andre...@chromium.org>
        Gerrit-Comment-Date: Fri, 24 Jul 2026 22:57:04 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: Yes
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Andrea Orru (Gerrit)

        unread,
        Jul 24, 2026, 7:59:58 PM (8 hours ago) Jul 24
        to Devlin Cronin, Chromium LUCI CQ, chromium...@chromium.org, chromium-a...@chromium.org, extension...@chromium.org

        Andrea Orru voted and added 2 comments

        Votes added by Andrea Orru

        Commit-Queue+2

        2 comments

        File extensions/browser/api/web_request/extension_web_request_event_router.h
        Line 756, Patchset 14: GroupListenersByDispatchTarget(const RawListeners& listeners);
        Devlin Cronin . resolved

        Is the only reason this is a static method (as opposed to an anonymous namespace method in the .cc file) because it returns a DispatchTargetKey, which is a private type? If so, maybe put a comment? (In most cases, private statics are kind of a code smell)

        Andrea Orru

        Done

        File extensions/browser/api/web_request/extension_web_request_event_router.cc
        Line 2077, Patchset 14: if (blocked_request.pending_targets.erase(target_key) == 0) {

        // The target was already resolved. Several independent triggers can
        // resolve a pending target, in any order:
        // - Renderer completion signals: renderer-controlled IPCs, which a
        // misbehaving renderer can send unsolicited.
        // - `OnTargetCannotDispatch()`, which runs from a posted task.
        // - Teardown of the target's renderer context.
        // A trigger that runs after the target is resolved must do nothing; in
        // particular, it must not decrement the block count again.
        return;
        }
        Devlin Cronin . resolved

        this... still seems like we should be able to be stricter here (e.g. maybe renderer kills).
        1) Misbehaving renderer: should terminate the renderer
        2) "CannotDispatch". This should only happen as a "second" signal if the renderer context was eliminated. We should never get a "cannot dispatch" for a live renderer as the second signal, since if we can't dispatch, we shouldn't get that first signal.
        3) Renderer teardown should probably only enter here if the renderer is being tracked as a pending target.

        This is probably okay for this CL, but I wonder if we should add a TODO to tighten it up? WDYT?

        Andrea Orru

        Sounds good. I added a TODO.

        Open in Gerrit

        Related details

        Attention set is empty
        Submit Requirements:
          • requirement satisfiedCode-Coverage
          • 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: chromium/src
          Gerrit-Branch: main
          Gerrit-Change-Id: Ic809ceb2b09718c14a754673e6246f8c9aab08d4
          Gerrit-Change-Number: 8120467
          Gerrit-PatchSet: 15
          Gerrit-Owner: Andrea Orru <andre...@chromium.org>
          Gerrit-Reviewer: Andrea Orru <andre...@chromium.org>
          Gerrit-Reviewer: Devlin Cronin <rdevlin...@chromium.org>
          Gerrit-Comment-Date: Fri, 24 Jul 2026 23:59:47 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: Yes
          Comment-In-Reply-To: Devlin Cronin <rdevlin...@chromium.org>
          satisfied_requirement
          open
          diffy

          Chromium LUCI CQ (Gerrit)

          unread,
          Jul 24, 2026, 11:35:11 PM (5 hours ago) Jul 24
          to Andrea Orru, Devlin Cronin, chromium...@chromium.org, chromium-a...@chromium.org, extension...@chromium.org

          Chromium LUCI CQ submitted the change with unreviewed changes

          Unreviewed changes

          14 is the latest approved patch-set.
          The change was submitted with unreviewed changes in the following files:

          ```
          The name of the file: extensions/browser/api/web_request/extension_web_request_event_router.h
          Insertions: 3, Deletions: 0.

          @@ -752,6 +752,9 @@

          // Groups the matched `listeners` by their renderer dispatch target,
          // producing exactly one entry per context.
          + //
          + // Static member rather than anonymous namespace helper because the signature
          + // names private nested types (`RawListeners`, `DispatchTargetKey`).
          static std::map<DispatchTargetKey, RawListeners>
          GroupListenersByDispatchTarget(const RawListeners& listeners);

          ```
          ```
          The name of the file: extensions/browser/api/web_request/extension_web_request_event_router.cc
          Insertions: 6, Deletions: 0.

          @@ -2083,6 +2083,12 @@

          // - Teardown of the target's renderer context.
          // A trigger that runs after the target is resolved must do nothing; in
          // particular, it must not decrement the block count again.
          +    //
          + // TODO(crbug.com/494684626): CHECK the erase on the completion signal
          + // path. `OnEventHandlingDone()` resolves only targets it just found, and
          + // stale renderer signals fail that lookup. Only `OnTargetCannotDispatch()`
          + // needs this return. Killing renderers that send unsolicited signals would
          + // require some additional tracking on the browser side.
          return;
          }
          DecrementBlockCount(browser_context, extension_id, event_name, request_id,
          ```

          Change information

          Commit message:
          [Extensions] Resolve per-context webRequest blocking dispatch targets

          Implements response resolution for per-context webRequest event
          dispatch, completing the lifecycle for PendingTarget entries recorded on
          a BlockedRequest.

          During event handling, the renderer delivers responses in two stages:

          1. Individual blocking listener responses arrive via
          "webRequestInternal.eventHandled" as they do today. Each response is
          clamped to the target's allowed extraInfoSpec bitmask and recorded as
          an event delta.
          2. Once all matching listeners in the context finish executing, a
          single "webRequestInternal.eventHandlingDone" IPC resolves the
          pending target, applies the collected deltas, and unblocks the
          network request if no other blocking sources remain.

          The renderer owns the completion signal by reporting "eventHandlingDone"
          for every awaited dispatch it receives. The browser resolves a pending
          target without applying response deltas only when the event cannot be
          delivered at dispatch time (Event::cannot_dispatch_callback). A
          follow-up will add resolution for targets whose renderer context is torn
          down.

          Additionally, refactors response delta recording into a reusable
          AppendResponseDelta() helper shared between the legacy per-listener and
          new per-context dispatch paths.

          Note: This code is currently inactive until the per-context event
          dispatch feature flag is enabled.

          Design doc: go/no-webrequest-subevent
          Bug: 494684626
          Change-Id: Ic809ceb2b09718c14a754673e6246f8c9aab08d4
          Reviewed-by: Devlin Cronin <rdevlin...@chromium.org>
          Commit-Queue: Andrea Orru <andre...@chromium.org>
          Cr-Commit-Position: refs/heads/main@{#1668248}
          Files:
          • M extensions/browser/api/web_request/extension_web_request_event_router.cc
          • M extensions/browser/api/web_request/extension_web_request_event_router.h
          • M extensions/browser/api/web_request/web_request_api.cc
          Change size: L
          Delta: 3 files changed, 370 insertions(+), 51 deletions(-)
          Branch: refs/heads/main
          Submit Requirements:
          • requirement satisfiedCode-Review: +1 by Devlin Cronin
          Open in Gerrit
          Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
          Gerrit-MessageType: merged
          Gerrit-Project: chromium/src
          Gerrit-Branch: main
          Gerrit-Change-Id: Ic809ceb2b09718c14a754673e6246f8c9aab08d4
          Gerrit-Change-Number: 8120467
          Gerrit-PatchSet: 16
          Gerrit-Owner: Andrea Orru <andre...@chromium.org>
          Gerrit-Reviewer: Andrea Orru <andre...@chromium.org>
          Gerrit-Reviewer: Chromium LUCI CQ <chromiu...@luci-project-accounts.iam.gserviceaccount.com>
          Gerrit-Reviewer: Devlin Cronin <rdevlin...@chromium.org>
          open
          diffy
          satisfied_requirement
          Reply all
          Reply to author
          Forward
          0 new messages