#53676: chore: rebase the custom-scheme code cache patch onto upstream's checks
Description of Change
feat_allow_code_cache_in_custom_schemes.patch (#40544, from crrev.com/c/5019665) replaced CheckSecurityForAccessingCodeCacheData in code_cache_host_impl.cc and the CheckValidResource / CheckValidContext DCHECK helpers in generated_code_cache.cc wholesale. Upstream has kept editing those functions since, and the rewrite had drifted from them in two ways:
- The
blink::CommonSchemeRegistry::IsExtensionSchemebranches Chromium added for extension script and wasm caching were gone from all three functions (only the one inGetOriginLocksurvived), so achrome-extension://resource write reachedmojo::ReportBadMessage("Invalid URL scheme for code cache.")instead of being cached. - http(s) scripts were only cacheable from processes locked to http(s) or to an embedder code-cache scheme. Upstream allows them from any non-WebUI process, so pages on
file://or on a standard custom scheme registered withoutcodeCache: truelost V8 code caching for scripts they load over https.
This rebuilds the patch as upstream's code plus the embedder additions only: a url::IsCodeCacheScheme() helper next to AddCodeCacheScheme / GetCodeCacheSchemes, one extra disjunct in each DCHECK, one extra branch in CheckSecurityForAccessingCodeCacheData (embedder-scheme scripts are cached only for processes locked to an embedder scheme, as before) and one in GetOriginLock. The content_client.h, url_schemes.cc, header comment and browsertest parts are unchanged. The patch goes from 210 to about 90 changed lines, which should also make the re-upload of the upstream CL easier. feat_allow_enabling_extensions_on_custom_protocols.patch only shifts context in url/url_util.cc.
Verified on Linux: builds, protocol.registerSchemesAsPrivileged codeCache specs pass (disabled by default, enabled with codeCache: true).
Checklist
- PR description included and stakeholders cc'd
-
npm testpasses - I have reviewed and verified the changes
Release Notes
Notes: Fixed V8 code caching for https scripts loaded by file:// and custom-scheme pages.
Backports
Semver Impact
Semantic Versioning helps users understand the impact of updates:
- Major (X.y.z): Breaking changes that may require code modifications
- Minor (x.Y.z): New features that maintain backward compatibility
- Patch (x.y.Z): Bug fixes that don't change the API
- None: Changes that don't affect using facing parts of Electron