0
Commit Graph

596 Commits

Author SHA1 Message Date
Ayu Ishii
baef7c60e6 Quota: Cleanup StorageType from QuotaManagerProxy::RegisterClient
This change removes StorageType param from
QuotaManagerProxy::RegisterClient. After
StorageType::kSyncable deprecation, all other storage types
except kTemporary are deprecated. So we no longer need to
specify StorageType.

As a side-effect there is also clean-up in
BrowsingDataQuotaHelper to no longer collect syncable usage.
No storage data is associated with Syncable type now and will
always return 0.

Further StorageType cleanup from QuotaManager/QuotaDatabase
will be done in a follow-up change.

Bug: 40211051
Change-Id: I70cb64c7b270def02d8b539a77498eba208b1e4a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6309405
Reviewed-by: Bo Liu <boliu@chromium.org>
Reviewed-by: Martin Šrámek <msramek@chromium.org>
Reviewed-by: Tsuyoshi Horo <horo@chromium.org>
Reviewed-by: Hiroki Nakagawa <nhiroki@chromium.org>
Reviewed-by: Nasko Oskov <nasko@chromium.org>
Reviewed-by: Marijn Kruisselbrink <mek@chromium.org>
Commit-Queue: Ayu Ishii <ayui@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1429075}
2025-03-06 11:41:24 -08:00
Ayu Ishii
6ecd458052 Quota: Cleanup StorageType in QuotaManagerProxy
This change removes some usages of StorageType in QuotaManagerProxy.
After StorageType::kSyncable deprecation, all other storage types
except kTemporary are deprecated. So we no longer need to specify
StorageType. Further cleanup to remove usage from QuotaManager,
QuotaDatabase, etc. will follow.

Bug: 40211051
Change-Id: Iba5caa5aefcc346cbcf9e7aac3f05ab33ca53d61
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6306646
Reviewed-by: Bo Liu <boliu@chromium.org>
Commit-Queue: Ayu Ishii <ayui@chromium.org>
Reviewed-by: Tsuyoshi Horo <horo@chromium.org>
Reviewed-by: Hiroki Nakagawa <nhiroki@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1426466}
2025-02-28 11:05:45 -08:00
Camille Lamy
61ee8e7fda [DIP] Plumb DIP reporter in CacheStorage
This CL plumbs the DocumentIsolationPolicy reporter through
CacheStorage, so that it can be passed to CORP checks triggered from
CacheStorage.

This CL is part of a chain implementing Document Isolation Policy

reporting:
1) Add DocumentIsolationPolicyReporter
2) Implement DocumentIsolationPolicyReporter
3) Pass the reporter to URLloaderFactory
4) Plumb DIP reporter into ServiceWorkers
5) Add a DIP reporter to DedicatedWorker
6) Add a DIP reporter to SharedWorker
7) Plumb DIP reporter in CacheStorage <- you are here

Bug: 333029815
Change-Id: I5a7b5a92b9e059242c1ddcfa218c1cfb6d9cd0e4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6088411
Reviewed-by: Arthur Sonzogni <arthursonzogni@chromium.org>
Commit-Queue: Camille Lamy <clamy@chromium.org>
Reviewed-by: Tsuyoshi Horo <horo@chromium.org>
Reviewed-by: Hiroki Nakagawa <nhiroki@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1414111}
2025-01-31 07:17:24 -08:00
Tom Sepez
8726d30ed0 Suppress unsafe_libc_call warning for initial identified files.
See docs/unsafe_buffers.md for details. Enforcement is not yet
enabled, but this set of files are not in compliance with the
new warnings.

Bug: 390223051
Change-Id: I4e24c2141b9399f572678302c833947494098b29
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6187925
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Owners-Override: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1412673}
2025-01-28 18:11:08 -08:00
Peter Kasting
1557e5fbe4 [cleanup] Replace base::ranges with std::ranges: content/
Done entirely with `git grep` and `sed` + `git cl format`, no
hand-editing.

Bug: 386918226
Change-Id: I8561612cb02c9d62c455836dba414ab402e40694
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6199140
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Owners-Override: Peter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1412009}
2025-01-27 17:14:08 -08:00
Emily Andrews
d15fd76ecb Change RenderProcessHost::GetID to RenderProcessHost::GetDeprecatedID
This change bulk changes RenderProcessHost::GetID to
RenderProcessHost::GetDeprecatedID to support the transition to a
strongly typed ChildProcessId.

Bug: 379869738
Change-Id: Ib0c991536486ef29702ea166cdcf12ea68ed70ee
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6065543
Reviewed-by: Arthur Sonzogni <arthursonzogni@chromium.org>
Owners-Override: Arthur Sonzogni <arthursonzogni@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Reviewed-by: Alex Moshchuk <alexmos@chromium.org>
Commit-Queue: Emily Andrews <emiled@microsoft.com>
Cr-Commit-Position: refs/heads/main@{#1394500}
2024-12-10 20:41:54 +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
Tom Sepez
8f3e25a5dd Replace const-value arguments where const-ref intended.
This is of concern when passing vectors and strings, as unintended
(and often expensive) copies occur under the covers.

-- Make non-const and move in callee where appropriate.
-- Convert to string_view where appropriate.
-- Avoid stray const in a few places

This CL was uploaded by git cl split.

R=drott@chromium.org, jdiggs@igalia.com, jsbell@chromium.org, kouhei@chromium.org, mmenke@chromium.org, nasko@chromium.org, peter@chromium.org, shuuran@chromium.org, steimel@chromium.org, yangguo@chromium.org

Bug: 369952985
Change-Id: If88f7d08190a75da995a49dedbd5fd1c711d1223
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5901985
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Auto-Submit: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Russ Hamilton <behamilton@google.com>
Reviewed-by: Nasko Oskov <nasko@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1364512}
2024-10-05 00:28:22 +00:00
Mike Wasserman
2a2e835b3c Storage: Remove kDeprecatedQuotaNotManaged type handling; use flat_set
Remove some minor handling of deprecated and unused storage type.
Convert QuotaManager std::vector usage to base::flat_set.
No behavior changes expected.

Bug: 1095844
Change-Id: Ifa759cedb63e0b7b3535435368e958e073f5d144
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5857353
Auto-Submit: Mike Wasserman <msw@chromium.org>
Reviewed-by: Charlie Reis <creis@chromium.org>
Commit-Queue: Mike Wasserman <msw@chromium.org>
Reviewed-by: Evan Stade <estade@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1356123}
2024-09-16 20:58:57 +00:00
Jan Keitel
852d5596c9 Spanify gfx::Image creation method.
This CL should contain no functionality change - it just replaces
unsigned char* and size_t arguments by a base::span<const uint8_t>
and adjusts the call sites.

Bug: 354829279
Change-Id: Ia71db4d270d2e7abc79f5334b42435660fc02e4b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5743597
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Reviewed-by: Florian Leimgruber <fleimgruber@google.com>
Commit-Queue: Jan Keitel <jkeitel@google.com>
Cr-Commit-Position: refs/heads/main@{#1336515}
2024-08-02 09:25:36 +00:00
Alex Gough
d836aa411b Turn iterator _!=_.end() DCHECK() into CHECK() for content/browser
Accessing an invalid iterator can sometimes be a security
issue and these checks are cheap, so upgrade to CHECKs.
Generally these DCHECKS precede a use or erase of the
checked iterator, which if the check is invalid (ie. the
iterator == .end()) is UB.

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(_ != _.end());' \
      -p 'DCHECK(_.end() != _);' \
      -p 'DCHECK_NE(_, _.end());' \
      -p 'DCHECK_NE(_.end(), _);'
```

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, dom@chromium.org, jinsukkim@chromium.org, peter@chromium.org, wanderview@chromium.org

Bug: 351745839
Change-Id: Ic4b66209052fde03394b9f34241ae2bd9173ed7a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5706540
Commit-Queue: Jinsuk Kim <jinsukkim@chromium.org>
Reviewed-by: Peter Beverloo <peter@chromium.org>
Reviewed-by: Alex Moshchuk <alexmos@chromium.org>
Reviewed-by: Jinsuk Kim <jinsukkim@chromium.org>
Auto-Submit: Alex Gough <ajgo@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1327876}
2024-07-15 23:56:52 +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
Owners Cleanup
0fdc7a82a6 Remove rayankans@chromium.org from content/browser/background_fetch/OWNERS
This suggested change is automatically generated based on group
memberships and affiliations.
If this change is unnecessary or in error, vote the lowest CR value
(i.e. reject the CL) and the bot will abandon it. Vote the highest CR to
approve this change. You may also abandon this change.

See the owner's recent activity for context:
https://chromium-review.googlesource.com/q/rayankans@chromium.org

To report an issue, file a bug in the Infra>Codereview component.

Change-Id: I4798c6f32ee061256b68d6b8c3986116e57aac20
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5684306
Auto-Submit: Owners Cleanup <swarming-tasks@owners-cleanup-prod.google.com.iam.gserviceaccount.com>
Reviewed-by: Peter Beverloo <peter@chromium.org>
Commit-Queue: Peter Beverloo <peter@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1326015}
2024-07-11 09:55:28 +00:00
Min Qin
31c2bf1b6e Don't download pdf for forward/back navigations if pdf viewer is enabled
For forward/back navigations, chrome should load the native page, which
will issue a download request, instead of loading a URL that leads to a
pdf download directly.
This CL cancels the download if a forward/back navigation results in a
pdf download.

Low-Coverage-Reason: TRIVIAL_CHANGE
Bug: 349917621
Change-Id: I01555ff83f763311f98ff32719bea0221650c440
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5665956
Reviewed-by: Shu Yang <shuyng@google.com>
Commit-Queue: Min Qin <qinmin@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1321311}
2024-06-29 05:25:00 +00:00
Camille Lamy
9cae81d88d [DIP] Add support for DIP in CacheStorage
This CL adds support for properly checking DocumentIsolationPolicy in
CacheStorage.

Bug: 333029144
Change-Id: I8643b2ea7df0a4f45efcb5f861ebb06e86118db0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5600534
Commit-Queue: Camille Lamy <clamy@chromium.org>
Reviewed-by: Ayu Ishii <ayui@chromium.org>
Reviewed-by: Joe DeBlasio <jdeblasio@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1320348}
2024-06-27 14:11:23 +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
Helmut Januschka
a965cc1a73 Remove std::to_string() //content
removes std::to_string() and uses either base::NumberToString()
or base::FormatNumber()

Bug: 335672557
Change-Id: I38c9c293cc6b5b0713235317a4337e47fcc3970d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5513781
Reviewed-by: Alex Moshchuk <alexmos@chromium.org>
Commit-Queue: Helmut Januschka <helmut@januschka.com>
Cr-Commit-Position: refs/heads/main@{#1297328}
2024-05-07 07:11:09 +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
923a33e9d5 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: Ib028de8bb63c99e5a81d90e24e422cf88061ad05
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5469583
Owners-Override: Alison Gale <agale@chromium.org>
Reviewed-by: Darryl James <dljames@chromium.org>
Commit-Queue: Alison Gale <agale@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1290952}
2024-04-22 23:34:28 +00:00
Alison Gale
81f4f2c793 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: Iee14d10d544e9f0ec046117cc4ec8a55c427adc0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5469947
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@{#1290838}
2024-04-22 19:33:31 +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
danakj
529a3eba25 Reland "Spanify base::RefCountedMemory"
This is a reland of commit 431722686b

Fixed the null deref of scoped_refptr in the usb descriptor code,
by not constructing the span from the RefCountedMemory before we
know the RefCountedMemory is really there.

Original change's description:
> Spanify base::RefCountedMemory
>
> - The base class gets data() and size() as well as begin() and end()
> - The virtual interface gets a span from the subclass.
> - All subclasses hold a bounded type.
> - Remove front_as<T>() from the base class. Use a span or data()
>   instead.
> - Remove most use of front() from the base class, but leave the
>   method there just to reduce the scope/size of this CL a bit. Use
>   a span or data() instead.
> - Rename data() in subclasses to be more specific: as_vector() or
>   as_string().
> - Remove the shadowing data(), and front_as(), from the vector-based
>   subclass that provided mutable access. Have mutable access go
>   through as_vector().
> - Remove the shadowing data() from the string-based subclasses that
>   provided mutable access. Have mutable access go through
>   as_string().
>
> The base class provides const access to the underlying data, as not
> all implementations point to mutable data. The subclasses provided
> methods to access the underlying data mutably, sometimes in ways that
> shadowed the base class methods (such as with front_as). When mutable
> access is required, we now go through the underlying storage accessor
> such as as_vector() or as_string().
>
> In the X11 code there's a bunch of RefCountedMemory that are
> actually unsized, since they come from void* in C APIs. So split
> those off to a separate x11::UnsizedRefCountedMemory, and use that
> for all reply type data fields.
>
> Add conversion types to move between sized and unsized, which are needed
> very rarely.
>
> Use RefCountedMemory as a span since it converts now:
> - Convert all front_as<char>() to use base::as_string_view(*mem).
> - Convert make_span(mem->front(), mem->size()) to span(*mem).
> - Except when mutable access is required, in which case we go through
>   the underlying storage type.
>
> Bug: 40284755
> Change-Id: Ib1c5fd61973092e3e02562646a7b3416e1070cd1
> Low-Coverage-Reason: refactoring, not new code
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5447596
> Reviewed-by: Reilly Grant <reillyg@chromium.org>
> Owners-Override: Kyle Charbonneau <kylechar@chromium.org>
> Reviewed-by: Kyle Charbonneau <kylechar@chromium.org>
> Commit-Queue: danakj <danakj@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#1288921}

Bug: 40284755
Change-Id: Ide0a71227c4930bd638bb07faffda44f5285bd4f
Low-Coverage-Reason: refactoring, not new code
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5462330
Reviewed-by: Reilly Grant <reillyg@chromium.org>
Commit-Queue: danakj <danakj@chromium.org>
Reviewed-by: Kyle Charbonneau <kylechar@chromium.org>
Owners-Override: Kyle Charbonneau <kylechar@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1289537}
2024-04-18 20:14:56 +00:00
Nidhi Jaju
f863796102 Revert "Spanify base::RefCountedMemory"
This reverts commit 431722686b.

Reason for revert: Suspicious for causing test failures related to devtools in chrome driver tests and USB related tests
i.e. https://ci.chromium.org/ui/p/chromium/builders/ci/win11-arm64-rel-tests/924/overview

Original change's description:
> Spanify base::RefCountedMemory
>
> - The base class gets data() and size() as well as begin() and end()
> - The virtual interface gets a span from the subclass.
> - All subclasses hold a bounded type.
> - Remove front_as<T>() from the base class. Use a span or data()
>   instead.
> - Remove most use of front() from the base class, but leave the
>   method there just to reduce the scope/size of this CL a bit. Use
>   a span or data() instead.
> - Rename data() in subclasses to be more specific: as_vector() or
>   as_string().
> - Remove the shadowing data(), and front_as(), from the vector-based
>   subclass that provided mutable access. Have mutable access go
>   through as_vector().
> - Remove the shadowing data() from the string-based subclasses that
>   provided mutable access. Have mutable access go through
>   as_string().
>
> The base class provides const access to the underlying data, as not
> all implementations point to mutable data. The subclasses provided
> methods to access the underlying data mutably, sometimes in ways that
> shadowed the base class methods (such as with front_as). When mutable
> access is required, we now go through the underlying storage accessor
> such as as_vector() or as_string().
>
> In the X11 code there's a bunch of RefCountedMemory that are
> actually unsized, since they come from void* in C APIs. So split
> those off to a separate x11::UnsizedRefCountedMemory, and use that
> for all reply type data fields.
>
> Add conversion types to move between sized and unsized, which are needed
> very rarely.
>
> Use RefCountedMemory as a span since it converts now:
> - Convert all front_as<char>() to use base::as_string_view(*mem).
> - Convert make_span(mem->front(), mem->size()) to span(*mem).
> - Except when mutable access is required, in which case we go through
>   the underlying storage type.
>
> Bug: 40284755
> Change-Id: Ib1c5fd61973092e3e02562646a7b3416e1070cd1
> Low-Coverage-Reason: refactoring, not new code
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5447596
> Reviewed-by: Reilly Grant <reillyg@chromium.org>
> Owners-Override: Kyle Charbonneau <kylechar@chromium.org>
> Reviewed-by: Kyle Charbonneau <kylechar@chromium.org>
> Commit-Queue: danakj <danakj@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#1288921}

Bug: 40284755
Change-Id: Ifa8478ea367d3767e474a9042afa3e5e0596ab9f
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5464882
Auto-Submit: Nidhi Jaju <nidhijaju@chromium.org>
Owners-Override: Nidhi Jaju <nidhijaju@chromium.org>
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Cr-Commit-Position: refs/heads/main@{#1289148}
2024-04-18 05:16:16 +00:00
danakj
431722686b Spanify base::RefCountedMemory
- The base class gets data() and size() as well as begin() and end()
- The virtual interface gets a span from the subclass.
- All subclasses hold a bounded type.
- Remove front_as<T>() from the base class. Use a span or data()
  instead.
- Remove most use of front() from the base class, but leave the
  method there just to reduce the scope/size of this CL a bit. Use
  a span or data() instead.
- Rename data() in subclasses to be more specific: as_vector() or
  as_string().
- Remove the shadowing data(), and front_as(), from the vector-based
  subclass that provided mutable access. Have mutable access go
  through as_vector().
- Remove the shadowing data() from the string-based subclasses that
  provided mutable access. Have mutable access go through
  as_string().

The base class provides const access to the underlying data, as not
all implementations point to mutable data. The subclasses provided
methods to access the underlying data mutably, sometimes in ways that
shadowed the base class methods (such as with front_as). When mutable
access is required, we now go through the underlying storage accessor
such as as_vector() or as_string().

In the X11 code there's a bunch of RefCountedMemory that are
actually unsized, since they come from void* in C APIs. So split
those off to a separate x11::UnsizedRefCountedMemory, and use that
for all reply type data fields.

Add conversion types to move between sized and unsized, which are needed
very rarely.

Use RefCountedMemory as a span since it converts now:
- Convert all front_as<char>() to use base::as_string_view(*mem).
- Convert make_span(mem->front(), mem->size()) to span(*mem).
- Except when mutable access is required, in which case we go through
  the underlying storage type.

Bug: 40284755
Change-Id: Ib1c5fd61973092e3e02562646a7b3416e1070cd1
Low-Coverage-Reason: refactoring, not new code
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5447596
Reviewed-by: Reilly Grant <reillyg@chromium.org>
Owners-Override: Kyle Charbonneau <kylechar@chromium.org>
Reviewed-by: Kyle Charbonneau <kylechar@chromium.org>
Commit-Queue: danakj <danakj@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1288921}
2024-04-17 19:51:00 +00:00
Arthur Sonzogni
f07f24815d Cleanup: Remove unused <optional> in content/
Script:
```
cd content

comm -13 \
 <(
   (
     git grep -l "std::make_optional";
     git grep -l "std::optional";
     git grep -l "std::nullopt";
     git grep -l "std::in_place";
     git grep -l "std::in_place_t";
   ) | cut -f1 -d: \
     | grep \
       -e "\.h" \
       -e "\.cc" \
       -e "\.mm" \
     | sort \
     | uniq
  ) \
 <(
   (
   git grep "#include <optional>"
   ) | cut -f1 -d: \
     | grep \
       -e "\.h" \
       -e "\.cc" \
       -e "\.mm" \
     | sort \
     | uniq
  ) \
  | xargs sed -i "s/#include <optional>//g"

cd ..

echo "Formatting"

echo "IncludeBlocks: Regroup" >> ".clang-format"
echo "IncludeIsMainRegex: \"(_(android|apple|chromeos|freebsd|fuchsia|fuzzer|ios|linux|mac|nacl|openbsd|posix|stubs?|win))?(_(unit|browser|perf)?tests?)?$\"" >> ".clang-format"
git cl format
git restore ".clang-format"

git cl format
```

Bug: chromium:1500249
Change-Id: I0302576941b2002d4175af119e1c894c3be37681
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5380322
Reviewed-by: Alex Moshchuk <alexmos@chromium.org>
Commit-Queue: Alex Moshchuk <alexmos@chromium.org>
Auto-Submit: Arthur Sonzogni <arthursonzogni@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1275803}
2024-03-20 20:21:43 +00:00
Andrew Rayskiy
7742172f14 [base] Remove unused cxx20_erase & cxx20_erase_vector headers
Bug: 40256229
Change-Id: I546d1080705b18d94a121b9ddb7df38ad92598eb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5331897
Reviewed-by: danakj <danakj@chromium.org>
Owners-Override: danakj <danakj@chromium.org>
Commit-Queue: Andrew Rayskiy <greengrape@google.com>
Cr-Commit-Position: refs/heads/main@{#1268973}
2024-03-06 13:12:58 +00:00
Jeff Yoon
d1328c4408 [buganizer] Migrate DIR_METADATA in content/browser/
Migrate all metadata files for content/browser.

Verify components with http://b/components/{id} or at
go/chrome-on-buganizer-prod-components.

Bug: chromium:1518875
Change-Id: I555b9fe40952a5707e167b3dcbaf2858bbdf1f34
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5284095
Reviewed-by: Avi Drissman <avi@chromium.org>
Commit-Queue: Avi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1258966}
2024-02-11 19:24:26 +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
Kevin Grosu
e388a1b0f9 Revert "[gardener] Disable BackgroundFetchEventDispatcherTest.Dispatch flaky* tests"
This reverts commit 08add924cf.

Reason for revert: Reverting because tests are actually not failing on main as the issue was fixed but rather in the branches.

Original change's description:
> [gardener] Disable BackgroundFetchEventDispatcherTest.Dispatch flaky* tests
>
> 2 flaky tests:
> BackgroundFetchEventDispatcherTest.DispatchClickEvent
> BackgroundFetchEventDispatcherTest.DisplatchFetchSuccessEvent
>
> Bug: 1506090
> Change-Id: I5f81551f962c62ae3d0c01cf1e172f73f8a5002b
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5072174
> Reviewed-by: Sinan Sahin <sinansahin@google.com>
> Owners-Override: Kevin Grosu <kgrosu@google.com>
> Commit-Queue: Kevin Grosu <kgrosu@google.com>
> Cr-Commit-Position: refs/heads/main@{#1230740}

Bug: 1506090
Change-Id: I193f0c0a25e6d01d26a30f94fd1a9018b0698b0a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5079509
Commit-Queue: Xi Han <hanxi@chromium.org>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Owners-Override: Xi Han <hanxi@chromium.org>
Reviewed-by: Xi Han <hanxi@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1232015}
2023-12-01 17:46:36 +00:00
Kevin Grosu
08add924cf [gardener] Disable BackgroundFetchEventDispatcherTest.Dispatch flaky* tests
2 flaky tests:
BackgroundFetchEventDispatcherTest.DispatchClickEvent
BackgroundFetchEventDispatcherTest.DisplatchFetchSuccessEvent

Bug: 1506090
Change-Id: I5f81551f962c62ae3d0c01cf1e172f73f8a5002b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5072174
Reviewed-by: Sinan Sahin <sinansahin@google.com>
Owners-Override: Kevin Grosu <kgrosu@google.com>
Commit-Queue: Kevin Grosu <kgrosu@google.com>
Cr-Commit-Position: refs/heads/main@{#1230740}
2023-11-29 17:47:30 +00:00
Andrew Rayskiy
eb8d184f1b [base] Remove base::Erase()/base::EraseIf() overloads for std::multimap
They're now replaced with C++20 std::erase()/std::erase_if().

Change-Id: I3f6b53e50fb9f69d5b03207fd357b8222c43cd86
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5054086
Owners-Override: Kyle Charbonneau <kylechar@chromium.org>
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Reviewed-by: Kyle Charbonneau <kylechar@chromium.org>
Commit-Queue: Andrew Rayskiy <greengrape@google.com>
Cr-Commit-Position: refs/heads/main@{#1228828}
2023-11-24 16:30:15 +00:00
Scott Haseley
997e048270 Fix dangling pointer in DevToolsBackgroundServicesContextImpl
DevToolsBackgroundServicesContextImpl can outlive its BrowserContext in
tests, which causes a dangling pointer. This CL fixes this by:
 - Fixing destruction order in ServiceWorkerUpdateJobTest, which was
   straightforward.

   Note: this also fixes an unrelated dangling pointer in one of the
   ServiceWorkerUpdateJobTest tests, which was straightforward and
   part of the same destruction sequence.

 - Making DevToolsBackgroundServicesContextImpl uniquely owned (no
   longer ref counted). The main interesting bits here were:
    - Get the DevToolsBackgroundServicesContextImpl directly rather
      than passing it across tasks (for service worker callbacks).
      This avoids a dangling pointer in the callback.

    - Plumb the Shutdown signal through BackgroundFetchContext to
      other objects that hold a raw_ptr to the devtools service. This
      can be further improved by making BackgroundFetchContext uniquely
      owned.

Bug: 1471073
Change-Id: I457c8492d21299dd60368711ed3814f3cf8fc3ec
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4868640
Commit-Queue: Scott Haseley <shaseley@chromium.org>
Reviewed-by: Rouslan Solomakhin <rouslan@chromium.org>
Reviewed-by: Andrey Kosyakov <caseq@chromium.org>
Reviewed-by: John Abd-El-Malek <jam@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1199589}
2023-09-21 14:52:04 +00:00
Ho Cheung
9722cbb523 [content] [browser] More base::Contains() usage in //content/browser
1. Use base::Contains() instead of std::find or <container>::find()
where appropriate in //content/browser.

2. Refactor some code to enhance performance when executing the code.

3. The remaining code that needs to be modified in the //content/browser
directory will be modified in subsequent patches.

AX-Relnotes: n/a
Bug: 561800
Change-Id: Ibf6b4f7919256484826dfeb73859e23185579061
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4845751
Reviewed-by: Łukasz Anforowicz <lukasza@chromium.org>
Reviewed-by: Arthur Sonzogni <arthursonzogni@chromium.org>
Commit-Queue: Ho Cheung <uioptt24@gmail.com>
Cr-Commit-Position: refs/heads/main@{#1193668}
2023-09-07 17:36:51 +00:00
Mariam Ali
8338d9fa2d Refactor: Rename storage_key() to GetStorageKey() in RenderFrameHost
Change-Id: I3bf063cd28d80f1208771e2562f7f2a9667b4bfd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4660670
Reviewed-by: Alexander Timin <altimin@chromium.org>
Commit-Queue: Mariam Ali <alimariam@google.com>
Reviewed-by: Kinuko Yasuda <kinuko@chromium.org>
Reviewed-by: Colin Blundell <blundell@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1174259}
2023-07-24 16:57:31 +00:00
Angelo Tadres
8a90ec85c8 Remove expired histograms BackgroundFetch.EventDispatchFailure.Dispatch.* and BackgroundFetch.EventDispatchResult.*
Bug: 1447135
Change-Id: If81d381dbbddda165961eccc3ed730b122d52727
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4679710
Reviewed-by: Rayan Kanso <rayankans@chromium.org>
Commit-Queue: Angelo Tadres <atadres@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1169858}
2023-07-13 12:24:27 +00:00
Nate Fischer
d85b7a862c Remove background_fetch OWNER
No change to logic. This removes one OWNER from this file. I had
intended to include this with https://crrev.com/c/4577923 (see that CL
for the rationale) but I must have overlooked this file.

Test: N/A
Change-Id: Ib9c0aa5203ef4441ab4d65d7ee75a0b504b80939
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4582522
Auto-Submit: Nate Fischer <ntfschr@chromium.org>
Reviewed-by: Peter Beverloo <peter@chromium.org>
Commit-Queue: Peter Beverloo <peter@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1153195}
2023-06-05 13:52:04 +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
Yoshisato Yanagisawa
8bffc18ee4 Add kErrorStorageDataCorrupted type.
During the investigation on crbug.com/1423325, we saw NOTREACHED
is caused by `blink::ServiceWorkerStatusCode::kErrorFailed`.
Upon some more investigations, we saw
`blink::ServiceWorkerStatusCode::kErrorFailed` is caused by
`Status::kErrorCorrupted`, and conversion happens in
`DatabaseStatusToStatusCode`.  However, `Status::kErrorCorrupted`
happens very often and it hide the real cause of crbug.com/1423325.
To avoid that, we need to make the data corruption error as separated
error.
Since enums this CL touches are recorded to UMA, this enum change
need to be permanent, and that is why the CL is separated from the
DumpWithoutCrash CL.

Bug: 1423325
Change-Id: I33826bcb19bd37841fdb4f3b4660dd8df1a64ed9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4560652
Reviewed-by: Kenichi Ishibashi <bashi@chromium.org>
Reviewed-by: Rakina Zata Amni <rakina@chromium.org>
Reviewed-by: Shunya Shishido <sisidovski@chromium.org>
Commit-Queue: Yoshisato Yanagisawa <yyanagisawa@chromium.org>
Reviewed-by: Minoru Chikamune <chikamune@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1149587}
2023-05-26 07:51:55 +00:00
Dylan Cutler
7eea01d952 Use StorageKey method to convert to IsolationInfo in background fetch
Now that this method was merged in https://crrev.com/c/4496124, I am cleaning up places where we derive IsolationInfo from a StorageKey so that we can have only one implementation of the casting logic.

The logic used in StorageKey::ToPartialNetIsolationInfo is almost identical to the logic here. The only difference is in first-party contexts, it uses the full storage origin for the top-frame origin, instead of making an origin from the top-frame site.

Bug: None
Change-Id: Ia0c2d1b8e776be5b918af54770dcc9a9450ed66c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4500186
Commit-Queue: Dylan Cutler <dylancutler@google.com>
Reviewed-by: Peter Beverloo <peter@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1140174}
2023-05-05 16:53:42 +00:00
Claudio DeSouza
dc344b7fd3 Replace base::GUID uses with base::Uuid (81/N)
`base::GUID` has been renamed, and is set to be  removed. This CL is
part of a batch of changes replacing all uses of `base::GUID`, with
`base::Uuid`, and its associated counterparts.

Additionally, deprecated functions in `base/uuid.h` are also also having
their uses removed wherever they occur.

Changes for path: /content/browser/background_fetch

This CL was uploaded by git cl split.

R=peter@chromium.org

Bug: 1428566
Change-Id: Ic2421b389a402f52cfecc2a407585783626b2353
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4429424
Auto-Submit: Claudio DeSouza <cdesouza@igalia.com>
Reviewed-by: Peter Beverloo <peter@chromium.org>
Commit-Queue: Peter Beverloo <peter@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1131149}
2023-04-17 11:36:03 +00:00
Michael Thiessen
2d864d931a Allow default initializing BrowserTaskTraits
Now that the circular dependency between browser_thread.h and
browser_task_traits.h has been resolved, browser_thread.h can include
browser_task_traits.h and provide a default ({}) for BrowserTaskTraits.

A bunch of includes in other files needed to be updated.

Bug: 1424788, 1026641, 1429044
Change-Id: Ibc44e495f743eee029fb45832b1084f03ca47555
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4402191
Reviewed-by: Gabriel Charette <gab@chromium.org>
Owners-Override: Gabriel Charette <gab@chromium.org>
Commit-Queue: Michael Thiessen <mthiesse@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1127199}
2023-04-06 15:20:56 +00:00
Matt Menke
d5244cf1f9 Make IsolationInfo and NetworkIsolationKey take nonces as optionals.
They were being taken as const pointers. This was due to overly strict
adherence to a line from the Google C++ style guide:

    Generally, use std::optional to represent optional by-value inputs,
    and use a const pointer when the non-optional form would have used
    a reference.

While this may make sense in the general case of a function that takes
a value and uses it directly, without more context, it doesn't make
sense in the case of a constructor that stores the input as an
absl::optional, particularly when every since production caller of that
constructor already has the value in an optional. Having all of those
callers have to convert an optional to a pointer, only to have the
constructor covert it back into an optional adds a lot of unnecessary
complexity, and doesn't accomplish anything useful.

BUG: None
Change-Id: I1a51cfab8df385df6fff8ae7dc064e2438740315
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4326990
Commit-Queue: Matt Menke <mmenke@chromium.org>
Reviewed-by: danakj <danakj@chromium.org>
Reviewed-by: John Abd-El-Malek <jam@chromium.org>
Reviewed-by: Ayu Ishii <ayui@chromium.org>
Reviewed-by: Brianna Goldstein <brgoldstein@google.com>
Cr-Commit-Position: refs/heads/main@{#1118897}
2023-03-17 21:53:28 +00:00
Wissem Gamra
55d2d6be6d [Code Health] Remove expired histograms BackgroundFetch.IncompleteFetchesOnStartup
Bug: 1385052
Change-Id: I6bdb4fade5eaa02ef024edde8f21ec10f8701faa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4312950
Commit-Queue: Wissem Gamra <wiss@chromium.org>
Reviewed-by: Rayan Kanso <rayankans@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1114000}
2023-03-07 17:16:35 +00:00
Ari Chivukula
504d9d6bf3 Remove expired histograms BackgroundFetch.Storage.CreateMetadataTask, BackgroundFetch.Storage.MatchRequestsTask
These histograms haven't been recorded since M99 so removal seems to be
the correct path here. This is a code-health task.

Bug: 1384805
Change-Id: I56ac6096a515af8730574cf773bd3e71f5cb7a09
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4303480
Reviewed-by: Rayan Kanso <rayankans@chromium.org>
Commit-Queue: Ari Chivukula <arichiv@chromium.org>
Auto-Submit: Ari Chivukula <arichiv@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1113897}
2023-03-07 13:27:37 +00:00
Ari Chivukula
efde83646b Remove expired histograms BackgroundFetch.PercentOfRequestsForWhichUpdatesAreSent
These histograms haven't been recorded since 2021 so removal seems to be
the correct path here. This is a code-health task.

Bug: 1385053
Change-Id: I7f5fd786dbcd004afdaa75164602335070c0e649
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4307092
Auto-Submit: Ari Chivukula <arichiv@chromium.org>
Reviewed-by: Rayan Kanso <rayankans@chromium.org>
Commit-Queue: Rayan Kanso <rayankans@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1113880}
2023-03-07 11:55:58 +00:00
Claudio DeSouza
bd27852621 Switch to simpler base::WriteFile() variants (104/N)
This CL is part of a batch of CLs to replace the use of the less
friendly base::WriteFile call with simpler variants, which are easier to
read, and less prone to mistakes.

Changes in this particular CL address files under the path
/content/browser.

This CL was uploaded by git cl split.

R=arichiv@chromium.org, caseq@chromium.org, dtrainor@chromium.org, rayankans@chromium.org, wanderview@chromium.org

AX-Relnotes: n/a.
Bug: 418837
Change-Id: I643f6e2a90ab996822b6a98d26946b65fd6b252f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4291981
Auto-Submit: Claudio DeSouza <cdesouza@igalia.com>
Reviewed-by: Andrey Kosyakov <caseq@chromium.org>
Reviewed-by: Ben Kelly <wanderview@chromium.org>
Commit-Queue: David Trainor <dtrainor@chromium.org>
Reviewed-by: Ari Chivukula <arichiv@chromium.org>
Reviewed-by: Rayan Kanso <rayankans@chromium.org>
Reviewed-by: David Trainor <dtrainor@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1110423}
2023-02-27 17:47:16 +00:00
Andrew Williams
900eb3d1ec Remove IsolationInfo::CreatePartial
Removes IsolationInfo::CreatePartial and updates the remaining two
uses of it.

In the case of
WellKnownChangePasswordNavigationThrottle::WillStartRequest,
an IsolationInfo is available, so use that instead of creating a
new IsolationInfo from the NIK (which may have less information when
we are experimenting with a 2.5-keyed NIK).

For BackgroundFetchServiceImpl::CreateForWorker, there's no
IsolationInfo available, but since this is called for Service
Workers, and a StorageKey is available, it seems logical to create
an IsolationInfo from that to align with what the Service Worker
itself will be partitioned by. This is similar to what's done in
RenderProcessHostImpl::BindRestrictedCookieManagerForServiceWorker.

Bug: 1414808
Change-Id: I1247fed903252becddf8fdc3f81589bedbbee677
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4247660
Reviewed-by: Vasilii Sukhanov <vasilii@chromium.org>
Reviewed-by: Rayan Kanso <rayankans@chromium.org>
Commit-Queue: Andrew Williams <awillia@chromium.org>
Reviewed-by: Matt Menke <mmenke@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1106625}
2023-02-17 04:40:13 +00:00
Ari Chivukula
c81e13e937 [StorageKey Cleanup] (2) Rename CreateFirstParty constructors
FOR REVIEWERS - This is a large CL, sorry about that. Please review just
the files you're an owner for. In almost all cases, the changes should
be minimal and straightforward.

There's a need to keep StorageKey and BlinkStorageKey partial sync, but
as each organically grew this has gotten lost. As we wrap up and launch
storage partitioning, we should leave this code in a good state.

This CL swaps out the origin constructor for a new static function
called CreateFirstParty. The reason for this is to ensure callsites know
that they are explicitly creating a first-party only StorageKey and
might be missing context important to partition storage. Further, if in
the future we were to want to deprecate this construction method in
prod, we would need a static function we could re-name like this
and so migrating to this style of syntax will make that easier.

This CL is part of a series:
(1) Organize public functions and map work
(2) Rename CreateFirstParty constructors
(3) Rename CreateWithNonce constructors
(4) Rename Create constructors
(5) Remove old test constructors
(6) Define opaque origin behavior

Bug: 1410254
Change-Id: I0be1305f91a454484c68d0faf4015bad3afe05ed
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4251237
Owners-Override: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Steven Bingler <bingler@chromium.org>
Auto-Submit: Ari Chivukula <arichiv@chromium.org>
Commit-Queue: Ari Chivukula <arichiv@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1105850}
2023-02-15 20:44:57 +00:00
Dustin J. Mitchell
6ae08d2d6f Keep a StorageKey in BackgroundFetchMetadata
This structure previously held only an origin, with conversions to/from
StorageKey. This loses storage-partitioning information such as
`top_level_site` and `ancestor_chain_bit`.

With this change, the entire StorageKey is serialized into the metadata.

This metadata is stored on-disk, so the implementation must also handle
"old" values not containing a storage key. It handles this case by
generating a storage key from the existing `origin` field, which was
the existing behavior.

If both fields are missing, then the existing behavior remains: the
situation is interpreted as a storage key with an opaque origin.

Bug: 1402863
Change-Id: I5787acad27028e2d41fc030a7bc73a05c74b5c25
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4221513
Reviewed-by: Peter Beverloo <peter@chromium.org>
Code-Coverage: Findit <findit-for-me@appspot.gserviceaccount.com>
Reviewed-by: Andrew Williams <awillia@chromium.org>
Commit-Queue: Dustin Mitchell <djmitche@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1101891}
2023-02-07 00:57:44 +00:00
Kasie Wang
ba02612b5b Saving and reading home tab icons to proto
Icons for the home tab within the tab strip specified in the manifest are saved (without filtering) through proto. Icons are saved as ImageResource, keeping the same shape it is set as in the manifest.

Change-Id: I2cce28fc171e2fc238cf2bc8fdc4205a2b6a0fd2
Bug: 1381377
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4136334
Reviewed-by: Peter Beverloo <peter@chromium.org>
Reviewed-by: Eric Willigers <ericwilligers@chromium.org>
Commit-Queue: Eric Willigers <ericwilligers@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1094699}
2023-01-19 21:58:59 +00:00