0
Commit Graph

124 Commits

Author SHA1 Message Date
Caleb Raitto
2cb34ddf00 Remove expired PotentialMemoryBackedCodeCacheSize2 histogram
Fixed: 333390326
Change-Id: I845bb1a2536b27ae57e1ad28d372fce554e6e4c2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6179528
Reviewed-by: Orr Bernstein <orrb@google.com>
Reviewed-by: Kenichi Ishibashi <bashi@chromium.org>
Reviewed-by: Nasko Oskov <nasko@chromium.org>
Reviewed-by: Takashi Toyoshima <toyoshim@chromium.org>
Commit-Queue: Caleb Raitto <caraitto@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1407949}
2025-01-17 08:31:32 -08:00
Nico Weber
77ce8969c2 Fix more -Wunused-private-field warnings
Bug: 383016423
Change-Id: I1f18e734b49a23f7fc10a567abbf677b7d7ee124
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6082735
Owners-Override: Nico Weber <thakis@chromium.org>
Reviewed-by: Arthur Eubanks <aeubanks@google.com>
Commit-Queue: Nico Weber <thakis@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1394069}
2024-12-10 04:09:21 +00:00
Peter Kasting
8eba25cb99 Remove usage of base::make_span(): content/browser/ part 1
Replace with span() CTAD use, or more targeted helpers.

Bug: 341907909
Low-Coverage-Reason: LARGE_SCALE_REFACTOR no meaningful functional change
Change-Id: I2635aeabe0b7eb4e8411b4579d922fccb0283784
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6059467
Reviewed-by: Dmitry Gozman <dgozman@chromium.org>
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1389916}
2024-11-29 22:30:10 +00:00
Peter Boström
fc7ddc185b Migrate to NOTREACHED() in content/
NOTREACHED() and NOTREACHED_IN_MIGRATION() are both CHECK-fatal now.
The former is [[noreturn]] so this CL also performs dead-code removal
after the NOTREACHED().

This CL does not attempt to do additional rewrites of any surrounding
code, like:

if (!foo) {
  NOTREACHED();
}

to CHECK(foo);

Those transforms take a non-trivial amount of time (and there are
thousands of instances). Cleanup can be left as an exercise for the
reader.

This does clean up kCrashOnDanglingBrowserContext as both paths of the
kill switch are currently fatal. This has been rolled out for a long
time.

Bug: 40580068, 40062641
Change-Id: Ib88e710d003e2e48df3fc502ca54d2341d157a0e
Cq-Include-Trybots: luci.chromium.try:linux-dcheck-off-rel
Low-Coverage-Reason: OTHER Should-be-unreachable code
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5974816
Reviewed-by: Łukasz Anforowicz <lukasza@chromium.org>
Commit-Queue: Łukasz Anforowicz <lukasza@chromium.org>
Reviewed-by: Rakina Zata Amni <rakina@chromium.org>
Auto-Submit: Peter Boström <pbos@chromium.org>
Reviewed-by: Sam McNally <sammc@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1376522}
2024-10-31 19:37:21 +00:00
Peter Kasting
2b138f1cce Remove vector constructor for BigBuffer.
We can construct a span implicitly from this. This also changes some
callsites to not use a vector at all, when going directly to a span is
cheaper.

Bug: 364987728
Change-Id: Ib65b0149c346c71c8d2565fa6cf50bba49b5bcde
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5972456
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Reviewed-by: Ken Rockot <rockot@google.com>
Owners-Override: Ken Rockot <rockot@google.com>
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Commit-Queue: Ken Rockot <rockot@google.com>
Cr-Commit-Position: refs/heads/main@{#1376413}
2024-10-31 17:10:27 +00:00
Tom Sepez
fde75b19bd Make net::IOBuffer::span() return spans of uint8_t
Currently, this returns spans of char. Most callers would rather
process uint8_t, so there are fewer conversions required.

Change-Id: I74f9d4c15131133783fef8564a34978266f2a2fc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5774394
Reviewed-by: Nico Weber <thakis@chromium.org>
Owners-Override: Nico Weber <thakis@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Ken Rockot <rockot@google.com>
Reviewed-by: Evan Stade <estade@chromium.org>
Reviewed-by: mmenke <mmenke@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1341226}
2024-08-13 20:24:56 +00:00
Tsuyoshi Horo
26ff6a0536 Fix JS module script code caching regression
This CL fixes the regression from http://crrev.com/c/5373700 where code
caching for JS module scripts was broken.

Key changes:
  - ScriptCachedMetadataHandler::SetSerializedCachedMetadata() is now
    called in ScriptResource::SetSerializedCachedMetadata() even when
    DisableOffThreadConsumeCache() was called.
  - Stop creating ConsumeCodeCacheTask for module scripts in
    BackgroundResourceScriptStreamer, because ModuleScript doesn't
    support off-thread cache consumption.

Additional fix:
  Set Cache-Control header for script resources in CodeCacheBrowserTest
  to store the resource in the HTTPCache. Also added logic to clear
  MemoryCache in CachingFromThirdPartyFrames tests to make sure that
  Blink fetches the script resource again. (See
  https://crrev.com/c//4554196/comment/e77b3615_033682a3/ for more
  context.)

Bug: 357726254
Change-Id: I84d079b70f0ce46039e8bd6a61644ca950da8869
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5759035
Reviewed-by: Kouhei Ueno <kouhei@chromium.org>
Reviewed-by: Rakina Zata Amni <rakina@chromium.org>
Commit-Queue: Tsuyoshi Horo <horo@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1338921}
2024-08-08 08:15:11 +00:00
David Benjamin
b54ed30e00 Replace base::numerics::Foo with base::Foo in //content
See https://chromium-review.googlesource.com/c/chromium/src/+/5402820

Bug: 40284755
Change-Id: I4b6692636043df7d4e8bb456b324fa5ad6ad1727
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5698546
Auto-Submit: David Benjamin <davidben@chromium.org>
Reviewed-by: Alexander Timin <altimin@chromium.org>
Commit-Queue: David Benjamin <davidben@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1326768}
2024-07-12 14:47:25 +00:00
Alex Gough
5b6ee2e0c7 Turn iterator $var!=.end() DCHECK() into CHECK() for content
Accessing an invalid iterator can sometimes be a security
issue and these checks are cheap, so upgrade to CHECKs.

Added checks are NotFatalUntil::M130.

`base/not_fatal_until.h` is added using tools/add_header.py,
this may result in some main-file (foo.h for foo.cc) headers
being re-sorted to be first as part `git cl format` of this CL.

For this CL instances were located with a weggli query:

```
weggli --verbose=1 --cpp \
      'DCHECK($var != _.end());' \
   -p 'DCHECK(_.end() != $var);' \
   -p 'DCHECK_NE($var, _.end());' \
   -p 'DCHECK_NE(_.end(), $var);'
```

which should avoid any potentially expensive calculations
of the thing to be matched against .end().

This CL was uploaded by git cl split.

R=alexmos@chromium.org, boliu@chromium.org, fabiansommer@chromium.org, mmenke@chromium.org, peter@chromium.org

Bug: 351745839
Change-Id: Icfe179b0d14dd9af5cfde3a51497c1b88964d7c0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5689315
Reviewed-by: Peter Beverloo <peter@chromium.org>
Commit-Queue: Alex Gough <ajgo@chromium.org>
Reviewed-by: Bo Liu <boliu@chromium.org>
Reviewed-by: Fabian Sommer <fabiansommer@chromium.org>
Reviewed-by: mmenke <mmenke@chromium.org>
Auto-Submit: Alex Gough <ajgo@chromium.org>
Reviewed-by: Scott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1326308}
2024-07-11 19:09:54 +00:00
Thomas Lukaszewicz
f0120f681a Reland "[code cache] Extend GeneratedCodeCache logging for Chrome WebUI"
This is a reland of commit 2278fa1f8a

See diff against PS1.

Fixed bad test setup in WebUIManagedInterfaceBrowserTest. Once
initialized ContentBrowserClient is expected to exist for the life
of the Chrome process.

This change avoids tearing down the test ContentBrowserClient
prematurely and aligns with how ContentBrowserClient is handled in
other content_browsertests.

Original change's description:
> [code cache] Extend GeneratedCodeCache logging for Chrome WebUI
>
> This CL extends metrics reporting for the WebUI specific
> GeneratedCodeCache. Chrome will now report cache behavior
>
>  - Per request resource host. This helps improve understanding of
>    how resources served by a specific WebUIDataSource are behaving.
>    e.g. resources served by chrome://resources
>
>  - Per origin lock. This helps improve understanding of how resources
>    served for a specific origin are behaving.
>    e.g. requests from multiple sources for a chrome://downloads load
>
> ContentBrowserClient has been extended to allow embedders to provide
> appropriate WebUI hostnames for logging while avoiding code layering
> violations.
>
> Logged WebUIs were chosen based on usage (see WebUI.CreatedForUrl).
>
> Bug: 40182411, 349683186
> Change-Id: Idb954f10fd76290a56bb42ca917401f27f5eae59
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5659029
> Commit-Queue: Thomas Lukaszewicz <tluk@chromium.org>
> Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
> Reviewed-by: Avi Drissman <avi@chromium.org>
> Reviewed-by: Jimmy Gong <jimmyxgong@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#1322368}

Bug: 40182411, 349683186
Change-Id: I4269b1d0e50a554c10049fcdf285a7e6b1bacc30
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5667623
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Reviewed-by: Jimmy Gong <jimmyxgong@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Commit-Queue: Thomas Lukaszewicz <tluk@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1322917}
2024-07-03 18:29:25 +00:00
luci-bisection@appspot.gserviceaccount.com
552dbc14e9 Revert "[code cache] Extend GeneratedCodeCache logging for Chrome WebUI"
This reverts commit 2278fa1f8a.

Reason for revert:
LUCI Bisection has identified this change as the cause of a test failure. See the analysis: https://ci.chromium.org/ui/p/chromium/bisection/test-analysis/b/5633403106885632

Sample build with failed test: https://ci.chromium.org/b/8743487828300736337
Affected test(s):
[ninja://content/test:content_browsertests/WebUIManagedInterfaceBrowserTest.WebUIInIframe](https://ci.chromium.org/ui/test/chromium/ninja:%2F%2Fcontent%2Ftest:content_browsertests%2FWebUIManagedInterfaceBrowserTest.WebUIInIframe?q=VHash%3Af16bf4d900f9bd6e)

If this is a false positive, please report it at http://b.corp.google.com/createIssue?component=1199205&description=Analysis%3A+https%3A%2F%2Fci.chromium.org%2Fui%2Fp%2Fchromium%2Fbisection%2Ftest-analysis%2Fb%2F5633403106885632&format=PLAIN&priority=P3&title=Wrongly+blamed+https%3A%2F%2Fchromium-review.googlesource.com%2Fc%2Fchromium%2Fsrc%2F%2B%2F5659029&type=BUG

Original change's description:
> [code cache] Extend GeneratedCodeCache logging for Chrome WebUI
>
> This CL extends metrics reporting for the WebUI specific
> GeneratedCodeCache. Chrome will now report cache behavior
>
>  - Per request resource host. This helps improve understanding of
>    how resources served by a specific WebUIDataSource are behaving.
>    e.g. resources served by chrome://resources
>
>  - Per origin lock. This helps improve understanding of how resources
>    served for a specific origin are behaving.
>    e.g. requests from multiple sources for a chrome://downloads load
>
> ContentBrowserClient has been extended to allow embedders to provide
> appropriate WebUI hostnames for logging while avoiding code layering
> violations.
>
> Logged WebUIs were chosen based on usage (see WebUI.CreatedForUrl).
>
> Bug: 40182411, 349683186
> Change-Id: Idb954f10fd76290a56bb42ca917401f27f5eae59
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5659029
> Commit-Queue: Thomas Lukaszewicz <tluk@chromium.org>
> Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
> Reviewed-by: Avi Drissman <avi@chromium.org>
> Reviewed-by: Jimmy Gong <jimmyxgong@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#1322368}
>

Bug: 40182411, 349683186
Change-Id: I0c9c109d3538603992e67f074219287af3a6343b
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5673727
Owners-Override: Michael Wilson <mjwilson@chromium.org>
Commit-Queue: Michael Wilson <mjwilson@chromium.org>
Reviewed-by: Michael Wilson <mjwilson@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1322478}
2024-07-02 23:57:28 +00:00
Thomas Lukaszewicz
2278fa1f8a [code cache] Extend GeneratedCodeCache logging for Chrome WebUI
This CL extends metrics reporting for the WebUI specific
GeneratedCodeCache. Chrome will now report cache behavior

 - Per request resource host. This helps improve understanding of
   how resources served by a specific WebUIDataSource are behaving.
   e.g. resources served by chrome://resources

 - Per origin lock. This helps improve understanding of how resources
   served for a specific origin are behaving.
   e.g. requests from multiple sources for a chrome://downloads load

ContentBrowserClient has been extended to allow embedders to provide
appropriate WebUI hostnames for logging while avoiding code layering
violations.

Logged WebUIs were chosen based on usage (see WebUI.CreatedForUrl).

Bug: 40182411, 349683186
Change-Id: Idb954f10fd76290a56bb42ca917401f27f5eae59
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5659029
Commit-Queue: Thomas Lukaszewicz <tluk@chromium.org>
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Reviewed-by: Avi Drissman <avi@chromium.org>
Reviewed-by: Jimmy Gong <jimmyxgong@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1322368}
2024-07-02 19:49:49 +00:00
Nasko Oskov
ee48dfb4fa Prepare to remove //content/ from unsafe_bufers_paths.txt
Suppress unsafe buffer usage on a file-by-file basis.  Out of
approximately 5850 .cc and .h files only roughly 160 files fail
compilation with the unsafe buffers warning.

Suppress only, by inserting boilerplate into affected files. Do not
re-write any code to work around the issues. Properly fixing each file
will be done in follow-up CLs.

//content/ is not removed from unsafe_bufers_paths.txt file and will be
also done as a follow-up, so it makes potential reverts simpler.

Bug: 342213636
Change-Id: I4a936e63dea95a78951f7bfae6d5487708ae3c0b
AX-Relnotes: n/a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5608913
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Owners-Override: Daniel Cheng <dcheng@chromium.org>
Commit-Queue: Nasko Oskov <nasko@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1312393}
2024-06-08 05:13:06 +00:00
Peter Boström
8472105d01 Use NOTREACHED_IN_MIGRATION() in content/
This was generated by replacing "  NOTREACHED()" with
"  NOTREACHED_IN_MIGRATION()" and running git cl format.

This prepares for making NOTREACHED() [[noreturn]] alongside
NotReachedIsFatal migration of existing inventory.

Bug: 40580068
Change-Id: I3b48b89911ac5e9ffcb211622992f917f8f9e8d9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5539619
Auto-Submit: Peter Boström <pbos@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Owners-Override: Lei Zhang <thestig@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Peter Boström <pbos@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1301096}
2024-05-15 04:36:02 +00:00
Alison Gale
770f3fce37 Migrate TODOs referencing old crbug IDs to the new issue tracker IDs
The canonical bug format is TODO(crbug.com/<id>). TODOs of the
following forms will all be migrated to the new format:

- TODO(crbug.com/<old id>)
- TODO(https://crbug.com/<old id>)
- TODO(crbug/<old id>)
- TODO(crbug/monorail/<old id>)
- TODO(<old id>)
- TODO(issues.chromium.org/<old id>)
- TODO(https://issues.chromium.org/<old id>)
- TODO(https://issues.chromium.org/u/1/issues/<old id>)
- TODO(bugs.chromium.org/<old id>)

Bug id mapping is sourced from go/chrome-on-buganizer-prod-issues.
See go/crbug-todo-migration for details.

#crbug-todo-migration

Bug: b/321899722
Change-Id: Ibc66b8c440e4bcdef414e77fef4d9874d2ea9951
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5493800
Auto-Submit: Alison Gale <agale@chromium.org>
Commit-Queue: Alison Gale <agale@chromium.org>
Reviewed-by: Peter Boström <pbos@chromium.org>
Owners-Override: Alison Gale <agale@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1293330}
2024-04-27 00:39:58 +00:00
Alison Gale
53c77f6b62 Migrate TODOs referencing old crbug IDs to the new issue tracker IDs
The canonical bug format is TODO(crbug.com/<id>). TODOs of the
following forms will all be migrated to the new format:

- TODO(crbug.com/<old id>)
- TODO(https://crbug.com/<old id>)
- TODO(crbug/<old id>)
- TODO(crbug/monorail/<old id>)
- TODO(<old id>)
- TODO(issues.chromium.org/<old id>)
- TODO(https://issues.chromium.org/<old id>)
- TODO(https://issues.chromium.org/u/1/issues/<old id>)
- TODO(bugs.chromium.org/<old id>)

Bug id mapping is sourced from go/chrome-on-buganizer-prod-issues.
See go/crbug-todo-migration for details.

#crbug-todo-migration

Bug: b/321899722
Change-Id: Iabdfea2fd5393d6bbc54390ca0c995eb2c55bbaa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5469882
Reviewed-by: Darryl James <dljames@chromium.org>
Owners-Override: Alison Gale <agale@chromium.org>
Commit-Queue: Alison Gale <agale@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1290673}
2024-04-22 15:16:27 +00:00
Alison Gale
47d1537de7 Migrate TODOs referencing old crbug IDs to the new issue tracker IDs
The canonical bug format is TODO(crbug.com/<id>). TODOs of the
following forms will all be migrated to the new format:

- TODO(crbug.com/<old id>)
- TODO(https://crbug.com/<old id>)
- TODO(crbug/<old id>)
- TODO(crbug/monorail/<old id>)
- TODO(<old id>)
- TODO(issues.chromium.org/<old id>)
- TODO(https://issues.chromium.org/<old id>)
- TODO(https://issues.chromium.org/u/1/issues/<old id>)
- TODO(bugs.chromium.org/<old id>)

Bug id mapping is sourced from go/chrome-on-buganizer-prod-issues.
See go/crbug-todo-migration for details.

#crbug-todo-migration

Bug: b/321899722
Change-Id: Ieeb461e2d489e86fd50b87a2a0721a2be34520c3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5467317
Owners-Override: Alison Gale <agale@chromium.org>
Commit-Queue: Darryl James <dljames@chromium.org>
Commit-Queue: Alison Gale <agale@chromium.org>
Reviewed-by: Darryl James <dljames@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1290198}
2024-04-19 21:31:46 +00:00
David Benjamin
37b313c7b2 Don't use BigBuffer::byte_span to access a general BigBuffer
BigBuffer::byte_span is misleading. It's the accessor for the kBytes
variant of the sum type, not a way to view a general BigBuffer as a
span.

See discussion in
https://chromium-review.googlesource.com/c/chromium/src/+/5420741/comment/f7e3c07a_341f8171/

Now that BigBuffer is span- and range-compatible, fix all the callers to
avoid that. To help avoid mistakes in the future, I've upgraded the
DCHECKs to CHECKs.

Change-Id: I47c1fdae18d45e1896674894a874609ef682f612
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5419810
Commit-Queue: David Benjamin <davidben@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Marijn Kruisselbrink <mek@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1282967}
2024-04-05 05:00:03 +00:00
Md Hasibul Hasan
a963a934b5 Convert base::StringPiece to std::string_view in content/browser
The changes of this CL are made using the following script.

```
target_directory="content/browser"
replace_string_in_files() {
  old_string="$1"
  new_string="$2"

  find "$target_directory" -type f \( -name "*.cc" -o -name "*.h" \) \
      -exec sed -i '' "s/$old_string/$new_string/g" {} +
}

delete_include() {
    find "$target_directory" \( -name "*.h" -o -name "*.cc" \) -print0 | while IFS= read -r -d '' file; do
        grep -v '#include "base/strings/string_piece.h"' "$file" > "$file.tmp" && mv "$file.tmp" "$file"
    done
}

add_include() {
    find "$target_directory" \( -name "*.h" -o -name "*.cc" \) -print0 | while IFS= read -r -d '' file; do
        local include_added=false
        local tempfile=$(mktemp)

        if grep -qE 'std::(string|u16string)_view' "$file"; then
            while IFS= read -r line; do
                echo "$line" >> "$tempfile"
                if [[ $line =~ ^\s*#include ]]; then
                    if ! $include_added; then
                        echo "#include <string_view>" >> "$tempfile"
                        include_added=true
                    fi
                fi
            done < "$file"

            mv "$tempfile" "$file"

            if $include_added; then
                echo "Added #include <string_view> after the first include line in $file"
            else
                echo "No include line found in $file"
            fi
        else
            echo "std::string_view not found in $file"
        fi
    done
}

replace_string_in_files "base::StringPiece16" "std::u16string_view"
replace_string_in_files "base::StringPiece" "std::string_view"
delete_include
add_include
```

Replaced base::StringPiece16 with std::u16string_view
Replaced base::StringPiece with std::string_view
Removed header "base/strings/string_piece.h"
Added header "<string_view>" where applicable

Bug: 40506050
Change-Id: I2bc22c79dd9a0c839745afe065123f7a53c4a5ca
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5401117
Reviewed-by: Arthur Sonzogni <arthursonzogni@chromium.org>
Commit-Queue: Arthur Sonzogni <arthursonzogni@chromium.org>
Reviewed-by: Mike West <mkwst@chromium.org>
Reviewed-by: Rakina Zata Amni <rakina@chromium.org>
Reviewed-by: Will Harris <wfh@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1281746}
2024-04-03 10:15:14 +00:00
David Benjamin
eabf759ede Spanifiy content/browser/code_cache
This does several things. First, it fixes a UBSan failure:
https://luci-milo.appspot.com/ui/inv/build-8752216573640518833/test-results?q=GeneratedCodeCacheTest%2FGeneratedCodeCacheTest.WriteEntryWithEmptyData%2F0&sortby=&groupby=

I think the UBSan failure was triggered by https://crrev.com/c/5402504,
but the root cause is the call to memcpy in this code. Due to a C
language bug, memcpy actually cannot be used with some representations
of the empty slice. (See
https://davidben.net/2024/01/15/empty-slices.html )

Any C++ abstraction, like std::copy or std::ranges::copy avoids this.
But while I'm here, go ahead and replace all of this with the new
span-based APIs, which are bounds-checked.

Bug: 40284755, 40248746
Change-Id: I099442fdb140da9886e089b261ca87b2c80aad34
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5403174
Commit-Queue: Arthur Sonzogni <arthursonzogni@chromium.org>
Auto-Submit: David Benjamin <davidben@chromium.org>
Reviewed-by: Arthur Sonzogni <arthursonzogni@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1281089}
2024-04-02 10:38:00 +00:00
Marja Hölttä
0271bc05a1 [local compile hints] Generate local compile hints multiple times
Previously, we generated local compile hints only when the page turned
interactive. It's possible that the user navigates away before that, so
in that case we didn't get any compile hints.

This CL makes us compile hints earlier, and when the page turns
interactive, we generate them again and replace the data.

We also add a histogram for observing how many navigations now
create compile hints data vs. how many would have created it in
the original version.

Bug: 40286622
Change-Id: Iec1bd1ec26a5fe870c456d1977109912cc560482
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5344969
Reviewed-by: Mike West <mkwst@chromium.org>
Reviewed-by: Charlie Reis <creis@chromium.org>
Reviewed-by: Chris Harrelson <chrishtr@chromium.org>
Reviewed-by: Kouhei Ueno <kouhei@chromium.org>
Commit-Queue: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1273270}
2024-03-15 07:55:39 +00:00
Marja Hölttä
bb62d3105a [local compile hints] Fix the WebCore.Scripts.V8CompileHintsStatus histogram
1) The histogram needs a "no compile hints" option to be able to
estimate e.g., how frequently the code cache is hit

2) The "produce compile hints, module, no streaming" bucket was
overcounted

Bug: b/40286622
Change-Id: I4ba0671aff44bd263e64034b18aace8b552d0c9e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5344415
Commit-Queue: Marja Hölttä <marja@chromium.org>
Reviewed-by: Alex Moshchuk <alexmos@chromium.org>
Reviewed-by: Chris Harrelson <chrishtr@chromium.org>
Reviewed-by: Kentaro Hara <haraken@chromium.org>
Reviewed-by: Kouhei Ueno <kouhei@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1270649}
2024-03-09 21:14:24 +00:00
Hiroshige Hayashizaki
b5e8a122c9 Remove redundant content:: for GetUIThreadTaskRunner/BrowserTaskType
Follow-up of
https://chromium-review.googlesource.com/c/chromium/src/+/5276439/comment/7e9833fe_c465c594/

AX-Relnotes: n/a.
Bug: 1403746
Change-Id: Ia7d838385677d350b803a855271182358acb1468
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5314820
Reviewed-by: Arthur Sonzogni <arthursonzogni@chromium.org>
Commit-Queue: Arthur Sonzogni <arthursonzogni@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1265192}
2024-02-26 14:44:07 +00:00
Takuto Ikuta
a47d7859c4 autofill: remove unnecessary include from browser_test_base.h
This is extracted from https://crrev.com/c/5280997 to reduce compile
time of some test files.

content/public/test/browser_test_base.h is the file removing
unnecessary header.

Bug: b/324519459
Change-Id: Ic6b8e4328f6be3161dd3f09711451c8578032ef4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5300036
Owners-Override: John Abd-El-Malek <jam@chromium.org>
Commit-Queue: Takuto Ikuta <tikuta@chromium.org>
Reviewed-by: John Abd-El-Malek <jam@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1262233}
2024-02-19 03:46:58 +00:00
Eva Herencsarova
3825de6fe0 Reland "[wasm] Add wasm module caching for extensions with streaming instantiation"
This is a reland of commit 90af84e33e.

Browsertest improvements:
- In the JS code of the extension, Wasm functions are called until all of them are optimised. In this change, once in a while we yield to the event loop by calling setTimeout().
- The flag "--wasm-tiering-budget" is set to 10 so that the optimised, TurboFan code is created right away.
- As it's not clear when the caching exactly happens, the test keeps opening new tabs (which triggers the execution of the JS code in the extension) and waiting until there is a cache hit. This makes the test more robust if the caching happens a bit later.
- Previously the test waited to see x hits and y misses after x+y loads of the extension. Now the test waits for x+y samples. This way we get an accurate error message if there is an issue and don't run into timeouts.
- Added logging for easier future debugging.

Original change's description:
> [wasm] Add wasm module caching for extensions with streaming
> instantiation
>
> Bug: v8:14518
> Change-Id: I896f85284d02feb089e095b8a925bd451bfee85e
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5117546
> Reviewed-by: Finnur Thorarinsson <finnur@chromium.org>
> Commit-Queue: Eva Herencsárová <evih@chromium.org>
> Reviewed-by: Arthur Sonzogni <arthursonzogni@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#1256324}

Bug: v8:14518
Change-Id: I4ee455cf97cbf140d32a0ab1abcf3b2054ba750c
Cq-Include-Trybots: luci.chromium.try:linux_chromium_chromeos_msan_rel_ng
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5268792
Reviewed-by: Finnur Thorarinsson <finnur@chromium.org>
Commit-Queue: Eva Herencsárová <evih@chromium.org>
Reviewed-by: Hiroki Nakagawa <nhiroki@chromium.org>
Reviewed-by: Arthur Sonzogni <arthursonzogni@chromium.org>
Reviewed-by: Yoshisato Yanagisawa <yyanagisawa@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1258421}
2024-02-09 09:56:06 +00:00
Kevin Grosu
ca2e0f01d4 Revert "[wasm] Add wasm module caching for extensions with streaming"
This reverts commit 90af84e33e.

Reason for revert: Added test is failing: https://ci.chromium.org/ui/test/chromium/ninja%3A%2F%2Fchrome%2Ftest%3Abrowser_tests%2FWasmExtensionCachingBrowserTest.CacheWasmExtensions?q=VHASH%3A5fcd6134c5b57ed5

Original change's description:
> [wasm] Add wasm module caching for extensions with streaming
> instantiation
>
> Bug: v8:14518
> Change-Id: I896f85284d02feb089e095b8a925bd451bfee85e
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5117546
> Reviewed-by: Finnur Thorarinsson <finnur@chromium.org>
> Commit-Queue: Eva Herencsárová <evih@chromium.org>
> Reviewed-by: Arthur Sonzogni <arthursonzogni@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#1256324}

Bug: v8:14518
Change-Id: I66ac01c68f337543ff6d362720e84716d9df33fd
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5270296
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Kevin Grosu <kgrosu@google.com>
Owners-Override: Kevin Grosu <kgrosu@google.com>
Cr-Commit-Position: refs/heads/main@{#1256463}
2024-02-05 22:57:09 +00:00
Eva Herencsarova
90af84e33e [wasm] Add wasm module caching for extensions with streaming
instantiation

Bug: v8:14518
Change-Id: I896f85284d02feb089e095b8a925bd451bfee85e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5117546
Reviewed-by: Finnur Thorarinsson <finnur@chromium.org>
Commit-Queue: Eva Herencsárová <evih@chromium.org>
Reviewed-by: Arthur Sonzogni <arthursonzogni@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1256324}
2024-02-05 18:50:58 +00:00
Tom Sepez
80e9e6e546 Avoid two-arg base::HexEncode() and RandBytes() calls.
Force the compiler to deduce the correct size, thus vastly
simplifying the code.

-- fix else-after-return as noticed.

Change-Id: I50a5c3387e0ec7693e1d9a4f72f03e2a980e01da
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5241357
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: danakj <danakj@chromium.org>
Owners-Override: danakj <danakj@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1254884}
2024-02-01 02:34:42 +00:00
Arthur Sonzogni
c686e8f4fd Rename {absl => std}::optional in //content/
Automated patch, intended to be effectively a no-op.

Context:
https://groups.google.com/a/chromium.org/g/cxx/c/nBD_1LaanTc/m/ghh-ZZhWAwAJ?utm_medium=email&utm_source=footer

As of https://crrev.com/1204351, absl::optional is now a type alias for
std::optional. We should migrate toward it.

Script:
```
function replace {
  echo "Replacing $1 by $2"
  git grep -l "$1" \
    | cut -f1 -d: \
    | grep \
      -e "^content" \
    | sort \
    | uniq \
    | grep \
      -e "\.h" \
      -e "\.cc" \
      -e "\.mm" \
      -e "\.py" \
    | xargs sed -i "s/$1/$2/g"
}
replace "absl::make_optional" "std::make_optional"
replace "absl::optional" "std::optional"
replace "absl::nullopt" "std::nullopt"
replace "absl::in_place" "std::in_place"
replace "absl::in_place_t" "std::in_place_t"
replace "\"third_party\/abseil-cpp\/absl\/types\/optional.h\"" "<optional>"
git cl format
```

# Skipping unrelated "check_network_annotation" errors.
NOTRY=True

Bug: chromium:1500249
Change-Id: Icfd31a71d8faf63a2e8d5401127e7ee74cc1c413
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5185537
Auto-Submit: Arthur Sonzogni <arthursonzogni@chromium.org>
Commit-Queue: Arthur Sonzogni <arthursonzogni@chromium.org>
Owners-Override: Avi Drissman <avi@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Reviewed-by: danakj <danakj@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1245739}
2024-01-11 08:36:37 +00:00
Marja Hölttä
ac53a59da7 [local compile hints] Add tests
The added content browsertest ensures that we produce and consume
local compile hints when running scripts.

To enable testing, this CL adds a capacity for making
InteractiveDetector ignore FCP - this is because the first paint never
happens in a content browser test, so without this the page would
never be detected as interactive.

Bug: chromium:1495723
Change-Id: Iceffed1244fbe4aa9048812653fd2874b59c703d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5024173
Reviewed-by: Kentaro Hara <haraken@chromium.org>
Commit-Queue: Marja Hölttä <marja@chromium.org>
Reviewed-by: Takashi Toyoshima <toyoshim@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1237944}
2023-12-15 06:45:47 +00:00
Tsuyoshi Horo
9872a4fed0 Run CodeCacheBrowserTest with BackgroundResourceFetch feature disabled
This cl makes CodeCacheBrowserTest run with BackgroundResourceFetch
feature disabled even when we will enable BackgroundResourceFetch
feature enabled by default.

Bug: 1379780
Change-Id: Ia48bff7b757f41a0068af3cbd88dd4c123a164bf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5004282
Reviewed-by: Rakina Zata Amni <rakina@chromium.org>
Commit-Queue: Tsuyoshi Horo <horo@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1221432}
2023-11-08 09:25:25 +00:00
Tsuyoshi Horo
c04d12e2a5 Support loading code cache on a background thread
This CL introduces BackgroundCodeCacheHost class which is created in the
main thread, and passed to the background thread to load code cache on
the background thread.

This CL only has an effect if the BackgroundResourceFetch feature is
enabled.

Bug: 1379780
Change-Id: Iaf7c4adfbf6ab7fc035acfabe4bea9ce65a1de13
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4982988
Reviewed-by: Yoshisato Yanagisawa <yyanagisawa@chromium.org>
Reviewed-by: Takashi Toyoshima <toyoshim@chromium.org>
Commit-Queue: Tsuyoshi Horo <horo@chromium.org>
Reviewed-by: John Abd-El-Malek <jam@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1218594}
2023-11-02 01:49:26 +00:00
Jagadesh P
d8dad714af [DanglingPointer] Remove dangling pointer in GeneratedCodeCache Test.
Bug: 1485837
Change-Id: I6c49c6df8445ece9ef4779b918e23bdfeb8a5c1c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4975327
Commit-Queue: Bo Liu <boliu@chromium.org>
Reviewed-by: Bo Liu <boliu@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1216122}
2023-10-27 15:12:41 +00:00
Arthur Sonzogni
bdeca8e234 Privatize content features.
There are two headers to declare features in content.
- the public one: `content/public/common/content_features.h`
- the private one: `content/common/features.h`.

Unfortunately, most are declared in the public one, despite being used
privately exclusively. This violate the `content/public/` rules. This
patches provides a fix.

Parts of this patch was made programmatically using this script:
https://paste.googleplex.com/6699322946093056, with the following
output: https://paste.googleplex.com/5591288895242240

This patch:
1. Update `docs/how_to_add_your_feature_flag.md` to incentive
   developers to the non public versions.
2. Move ~70 features back into the private version.
3. Programmatically update the includes to include the correct
   #include header(s).
4. For consistency and minimizing the amount of files modified,
   the two headers to use the `features::` namespace.

AX-Relnotes: n/a.
Change-Id: Id9126a95dfbc533d4778b188b659b5acc9b3d9e3
Bug: None
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4836057
Reviewed-by: Alex Moshchuk <alexmos@chromium.org>
Commit-Queue: Arthur Sonzogni <arthursonzogni@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1194718}
2023-09-11 08:32:12 +00:00
Arthur Sonzogni
e98d214c48 DanglingPointer: annotate for unittests base+linux [1/N]
The DanglingPointerDetector is configured only when the test enters the
ContentMain function. See https://crbug.com/1400059

I would like to configure it no matter the kind of test. For this to
happen, we need to annotate every pre-existing dangling pointers.

This patch annotates the ones you can find by running targets depending
on the GoogleTest library.

Statistic:

This adds 1776 new DanglingUntriaged. Among them:
- 1288 are in unittests.
- 488 are in implementation.

To produce those numbers, I used the command:
```bash
git diff annotate-linux origin/main -- "*test*" | grep "DanglingUntriaged" | wc -l
```

This patch has been generated by:

1. Apply the "auto-annotator" patch:
   https://chromium-review.googlesource.com/c/chromium/src/+/4474553

2. Compile the compiler again:
   ```bash
   ./tools/clang/scripts/build.py
   ```

3. List and run all the targets. You can use a bash script like:
   https://docs.google.com/document/d/1AMMERcqy0eafFWopUCHYsIKIKEp3J8DFxqW9UIbzIHo

4. Concatenate output, filter by "Found dangling ptr", sort, remove
   duplicate.

5. Apply the rewriter script from:
   https://github.com/ArthurSonzogni/chrome-dangling-ptr-apply-edit

6. Revert the "auto-annotate" patch.

7. Apply `git cl format`

AX-Relnotes: n/a.
Bug: chromium:1400059
Change-Id: I217d5c0b925da5176fc53baf95919a3690f1e9a3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4570424
Reviewed-by: danakj <danakj@chromium.org>
Owners-Override: danakj <danakj@chromium.org>
Commit-Queue: Arthur Sonzogni <arthursonzogni@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1151859}
2023-06-01 15:02:25 +00:00
Andrew Williams
341a668163 [Generated Code Cache] Add test for partitioning by NIK
Adds one test for frame contexts, and another that we can use
to test generated code cache usage by shared workers if that gets
implemented at some point.

Bug: 964467, 1445719
Change-Id: I822e7115ffadee15baea5082a7b1c01041248ea0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4554196
Commit-Queue: Andrew Williams <awillia@chromium.org>
Reviewed-by: Arthur Sonzogni <arthursonzogni@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1149679}
2023-05-26 12:48:58 +00:00
Teresa Mao
98cb05ab89 Add histograms for better measuring feature adoption
- WebUICodeCache.FeatureEnabled increments when generated code cache for WebUI JS is instantiated.
- SiteIsolatedCodeCache.JS.WebUI.Behaviour logs caching behavior (clear/create/hit/miss/update) for WebUI JS scripts only.

Bug: None
Change-Id: Iba1e0fed76c686ced917345a3b7a8131c20132e3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4420273
Reviewed-by: Sophie Chang <sophiechang@chromium.org>
Commit-Queue: Teresa Mao <temao@chromium.org>
Reviewed-by: Thomas Lukaszewicz <tluk@chromium.org>
Reviewed-by: Bo Liu <boliu@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1139149}
2023-05-03 21:29:01 +00:00
Andrew Williams
d5fa8ad0e1 Have the Code Cache use the NIK when the HTTP Cache does
This CL updates the Code Cache to use the NIK when the
HTTP Cache does (which isn't only when
kSplitCacheByNetworkIsolationKey is enabled, as it once
was).

This is implemented behind it's own feature flag so that
it could be enabled via a slow rollout or as a killswitch.

For more context, see:
https://bugs.chromium.org/p/chromium/issues/detail?id=1213818#c30

Bug: 1213818
Change-Id: Iece67fb7f34269d1f1586de7854dc7526e50e7a0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4303800
Reviewed-by: Matt Menke <mmenke@chromium.org>
Commit-Queue: Andrew Williams <awillia@chromium.org>
Reviewed-by: Kinuko Yasuda <kinuko@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1120187}
2023-03-21 21:15:43 +00:00
Avi Drissman
adac219925 Update header includes for /base/functional in /content
bind.h, callback.h, callback_forward.h, and callback_helpers.h
moved into /base/functional/. Update the include paths to
directly include them in their new location.

Bug: 1364441
Change-Id: I32ec425b9c0e52ec4b50047bf3290fecc5c905ff
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4148554
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Auto-Submit: Avi Drissman <avi@chromium.org>
Owners-Override: Avi Drissman <avi@chromium.org>
Owners-Override: Daniel Cheng <dcheng@chromium.org>
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1091567}
2023-01-11 23:46:39 +00:00
Sean Maher
e672a665ff task posting v3: remove includes of runner handles and IWYU task runners
Turns out there's a lot of includes, so these will have to be removed
before deleting the implementation of the task runner handles.

To allow the deletion of the task runner handle headers, add
the sequenced/thread task runner handles where they are used in
the codebase with scripts.

This was done with an automated change, with a few touchups afterwards.
The code for the mass-refactor changes are here:
python:
https://paste.googleplex.com/5534570878337024
shell:
https://paste.googleplex.com/6466750748033024

In terms of touchups:
- add sequenced/thread task runner handles to
  the third_party/blink/public/DEPS, because multiple files were using
  it transitively anyways.
- rewrite certain parts of the codebase which used
  ThreadTaskRunnerHandles instead of CurrentDefaultHandles.
- fix a compile issue with forward-declaration in
  extensions/browser/extension_file_task_runner.h.

AX-Relnotes: n/a.
Bug: 1026641
Change-Id: I737ef32aee4e77c21eaa3a2bdc403a28322cf1b7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4133323
Owners-Override: Gabriel Charette <gab@chromium.org>
Commit-Queue: Sean Maher <spvw@chromium.org>
Commit-Queue: Gabriel Charette <gab@chromium.org>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1090532}
2023-01-09 21:42:28 +00:00
Clark DuVall
d4d0f454f9 Clean up launched features from CombinedNavigationOptimizations
These have been enabled by default for awhile and it should be safe to
clean up the old code now.

Bug: 1309246
Change-Id: I6f97fd2dc5e5135b3682916f6bfcc3deb37669cb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4021617
Auto-Submit: Clark DuVall <cduvall@chromium.org>
Reviewed-by: Christian Dullweber <dullweber@chromium.org>
Reviewed-by: John Abd-El-Malek <jam@chromium.org>
Reviewed-by: Philip Rogers <pdr@chromium.org>
Reviewed-by: Ayu Ishii <ayui@chromium.org>
Reviewed-by: Scott Violet <sky@chromium.org>
Commit-Queue: Christian Dullweber <dullweber@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1071506}
2022-11-15 09:31:20 +00:00
Sean Maher
52fa5a7f26 task posting v3: moving away from SequencedTaskRunnerHandle
To continue the migration away from TaskRunnerHandles, the codebase
was refactored using the following scripts:
shell script:
https://paste.googleplex.com/4673967729147904
python:
https://paste.googleplex.com/5302682490241024

This will do a few sed-like modifications, changing calls to methods of
SequencedTaskRunnerHandle to calls to methods of
SequencedTaskRunner::CurrentDefaultHandle, and swapping includes.

Bug: 1026641
AX-Relnotes: n/a.
Change-Id: I49e50a2bd1e78b00e7c067219fff96d2e0bc0b46
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3983373
Commit-Queue: Gabriel Charette <gab@chromium.org>
Owners-Override: Gabriel Charette <gab@chromium.org>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1071032}
2022-11-14 15:53:25 +00:00
Avi Drissman
4e1b7bc33d Update copyright headers in content/
The methodology used to generate this CL is documented in
https://crbug.com/1098010#c34.

No-Try: true
No-Presubmit: true
Bug: 1098010
Change-Id: I8c0f009d16350271f07d8e5e561085822cc9dd27
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3895935
Owners-Override: Avi Drissman <avi@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
Auto-Submit: Avi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1047456}
2022-09-15 14:03:50 +00:00
Nico Weber
bb340f66aa Fix invalid constexpr enum operations that clang will soon flag
constexpr enum expressions for enums without fixed underlying type must
now be in the range of the enum type.

The biggest change is that the 3-arg form of UMA_HISTOGRAM_ENUMERATION now
requires its enum arg to have a fixed underlying type (see bug for details),
so add a whole bunch of underlying types.

Fix other issues by slightly reordering arithmetic, or by making some
values const instead of constexpr.

No intended behavior change.

Bug: 1348574
Change-Id: I59d06a095c20ec1c2a5eea5928c73793f89856ab
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3796909
Reviewed-by: Hans Wennborg <hans@chromium.org>
Commit-Queue: Alexei Svitkine <asvitkine@chromium.org>
Owners-Override: Nico Weber <thakis@chromium.org>
Auto-Submit: Nico Weber <thakis@chromium.org>
Reviewed-by: Alexei Svitkine <asvitkine@chromium.org>
Commit-Queue: Nico Weber <thakis@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1030177}
2022-08-01 18:00:54 +00:00
Matt Menke
11ffd53213 Make HttpCache::GenerateCacheKey() return an absl::optional.
When including a NetworkIsolationKey in the cache key, and the
NetworkIsolationKey is transient, return absl::nullopt. Previously it
would return an empty string, which would cause cross-site leaks if it
were ever actually used as a cache key.

Also make NetworkIsolationKey::ToString() return an optional, and return
nullopt if transient, for the exact same reason.  Rename ToString() to
ToCacheString(), since DCHECK_EQ(nik, nik) expects ToString() to return
a std::string. Also Migrate those DCHECK_EQs to DCHECK(nik==nik).

Bug: None
Change-Id: I4c7f9a2ff16755aff8d5a7590eb8877a16d3611e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3777742
Reviewed-by: Kenichi Ishibashi <bashi@chromium.org>
Reviewed-by: Kunihiko Sakamoto <ksakamoto@chromium.org>
Commit-Queue: Matt Menke <mmenke@chromium.org>
Reviewed-by: Bo Liu <boliu@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1027064}
2022-07-22 00:49:33 +00:00
Yutaka Hirano
b1597eda0c Plumb max_size_bytes to SimpleLruCache
This fixes unittests with enabling kInMemoryCodeCache.

Bug: 1324058
Change-Id: Ia2f07e7b076dc1961a092131421db18726ddcac4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3775360
Reviewed-by: Charlie Reis <creis@chromium.org>
Commit-Queue: Charlie Reis <creis@chromium.org>
Auto-Submit: Yutaka Hirano <yhirano@chromium.org>
Reviewed-by: Kenichi Ishibashi <bashi@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1026327}
2022-07-20 18:21:18 +00:00
Yutaka Hirano
2db0b4f467 Add cache clear support for in-memory code cache
Bug: 1324058
Change-Id: Ice2cc1230b3edf290b8fb02bf565aa43fd40af7a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3774641
Auto-Submit: Yutaka Hirano <yhirano@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Commit-Queue: Avi Drissman <avi@chromium.org>
Reviewed-by: Kenichi Ishibashi <bashi@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1026246}
2022-07-20 14:59:54 +00:00
Yutaka Hirano
f38f7e51cb Implement in-memory code cache
Implement a simple in-memory code cache behind a feature flag in order
to see its potential performance gain.

Bug: 1324058
Change-Id: Ia60b245759fa7e78fe1eee529b24b6a4ea5b991e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3759056
Reviewed-by: Alex Moshchuk <alexmos@chromium.org>
Reviewed-by: Kenichi Ishibashi <bashi@chromium.org>
Commit-Queue: Yutaka Hirano <yhirano@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1024572}
2022-07-15 03:57:58 +00:00
Yutaka Hirano
0d4be98470 Rename SimpleLruCacheIndex
As we're going to store actual contents, SimpleLruCacheIndex is no more the right name for the class - let's rename it.

Bug: 1324058
Change-Id: I869796f77af57638ca40cb264c6204cb790c1b6a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3755954
Reviewed-by: Alex Moshchuk <alexmos@chromium.org>
Commit-Queue: Yutaka Hirano <yhirano@chromium.org>
Reviewed-by: Kenichi Ishibashi <bashi@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1024523}
2022-07-15 01:02:21 +00:00
Maks Orlovich
2690c357b0 disk_cache: Cleanup CreateCacheBacked API
This is the last remaining method in disk_cache.h that takes an out pointer while being able to execute both synchronously and asynchronously, which requires highly error-prone lifetime management of the destination.

The changed version simply produces a unique_ptr by value, either as return value or via callback.

HttpCache::GetBackend still has a similar issue, but it would be too much to handle in this one CL, and it's also different in that it's not a factory method, and both the callback invocation and lifetime of the disk_cache::Backend it returns are tied to the underlying HttpCache, so it likely needs a different solution (like it reporting success/failure, and users using HttpCache::GetCurrentBackend to make the lifetime dependency obvious).

Bug: 854716
Change-Id: I79807021c74ffadbe0acd62145345f887626f1fd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3688361
Reviewed-by: Bo Liu <boliu@chromium.org>
Commit-Queue: Maks Orlovich <morlovich@chromium.org>
Reviewed-by: Yutaka Hirano <yhirano@chromium.org>
Reviewed-by: Marijn Kruisselbrink <mek@chromium.org>
Reviewed-by: Derek Schuff <dschuff@chromium.org>
Reviewed-by: Zhenyao Mo <zmo@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1017654}
2022-06-24 15:48:44 +00:00