content: Add URLLoaderFactory able to serve resources in-process [chromium/src : main]

1 view
Skip to first unread message

Alex Yang (Gerrit)

unread,
Oct 31, 2024, 3:22:11 AM10/31/24
to Daniel Cheng, Tsuyoshi Horo, Kentaro Hara, Kouhei Ueno, Tricium, findit...@appspot.gserviceaccount.com, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, blink-re...@chromium.org, blink-...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading...@chromium.org
Attention needed from Daniel Cheng

Alex Yang added 1 comment

Patchset-level comments
File-level comment, Patchset 8 (Latest):
Alex Yang . resolved

Hi Daniel, I've moved the resource loader implementation from Blink to //content/renderer as we discussed. Please take a look. Thanks!

Open in Gerrit

Related details

Attention is currently required from:
  • Daniel Cheng
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
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: If1a9ecf61f917baafb8e1890ee28c1e806d996a9
Gerrit-Change-Number: 5955670
Gerrit-PatchSet: 8
Gerrit-Owner: Alex Yang <ayc...@chromium.org>
Gerrit-Reviewer: Alex Yang <ayc...@chromium.org>
Gerrit-Reviewer: Daniel Cheng <dch...@chromium.org>
Gerrit-CC: Kentaro Hara <har...@chromium.org>
Gerrit-CC: Kouhei Ueno <kou...@chromium.org>
Gerrit-CC: Nate Chapin <jap...@chromium.org>
Gerrit-CC: Tsuyoshi Horo <ho...@chromium.org>
Gerrit-Attention: Daniel Cheng <dch...@chromium.org>
Gerrit-Comment-Date: Thu, 31 Oct 2024 07:22:02 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Alex Yang (Gerrit)

unread,
Oct 31, 2024, 4:16:01 PM10/31/24
to findit...@appspot.gserviceaccount.com, Daniel Cheng, Tsuyoshi Horo, Kentaro Hara, Kouhei Ueno, Tricium, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, blink-re...@chromium.org, blink-...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading...@chromium.org
Attention needed from Daniel Cheng

Alex Yang added 1 comment

Patchset-level comments
File-level comment, Patchset 6:
Daniel Cheng . resolved

I know I originally gave the recommendation of just implementing it directly in Blink, but the implementation looks kind of awkward to me. Are there other URL loader factories like this that are already implemented in Blink? Or are most of them implemented in //content today?

Alex Yang

There are a bunch at //content/browser/loader [1], those are somewhat different from this one because they run in the browser process. I don't know of any that are implemented in Blink.

[1] https://source.chromium.org/chromium/chromium/src/+/main:content/browser/loader/;drc=4a29e2d51f26573e0182f24380be14b980db1d80

Alex Yang

An alternate approach I was considering before I reached out to you and others on the Blink team for guidance was to put the resource loader implementation in //content/renderer/. It was more work so I dropped it when I got the ok to leave it in Blink. I can revisit it but I may need additional guidance on how to update the public Blink API to accommodate something like that.

Alex Yang

Moved loader out of Blink as discussed offline

Open in Gerrit

Related details

Attention is currently required from:
  • Daniel Cheng
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Review
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: If1a9ecf61f917baafb8e1890ee28c1e806d996a9
Gerrit-Change-Number: 5955670
Gerrit-PatchSet: 9
Gerrit-Owner: Alex Yang <ayc...@chromium.org>
Gerrit-Reviewer: Alex Yang <ayc...@chromium.org>
Gerrit-Reviewer: Daniel Cheng <dch...@chromium.org>
Gerrit-CC: Kentaro Hara <har...@chromium.org>
Gerrit-CC: Kouhei Ueno <kou...@chromium.org>
Gerrit-CC: Nate Chapin <jap...@chromium.org>
Gerrit-CC: Tsuyoshi Horo <ho...@chromium.org>
Gerrit-Attention: Daniel Cheng <dch...@chromium.org>
Gerrit-Comment-Date: Thu, 31 Oct 2024 20:15:52 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Daniel Cheng <dch...@chromium.org>
Comment-In-Reply-To: Alex Yang <ayc...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Daniel Cheng (Gerrit)

unread,
Nov 5, 2024, 8:13:40 PM11/5/24
to Alex Yang, Code Review Nudger, findit...@appspot.gserviceaccount.com, Daniel Cheng, Tsuyoshi Horo, Kentaro Hara, Kouhei Ueno, Tricium, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, blink-re...@chromium.org, blink-...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading...@chromium.org
Attention needed from Alex Yang

Daniel Cheng added 12 comments

Patchset-level comments
File-level comment, Patchset 9 (Latest):
Daniel Cheng . unresolved

I've been thinking about the integration overall. I don't love the current way it's written because we add a special case to ChildURLLoaderFactoryBundle just for `chrome` even though we already have `scheme_specific_factories_`.

This means that there are two different ways to gate requests to the `chrome` scheme now, and I think that is worse.

1. The original gating is based off of `scheme_specific_factories_`; if a factory for the `chrome` scheme isn't present in the map, then we just can't satisfy requests for the `chrome` scheme.
2. But now we also have `local_resource_loader_factory_` which is populated using a different IPC and gated on a different set of checks.

It's hard to make sure that these stay in sync.

Have you considered if there's any way to reuse `scheme_specific_factories_` here? It would require some changes from the original CLs to make it work, but if we plumb it across with `URLLoaderFactoryBundle`, I feel like that would better ensure everything always stays in sync: https://source.chromium.org/search?q=subresource_loader_factories%20f:mojom$&ss=chromium

The tricky part here is that the map owns a `mojo::Remote`. We can:

  • either have `mojo::Remote` be in-process and just have that be an additional async call or
  • add some indirection so that there could be an in-process facade using `URLLoaderFactory*` directly instead of `mojo::Remote<URLLoaderFactory>`.

However, I think the first option would be better unless we find out that even an in-process async call is bad for performance.

File content/renderer/local_resource_url_loader_factory_impl.cc
Line 44, Patchset 9 (Latest): return ranges[0];
Daniel Cheng . unresolved

Just curious, but is this a cleanroom implementation or taken from something else? Wondering if this snippet should be shared somehow (perhaps in a separate CL)

Line 53, Patchset 9 (Latest): std::map<const std::string, std::string> replacement_strings)
Daniel Cheng . unresolved

It's unusual to specify `const` in a map key, as it's implicitly const. Is this needed?

Line 60, Patchset 9 (Latest): std::map<url::Origin, std::unique_ptr<Source>> sources)
Daniel Cheng . resolved

i.e. this one doesn't have `const` on the key type.

Line 77, Patchset 9 (Latest): url::Origin::CreateFromNormalizedTuple("chrome", source->name, 0);
Daniel Cheng . unresolved

I am not very comfortable with doing this. Can we just pass an origin directly over IPC? Is there any place where the WebUI would already have a tuple? Does WebUI have any helper for this sort of thing?

Line 129, Patchset 9 (Latest):void LocalResourceURLLoaderFactoryImpl::CreateLoaderAndStart(
Daniel Cheng . unresolved

Is there any world where it'd make sense to combine CreateLoaderAndStart() and CanServe(), i.e. `MaybeCreateLoaderAndStart()` and have it returning a PendingReceiver?

Line 131, Patchset 9 (Latest): mojo::PendingRemote<network::mojom::URLLoaderClient> client) const {
Daniel Cheng . unresolved

Worth adding `DCHECK(CanServce(request))` here?

Line 242, Patchset 9 (Latest): base::span<uint8_t> to_buffer;
MojoResult result = pipe_producer_handle->BeginWriteData(
output_size, MOJO_WRITE_DATA_FLAG_NONE, to_buffer);
CHECK_EQ(result, MOJO_RESULT_OK);
CHECK_GE(to_buffer.size(), output_size);
CHECK_LE(output_offset + output_size, bytes.size());

to_buffer.copy_prefix_from(base::as_bytes(
base::make_span(bytes).subspan(output_offset, output_size)));
result = pipe_producer_handle->EndWriteData(output_size);
CHECK_EQ(result, MOJO_RESULT_OK);

resource_response->content_length = output_size;
Line 256, Patchset 9 (Latest): // Reply to loader client.
mojo::Remote<network::mojom::URLLoaderClient> client_remote(
std::move(client));
client_remote->OnReceiveResponse(std::move(resource_response),
std::move(pipe_consumer_handle),
std::nullopt);
Daniel Cheng . unresolved

Would it make sense to reply to the client before doing the write?

File content/renderer/local_resource_url_loader_factory_impl_unittest.cc
Line 77, Patchset 9 (Latest): void AddReplacementString(std::string key, std::string value) {
Daniel Cheng . unresolved

Nit: either use const ref or use std::move() below. Same comment elsewhere this shows up

Line 90, Patchset 9 (Latest): result = client.response_body().ReadData(
Daniel Cheng . unresolved

`BlockingCopyFromString()`?

File third_party/blink/public/platform/local_resource_url_loader_factory.h
Line 15, Patchset 9 (Latest):class LocalResourceURLLoaderFactory
Daniel Cheng . unresolved

Classes and public/protected methods in the Blink public API should have some documentation comments.

Open in Gerrit

Related details

Attention is currently required from:
  • Alex Yang
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    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: If1a9ecf61f917baafb8e1890ee28c1e806d996a9
    Gerrit-Change-Number: 5955670
    Gerrit-PatchSet: 9
    Gerrit-Owner: Alex Yang <ayc...@chromium.org>
    Gerrit-Reviewer: Alex Yang <ayc...@chromium.org>
    Gerrit-Reviewer: Daniel Cheng <dch...@chromium.org>
    Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
    Gerrit-CC: Kentaro Hara <har...@chromium.org>
    Gerrit-CC: Kouhei Ueno <kou...@chromium.org>
    Gerrit-CC: Nate Chapin <jap...@chromium.org>
    Gerrit-CC: Tsuyoshi Horo <ho...@chromium.org>
    Gerrit-Attention: Alex Yang <ayc...@chromium.org>
    Gerrit-Comment-Date: Wed, 06 Nov 2024 01:13:31 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Alex Yang (Gerrit)

    unread,
    Nov 6, 2024, 1:49:59 AM11/6/24
    to Code Review Nudger, findit...@appspot.gserviceaccount.com, Daniel Cheng, Tsuyoshi Horo, Kentaro Hara, Kouhei Ueno, Tricium, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, blink-re...@chromium.org, blink-...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading...@chromium.org
    Attention needed from Daniel Cheng

    Alex Yang added 5 comments

    Patchset-level comments
    Daniel Cheng . unresolved

    I've been thinking about the integration overall. I don't love the current way it's written because we add a special case to ChildURLLoaderFactoryBundle just for `chrome` even though we already have `scheme_specific_factories_`.

    This means that there are two different ways to gate requests to the `chrome` scheme now, and I think that is worse.

    1. The original gating is based off of `scheme_specific_factories_`; if a factory for the `chrome` scheme isn't present in the map, then we just can't satisfy requests for the `chrome` scheme.
    2. But now we also have `local_resource_loader_factory_` which is populated using a different IPC and gated on a different set of checks.

    It's hard to make sure that these stay in sync.

    Have you considered if there's any way to reuse `scheme_specific_factories_` here? It would require some changes from the original CLs to make it work, but if we plumb it across with `URLLoaderFactoryBundle`, I feel like that would better ensure everything always stays in sync: https://source.chromium.org/search?q=subresource_loader_factories%20f:mojom$&ss=chromium

    The tricky part here is that the map owns a `mojo::Remote`. We can:

    • either have `mojo::Remote` be in-process and just have that be an additional async call or
    • add some indirection so that there could be an in-process facade using `URLLoaderFactory*` directly instead of `mojo::Remote<URLLoaderFactory>`.

    However, I think the first option would be better unless we find out that even an in-process async call is bad for performance.

    Alex Yang

    Thanks for calling out `scheme_specific_factories_`, I wasn't aware of it. At a glance, it looks like it would make more sense to integrate there. I can look into it when I get back from PTO next week.

    Alex Yang . resolved

    Responded to the larger comments, will address the rest later. TL;DR will probably spin off at least 2 CLs and eventually rebase this on top. Will pick this back up when I'm back from PTO (11/14)

    File content/renderer/local_resource_url_loader_factory_impl.cc
    Daniel Cheng . unresolved

    Just curious, but is this a cleanroom implementation or taken from something else? Wondering if this snippet should be shared somehow (perhaps in a separate CL)

    Alex Yang
    Line 53, Patchset 9 (Latest): std::map<const std::string, std::string> replacement_strings)
    Daniel Cheng . unresolved

    It's unusual to specify `const` in a map key, as it's implicitly const. Is this needed?

    Line 77, Patchset 9 (Latest): url::Origin::CreateFromNormalizedTuple("chrome", source->name, 0);
    Daniel Cheng . unresolved

    I am not very comfortable with doing this. Can we just pass an origin directly over IPC? Is there any place where the WebUI would already have a tuple? Does WebUI have any helper for this sort of thing?

    Alex Yang

    We could create the origin on the browser side [1] and send that instead of the source name. I feel like that's also hacky for the same reason. But no, there is no place where the data source would already have a tuple. This is because URLDataManagerBackend (ab)uses the fact that a data source with no scheme in its name implicitly serves chrome://-scheme URLs [2].

    I don't know of a helper for this. Speaking of helpers though, maybe WebUIDataSource should have an API to return the origin it serves; that way URLDataManagerBackend would not have to rely on the format of the source name. We would have to create that API and maybe refactor the normal browser-side codepath to use it.

    [1] https://source.chromium.org/chromium/chromium/src/+/main:content/browser/webui/web_ui_impl.cc;l=85;drc=8f98cea7f548d3bb3e37f7773a52584ecfe857e3
    [2] https://source.chromium.org/chromium/chromium/src/+/main:content/browser/webui/url_data_manager_backend.cc;l=145;drc=fc7ddc185b7f027dd7f4981ba8b2334c69a2e79c

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Daniel Cheng
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    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: If1a9ecf61f917baafb8e1890ee28c1e806d996a9
    Gerrit-Change-Number: 5955670
    Gerrit-PatchSet: 9
    Gerrit-Owner: Alex Yang <ayc...@chromium.org>
    Gerrit-Reviewer: Alex Yang <ayc...@chromium.org>
    Gerrit-Reviewer: Daniel Cheng <dch...@chromium.org>
    Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
    Gerrit-CC: Kentaro Hara <har...@chromium.org>
    Gerrit-CC: Kouhei Ueno <kou...@chromium.org>
    Gerrit-CC: Nate Chapin <jap...@chromium.org>
    Gerrit-CC: Tsuyoshi Horo <ho...@chromium.org>
    Gerrit-Attention: Daniel Cheng <dch...@chromium.org>
    Gerrit-Comment-Date: Wed, 06 Nov 2024 06:49:50 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Daniel Cheng <dch...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Alex Yang (Gerrit)

    unread,
    Nov 21, 2024, 4:00:47 PM11/21/24
    to Code Review Nudger, findit...@appspot.gserviceaccount.com, Daniel Cheng, Tsuyoshi Horo, Kentaro Hara, Kouhei Ueno, Tricium, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, blink-re...@chromium.org, blink-...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading...@chromium.org
    Attention needed from Daniel Cheng

    Alex Yang added 1 comment

    Patchset-level comments
    Daniel Cheng . unresolved

    I've been thinking about the integration overall. I don't love the current way it's written because we add a special case to ChildURLLoaderFactoryBundle just for `chrome` even though we already have `scheme_specific_factories_`.

    This means that there are two different ways to gate requests to the `chrome` scheme now, and I think that is worse.

    1. The original gating is based off of `scheme_specific_factories_`; if a factory for the `chrome` scheme isn't present in the map, then we just can't satisfy requests for the `chrome` scheme.
    2. But now we also have `local_resource_loader_factory_` which is populated using a different IPC and gated on a different set of checks.

    It's hard to make sure that these stay in sync.

    Have you considered if there's any way to reuse `scheme_specific_factories_` here? It would require some changes from the original CLs to make it work, but if we plumb it across with `URLLoaderFactoryBundle`, I feel like that would better ensure everything always stays in sync: https://source.chromium.org/search?q=subresource_loader_factories%20f:mojom$&ss=chromium

    The tricky part here is that the map owns a `mojo::Remote`. We can:

    • either have `mojo::Remote` be in-process and just have that be an additional async call or
    • add some indirection so that there could be an in-process facade using `URLLoaderFactory*` directly instead of `mojo::Remote<URLLoaderFactory>`.

    However, I think the first option would be better unless we find out that even an in-process async call is bad for performance.

    Alex Yang

    Thanks for calling out `scheme_specific_factories_`, I wasn't aware of it. At a glance, it looks like it would make more sense to integrate there. I can look into it when I get back from PTO next week.

    Alex Yang

    I'm in the process of understanding how this would work. I have two questions so far:

    1. I think I see how we could plumb the LocalResourceLoaderConfig across in a URLLoaderFactoryBundle via UpdateSubresourceLoaderFactories. We would pass the LocalResourceLoaderConfig in the PendingURLLoaderFactoryBundle, and then in RenderFrameImpl we would construct the actual LocalResourceURLLoaderFactory and own it, and construct a mojo::Remote<URLLoaderFactory> from it and move it into scheme_specific_factories_. This would involve adding code to URLLoaderFactoryBundle::Update [1]. Is that sort of what you had in mind?
    2. Re-using scheme_specific_factories_ would mean making the LocalResourceURLLoaderFactory implement the URLLoaderFactory interface. This is almost possible, but one thing that is stopping me is that LocalResourceURLLoaderFactory has an extra method, CanServe, which is used to preemptively check for URLs it can't serve and fallback to the default handling if it can't serve them. One way I can think of to accommodate this with scheme_specific_factories_ would be to add CanServe to the URLLoaderFactory interface, with a default implementation of always returning true, and override this in LocalResourceURLLoaderFactory with the real implementation. WDYT about this approach?

    [1] https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/common/loader/url_loader_factory_bundle.cc;l=156;drc=c325fff94cab7b3d378b5f367f75249662bbeaeb

    Gerrit-Comment-Date: Thu, 21 Nov 2024 21:00:37 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Daniel Cheng <dch...@chromium.org>
    Comment-In-Reply-To: Alex Yang <ayc...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Alex Yang (Gerrit)

    unread,
    Nov 21, 2024, 6:33:52 PM11/21/24
    to Code Review Nudger, findit...@appspot.gserviceaccount.com, Daniel Cheng, Tsuyoshi Horo, Kentaro Hara, Kouhei Ueno, Tricium, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, blink-re...@chromium.org, blink-...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading...@chromium.org
    Attention needed from Daniel Cheng

    Alex Yang added 9 comments

    File content/renderer/local_resource_url_loader_factory_impl.cc
    Line 44, Patchset 9: return ranges[0];
    Daniel Cheng . resolved

    Just curious, but is this a cleanroom implementation or taken from something else? Wondering if this snippet should be shared somehow (perhaps in a separate CL)

    Alex Yang

    It's approximately copied from here: https://source.chromium.org/chromium/chromium/src/+/main:content/browser/webui/web_ui_url_loader_factory.cc;l=213-228;drc=13d96e931eb929b66d26ead4e98a2243a4e5d2c6

    I agree, sharing this somehow would be ideal. I'll explore that.

    Alex Yang

    This is now shared with WebUIURLLoaderFactory

    Line 77, Patchset 9: url::Origin::CreateFromNormalizedTuple("chrome", source->name, 0);
    Daniel Cheng . resolved

    I am not very comfortable with doing this. Can we just pass an origin directly over IPC? Is there any place where the WebUI would already have a tuple? Does WebUI have any helper for this sort of thing?

    Alex Yang

    We could create the origin on the browser side [1] and send that instead of the source name. I feel like that's also hacky for the same reason. But no, there is no place where the data source would already have a tuple. This is because URLDataManagerBackend (ab)uses the fact that a data source with no scheme in its name implicitly serves chrome://-scheme URLs [2].

    I don't know of a helper for this. Speaking of helpers though, maybe WebUIDataSource should have an API to return the origin it serves; that way URLDataManagerBackend would not have to rely on the format of the source name. We would have to create that API and maybe refactor the normal browser-side codepath to use it.

    [1] https://source.chromium.org/chromium/chromium/src/+/main:content/browser/webui/web_ui_impl.cc;l=85;drc=8f98cea7f548d3bb3e37f7773a52584ecfe857e3
    [2] https://source.chromium.org/chromium/chromium/src/+/main:content/browser/webui/url_data_manager_backend.cc;l=145;drc=fc7ddc185b7f027dd7f4981ba8b2334c69a2e79c

    Alex Yang

    The origin is now created on the browser side and passed to the renderer process via IPC.

    Line 129, Patchset 9:void LocalResourceURLLoaderFactoryImpl::CreateLoaderAndStart(
    Daniel Cheng . unresolved

    Is there any world where it'd make sense to combine CreateLoaderAndStart() and CanServe(), i.e. `MaybeCreateLoaderAndStart()` and have it returning a PendingReceiver?

    Alex Yang

    How would this work if I wanted to implement the URLLoaderFactory interface?

    Line 131, Patchset 9: mojo::PendingRemote<network::mojom::URLLoaderClient> client) const {
    Daniel Cheng . resolved

    Worth adding `DCHECK(CanServce(request))` here?

    Alex Yang

    Done

    Line 242, Patchset 9: base::span<uint8_t> to_buffer;

    MojoResult result = pipe_producer_handle->BeginWriteData(
    output_size, MOJO_WRITE_DATA_FLAG_NONE, to_buffer);
    CHECK_EQ(result, MOJO_RESULT_OK);
    CHECK_GE(to_buffer.size(), output_size);
    CHECK_LE(output_offset + output_size, bytes.size());

    to_buffer.copy_prefix_from(base::as_bytes(
    base::make_span(bytes).subspan(output_offset, output_size)));
    result = pipe_producer_handle->EndWriteData(output_size);
    CHECK_EQ(result, MOJO_RESULT_OK);

    resource_response->content_length = output_size;
    Daniel Cheng . resolved
    Alex Yang

    This code is now shared with WebUIURLLoaderFactory so I would say this is out of scope of this CL now.

    Line 256, Patchset 9: // Reply to loader client.

    mojo::Remote<network::mojom::URLLoaderClient> client_remote(
    std::move(client));
    client_remote->OnReceiveResponse(std::move(resource_response),
    std::move(pipe_consumer_handle),
    std::nullopt);
    Daniel Cheng . resolved

    Would it make sense to reply to the client before doing the write?

    Alex Yang

    This code is now shared with WebUIURLLoaderFactory so I would say this is out of scope of this CL now.

    File content/renderer/local_resource_url_loader_factory_impl_unittest.cc
    Line 77, Patchset 9: void AddReplacementString(std::string key, std::string value) {
    Daniel Cheng . resolved

    Nit: either use const ref or use std::move() below. Same comment elsewhere this shows up

    Alex Yang

    Done

    Line 90, Patchset 9: result = client.response_body().ReadData(
    Daniel Cheng . resolved

    `BlockingCopyFromString()`?

    Alex Yang

    Done

    File third_party/blink/public/platform/local_resource_url_loader_factory.h
    Line 15, Patchset 9:class LocalResourceURLLoaderFactory
    Daniel Cheng . resolved

    Classes and public/protected methods in the Blink public API should have some documentation comments.

    Alex Yang

    Done

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Daniel Cheng
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    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: If1a9ecf61f917baafb8e1890ee28c1e806d996a9
    Gerrit-Change-Number: 5955670
    Gerrit-PatchSet: 10
    Gerrit-Owner: Alex Yang <ayc...@chromium.org>
    Gerrit-Reviewer: Alex Yang <ayc...@chromium.org>
    Gerrit-Reviewer: Daniel Cheng <dch...@chromium.org>
    Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
    Gerrit-CC: Kentaro Hara <har...@chromium.org>
    Gerrit-CC: Kouhei Ueno <kou...@chromium.org>
    Gerrit-CC: Nate Chapin <jap...@chromium.org>
    Gerrit-CC: Tsuyoshi Horo <ho...@chromium.org>
    Gerrit-Attention: Daniel Cheng <dch...@chromium.org>
    Gerrit-Comment-Date: Thu, 21 Nov 2024 23:33:41 +0000
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Daniel Cheng (Gerrit)

    unread,
    Nov 25, 2024, 5:37:46 PM11/25/24
    to Alex Yang, Code Review Nudger, findit...@appspot.gserviceaccount.com, Daniel Cheng, Tsuyoshi Horo, Kentaro Hara, Kouhei Ueno, Tricium, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, blink-re...@chromium.org, blink-...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading...@chromium.org
    Attention needed from Alex Yang

    Daniel Cheng added 2 comments

    Patchset-level comments
    Daniel Cheng . unresolved

    I've been thinking about the integration overall. I don't love the current way it's written because we add a special case to ChildURLLoaderFactoryBundle just for `chrome` even though we already have `scheme_specific_factories_`.

    This means that there are two different ways to gate requests to the `chrome` scheme now, and I think that is worse.

    1. The original gating is based off of `scheme_specific_factories_`; if a factory for the `chrome` scheme isn't present in the map, then we just can't satisfy requests for the `chrome` scheme.
    2. But now we also have `local_resource_loader_factory_` which is populated using a different IPC and gated on a different set of checks.

    It's hard to make sure that these stay in sync.

    Have you considered if there's any way to reuse `scheme_specific_factories_` here? It would require some changes from the original CLs to make it work, but if we plumb it across with `URLLoaderFactoryBundle`, I feel like that would better ensure everything always stays in sync: https://source.chromium.org/search?q=subresource_loader_factories%20f:mojom$&ss=chromium

    The tricky part here is that the map owns a `mojo::Remote`. We can:

    • either have `mojo::Remote` be in-process and just have that be an additional async call or
    • add some indirection so that there could be an in-process facade using `URLLoaderFactory*` directly instead of `mojo::Remote<URLLoaderFactory>`.

    However, I think the first option would be better unless we find out that even an in-process async call is bad for performance.

    Alex Yang

    Thanks for calling out `scheme_specific_factories_`, I wasn't aware of it. At a glance, it looks like it would make more sense to integrate there. I can look into it when I get back from PTO next week.

    Alex Yang

    I'm in the process of understanding how this would work. I have two questions so far:

    1. I think I see how we could plumb the LocalResourceLoaderConfig across in a URLLoaderFactoryBundle via UpdateSubresourceLoaderFactories. We would pass the LocalResourceLoaderConfig in the PendingURLLoaderFactoryBundle, and then in RenderFrameImpl we would construct the actual LocalResourceURLLoaderFactory and own it, and construct a mojo::Remote<URLLoaderFactory> from it and move it into scheme_specific_factories_. This would involve adding code to URLLoaderFactoryBundle::Update [1]. Is that sort of what you had in mind?
    2. Re-using scheme_specific_factories_ would mean making the LocalResourceURLLoaderFactory implement the URLLoaderFactory interface. This is almost possible, but one thing that is stopping me is that LocalResourceURLLoaderFactory has an extra method, CanServe, which is used to preemptively check for URLs it can't serve and fallback to the default handling if it can't serve them. One way I can think of to accommodate this with scheme_specific_factories_ would be to add CanServe to the URLLoaderFactory interface, with a default implementation of always returning true, and override this in LocalResourceURLLoaderFactory with the real implementation. WDYT about this approach?

    [1] https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/common/loader/url_loader_factory_bundle.cc;l=156;drc=c325fff94cab7b3d378b5f367f75249662bbeaeb

    Daniel Cheng

    1. Yes, I think something like that.
    2. See the other part about falling back—ideally the fallback would be internal and not an external `CanServe()` method.

    File content/renderer/local_resource_url_loader_factory_impl.cc
    Line 129, Patchset 9:void LocalResourceURLLoaderFactoryImpl::CreateLoaderAndStart(
    Daniel Cheng . unresolved

    Is there any world where it'd make sense to combine CreateLoaderAndStart() and CanServe(), i.e. `MaybeCreateLoaderAndStart()` and have it returning a PendingReceiver?

    Alex Yang

    How would this work if I wanted to implement the URLLoaderFactory interface?

    Daniel Cheng

    In an optimally ideal world, you wouldn't need the delegation at all (i.e. the 'fallback that happens to make browser tests work' wouldn't be needed at all).

    In a slightly ideal world, you'd be able to delegate internally to the original URLLoaderFactory for chrome:

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Alex Yang
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    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: If1a9ecf61f917baafb8e1890ee28c1e806d996a9
    Gerrit-Change-Number: 5955670
    Gerrit-PatchSet: 11
    Gerrit-Owner: Alex Yang <ayc...@chromium.org>
    Gerrit-Reviewer: Alex Yang <ayc...@chromium.org>
    Gerrit-Reviewer: Daniel Cheng <dch...@chromium.org>
    Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
    Gerrit-CC: Kentaro Hara <har...@chromium.org>
    Gerrit-CC: Kouhei Ueno <kou...@chromium.org>
    Gerrit-CC: Nate Chapin <jap...@chromium.org>
    Gerrit-CC: Tsuyoshi Horo <ho...@chromium.org>
    Gerrit-Attention: Alex Yang <ayc...@chromium.org>
    Gerrit-Comment-Date: Mon, 25 Nov 2024 22:37:32 +0000
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Dave Tapuska (Gerrit)

    unread,
    Dec 2, 2024, 2:35:24 PM12/2/24
    to Alex Yang, Code Review Nudger, findit...@appspot.gserviceaccount.com, Daniel Cheng, Tsuyoshi Horo, Kentaro Hara, Kouhei Ueno, Tricium, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, blink-re...@chromium.org, blink-...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading...@chromium.org
    Attention needed from Alex Yang

    Dave Tapuska added 1 comment

    File content/renderer/local_resource_url_loader_factory_impl.h
    Line 23, Patchset 11 (Latest):class LocalResourceURLLoaderFactoryImpl
    Dave Tapuska . unresolved

    What is the desire to implement this in content/renderer and not inside blink directly?

    It is unclear having the implementation be inside content brings us.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Alex Yang
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    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: If1a9ecf61f917baafb8e1890ee28c1e806d996a9
    Gerrit-Change-Number: 5955670
    Gerrit-PatchSet: 11
    Gerrit-Owner: Alex Yang <ayc...@chromium.org>
    Gerrit-Reviewer: Alex Yang <ayc...@chromium.org>
    Gerrit-Reviewer: Daniel Cheng <dch...@chromium.org>
    Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
    Gerrit-CC: Dave Tapuska <dtap...@chromium.org>
    Gerrit-CC: Kentaro Hara <har...@chromium.org>
    Gerrit-CC: Kouhei Ueno <kou...@chromium.org>
    Gerrit-CC: Nate Chapin <jap...@chromium.org>
    Gerrit-CC: Tsuyoshi Horo <ho...@chromium.org>
    Gerrit-Attention: Alex Yang <ayc...@chromium.org>
    Gerrit-Comment-Date: Mon, 02 Dec 2024 19:35:16 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Alex Yang (Gerrit)

    unread,
    Dec 2, 2024, 3:22:35 PM12/2/24
    to Dave Tapuska, Code Review Nudger, findit...@appspot.gserviceaccount.com, Daniel Cheng, Tsuyoshi Horo, Kentaro Hara, Kouhei Ueno, Tricium, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, blink-re...@chromium.org, blink-...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading...@chromium.org
    Attention needed from Dave Tapuska

    Alex Yang added 1 comment

    File content/renderer/local_resource_url_loader_factory_impl.h
    Line 23, Patchset 11 (Latest):class LocalResourceURLLoaderFactoryImpl
    Dave Tapuska . unresolved

    What is the desire to implement this in content/renderer and not inside blink directly?

    It is unclear having the implementation be inside content brings us.

    Alex Yang

    An earlier iteration of this CL had the implementation in Blink: https://chromium-review.googlesource.com/c/chromium/src/+/5955670/7

    It felt weird because we were making a lot of exceptions for it in Blink's type allowlist and there was no precedent for implementing a URLLoaderFactory in Blink, so I moved the implementation out of Blink. See this doc for context on this decision: https://docs.google.com/document/d/1fN0Z5OcKY5kLiMBFaOSC3a5__wRJhohVuiEC5tkNIMI/edit?usp=sharing&resourcekey=0-1tB7UQVP2vg2rO_YsGQyvA

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Dave Tapuska
    Gerrit-Attention: Dave Tapuska <dtap...@chromium.org>
    Gerrit-Comment-Date: Mon, 02 Dec 2024 20:22:27 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Dave Tapuska <dtap...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Alex Yang (Gerrit)

    unread,
    Dec 3, 2024, 8:21:05 PM12/3/24
    to Dave Tapuska, Code Review Nudger, findit...@appspot.gserviceaccount.com, Daniel Cheng, Tsuyoshi Horo, Kentaro Hara, Kouhei Ueno, Tricium, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, blink-re...@chromium.org, blink-...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading...@chromium.org
    Attention needed from Daniel Cheng and Dave Tapuska

    Alex Yang added 2 comments

    Patchset-level comments
    Daniel Cheng . unresolved

    I've been thinking about the integration overall. I don't love the current way it's written because we add a special case to ChildURLLoaderFactoryBundle just for `chrome` even though we already have `scheme_specific_factories_`.

    This means that there are two different ways to gate requests to the `chrome` scheme now, and I think that is worse.

    1. The original gating is based off of `scheme_specific_factories_`; if a factory for the `chrome` scheme isn't present in the map, then we just can't satisfy requests for the `chrome` scheme.
    2. But now we also have `local_resource_loader_factory_` which is populated using a different IPC and gated on a different set of checks.

    It's hard to make sure that these stay in sync.

    Have you considered if there's any way to reuse `scheme_specific_factories_` here? It would require some changes from the original CLs to make it work, but if we plumb it across with `URLLoaderFactoryBundle`, I feel like that would better ensure everything always stays in sync: https://source.chromium.org/search?q=subresource_loader_factories%20f:mojom$&ss=chromium

    The tricky part here is that the map owns a `mojo::Remote`. We can:

    • either have `mojo::Remote` be in-process and just have that be an additional async call or
    • add some indirection so that there could be an in-process facade using `URLLoaderFactory*` directly instead of `mojo::Remote<URLLoaderFactory>`.

    However, I think the first option would be better unless we find out that even an in-process async call is bad for performance.

    Alex Yang

    Thanks for calling out `scheme_specific_factories_`, I wasn't aware of it. At a glance, it looks like it would make more sense to integrate there. I can look into it when I get back from PTO next week.

    Alex Yang

    I'm in the process of understanding how this would work. I have two questions so far:

    1. I think I see how we could plumb the LocalResourceLoaderConfig across in a URLLoaderFactoryBundle via UpdateSubresourceLoaderFactories. We would pass the LocalResourceLoaderConfig in the PendingURLLoaderFactoryBundle, and then in RenderFrameImpl we would construct the actual LocalResourceURLLoaderFactory and own it, and construct a mojo::Remote<URLLoaderFactory> from it and move it into scheme_specific_factories_. This would involve adding code to URLLoaderFactoryBundle::Update [1]. Is that sort of what you had in mind?
    2. Re-using scheme_specific_factories_ would mean making the LocalResourceURLLoaderFactory implement the URLLoaderFactory interface. This is almost possible, but one thing that is stopping me is that LocalResourceURLLoaderFactory has an extra method, CanServe, which is used to preemptively check for URLs it can't serve and fallback to the default handling if it can't serve them. One way I can think of to accommodate this with scheme_specific_factories_ would be to add CanServe to the URLLoaderFactory interface, with a default implementation of always returning true, and override this in LocalResourceURLLoaderFactory with the real implementation. WDYT about this approach?

    [1] https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/common/loader/url_loader_factory_bundle.cc;l=156;drc=c325fff94cab7b3d378b5f367f75249662bbeaeb

    Daniel Cheng

    1. Yes, I think something like that.
    2. See the other part about falling back—ideally the fallback would be internal and not an external `CanServe()` method.

    Alex Yang

    I wrote down what it would take to implement your suggestion here: https://docs.google.com/document/d/1rIDkAXZEmHPX4OKR7yqD5tQBPPti75Y1dbIcwDtgWzY/edit?resourcekey=0-HFAgyAgrwbDxBOGLbJl3-g&tab=t.0#heading=h.fldpq3jw2h8a

    Determine where the pipe to the WebUIURLLoaderFactory is. It will be in one of 3 places: (1) already set as the fallback for an existing in-process URLLoaderFactory, (2) in the chrome:// scheme entry in scheme_specific_factories_, or (3) it is the default_factory_. Set the existing pipe as the fallback in the in-process URLLoaderFactory, then replace the existing pipe with a pipe to the in-process URLLoaderFactory via assignment.

    Unfortunately it's complicated by two facts:
    1. The ability for the in-process loader to fall back to the browser process is mandatory
    2. The WebUIURLLoaderFactory can actually be in one of two places: scheme_specific_factories_ (rare) or default_factory_ (common case)

    If and when WebUIURLLoaderFactory is consolidated into one place, it will be easier to set it as the fallback for the in-process loader. Until then, it will be messy to do what you're suggesting.

    File content/renderer/local_resource_url_loader_factory_impl.cc
    Line 129, Patchset 9:void LocalResourceURLLoaderFactoryImpl::CreateLoaderAndStart(
    Daniel Cheng . unresolved

    Is there any world where it'd make sense to combine CreateLoaderAndStart() and CanServe(), i.e. `MaybeCreateLoaderAndStart()` and have it returning a PendingReceiver?

    Alex Yang

    How would this work if I wanted to implement the URLLoaderFactory interface?

    Daniel Cheng

    In an optimally ideal world, you wouldn't need the delegation at all (i.e. the 'fallback that happens to make browser tests work' wouldn't be needed at all).

    In a slightly ideal world, you'd be able to delegate internally to the original URLLoaderFactory for chrome:

    Alex Yang

    As I said, the ability for the in-process loader to fall back to the browser process is mandatory. This is because

    There are certain resources which the renderer process is not capable of serving in-process:
    > 1. Dynamic resources that are generated on-the-fly in the browser process (e.g. strings.m.js, chrome://theme/colors.css)
    2. Resources that reside in a pak file that is not memory-mapped in the renderer process (e.g. browser_tests.pak)

    See design doc: https://docs.google.com/document/d/1rIDkAXZEmHPX4OKR7yqD5tQBPPti75Y1dbIcwDtgWzY/edit?resourcekey=0-HFAgyAgrwbDxBOGLbJl3-g&tab=t.0#heading=h.uz7fuki4guj8

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Daniel Cheng
    • Dave Tapuska
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    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: If1a9ecf61f917baafb8e1890ee28c1e806d996a9
    Gerrit-Change-Number: 5955670
    Gerrit-PatchSet: 12
    Gerrit-Owner: Alex Yang <ayc...@chromium.org>
    Gerrit-Reviewer: Alex Yang <ayc...@chromium.org>
    Gerrit-Reviewer: Daniel Cheng <dch...@chromium.org>
    Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
    Gerrit-CC: Dave Tapuska <dtap...@chromium.org>
    Gerrit-CC: Kentaro Hara <har...@chromium.org>
    Gerrit-CC: Kouhei Ueno <kou...@chromium.org>
    Gerrit-CC: Nate Chapin <jap...@chromium.org>
    Gerrit-CC: Tsuyoshi Horo <ho...@chromium.org>
    Gerrit-Attention: Dave Tapuska <dtap...@chromium.org>
    Gerrit-Attention: Daniel Cheng <dch...@chromium.org>
    Gerrit-Comment-Date: Wed, 04 Dec 2024 01:20:56 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Dave Tapuska (Gerrit)

    unread,
    Dec 4, 2024, 10:40:14 AM12/4/24
    to Alex Yang, Code Review Nudger, findit...@appspot.gserviceaccount.com, Daniel Cheng, Tsuyoshi Horo, Kentaro Hara, Kouhei Ueno, Tricium, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, blink-re...@chromium.org, blink-...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading...@chromium.org
    Attention needed from Alex Yang and Daniel Cheng

    Dave Tapuska added 1 comment

    Attention is currently required from:
    • Alex Yang
    • Daniel Cheng
    Gerrit-Attention: Daniel Cheng <dch...@chromium.org>
    Gerrit-Attention: Alex Yang <ayc...@chromium.org>
    Gerrit-Comment-Date: Wed, 04 Dec 2024 15:40:04 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Alex Yang (Gerrit)

    unread,
    Dec 4, 2024, 3:49:57 PM12/4/24
    to Dave Tapuska, Code Review Nudger, findit...@appspot.gserviceaccount.com, Daniel Cheng, Tsuyoshi Horo, Kentaro Hara, Kouhei Ueno, Tricium, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, blink-re...@chromium.org, blink-...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading...@chromium.org
    Attention needed from Daniel Cheng and Dave Tapuska

    Alex Yang added 1 comment

    Patchset-level comments
    Alex Yang

    We did not explore that. Thank you for the suggestion. I took a brief look just now and my sense is that the special casing for handling data URLs in-process in ResourceLoader is scattered (there are 4 conditional branches that check if the protocol is data://) so adding similar special casing for a subset of chrome:// URLs would get messy I think.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Daniel Cheng
    • Dave Tapuska
    Gerrit-Attention: Dave Tapuska <dtap...@chromium.org>
    Gerrit-Attention: Daniel Cheng <dch...@chromium.org>
    Gerrit-Comment-Date: Wed, 04 Dec 2024 20:49:48 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Dave Tapuska <dtap...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Alex Yang (Gerrit)

    unread,
    Dec 12, 2024, 7:43:35 PM12/12/24
    to findit...@appspot.gserviceaccount.com, Chromium Metrics Reviews, AyeAye, Dave Tapuska, Code Review Nudger, Daniel Cheng, Tsuyoshi Horo, Kentaro Hara, Kouhei Ueno, Tricium, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, alexmo...@chromium.org, creis...@chromium.org, navigation...@chromium.org, asvitkine...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading...@chromium.org
    Attention needed from Daniel Cheng

    Alex Yang added 3 comments

    Patchset-level comments
    File-level comment, Patchset 9:
    Daniel Cheng . resolved
    Alex Yang
    File-level comment, Patchset 16 (Latest):
    Alex Yang . resolved

    Hi Daniel, I've completed the changes you requested. Please take another look. Thanks!

    File content/renderer/local_resource_url_loader_factory_impl.cc
    Line 129, Patchset 9:void LocalResourceURLLoaderFactoryImpl::CreateLoaderAndStart(
    Daniel Cheng . resolved

    Is there any world where it'd make sense to combine CreateLoaderAndStart() and CanServe(), i.e. `MaybeCreateLoaderAndStart()` and have it returning a PendingReceiver?

    Alex Yang

    How would this work if I wanted to implement the URLLoaderFactory interface?

    Daniel Cheng

    In an optimally ideal world, you wouldn't need the delegation at all (i.e. the 'fallback that happens to make browser tests work' wouldn't be needed at all).

    In a slightly ideal world, you'd be able to delegate internally to the original URLLoaderFactory for chrome:

    Alex Yang

    As I said, the ability for the in-process loader to fall back to the browser process is mandatory. This is because

    There are certain resources which the renderer process is not capable of serving in-process:
    > 1. Dynamic resources that are generated on-the-fly in the browser process (e.g. strings.m.js, chrome://theme/colors.css)
    2. Resources that reside in a pak file that is not memory-mapped in the renderer process (e.g. browser_tests.pak)

    See design doc: https://docs.google.com/document/d/1rIDkAXZEmHPX4OKR7yqD5tQBPPti75Y1dbIcwDtgWzY/edit?resourcekey=0-HFAgyAgrwbDxBOGLbJl3-g&tab=t.0#heading=h.uz7fuki4guj8

    Alex Yang

    In patch set 15 I've internalized the fallback, which has made it possible for LocalResourceURLLoaderFactory to implement network::mojom::URLLoaderFactory.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Daniel Cheng
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    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: If1a9ecf61f917baafb8e1890ee28c1e806d996a9
    Gerrit-Change-Number: 5955670
    Gerrit-PatchSet: 16
    Gerrit-Owner: Alex Yang <ayc...@chromium.org>
    Gerrit-Reviewer: Alex Yang <ayc...@chromium.org>
    Gerrit-Reviewer: Daniel Cheng <dch...@chromium.org>
    Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
    Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
    Gerrit-CC: Dave Tapuska <dtap...@chromium.org>
    Gerrit-CC: Kentaro Hara <har...@chromium.org>
    Gerrit-CC: Kouhei Ueno <kou...@chromium.org>
    Gerrit-CC: Nate Chapin <jap...@chromium.org>
    Gerrit-CC: Tsuyoshi Horo <ho...@chromium.org>
    Gerrit-Attention: Daniel Cheng <dch...@chromium.org>
    Gerrit-Comment-Date: Fri, 13 Dec 2024 00:43:25 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Daniel Cheng (Gerrit)

    unread,
    Dec 16, 2024, 6:28:44 PM12/16/24
    to Alex Yang, findit...@appspot.gserviceaccount.com, Chromium Metrics Reviews, AyeAye, Dave Tapuska, Code Review Nudger, Daniel Cheng, Tsuyoshi Horo, Kentaro Hara, Kouhei Ueno, Tricium, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, alexmo...@chromium.org, creis...@chromium.org, navigation...@chromium.org, asvitkine...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading...@chromium.org
    Attention needed from Alex Yang

    Daniel Cheng added 6 comments

    File content/renderer/local_resource_url_loader_factory.h
    Line 97, Patchset 17 (Latest): const std::map<url::Origin, std::unique_ptr<Source>> sources_;
    Daniel Cheng . unresolved

    I'm a bit unclear on why this is a unique_ptr; Source could be movable, right?

    Line 38, Patchset 17 (Latest): std::map<const std::string, std::string> replacement_strings);
    Daniel Cheng . unresolved

    Nit: no need for `const` here, as map keys are implicitly const always.

    File content/renderer/local_resource_url_loader_factory.cc
    Line 62, Patchset 17 (Latest): for (const auto& source : config->sources) {
    Daniel Cheng . unresolved

    Can you help me understand why we need this instead of just moving `config` or `config->sources` as-is into a field? Aren't we already saving `config->sources`?

    Edit: OK, I guess this is because the ui helpers don't take the right map type.

    ... if you want to land this as-is for now, that's fine, but I think there should be a comment/TODO + a followup bug to fix //ui's signature.

    Line 67, Patchset 17 (Latest): sources[origin] = std::make_unique<LocalResourceURLLoaderFactory::Source>(
    Daniel Cheng . unresolved

    Do we expect multiple entries for the same origin? We don't, right, so we could just use insert({origin, ...})

    Line 77, Patchset 17 (Latest): std::make_unique<mojo::Receiver<network::mojom::URLLoaderFactory>>(this);
    Daniel Cheng . unresolved

    receiver_ doesn't need to be a unique_ptr here; can just reset and then rebind if this is what we want.

    Line 125, Patchset 17 (Latest): base::ThreadPool::CreateSequencedTaskRunner(
    Daniel Cheng . unresolved

    One followup idea is to just have `this` live on a non-main sequence so we don't need this thread hop at all. But that can wait.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Alex Yang
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    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: If1a9ecf61f917baafb8e1890ee28c1e806d996a9
    Gerrit-Change-Number: 5955670
    Gerrit-PatchSet: 17
    Gerrit-Owner: Alex Yang <ayc...@chromium.org>
    Gerrit-Reviewer: Alex Yang <ayc...@chromium.org>
    Gerrit-Reviewer: Daniel Cheng <dch...@chromium.org>
    Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
    Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
    Gerrit-CC: Dave Tapuska <dtap...@chromium.org>
    Gerrit-CC: Kentaro Hara <har...@chromium.org>
    Gerrit-CC: Kouhei Ueno <kou...@chromium.org>
    Gerrit-CC: Nate Chapin <jap...@chromium.org>
    Gerrit-CC: Tsuyoshi Horo <ho...@chromium.org>
    Gerrit-Attention: Alex Yang <ayc...@chromium.org>
    Gerrit-Comment-Date: Mon, 16 Dec 2024 23:28:36 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Alex Yang (Gerrit)

    unread,
    Dec 17, 2024, 5:33:27 PM12/17/24
    to findit...@appspot.gserviceaccount.com, Chromium Metrics Reviews, AyeAye, Dave Tapuska, Code Review Nudger, Daniel Cheng, Tsuyoshi Horo, Kentaro Hara, Kouhei Ueno, Tricium, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, alexmo...@chromium.org, creis...@chromium.org, navigation...@chromium.org, asvitkine...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading...@chromium.org
    Attention needed from Daniel Cheng

    Alex Yang added 7 comments

    File content/renderer/local_resource_url_loader_factory.h
    Line 97, Patchset 17: const std::map<url::Origin, std::unique_ptr<Source>> sources_;
    Daniel Cheng . resolved

    I'm a bit unclear on why this is a unique_ptr; Source could be movable, right?

    Alex Yang

    I made it unique_ptr because I couldn't figure out why I was getting compiler errors when I tried to insert a value of this type into the map (where the type was std::map<url::Origin, Source>). I think that was because I didn't define a move constructor for it. So I've done that now and I made the type std::map<url::Origin, Source>

    Line 38, Patchset 17: std::map<const std::string, std::string> replacement_strings);
    Daniel Cheng . resolved

    Nit: no need for `const` here, as map keys are implicitly const always.

    Alex Yang

    Will fix in follow-up CL. Tracked in https://issues.chromium.org/384765582

    File content/renderer/local_resource_url_loader_factory.cc
    Line 62, Patchset 17: for (const auto& source : config->sources) {
    Daniel Cheng . resolved

    Can you help me understand why we need this instead of just moving `config` or `config->sources` as-is into a field? Aren't we already saving `config->sources`?

    Edit: OK, I guess this is because the ui helpers don't take the right map type.

    ... if you want to land this as-is for now, that's fine, but I think there should be a comment/TODO + a followup bug to fix //ui's signature.

    Alex Yang

    Created a bug to fix //ui's signature: https://issues.chromium.org/384765582

    Added a TODO comment here with link to bug

    Line 67, Patchset 17: sources[origin] = std::make_unique<LocalResourceURLLoaderFactory::Source>(
    Daniel Cheng . resolved

    Do we expect multiple entries for the same origin? We don't, right, so we could just use insert({origin, ...})

    Alex Yang

    Done

    Line 77, Patchset 17: std::make_unique<mojo::Receiver<network::mojom::URLLoaderFactory>>(this);
    Daniel Cheng . resolved

    receiver_ doesn't need to be a unique_ptr here; can just reset and then rebind if this is what we want.

    Alex Yang

    Done

    Line 125, Patchset 17: base::ThreadPool::CreateSequencedTaskRunner(
    Daniel Cheng . unresolved

    One followup idea is to just have `this` live on a non-main sequence so we don't need this thread hop at all. But that can wait.

    Alex Yang

    I don't fully understand how that would work. Don't we still need to post the task in order to parallelize the task? Could you explain a bit more, or perhaps you could create a tracking bug that explains how it would work?

    File content/renderer/local_resource_url_loader_factory_impl.cc
    Line 53, Patchset 9: std::map<const std::string, std::string> replacement_strings)
    Daniel Cheng . resolved

    It's unusual to specify `const` in a map key, as it's implicitly const. Is this needed?

    Alex Yang

    It's because ui::ReplaceTemplateExpressions takes map<const string, string>

    https://source.chromium.org/chromium/chromium/src/+/main:ui/base/template_expressions.h;l=37;drc=36619c19f1c497cb673f1a5d1b82e20da90663df

    Alex Yang

    Created bug to track this: https://issues.chromium.org/384765582

    and I will submit a follow-up CL.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Daniel Cheng
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    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: If1a9ecf61f917baafb8e1890ee28c1e806d996a9
    Gerrit-Change-Number: 5955670
    Gerrit-PatchSet: 18
    Gerrit-Owner: Alex Yang <ayc...@chromium.org>
    Gerrit-Reviewer: Alex Yang <ayc...@chromium.org>
    Gerrit-Reviewer: Daniel Cheng <dch...@chromium.org>
    Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
    Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
    Gerrit-CC: Dave Tapuska <dtap...@chromium.org>
    Gerrit-CC: Kentaro Hara <har...@chromium.org>
    Gerrit-CC: Kouhei Ueno <kou...@chromium.org>
    Gerrit-CC: Nate Chapin <jap...@chromium.org>
    Gerrit-CC: Tsuyoshi Horo <ho...@chromium.org>
    Gerrit-Attention: Daniel Cheng <dch...@chromium.org>
    Gerrit-Comment-Date: Tue, 17 Dec 2024 22:33:18 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Daniel Cheng (Gerrit)

    unread,
    Dec 20, 2024, 9:29:26 AM12/20/24
    to Alex Yang, Daniel Cheng, findit...@appspot.gserviceaccount.com, Chromium Metrics Reviews, AyeAye, Dave Tapuska, Code Review Nudger, Tsuyoshi Horo, Kentaro Hara, Kouhei Ueno, Tricium, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, alexmo...@chromium.org, creis...@chromium.org, navigation...@chromium.org, asvitkine...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading...@chromium.org
    Attention needed from Alex Yang

    Daniel Cheng voted and added 2 comments

    Votes added by Daniel Cheng

    Code-Review+1

    2 comments

    File content/renderer/local_resource_url_loader_factory.h
    Line 39, Patchset 18 (Latest): Source(Source&& other);
    Daniel Cheng . unresolved

    Very minor nit: usually it's good practice to define the assignment operator too (even if it's not needed)

    File content/renderer/local_resource_url_loader_factory.cc
    Line 125, Patchset 17: base::ThreadPool::CreateSequencedTaskRunner(
    Daniel Cheng . unresolved

    One followup idea is to just have `this` live on a non-main sequence so we don't need this thread hop at all. But that can wait.

    Alex Yang

    I don't fully understand how that would work. Don't we still need to post the task in order to parallelize the task? Could you explain a bit more, or perhaps you could create a tracking bug that explains how it would work?

    Daniel Cheng

    When you bind a receiver (BindNewPipeAndPassRemote in this case), Mojo dispatches messages to the receiver on the sequence that BindNewPipeAndPassRemote was called on.

    Usually I would say we can just own it with a `base::SequenceBound`, but it gets a bit trickier here because you're planning on reusing the fallback factory in certain cases.

    It's fine to save this for a followup because of this complexity.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Alex Yang
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    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: If1a9ecf61f917baafb8e1890ee28c1e806d996a9
    Gerrit-Change-Number: 5955670
    Gerrit-PatchSet: 18
    Gerrit-Owner: Alex Yang <ayc...@chromium.org>
    Gerrit-Reviewer: Alex Yang <ayc...@chromium.org>
    Gerrit-Reviewer: Daniel Cheng <dch...@chromium.org>
    Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
    Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
    Gerrit-CC: Dave Tapuska <dtap...@chromium.org>
    Gerrit-CC: Kentaro Hara <har...@chromium.org>
    Gerrit-CC: Kouhei Ueno <kou...@chromium.org>
    Gerrit-CC: Nate Chapin <jap...@chromium.org>
    Gerrit-CC: Tsuyoshi Horo <ho...@chromium.org>
    Gerrit-Attention: Alex Yang <ayc...@chromium.org>
    Gerrit-Comment-Date: Fri, 20 Dec 2024 14:29:15 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Alex Yang (Gerrit)

    unread,
    Dec 20, 2024, 6:19:56 PM12/20/24
    to Daniel Cheng, findit...@appspot.gserviceaccount.com, Chromium Metrics Reviews, AyeAye, Dave Tapuska, Code Review Nudger, Tsuyoshi Horo, Kentaro Hara, Kouhei Ueno, Tricium, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, alexmo...@chromium.org, creis...@chromium.org, navigation...@chromium.org, asvitkine...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading...@chromium.org

    Alex Yang added 4 comments

    Patchset-level comments
    File-level comment, Patchset 12:
    Dave Tapuska . resolved

    Have we explored special casing say a like data URLs are? (https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/platform/loader/fetch/resource_loader.cc;l=332;drc=5108636c70c0b08fdbeb57de2640a22e138f6685;bpv=1;bpt=1)

    Going through a whole URL loader might be so much more machinery.. We already load stylesheets in blink from resource bundles... https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/platform/data_resource_helper.cc;drc=5108636c70c0b08fdbeb57de2640a22e138f6685;bpv=1;bpt=1;l=18

    Alex Yang

    We did not explore that. Thank you for the suggestion. I took a brief look just now and my sense is that the special casing for handling data URLs in-process in ResourceLoader is scattered (there are 4 conditional branches that check if the protocol is data://) so adding similar special casing for a subset of chrome:// URLs would get messy I think.

    Alex Yang

    I followed up with Dave offline. We discussed that having this loader implementation in //content is the most straightforward and flexible path for right now, though in the future that may change when //content/renderer is eventually pared down. Prioritizing landing this as is since the primary purpose of this code as written is to gather data and not necessarily to land a finalized implementation right now. Marking resolved with no action.

    File content/renderer/local_resource_url_loader_factory.h
    Line 39, Patchset 18: Source(Source&& other);
    Daniel Cheng . resolved

    Very minor nit: usually it's good practice to define the assignment operator too (even if it's not needed)

    Alex Yang

    Done

    File content/renderer/local_resource_url_loader_factory.cc
    Line 125, Patchset 17: base::ThreadPool::CreateSequencedTaskRunner(
    Daniel Cheng . resolved

    One followup idea is to just have `this` live on a non-main sequence so we don't need this thread hop at all. But that can wait.

    Alex Yang

    I don't fully understand how that would work. Don't we still need to post the task in order to parallelize the task? Could you explain a bit more, or perhaps you could create a tracking bug that explains how it would work?

    Daniel Cheng

    When you bind a receiver (BindNewPipeAndPassRemote in this case), Mojo dispatches messages to the receiver on the sequence that BindNewPipeAndPassRemote was called on.

    Usually I would say we can just own it with a `base::SequenceBound`, but it gets a bit trickier here because you're planning on reusing the fallback factory in certain cases.

    It's fine to save this for a followup because of this complexity.

    Alex Yang

    Created a bug to track this: https://issues.chromium.org/385317089

    Added TODO comment with link to bug

    File content/renderer/local_resource_url_loader_factory_impl.h
    Line 23, Patchset 11:class LocalResourceURLLoaderFactoryImpl
    Dave Tapuska . resolved

    What is the desire to implement this in content/renderer and not inside blink directly?

    It is unclear having the implementation be inside content brings us.

    Alex Yang

    An earlier iteration of this CL had the implementation in Blink: https://chromium-review.googlesource.com/c/chromium/src/+/5955670/7

    It felt weird because we were making a lot of exceptions for it in Blink's type allowlist and there was no precedent for implementing a URLLoaderFactory in Blink, so I moved the implementation out of Blink. See this doc for context on this decision: https://docs.google.com/document/d/1fN0Z5OcKY5kLiMBFaOSC3a5__wRJhohVuiEC5tkNIMI/edit?usp=sharing&resourcekey=0-1tB7UQVP2vg2rO_YsGQyvA

    Alex Yang

    See other comment. Marking resolved with no action

    Open in Gerrit

    Related details

    Attention set is empty
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement satisfiedCode-Review
    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: If1a9ecf61f917baafb8e1890ee28c1e806d996a9
    Gerrit-Change-Number: 5955670
    Gerrit-PatchSet: 19
    Gerrit-Owner: Alex Yang <ayc...@chromium.org>
    Gerrit-Reviewer: Alex Yang <ayc...@chromium.org>
    Gerrit-Reviewer: Daniel Cheng <dch...@chromium.org>
    Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
    Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
    Gerrit-CC: Dave Tapuska <dtap...@chromium.org>
    Gerrit-CC: Kentaro Hara <har...@chromium.org>
    Gerrit-CC: Kouhei Ueno <kou...@chromium.org>
    Gerrit-CC: Nate Chapin <jap...@chromium.org>
    Gerrit-CC: Tsuyoshi Horo <ho...@chromium.org>
    Gerrit-Comment-Date: Fri, 20 Dec 2024 23:19:45 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Dave Tapuska <dtap...@chromium.org>
    satisfied_requirement
    open
    diffy

    Alex Yang (Gerrit)

    unread,
    Dec 20, 2024, 6:21:25 PM12/20/24
    to Daniel Cheng, findit...@appspot.gserviceaccount.com, Chromium Metrics Reviews, AyeAye, Dave Tapuska, Code Review Nudger, Tsuyoshi Horo, Kentaro Hara, Kouhei Ueno, Tricium, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, alexmo...@chromium.org, creis...@chromium.org, navigation...@chromium.org, asvitkine...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading...@chromium.org
    Attention needed from Nasko Oskov

    Alex Yang added 1 comment

    Patchset-level comments
    File-level comment, Patchset 19 (Latest):
    Alex Yang . resolved

    Nasko, please take a look at changes to //content/test/*. Thanks!

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Nasko Oskov
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement satisfiedCode-Review
    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: If1a9ecf61f917baafb8e1890ee28c1e806d996a9
    Gerrit-Change-Number: 5955670
    Gerrit-PatchSet: 19
    Gerrit-Owner: Alex Yang <ayc...@chromium.org>
    Gerrit-Reviewer: Alex Yang <ayc...@chromium.org>
    Gerrit-Reviewer: Daniel Cheng <dch...@chromium.org>
    Gerrit-Reviewer: Nasko Oskov <na...@chromium.org>
    Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
    Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
    Gerrit-CC: Dave Tapuska <dtap...@chromium.org>
    Gerrit-CC: Kentaro Hara <har...@chromium.org>
    Gerrit-CC: Kouhei Ueno <kou...@chromium.org>
    Gerrit-CC: Nate Chapin <jap...@chromium.org>
    Gerrit-CC: Tsuyoshi Horo <ho...@chromium.org>
    Gerrit-Attention: Nasko Oskov <na...@chromium.org>
    Gerrit-Comment-Date: Fri, 20 Dec 2024 23:21:16 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    open
    diffy

    Alex Yang (Gerrit)

    unread,
    Jan 2, 2025, 6:47:37 PMJan 2
    to Daniel Cheng, findit...@appspot.gserviceaccount.com, Chromium Metrics Reviews, AyeAye, Dave Tapuska, Code Review Nudger, Tsuyoshi Horo, Kentaro Hara, Kouhei Ueno, Tricium, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, alexmo...@chromium.org, creis...@chromium.org, navigation...@chromium.org, asvitkine...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading...@chromium.org
    Attention needed from Daniel Cheng

    Alex Yang added 1 comment

    File content/renderer/local_resource_url_loader_factory.cc
    Line 125, Patchset 17: base::ThreadPool::CreateSequencedTaskRunner(
    Daniel Cheng . unresolved

    One followup idea is to just have `this` live on a non-main sequence so we don't need this thread hop at all. But that can wait.

    Alex Yang

    I don't fully understand how that would work. Don't we still need to post the task in order to parallelize the task? Could you explain a bit more, or perhaps you could create a tracking bug that explains how it would work?

    Daniel Cheng

    When you bind a receiver (BindNewPipeAndPassRemote in this case), Mojo dispatches messages to the receiver on the sequence that BindNewPipeAndPassRemote was called on.

    Usually I would say we can just own it with a `base::SequenceBound`, but it gets a bit trickier here because you're planning on reusing the fallback factory in certain cases.

    It's fine to save this for a followup because of this complexity.

    Alex Yang

    Created a bug to track this: https://issues.chromium.org/385317089

    Added TODO comment with link to bug

    Alex Yang

    Marking unresolved and working on this now, since I suspect this is causing test failures where sync requests get stuck waiting for a reply from the in-process loader because both are on the same sequence

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Daniel Cheng
    Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      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: If1a9ecf61f917baafb8e1890ee28c1e806d996a9
      Gerrit-Change-Number: 5955670
      Gerrit-PatchSet: 22
      Gerrit-Owner: Alex Yang <ayc...@chromium.org>
      Gerrit-Reviewer: Alex Yang <ayc...@chromium.org>
      Gerrit-Reviewer: Daniel Cheng <dch...@chromium.org>
      Gerrit-Reviewer: Nasko Oskov <na...@chromium.org>
      Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
      Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
      Gerrit-CC: Dave Tapuska <dtap...@chromium.org>
      Gerrit-CC: Kentaro Hara <har...@chromium.org>
      Gerrit-CC: Kouhei Ueno <kou...@chromium.org>
      Gerrit-CC: Nate Chapin <jap...@chromium.org>
      Gerrit-CC: Tsuyoshi Horo <ho...@chromium.org>
      Gerrit-Attention: Daniel Cheng <dch...@chromium.org>
      Gerrit-Comment-Date: Thu, 02 Jan 2025 23:47:26 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Alex Yang (Gerrit)

      unread,
      Jan 8, 2025, 8:43:44 PMJan 8
      to Daniel Cheng, findit...@appspot.gserviceaccount.com, Chromium Metrics Reviews, AyeAye, Dave Tapuska, Code Review Nudger, Tsuyoshi Horo, Kentaro Hara, Kouhei Ueno, Tricium, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, alexmo...@chromium.org, creis...@chromium.org, navigation...@chromium.org, asvitkine...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading...@chromium.org
      Attention needed from Daniel Cheng and Nasko Oskov

      Alex Yang voted and added 2 comments

      Votes added by Alex Yang

      Commit-Queue+1

      2 comments

      Patchset-level comments
      Alex Yang . resolved

      Nasko, please take a look at changes to //content/test/*. Thanks!

      File content/renderer/local_resource_url_loader_factory.cc
      Line 125, Patchset 17: base::ThreadPool::CreateSequencedTaskRunner(
      Daniel Cheng . resolved

      One followup idea is to just have `this` live on a non-main sequence so we don't need this thread hop at all. But that can wait.

      Alex Yang

      I don't fully understand how that would work. Don't we still need to post the task in order to parallelize the task? Could you explain a bit more, or perhaps you could create a tracking bug that explains how it would work?

      Daniel Cheng

      When you bind a receiver (BindNewPipeAndPassRemote in this case), Mojo dispatches messages to the receiver on the sequence that BindNewPipeAndPassRemote was called on.

      Usually I would say we can just own it with a `base::SequenceBound`, but it gets a bit trickier here because you're planning on reusing the fallback factory in certain cases.

      It's fine to save this for a followup because of this complexity.

      Alex Yang

      Created a bug to track this: https://issues.chromium.org/385317089

      Added TODO comment with link to bug

      Alex Yang

      Marking unresolved and working on this now, since I suspect this is causing test failures where sync requests get stuck waiting for a reply from the in-process loader because both are on the same sequence

      Alex Yang
      Open in Gerrit

      Related details

      Attention is currently required from:
      • Daniel Cheng
      • Nasko Oskov
      Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement satisfiedCode-Review
      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: If1a9ecf61f917baafb8e1890ee28c1e806d996a9
      Gerrit-Change-Number: 5955670
      Gerrit-PatchSet: 23
      Gerrit-Owner: Alex Yang <ayc...@chromium.org>
      Gerrit-Reviewer: Alex Yang <ayc...@chromium.org>
      Gerrit-Reviewer: Daniel Cheng <dch...@chromium.org>
      Gerrit-Reviewer: Nasko Oskov <na...@chromium.org>
      Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
      Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
      Gerrit-CC: Dave Tapuska <dtap...@chromium.org>
      Gerrit-CC: Kentaro Hara <har...@chromium.org>
      Gerrit-CC: Kouhei Ueno <kou...@chromium.org>
      Gerrit-CC: Nate Chapin <jap...@chromium.org>
      Gerrit-CC: Tsuyoshi Horo <ho...@chromium.org>
      Gerrit-Attention: Daniel Cheng <dch...@chromium.org>
      Gerrit-Attention: Nasko Oskov <na...@chromium.org>
      Gerrit-Comment-Date: Thu, 09 Jan 2025 01:43:32 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: Yes
      satisfied_requirement
      open
      diffy

      Daniel Cheng (Gerrit)

      unread,
      Jan 9, 2025, 2:02:05 PMJan 9
      to Alex Yang, Daniel Cheng, findit...@appspot.gserviceaccount.com, Chromium Metrics Reviews, AyeAye, Dave Tapuska, Code Review Nudger, Tsuyoshi Horo, Kentaro Hara, Kouhei Ueno, Tricium, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, alexmo...@chromium.org, creis...@chromium.org, navigation...@chromium.org, asvitkine...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading...@chromium.org
      Attention needed from Alex Yang and Nasko Oskov

      Daniel Cheng voted and added 6 comments

      Votes added by Daniel Cheng

      Code-Review+0

      6 comments

      Patchset-level comments
      Daniel Cheng . resolved

      Just some minor nits.

      File content/renderer/local_resource_url_loader_factory.cc
      Line 133, Patchset 23 (Latest): const url::Origin origin = url::Origin::Create(request.url);
      auto it = sources_.find(origin);
      // CanServe should have been called before this point, which would have
      // confirmed that there exists a source corresponding to the URL origin.
      CHECK(it != sources_.end());

      const blink::mojom::LocalResourceSourcePtr& source = it->second.source;
      const std::map<const std::string, std::string>& replacement_strings =
      it->second.replacement_strings;
      Daniel Cheng . resolved

      It might be worth refactoring this to eliminate the duplication between here and `CanServe()` in the future. For now it's fine though (and it'll make the parallelization CL easier to leave it as-is).

      Line 163, Patchset 23 (Latest): std::string mime_type;
      if (net::GetMimeTypeFromFile(
      base::FilePath::FromASCII(request.url.ExtractFileName()),
      &mime_type)) {
      url_response_head->mime_type = mime_type;
      } else {
      url_response_head->mime_type = "text/html";
      }
      Daniel Cheng . unresolved
      File content/renderer/local_resource_url_loader_factory_unittest.cc
      Line 26, Patchset 23 (Latest):#include "gmock/gmock.h"
      Daniel Cheng . unresolved

      I think this should be `testing/gmock/include/gmock/gmock.h`; then we might not need the DEPS change.

      Line 132, Patchset 23 (Latest): return std::nullopt;
      Daniel Cheng . unresolved

      We don't want this to ever fail in the test right?

      I guess ASSERT_TRUE is hard here, due to the non-void return, so we'd have to CHECK to make that work. And it's a bit stylistic, but the way it's written makes it look like maybe it should be allowed (and expected) to fail sometimes.

      Line 154, Patchset 23 (Latest): void UpdateLoaderFactory() {
      Daniel Cheng . unresolved

      Style nit: fields should come after everything else per https://google.github.io/styleguide/cppguide.html#Declaration_Order

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Alex Yang
      • Nasko Oskov
      Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      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: If1a9ecf61f917baafb8e1890ee28c1e806d996a9
      Gerrit-Change-Number: 5955670
      Gerrit-PatchSet: 23
      Gerrit-Owner: Alex Yang <ayc...@chromium.org>
      Gerrit-Reviewer: Alex Yang <ayc...@chromium.org>
      Gerrit-Reviewer: Daniel Cheng <dch...@chromium.org>
      Gerrit-Reviewer: Nasko Oskov <na...@chromium.org>
      Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
      Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
      Gerrit-CC: Dave Tapuska <dtap...@chromium.org>
      Gerrit-CC: Kentaro Hara <har...@chromium.org>
      Gerrit-CC: Kouhei Ueno <kou...@chromium.org>
      Gerrit-CC: Nate Chapin <jap...@chromium.org>
      Gerrit-CC: Tsuyoshi Horo <ho...@chromium.org>
      Gerrit-Attention: Alex Yang <ayc...@chromium.org>
      Gerrit-Attention: Nasko Oskov <na...@chromium.org>
      Gerrit-Comment-Date: Thu, 09 Jan 2025 19:01:51 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: Yes
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Alex Yang (Gerrit)

      unread,
      Jan 9, 2025, 3:51:23 PMJan 9
      to Daniel Cheng, findit...@appspot.gserviceaccount.com, Chromium Metrics Reviews, AyeAye, Dave Tapuska, Code Review Nudger, Tsuyoshi Horo, Kentaro Hara, Kouhei Ueno, Tricium, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, alexmo...@chromium.org, creis...@chromium.org, navigation...@chromium.org, asvitkine...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading...@chromium.org
      Attention needed from Daniel Cheng and Nasko Oskov

      Alex Yang added 5 comments

      File content/renderer/local_resource_url_loader_factory.cc
      Line 133, Patchset 23: const url::Origin origin = url::Origin::Create(request.url);

      auto it = sources_.find(origin);
      // CanServe should have been called before this point, which would have
      // confirmed that there exists a source corresponding to the URL origin.
      CHECK(it != sources_.end());

      const blink::mojom::LocalResourceSourcePtr& source = it->second.source;
      const std::map<const std::string, std::string>& replacement_strings =
      it->second.replacement_strings;
      Daniel Cheng . resolved

      It might be worth refactoring this to eliminate the duplication between here and `CanServe()` in the future. For now it's fine though (and it'll make the parallelization CL easier to leave it as-is).

      Alex Yang

      Created a bug to track this https://issues.chromium.org/388870472

      Line 163, Patchset 23: std::string mime_type;

      if (net::GetMimeTypeFromFile(
      base::FilePath::FromASCII(request.url.ExtractFileName()),
      &mime_type)) {
      url_response_head->mime_type = mime_type;
      } else {
      url_response_head->mime_type = "text/html";
      }
      Daniel Cheng . resolved
      Alex Yang

      Created a bug to track this https://issues.chromium.org/388871395

      File content/renderer/local_resource_url_loader_factory_unittest.cc
      Line 26, Patchset 23:#include "gmock/gmock.h"
      Daniel Cheng . resolved

      I think this should be `testing/gmock/include/gmock/gmock.h`; then we might not need the DEPS change.

      Alex Yang

      Done

      Line 132, Patchset 23: return std::nullopt;
      Daniel Cheng . resolved

      We don't want this to ever fail in the test right?

      I guess ASSERT_TRUE is hard here, due to the non-void return, so we'd have to CHECK to make that work. And it's a bit stylistic, but the way it's written makes it look like maybe it should be allowed (and expected) to fail sometimes.

      Alex Yang

      changed to use CHECK

      Line 154, Patchset 23: void UpdateLoaderFactory() {
      Daniel Cheng . resolved

      Style nit: fields should come after everything else per https://google.github.io/styleguide/cppguide.html#Declaration_Order

      Alex Yang

      Done

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Daniel Cheng
      • Nasko Oskov
      Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement is not satisfiedCode-Review
      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: If1a9ecf61f917baafb8e1890ee28c1e806d996a9
      Gerrit-Change-Number: 5955670
      Gerrit-PatchSet: 24
      Gerrit-Owner: Alex Yang <ayc...@chromium.org>
      Gerrit-Reviewer: Alex Yang <ayc...@chromium.org>
      Gerrit-Reviewer: Daniel Cheng <dch...@chromium.org>
      Gerrit-Reviewer: Nasko Oskov <na...@chromium.org>
      Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
      Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
      Gerrit-CC: Dave Tapuska <dtap...@chromium.org>
      Gerrit-CC: Kentaro Hara <har...@chromium.org>
      Gerrit-CC: Kouhei Ueno <kou...@chromium.org>
      Gerrit-CC: Nate Chapin <jap...@chromium.org>
      Gerrit-CC: Tsuyoshi Horo <ho...@chromium.org>
      Gerrit-Attention: Daniel Cheng <dch...@chromium.org>
      Gerrit-Attention: Nasko Oskov <na...@chromium.org>
      Gerrit-Comment-Date: Thu, 09 Jan 2025 20:51:13 +0000
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Daniel Cheng (Gerrit)

      unread,
      Jan 9, 2025, 5:27:48 PMJan 9
      to Alex Yang, Daniel Cheng, findit...@appspot.gserviceaccount.com, Chromium Metrics Reviews, AyeAye, Dave Tapuska, Code Review Nudger, Tsuyoshi Horo, Kentaro Hara, Kouhei Ueno, Tricium, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, alexmo...@chromium.org, creis...@chromium.org, navigation...@chromium.org, asvitkine...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading...@chromium.org
      Attention needed from Alex Yang and Nasko Oskov

      Daniel Cheng voted and added 2 comments

      Votes added by Daniel Cheng

      Code-Review+1

      2 comments

      Patchset-level comments
      File content/renderer/local_resource_url_loader_factory.cc
      Line 187, Patchset 24 (Latest): base::MakeRefCounted<base::RefCountedString>(replaced_string);
      Daniel Cheng . unresolved

      Nit: std::move() and avoid a copy here

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Alex Yang
      • Nasko Oskov
      Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      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: If1a9ecf61f917baafb8e1890ee28c1e806d996a9
      Gerrit-Change-Number: 5955670
      Gerrit-PatchSet: 24
      Gerrit-Owner: Alex Yang <ayc...@chromium.org>
      Gerrit-Reviewer: Alex Yang <ayc...@chromium.org>
      Gerrit-Reviewer: Daniel Cheng <dch...@chromium.org>
      Gerrit-Reviewer: Nasko Oskov <na...@chromium.org>
      Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
      Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
      Gerrit-CC: Dave Tapuska <dtap...@chromium.org>
      Gerrit-CC: Kentaro Hara <har...@chromium.org>
      Gerrit-CC: Kouhei Ueno <kou...@chromium.org>
      Gerrit-CC: Nate Chapin <jap...@chromium.org>
      Gerrit-CC: Tsuyoshi Horo <ho...@chromium.org>
      Gerrit-Attention: Alex Yang <ayc...@chromium.org>
      Gerrit-Attention: Nasko Oskov <na...@chromium.org>
      Gerrit-Comment-Date: Thu, 09 Jan 2025 22:27:38 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: Yes
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Alex Yang (Gerrit)

      unread,
      Jan 9, 2025, 5:43:47 PMJan 9
      to Daniel Cheng, findit...@appspot.gserviceaccount.com, Chromium Metrics Reviews, AyeAye, Dave Tapuska, Code Review Nudger, Tsuyoshi Horo, Kentaro Hara, Kouhei Ueno, Tricium, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, alexmo...@chromium.org, creis...@chromium.org, navigation...@chromium.org, asvitkine...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading...@chromium.org
      Attention needed from Nasko Oskov

      Alex Yang added 1 comment

      File content/renderer/local_resource_url_loader_factory.cc
      Line 187, Patchset 24: base::MakeRefCounted<base::RefCountedString>(replaced_string);
      Daniel Cheng . resolved

      Nit: std::move() and avoid a copy here

      Alex Yang

      Done

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Nasko Oskov
      Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement satisfiedCode-Review
      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: If1a9ecf61f917baafb8e1890ee28c1e806d996a9
      Gerrit-Change-Number: 5955670
      Gerrit-PatchSet: 25
      Gerrit-Owner: Alex Yang <ayc...@chromium.org>
      Gerrit-Reviewer: Alex Yang <ayc...@chromium.org>
      Gerrit-Reviewer: Daniel Cheng <dch...@chromium.org>
      Gerrit-Reviewer: Nasko Oskov <na...@chromium.org>
      Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
      Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
      Gerrit-CC: Dave Tapuska <dtap...@chromium.org>
      Gerrit-CC: Kentaro Hara <har...@chromium.org>
      Gerrit-CC: Kouhei Ueno <kou...@chromium.org>
      Gerrit-CC: Nate Chapin <jap...@chromium.org>
      Gerrit-CC: Tsuyoshi Horo <ho...@chromium.org>
      Gerrit-Attention: Nasko Oskov <na...@chromium.org>
      Gerrit-Comment-Date: Thu, 09 Jan 2025 22:43:33 +0000
      satisfied_requirement
      open
      diffy

      Nasko Oskov (Gerrit)

      unread,
      Jan 9, 2025, 5:50:02 PMJan 9
      to Alex Yang, Daniel Cheng, findit...@appspot.gserviceaccount.com, Chromium Metrics Reviews, AyeAye, Dave Tapuska, Code Review Nudger, Tsuyoshi Horo, Kentaro Hara, Kouhei Ueno, Tricium, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, alexmo...@chromium.org, creis...@chromium.org, navigation...@chromium.org, asvitkine...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading...@chromium.org

      Nasko Oskov voted and added 3 comments

      Votes added by Nasko Oskov

      Code-Review+1

      3 comments

      Patchset-level comments
      File-level comment, Patchset 24:
      Nasko Oskov . resolved

      LGTM with a couple of comments.

      File content/renderer/local_resource_url_loader_factory.h
      Line 68, Patchset 24: // (whether the URL-to-ID mapping is present depends on what resource
      Nasko Oskov . unresolved

      nit: Unclosed parenthesis.

      File content/renderer/local_resource_url_loader_factory.cc
      Line 83, Patchset 24: const url::Origin origin = url::Origin::Create(request.url);
      Nasko Oskov . unresolved

      Should we put a CHECK here to ensure the scheme of the URL is a WebUI scheme or one supported by this URLLoaderFactory?

      Open in Gerrit

      Related details

      Attention set is empty
      Submit Requirements:
        • requirement satisfiedCode-Coverage
        • requirement satisfiedCode-Review
        • requirement is not satisfiedNo-Unresolved-Comments
        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: If1a9ecf61f917baafb8e1890ee28c1e806d996a9
        Gerrit-Change-Number: 5955670
        Gerrit-PatchSet: 24
        Gerrit-Owner: Alex Yang <ayc...@chromium.org>
        Gerrit-Reviewer: Alex Yang <ayc...@chromium.org>
        Gerrit-Reviewer: Daniel Cheng <dch...@chromium.org>
        Gerrit-Reviewer: Nasko Oskov <na...@chromium.org>
        Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
        Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
        Gerrit-CC: Dave Tapuska <dtap...@chromium.org>
        Gerrit-CC: Kentaro Hara <har...@chromium.org>
        Gerrit-CC: Kouhei Ueno <kou...@chromium.org>
        Gerrit-CC: Nate Chapin <jap...@chromium.org>
        Gerrit-CC: Tsuyoshi Horo <ho...@chromium.org>
        Gerrit-Comment-Date: Thu, 09 Jan 2025 22:49:46 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: Yes
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Alex Yang (Gerrit)

        unread,
        Jan 9, 2025, 6:27:18 PMJan 9
        to Daniel Cheng, findit...@appspot.gserviceaccount.com, Chromium Metrics Reviews, AyeAye, Dave Tapuska, Code Review Nudger, Tsuyoshi Horo, Kentaro Hara, Kouhei Ueno, Tricium, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, alexmo...@chromium.org, creis...@chromium.org, navigation...@chromium.org, asvitkine...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading...@chromium.org

        Alex Yang added 2 comments

        File content/renderer/local_resource_url_loader_factory.h
        Line 68, Patchset 24: // (whether the URL-to-ID mapping is present depends on what resource
        Nasko Oskov . resolved

        nit: Unclosed parenthesis.

        Alex Yang

        Thanks, fixed.

        File content/renderer/local_resource_url_loader_factory.cc
        Line 83, Patchset 24: const url::Origin origin = url::Origin::Create(request.url);
        Nasko Oskov . unresolved

        Should we put a CHECK here to ensure the scheme of the URL is a WebUI scheme or one supported by this URLLoaderFactory?

        Alex Yang

        I believe we can assert that the scheme of incoming request URLs is always going to be "chrome". This is only used for WebUIs that are not network-enabled, and also, "chrome-untrusted" goes to a scheme-specific factory I believe; not the default factory in the URLLoaderFactoryBundle, so they shouldn't end up here. Added the CHECK and will wait to see if any browser tests fail in the integration CL, in any case: https://chromium-review.googlesource.com/c/chromium/src/+/5955234

        Open in Gerrit

        Related details

        Attention set is empty
        Submit Requirements:
        • requirement satisfiedCode-Coverage
        • requirement satisfiedCode-Review
        • requirement is not satisfiedNo-Unresolved-Comments
        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: If1a9ecf61f917baafb8e1890ee28c1e806d996a9
        Gerrit-Change-Number: 5955670
        Gerrit-PatchSet: 26
        Gerrit-Owner: Alex Yang <ayc...@chromium.org>
        Gerrit-Reviewer: Alex Yang <ayc...@chromium.org>
        Gerrit-Reviewer: Daniel Cheng <dch...@chromium.org>
        Gerrit-Reviewer: Nasko Oskov <na...@chromium.org>
        Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
        Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
        Gerrit-CC: Dave Tapuska <dtap...@chromium.org>
        Gerrit-CC: Kentaro Hara <har...@chromium.org>
        Gerrit-CC: Kouhei Ueno <kou...@chromium.org>
        Gerrit-CC: Nate Chapin <jap...@chromium.org>
        Gerrit-CC: Tsuyoshi Horo <ho...@chromium.org>
        Gerrit-Comment-Date: Thu, 09 Jan 2025 23:27:06 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        Comment-In-Reply-To: Nasko Oskov <na...@chromium.org>
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Nasko Oskov (Gerrit)

        unread,
        Jan 9, 2025, 7:08:07 PMJan 9
        to Alex Yang, Daniel Cheng, findit...@appspot.gserviceaccount.com, Chromium Metrics Reviews, AyeAye, Dave Tapuska, Code Review Nudger, Tsuyoshi Horo, Kentaro Hara, Kouhei Ueno, Tricium, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, alexmo...@chromium.org, creis...@chromium.org, navigation...@chromium.org, asvitkine...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading...@chromium.org
        Attention needed from Alex Yang

        Nasko Oskov voted and added 1 comment

        Votes added by Nasko Oskov

        Code-Review+1

        1 comment

        File content/renderer/local_resource_url_loader_factory.cc
        Line 83, Patchset 24: const url::Origin origin = url::Origin::Create(request.url);
        Nasko Oskov . unresolved

        Should we put a CHECK here to ensure the scheme of the URL is a WebUI scheme or one supported by this URLLoaderFactory?

        Alex Yang

        I believe we can assert that the scheme of incoming request URLs is always going to be "chrome". This is only used for WebUIs that are not network-enabled, and also, "chrome-untrusted" goes to a scheme-specific factory I believe; not the default factory in the URLLoaderFactoryBundle, so they shouldn't end up here. Added the CHECK and will wait to see if any browser tests fail in the integration CL, in any case: https://chromium-review.googlesource.com/c/chromium/src/+/5955234

        Nasko Oskov

        👍

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Alex Yang
        Gerrit-Attention: Alex Yang <ayc...@chromium.org>
        Gerrit-Comment-Date: Fri, 10 Jan 2025 00:07:57 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: Yes
        Comment-In-Reply-To: Alex Yang <ayc...@chromium.org>
        Comment-In-Reply-To: Nasko Oskov <na...@chromium.org>
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Alex Yang (Gerrit)

        unread,
        Jan 10, 2025, 4:36:37 AMJan 10
        to Daniel Cheng, findit...@appspot.gserviceaccount.com, Chromium Metrics Reviews, AyeAye, Dave Tapuska, Code Review Nudger, Tsuyoshi Horo, Kentaro Hara, Kouhei Ueno, Tricium, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, alexmo...@chromium.org, creis...@chromium.org, navigation...@chromium.org, asvitkine...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading...@chromium.org
        Attention needed from Nasko Oskov

        Alex Yang added 1 comment

        File content/renderer/local_resource_url_loader_factory.cc
        Line 83, Patchset 24: const url::Origin origin = url::Origin::Create(request.url);
        Nasko Oskov . unresolved

        Should we put a CHECK here to ensure the scheme of the URL is a WebUI scheme or one supported by this URLLoaderFactory?

        Alex Yang

        I believe we can assert that the scheme of incoming request URLs is always going to be "chrome". This is only used for WebUIs that are not network-enabled, and also, "chrome-untrusted" goes to a scheme-specific factory I believe; not the default factory in the URLLoaderFactoryBundle, so they shouldn't end up here. Added the CHECK and will wait to see if any browser tests fail in the integration CL, in any case: https://chromium-review.googlesource.com/c/chromium/src/+/5955234

        Nasko Oskov

        👍

        Alex Yang

        Looks like it failed on these 3 tests:

        NetworkServiceBrowserTest.WebUIBindingsNoHttp
        WebUIManagedInterfaceBrowserTest.RemoveIframe
        WebUIManagedInterfaceBrowserTest.WebUIInIframe

        because somehow it ended up handling "http:" and "chrome-untrusted:" -scheme URLs in those tests. Not sure how that's happening, but...

        I've put the CHECK after CanServe returns true, because while it might receive requests with those schemes in some edge cases, it definitely should not decide to service them, and this would shut that down if that happens, because that would be very unexpected indeed.

        Let me know if that addresses your concerns.

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Nasko Oskov
        Submit Requirements:
        • requirement satisfiedCode-Coverage
        • requirement satisfiedCode-Review
        • requirement is not satisfiedNo-Unresolved-Comments
        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: If1a9ecf61f917baafb8e1890ee28c1e806d996a9
        Gerrit-Change-Number: 5955670
        Gerrit-PatchSet: 27
        Gerrit-Owner: Alex Yang <ayc...@chromium.org>
        Gerrit-Reviewer: Alex Yang <ayc...@chromium.org>
        Gerrit-Reviewer: Daniel Cheng <dch...@chromium.org>
        Gerrit-Reviewer: Nasko Oskov <na...@chromium.org>
        Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
        Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
        Gerrit-CC: Dave Tapuska <dtap...@chromium.org>
        Gerrit-CC: Kentaro Hara <har...@chromium.org>
        Gerrit-CC: Kouhei Ueno <kou...@chromium.org>
        Gerrit-CC: Nate Chapin <jap...@chromium.org>
        Gerrit-CC: Tsuyoshi Horo <ho...@chromium.org>
        Gerrit-Attention: Nasko Oskov <na...@chromium.org>
        Gerrit-Comment-Date: Fri, 10 Jan 2025 09:36:27 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Nasko Oskov (Gerrit)

        unread,
        Jan 13, 2025, 7:24:11 PMJan 13
        to Alex Yang, Daniel Cheng, findit...@appspot.gserviceaccount.com, Chromium Metrics Reviews, AyeAye, Dave Tapuska, Code Review Nudger, Tsuyoshi Horo, Kentaro Hara, Kouhei Ueno, Tricium, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, alexmo...@chromium.org, creis...@chromium.org, navigation...@chromium.org, asvitkine...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading...@chromium.org
        Attention needed from Alex Yang

        Nasko Oskov voted and added 2 comments

        Votes added by Nasko Oskov

        Code-Review+1

        2 comments

        Patchset-level comments
        File-level comment, Patchset 28 (Latest):
        Nasko Oskov . resolved

        Thanks for the extra details! Still LGTM

        File content/renderer/local_resource_url_loader_factory.cc
        Line 83, Patchset 24: const url::Origin origin = url::Origin::Create(request.url);
        Nasko Oskov . resolved

        Should we put a CHECK here to ensure the scheme of the URL is a WebUI scheme or one supported by this URLLoaderFactory?

        Alex Yang

        I believe we can assert that the scheme of incoming request URLs is always going to be "chrome". This is only used for WebUIs that are not network-enabled, and also, "chrome-untrusted" goes to a scheme-specific factory I believe; not the default factory in the URLLoaderFactoryBundle, so they shouldn't end up here. Added the CHECK and will wait to see if any browser tests fail in the integration CL, in any case: https://chromium-review.googlesource.com/c/chromium/src/+/5955234

        Nasko Oskov

        👍

        Alex Yang

        Looks like it failed on these 3 tests:

        NetworkServiceBrowserTest.WebUIBindingsNoHttp
        WebUIManagedInterfaceBrowserTest.RemoveIframe
        WebUIManagedInterfaceBrowserTest.WebUIInIframe

        because somehow it ended up handling "http:" and "chrome-untrusted:" -scheme URLs in those tests. Not sure how that's happening, but...

        I've put the CHECK after CanServe returns true, because while it might receive requests with those schemes in some edge cases, it definitely should not decide to service them, and this would shut that down if that happens, because that would be very unexpected indeed.

        Let me know if that addresses your concerns.

        Nasko Oskov

        Thanks for investigating and adding the CHECK in CanServe! This is a very useful defense against bugs that can crop up.
        Let's proceed with this and we can look independently into why this is getting http cases.

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Alex Yang
        Submit Requirements:
        • requirement satisfiedCode-Coverage
        • requirement satisfiedCode-Review
        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: If1a9ecf61f917baafb8e1890ee28c1e806d996a9
        Gerrit-Change-Number: 5955670
        Gerrit-PatchSet: 28
        Gerrit-Owner: Alex Yang <ayc...@chromium.org>
        Gerrit-Reviewer: Alex Yang <ayc...@chromium.org>
        Gerrit-Reviewer: Daniel Cheng <dch...@chromium.org>
        Gerrit-Reviewer: Nasko Oskov <na...@chromium.org>
        Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
        Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
        Gerrit-CC: Dave Tapuska <dtap...@chromium.org>
        Gerrit-CC: Kentaro Hara <har...@chromium.org>
        Gerrit-CC: Kouhei Ueno <kou...@chromium.org>
        Gerrit-CC: Nate Chapin <jap...@chromium.org>
        Gerrit-CC: Tsuyoshi Horo <ho...@chromium.org>
        Gerrit-Attention: Alex Yang <ayc...@chromium.org>
        Gerrit-Comment-Date: Tue, 14 Jan 2025 00:24:01 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: Yes
        satisfied_requirement
        open
        diffy

        Chromium LUCI CQ (Gerrit)

        unread,
        Jan 13, 2025, 7:29:13 PMJan 13
        to Alex Yang, Daniel Cheng, findit...@appspot.gserviceaccount.com, Chromium Metrics Reviews, AyeAye, Dave Tapuska, Code Review Nudger, Tsuyoshi Horo, Kentaro Hara, Kouhei Ueno, Tricium, chromium...@chromium.org, Nate Chapin, alexmo...@chromium.org, creis...@chromium.org, navigation...@chromium.org, asvitkine...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, gavinp...@chromium.org, kinuko...@chromium.org, loading...@chromium.org

        Chromium LUCI CQ submitted the change

        Change information

        Commit message:
        content: Add URLLoaderFactory able to serve resources in-process

        Implement a URLLoaderFactory with the ability to retrieve resources from
        the memory-mapped 'resources.pak' file.

        In a future commit, this URLLoaderFactory will be used in WebUI renderer
        processes to load resources in-process, without having to request them
        from the browser process.
        Bug: 362511750
        Change-Id: If1a9ecf61f917baafb8e1890ee28c1e806d996a9
        Commit-Queue: Alex Yang <ayc...@chromium.org>
        Reviewed-by: Daniel Cheng <dch...@chromium.org>
        Reviewed-by: Nasko Oskov <na...@chromium.org>
        Cr-Commit-Position: refs/heads/main@{#1405811}
        Files:
        • M content/renderer/BUILD.gn
        • M content/renderer/DEPS
        • A content/renderer/local_resource_url_loader_factory.cc
        • A content/renderer/local_resource_url_loader_factory.h
        • A content/renderer/local_resource_url_loader_factory_unittest.cc
        • M content/test/BUILD.gn
        • M content/test/test_content_client.cc
        • M content/test/test_content_client.h
        Change size: L
        Delta: 8 files changed, 684 insertions(+), 0 deletions(-)
        Branch: refs/heads/main
        Submit Requirements:
        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: If1a9ecf61f917baafb8e1890ee28c1e806d996a9
        Gerrit-Change-Number: 5955670
        Gerrit-PatchSet: 29
        Gerrit-Owner: Alex Yang <ayc...@chromium.org>
        Gerrit-Reviewer: Alex Yang <ayc...@chromium.org>
        Gerrit-Reviewer: Chromium LUCI CQ <chromiu...@luci-project-accounts.iam.gserviceaccount.com>
        Gerrit-Reviewer: Daniel Cheng <dch...@chromium.org>
        Gerrit-Reviewer: Nasko Oskov <na...@chromium.org>
        open
        diffy
        satisfied_requirement
        Reply all
        Reply to author
        Forward
        0 new messages