0
Commit Graph

39 Commits

Author SHA1 Message Date
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
Alex Moshchuk
15d6c14f5e Cancel all ongoing navigations at the start of profile shutdown.
Normally, in response to profile shutdown, features above //content
(such as the tab strip) destroy the WebContents that they own, which
also destroys the associated frame trees and its FrameTreeNodes and
cancels any ongoing navigations. Unfortunately, there have been
several bugs where the WebContents was not properly destroyed and
was allowed to outlive the BrowserContext (e.g.,
https://crbug.com/40062641, https://crbug.com/40243371,
https://crbug.com/358487779). Although there are mechanisms to catch
the creator of WebContents when this happens (see
~WebContentsOfBrowserContext) and collect crash keys, it is suspected
that they aren't always reached due to earlier crashes, at least some
of which are triggered by navigations that are still proceeding in
the dangling WebContents, after the profile shutdown has begun and its
RenderProcessHosts have been told to shut down (in
BrowserContext::NotifyWillBeDestroyed), but before the BrowserContext
destructor actually runs. So far, we've been playing whack-a-mole
(e.g., https://crrev.com/c/5755530), trying to add early returns to
various points in the middle of navigations in case they're reached
when the underlying profile is being destroyed.

In an attempt to more systematically mitigate the damage when this bug
happens, this CL adds "fallback" code to cancel any ongoing
navigations that are still around at the point of
BrowserContext::NotifyWillBeDestroyed(). This will avoid reaching the
numerous async points in the navigation flow during profile shutdown,
which could break assumptions in the navigation stack and lead to
crashes. Examples of those include GetFrameHostForNavigation trying to
create a process in a destroyed profile (https://crbug.com/40274462),
attempts to commit a resumed navigation where profile started shutting
down while it was deferred (https://crbug.com/355334226), etc.

Combining this with checks to prevent new navigations from starting
during profile shutdown (which are already partially there and will
be completed in followup work) should ensure that no navigation code
runs during (or after) profile destruction.

Doc: https://docs.google.com/document/d/1vfq22Atc_GUoRs-vGtQ6lbMRzSuio5pHZk5buzTX6P4/edit?usp=sharing&resourcekey=0-G9WuZdN2CLXToJEUwzwdYQ

Bug: 40274462, 355334226, 346864141
Change-Id: I496621052d34525b4c1676e72c9dbe2740cb46e7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5875148
Reviewed-by: Charlie Reis <creis@chromium.org>
Reviewed-by: Alex Ilin <alexilin@chromium.org>
Commit-Queue: Alex Moshchuk <alexmos@chromium.org>
Auto-Submit: Alex Moshchuk <alexmos@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1364251}
2024-10-04 16:02:25 +00:00
Khushal Sagar
94ea2dc490 content: Move all finch controlled config for navigation transitions.
Refactor the cache budgeting to use finch parameters. Also move it to
a common file for all settings which can be controlled via finch.

Bug: 40256003
Change-Id: I4bcee9124318ed0fe25d7f2ef5d95bba59e52f21
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5758306
Reviewed-by: Dave Tapuska <dtapuska@chromium.org>
Reviewed-by: William Liu <liuwilliam@chromium.org>
Reviewed-by: David Bokan <bokan@chromium.org>
Auto-Submit: Khushal Sagar <khushalsagar@chromium.org>
Commit-Queue: Khushal Sagar <khushalsagar@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1337958}
2024-08-06 17:15:26 +00:00
Christian Biesinger
c59336f303 [FedCM] Move delegate implementation to content/browser
Currently, there is no default implementation of the federated identity
delegates in content/browser. In order to make FedCM work in headless,
this CL moves the in-memory delegate implementation from content/shell
to content/browser.

Bug: 336561988
Change-Id: I5097f86c76bcd5bb41193ef14f16d1b2f0eef6a7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5740871
Reviewed-by: Nicolás Peña <npm@chromium.org>
Commit-Queue: Christian Biesinger <cbiesinger@chromium.org>
Reviewed-by: Dave Tapuska <dtapuska@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1333637}
2024-07-26 17:08:22 +00:00
Peter Boström
cb0d53064e Rename DUMP_ version of NOTREACHED()
NOTREACHED_NORETURN() is now a synonym for NOTREACHED() which we'll
eventually move over to completely. Renaming
DUMP_WILL_BE_NOTREACHED_NORETURN() first makes
s/NOTREACHED_NORETURN/NOTREACHED easier.

Bug: 40580068
Change-Id: I565a899b00796bc342f5a907ed1287bb5d680a57
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5595035
Owners-Override: danakj <danakj@chromium.org>
Reviewed-by: danakj <danakj@chromium.org>
Commit-Queue: danakj <danakj@chromium.org>
Commit-Queue: Peter Boström <pbos@chromium.org>
Auto-Submit: Peter Boström <pbos@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1310055}
2024-06-04 18:45:31 +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
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
Peter Boström
36684f8d93 Downgrade NOTREACHEDs that still hit frequently
This turns topmost NOTREACHEDs, especially on ChromeOS, into
DUMP_WILL_BE_NOTREACHED_NORETURNs to exclude them from the
kNotReachedIsFatal experiment.

These were found by looking at the topmost crashes with [NOTREACHED] on
a ~2-week-old Dev release for all platforms.

Bug: 40580068
Change-Id: Id7a0db94226cfb91c8955bb45bca6a7d5ffc1502
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5289195
Owners-Override: Lei Zhang <thestig@chromium.org>
Auto-Submit: Peter Boström <pbos@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1259978}
2024-02-13 19:32:55 +00:00
Arthur Sonzogni
ff8375879e Deduplicate BrowserContext's ResourceContext
This seems to be an empty class meant to be removed at some point.
Today, this is only a class supporting `SupportsUserData`.

I observed every content/ embedder was required to provide one, and none
of them was really providing some kind of customization.

This patch merge all the different embedders implementations into
the content/ implementation. This has the
side effect of helping linnan@chromium.org to remove a dangling pointer.
This is an alternative to her patch from:
https://chromium-review.googlesource.com/c/chromium/src/+/5132493

Bug: chromium:1471070, chromium:908955
Change-Id: I4938957822d0a77be642aef3098faaa87616295f
Fixed: 1471070
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5139789
Commit-Queue: Arthur Sonzogni <arthursonzogni@chromium.org>
Reviewed-by: John Abd-El-Malek <jam@chromium.org>
Auto-Submit: Arthur Sonzogni <arthursonzogni@chromium.org>
Owners-Override: John Abd-El-Malek <jam@chromium.org>
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Cr-Commit-Position: refs/heads/main@{#1240500}
2023-12-22 10:05:45 +00:00
Daniel Cheng
cb3ab647b4 Simplify BrowserContext::ForEachLoadedStoragePartition with FunctionRef.
base::RepeatingCallback is intended for asynchronous callbacks. In this
case, the callback is always synchronously invoked, so use
base::FunctionRef to make it easier to write adapter lambdas.

Change-Id: I77dba1bab5d95c4f44a2d62e51ceeb232493ba84
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5050415
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Owners-Override: Rakina Zata Amni <rakina@chromium.org>
Reviewed-by: Rakina Zata Amni <rakina@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1227827}
2023-11-22 06:41:59 +00:00
Scott Haseley
2a05a493f8 Move SW service shutdown to StoragePartitionImpl
Follow-up from crrev.com/c/4869214. This moves shutting down of
ServiceWorkerContext and SharedWorkerService from
BrowserContextImpl::NotifyWillBeDestroyed to
StoragePartitionImpl::OnBrowserContextWillBeDestroyed.

Bug: 1492282
Change-Id: I74b8c88540771e4f11efc0cd8e8183b5998c6f30
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4961074
Reviewed-by: Alex Moshchuk <alexmos@chromium.org>
Commit-Queue: Scott Haseley <shaseley@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1213569}
2023-10-23 16:59:32 +00:00
Scott Haseley
c3dde9c711 Add StoragePartitionImpl::OnBrowserContextWillBeDestroyed
StoragePartitionImpl::OnBrowserContextWillBeDestroyed is called by
BrowserContextImpl prior to destruction, which allows the partition to
shut down objects that hold raw pointers to about-to-be-destroyed
objects. This fixes dangling pointers in content_index and
FileSystemAccessManager** that result from objects being destroyed in
~ProfileImpl before shutting down all partitions.

**This CL also changes a couple browser tests to clear the testing
permission context to fix the remaining FileSystemAccessManager
dangling pointer causes.

Bug: 1471071, 1471072, 1471074
Change-Id: I569a2051f9e69e53f2d88d3ce4b6caeb4f74549f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4869214
Reviewed-by: Alex Moshchuk <alexmos@chromium.org>
Reviewed-by: Sergey Poromov <poromov@chromium.org>
Commit-Queue: Scott Haseley <shaseley@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1209101}
2023-10-12 21:47:32 +00:00
Jack Hsieh
926fda3ac3 Reland "service worker: ServiceWorkerContextWrapper to maintain browser context"
This reverts commit 02c2da9705.

Reason for revert: Issue identified in https://crbug.com/1473204#c6.

Original change's description:
> Revert "service worker: ServiceWorkerContextWrapper to maintain browser context"
>
> This reverts commit b53126e0dd.
>
> Reason for revert: Causing consistent test failures on Linux Tests (Wayland) builder
> i.e. https://ci.chromium.org/ui/p/chromium/builders/ci/Linux%20Tests%20(Wayland)/41977/test-results?sortby=&groupby=
>
> Original change's description:
> > service worker: ServiceWorkerContextWrapper to maintain browser context
> >
> > This CL makes ServiceWorkerContextWrapper to maintain the browser
> > context by itself rather than having the dependency of
> > ServiceWorkerProcessManager. This is to avoid the complication when
> > destroying its own members. For example, ServiceWorkerContextCore
> > requires a valid browser context during destruction and
> > ServiceWorkerContextWrapper ends up needing to be careful on the
> > sequence of shutting down ServiceWorkerProcessManager and destroying
> > ServiceWorkerContextCore.
> >
> > Bug: 1473204
> > Change-Id: I9a8a82f3e228fda41041be74f88b308e776d8f53
> > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4791907
> > Reviewed-by: Hiroki Nakagawa <nhiroki@chromium.org>
> > Reviewed-by: Yoshisato Yanagisawa <yyanagisawa@chromium.org>
> > Commit-Queue: Jack Hsieh <chengweih@chromium.org>
> > Reviewed-by: John Abd-El-Malek <jam@chromium.org>
> > Cr-Commit-Position: refs/heads/main@{#1186148}
>
> Bug: 1473204
> Change-Id: Ifdef33cfd43fdfe3539ee81a549d8ed63bc3efad
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4800630
> Owners-Override: Nidhi Jaju <nidhijaju@chromium.org>
> Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
> Auto-Submit: Nidhi Jaju <nidhijaju@chromium.org>
> Commit-Queue: Nidhi Jaju <nidhijaju@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#1186227}

Bug: 1473204
Change-Id: I10ce004f8fa2b73593016bac377f765747ab381e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4799843
Commit-Queue: Jack Hsieh <chengweih@chromium.org>
Reviewed-by: John Abd-El-Malek <jam@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1188050}
2023-08-24 22:23:31 +00:00
Nidhi Jaju
02c2da9705 Revert "service worker: ServiceWorkerContextWrapper to maintain browser context"
This reverts commit b53126e0dd.

Reason for revert: Causing consistent test failures on Linux Tests (Wayland) builder
i.e. https://ci.chromium.org/ui/p/chromium/builders/ci/Linux%20Tests%20(Wayland)/41977/test-results?sortby=&groupby=

Original change's description:
> service worker: ServiceWorkerContextWrapper to maintain browser context
>
> This CL makes ServiceWorkerContextWrapper to maintain the browser
> context by itself rather than having the dependency of
> ServiceWorkerProcessManager. This is to avoid the complication when
> destroying its own members. For example, ServiceWorkerContextCore
> requires a valid browser context during destruction and
> ServiceWorkerContextWrapper ends up needing to be careful on the
> sequence of shutting down ServiceWorkerProcessManager and destroying
> ServiceWorkerContextCore.
>
> Bug: 1473204
> Change-Id: I9a8a82f3e228fda41041be74f88b308e776d8f53
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4791907
> Reviewed-by: Hiroki Nakagawa <nhiroki@chromium.org>
> Reviewed-by: Yoshisato Yanagisawa <yyanagisawa@chromium.org>
> Commit-Queue: Jack Hsieh <chengweih@chromium.org>
> Reviewed-by: John Abd-El-Malek <jam@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#1186148}

Bug: 1473204
Change-Id: Ifdef33cfd43fdfe3539ee81a549d8ed63bc3efad
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4800630
Owners-Override: Nidhi Jaju <nidhijaju@chromium.org>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Auto-Submit: Nidhi Jaju <nidhijaju@chromium.org>
Commit-Queue: Nidhi Jaju <nidhijaju@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1186227}
2023-08-22 02:09:41 +00:00
Jack Hsieh
b53126e0dd service worker: ServiceWorkerContextWrapper to maintain browser context
This CL makes ServiceWorkerContextWrapper to maintain the browser
context by itself rather than having the dependency of
ServiceWorkerProcessManager. This is to avoid the complication when
destroying its own members. For example, ServiceWorkerContextCore
requires a valid browser context during destruction and
ServiceWorkerContextWrapper ends up needing to be careful on the
sequence of shutting down ServiceWorkerProcessManager and destroying
ServiceWorkerContextCore.

Bug: 1473204
Change-Id: I9a8a82f3e228fda41041be74f88b308e776d8f53
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4791907
Reviewed-by: Hiroki Nakagawa <nhiroki@chromium.org>
Reviewed-by: Yoshisato Yanagisawa <yyanagisawa@chromium.org>
Commit-Queue: Jack Hsieh <chengweih@chromium.org>
Reviewed-by: John Abd-El-Malek <jam@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1186148}
2023-08-21 23:35:20 +00:00
Adithya Srinivasan
8e0c92eefe Prefetch: Stop guarding code behind kPrefetchUseContentRefactor
The flag has been enabled by default for > 2 milestones.

Bug: 1299059
Change-Id: Ib0e11a50728a7a03c4fb5f0254d01cf01028f916
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4616149
Reviewed-by: Max Curran <curranmax@chromium.org>
Reviewed-by: Jeremy Roman <jbroman@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Commit-Queue: Adithya Srinivasan <adithyas@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1163135}
2023-06-27 19:15:04 +00:00
William Liu
055a3549f4 [navigation-transitions]: Cache screenshots for navigation entries
Introduce NavigationEntryScreenshot, which preserves a screenshot on the
current NavigationEntry when the user is navigating away from it. The
stored screenshot will later be used to present the user with a preview,
when the user navigates back to this page.

The caching mechanism is composed of the screenshot, the cache and a
global manager. The global manager lives on the BrowserContext and is
responsible for memory budgeting. The cache lives on the primary
NavigationController which owns the NavigationEntry where the
screenshot is stashed.

This CL contains the impl of caching, retrieving and eviction of the
screenshots with unittests. The cache is not integrated with the navigation thus no browsertest.

The code resides in `//content/browser/renderer_host/` because no need
to access WebContents.

[Updated] DD/Explainer (chromium access): https://docs.google.com/document/d/1-7TatVjSL4n-RNyvN_MWdFoOiR6YJ1BjvJKgvym_ArU

Feature EngDoc: https://docs.google.com/document/d/1H99XZHdAWNfbfboHbGdMB97k81AzAxVtPSizAjO2Poc/

PRD (google access): https://docs.google.com/document/d/1JMWzArv0VR-G4xx3a5ku8N5np8mDeGSuvR95kZc8ynY/

Bug: 1415332, 1413521
Change-Id: Icc3b2aa7b5b36ed460ad2ddd1ff5f645a38d2835
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4245857
Reviewed-by: Kyle Charbonneau <kylechar@chromium.org>
Commit-Queue: William Liu <liuwilliam@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1125127}
2023-04-02 17:21:19 +00:00
Hiroshige Hayashizaki
805be68671 Introduce prefetch_url_loader_helper.h/cc
This CL split the core, interceptor-independent parts of
PrefetchUrlLoaderInterceptor into prefetch_url_loader_helper.h/cc.

To remove dependencies to `PrefetchURLLoaderInterceptor`,
this CL injects GetPrefetchOriginProber/CopyIsolatedCookies
in unit tests via `TestPrefetchService`
instead of via `TestPrefetchURLLoaderInterceptor`.

This CL doesn't change the behavior.

Bug: 1422820
Change-Id: If091ddb511f6631b6f5769bca2037bd46c8b835f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4150615
Commit-Queue: Hiroshige Hayashizaki <hiroshige@chromium.org>
Reviewed-by: Max Curran <curranmax@chromium.org>
Reviewed-by: Arthur Sonzogni <arthursonzogni@chromium.org>
Reviewed-by: Lingqi Chi <lingqi@chromium.org>
Reviewed-by: Kouhei Ueno <kouhei@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1122886}
2023-03-28 08:16:22 +00:00
Peter Boström
db4913e7d5 Remove redundant DWC in BrowserContextImpl
NOTREACHED() currently uploads using DumpWithoutCrashing so we get
duplicate reports for all of these.

Bug: 1423567
Change-Id: I9953c10772a0c7aba5ffee0c4c8b57a2aa5eb96e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4345488
Reviewed-by: Avi Drissman <avi@chromium.org>
Commit-Queue: Avi Drissman <avi@chromium.org>
Auto-Submit: Peter Boström <pbos@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1118223}
2023-03-16 18:25:23 +00:00
Nicolas Ouellet-Payeur
3f7c36a603 ~BrowserContextImpl(): include crashkey in NOTREACHED()
~BrowserContextImpl() detects dangling RenderProcessHost, and uploads a
crash report via NOTREACHED and DumpWithoutCrashing. However, the
crash-key is defined *after* the NOTREACHED call, so it's only
included in the DumpWithoutCrashing reports. In DCHECK-enabled builds,
the NOTREACHED crash report doesn't actually include this crash key,
making the issue harder to troubleshoot.

Move the NOTREACHED call down one line, so the crash report includes
the crash key.

Bug: 1409750
Change-Id: I50e023a28a2de1422e54e0243e246c8c6554b600
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4287687
Reviewed-by: Arthur Sonzogni <arthursonzogni@chromium.org>
Commit-Queue: Arthur Sonzogni <arthursonzogni@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1110273}
2023-02-27 11:37:10 +00:00
Robbie McElrath
785b5e03a0 Rename ForEachStoragePartition to ForEachLoadedStoragePartition
This CL renames BrowserContext::ForEachStoragePartition to
ForEachLoadedStoragePartition to capture that it only iterates over
loaded StoragePartitions, and updates several comments in BrowserContext
to clarify StoragePartition lifetime-related behavior.

This also renames GetStoragePartitionCount to
GetLoadedStoragePartitionCount for the same reason.

Change-Id: I14dd6ed6c076989ae4d7dd04ae0e91da5a15f171
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4163530
Reviewed-by: Alex Moshchuk <alexmos@chromium.org>
Owners-Override: Alex Moshchuk <alexmos@chromium.org>
Commit-Queue: Robbie McElrath <rmcelrath@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1093642}
2023-01-18 00:32:46 +00:00
Etienne Noel
2ac27c2761 Supporting storage buckets in 'Clear-Site-Data' header
This cl adds support for deleting specific storage buckets using
the clear-site-data http header.

The explainer is available here: `https://github.com/WICG/storage-buckets/blob/gh-pages/explainer.md#storage-buckets-and-the-clear-site-data`

Also removed expired `Navigation.ClearSiteData.Parameters` histogram.

Bug: 1354360

Change-Id: I70a6be39bafd946db5c5eb1e3cfeb77b291ee0fc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3910656
Reviewed-by: Joshua Bell <jsbell@chromium.org>
Reviewed-by: Evan Stade <estade@chromium.org>
Reviewed-by: Alex Moshchuk <alexmos@chromium.org>
Commit-Queue: Etienne Noël <etiennenoel@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1079625}
2022-12-06 04:28:46 +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
Sreeja Kamishetty
f66553a7c2 Move content/browser/speculation_rules/prefetch directory to //preloading/
With our Precog effort, we want to bring together all Preloading code
together at one place to bring more structuring and reusing the common logic between various preloading types and predictors to decrease the code complexity.

In this CL, we move all files in the
content/browser/speculation_rules/prefetch directory to
content/browser/preloading/prefetch.

This is a no-op move.

For more details on directory structuring please see:
https://docs.google.com/document/d/13SnVgi16aD6X0rb-b4_F5h-7Reb9iGY_cKfzHZmXGDg/edit?usp=sharing

BUG=1337129

Change-Id: I1a6d85fa1dc1ad7927210fcbf0cf1785dfc5a433
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3741130
Reviewed-by: Max Curran <curranmax@chromium.org>
Commit-Queue: Sreeja Kamishetty <sreejakshetty@chromium.org>
Reviewed-by: Ryan Sturm <ryansturm@chromium.org>
Auto-Submit: Sreeja Kamishetty <sreejakshetty@chromium.org>
Reviewed-by: Simon Pelchat <spelchat@chromium.org>
Reviewed-by: Christian Dullweber <dullweber@chromium.org>
Reviewed-by: Alexander Timin <altimin@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1024306}
2022-07-14 17:41:27 +00:00
Max Curran
146bf4437d Check eligibility of new prefetches.
This CL adds the eligibility check to the content/ refactor of the
prefetch code. Some of the checks are not possible within content/ and
will require a delegate. The delegate will be added in a later CL.

Bug: 1299059
Change-Id: I4a58f670f11e86ea23a1123c6eb42d1debe4d4dc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3537152
Reviewed-by: Ryan Sturm <ryansturm@chromium.org>
Reviewed-by: Arthur Sonzogni <arthursonzogni@chromium.org>
Commit-Queue: Max Curran <curranmax@chromium.org>
Cr-Commit-Position: refs/heads/main@{#986205}
2022-03-28 23:22:14 +00:00
Alexander Timin
074cd18fa3 [tracing] Use TracedProto in //content.
Use the new ability to write typed messages into the untyped and untyped
into typed to eliminate WriteIntoTrace(TracedValue) /
WriteIntoTrace(TracedProto) duplicated methods in //content.

After this patch, all key //content types listed below now have
corresponding proto messages (with DebugAnnotation support) and
WriteIntoTrace(TracedValue) methods have been removed:
- BrowserContext
- BrowsingContextState
- FrameTreeNode
- NavigationRequest
- RenderFrameHost
- RenderFrameProxyHost
- RenderViewHost
- SiteInstance
- SiteInstanceGroup
- GlobalRenderFrameHostId

This patch also adds a few `const` qualifiers to the appropriate methods
in //content to ensure that all WriteIntoTrace methods can be marked as
const.

R=rakina@chromium.org

Bug: 1137154
Change-Id: I306e7619f594e2a02ca24183720714f234661ff4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3540169
Reviewed-by: Rakina Zata Amni <rakina@chromium.org>
Reviewed-by: Alex Ilin <alexilin@chromium.org>
Commit-Queue: Alexander Timin <altimin@chromium.org>
Cr-Commit-Position: refs/heads/main@{#984436}
2022-03-23 18:11:22 +00:00
Hans Wennborg
a8911afc4c Cull two large includes from storage_partition_impl.h
Don't include devtools_background_services_context_impl.h or
shared_worker_service_impl.h. This saves 391 MB of total compiler input
size for the 'chrome' target on Linux.

Bug: 242216
Change-Id: Ibc2f107c93f7bcf712b6f8b2daed73c2c74f2699
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3501697
Reviewed-by: Nasko Oskov <nasko@chromium.org>
Commit-Queue: Hans Wennborg <hans@chromium.org>
Cr-Commit-Position: refs/heads/main@{#983742}
2022-03-22 09:57:03 +00:00
Max Curran
6c2835eabe Establish high level structure of PrefetchProxy client refactor.
This CL creates the main classes of this refactor, and outlines their
responsibilities and major dependencies. These classes will be completed
in future CLs.

Bug: 1299059
Change-Id: Iff1c2b0de4e6d6e517d89e350ee94fb31c6165aa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3475599
Reviewed-by: Ryan Sturm <ryansturm@chromium.org>
Reviewed-by: Simon Pelchat <spelchat@chromium.org>
Reviewed-by: Arthur Sonzogni <arthursonzogni@chromium.org>
Commit-Queue: Max Curran <curranmax@chromium.org>
Cr-Commit-Position: refs/heads/main@{#978388}
2022-03-07 19:52:38 +00:00
Johannes Kron
b1209bd19e Store WebRTC MediaCapabilities stats to local DB
This CL introduces the classes
WebrtcVideoPerfReporter
WebrtcVideoPerfRecorder
WebrtcVideoPerfHistory

The Reporter sends stats from the render process over mojo
to the Recorder in the browser process. The Recorder
keeps track of the current encode and decode stream configuration
and forwards the data to the History class.
History verifies that the stats look okay and persists to the local
database. History also retrieves stats from the database that are
used in order to predict if a certain configuration will be smooth
or not.

This CL implements functionality needed for the WebRTC
MediaCapabilities implementation. The binary size will therefore
be increased. I will do a follow-up CL that the reuses the
PendingOperation code that is shared between VideoDecodeStatsDBImpl
and WebrtcVideoStatsDBImpl.

Bug: chromium:1187565
Change-Id: I6588299611e591ab318e6ebe9d9bae825f9dd09e
Binary-Size: Size increase is unavoidable (see above).
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3443426
Reviewed-by: Matthew Denton <mpdenton@chromium.org>
Reviewed-by: Henrik Boström <hbos@chromium.org>
Reviewed-by: Chrome Cunningham <chcunningham@chromium.org>
Reviewed-by: Jeremy Roman <jbroman@chromium.org>
Reviewed-by: Arthur Sonzogni <arthursonzogni@chromium.org>
Commit-Queue: Johannes Kron <kron@chromium.org>
Cr-Commit-Position: refs/heads/main@{#971146}
2022-02-15 10:32:39 +00:00
Arthur Sonzogni
2a0c01a2fe Add BrowserContextImpl::From(BrowserContext*)
* Rename BrowserContext::Impl into BrowserContextImpl
* Add static BrowserContextImpl::From(BrowserContext*)

This avoids content/ internal users to define in the content/public
browser_context.h new "friend" function, in order to access the
implementation from within content/

In the future, BrowserContext will be a pure interface, implemented by a
BrowserContextImpl. So, this is equivalent to the "future" possibility
of doing static_cast<BrowserContext*>, but available to today.

This is similar to what we did with the
NavigationRequest/NavigationHandle class deduplication with
NavigationRequest::From(NavigationHandle*).

Practically, this will avoid patch:
https://chromium-review.googlesource.com/c/chromium/src/+/3443426/16
From forward declaring RenderFrameHostImpl* and some content::internal
namespace.

Bug: https://crbug.com/1179776

Change-Id: I33baeca3f70ed9bb791f7a50a4795546f46fbae8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3461652
Reviewed-by: Łukasz Anforowicz <lukasza@chromium.org>
Commit-Queue: Arthur Sonzogni <arthursonzogni@chromium.org>
Cr-Commit-Position: refs/heads/main@{#971109}
2022-02-15 08:28:46 +00:00
Ahmed Fakhry
766bac66d1 capture_mode_settings: Implement backend of the save-to dialog
This CL adds support for setting a custom save location for the
captured images and videos.
This will later be hooked to the new settings menu UI which is hidden
behind a flag.
This CL does not change the current behavior.

Later follow-up will handle edge cases if an arbitrary selected
folder becomes unavailable.

BUG=1250885
TEST=Manually, added new tests.

Change-Id: I17e09b20e4344d998565eadbefd48dca02ff16d8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3177404
Commit-Queue: Ahmed Fakhry <afakhry@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Reviewed-by: James Cook <jamescook@chromium.org>
Cr-Commit-Position: refs/heads/main@{#924609}
2021-09-24 02:36:19 +00:00
W. James MacLean
94cc8496d3 Split the shutdown-delay count from |keep_alive_ref_count_|.
DelayProcessShutdown() calls IncrementKeepAliveRefCount(), and
CancelProcessShutdownDelay() calls DecrementKeepAliveRefCount().
But shutdown delays are of a notably different duration than KeepAlives,
so this CL splits out the shutdown-delay count into a separate variable,
|shutdown_delay_ref_count_| so that we can more accurately track times
associated with each.

Bug: 1148542
Change-Id: Ie4e3019fa44a2e9f2b8200d4bc9e5cb34c450bb4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3133707
Commit-Queue: W. James MacLean <wjmaclean@chromium.org>
Reviewed-by: Eric Seckler <eseckler@chromium.org>
Reviewed-by: Colin Blundell <blundell@chromium.org>
Reviewed-by: Charlie Reis <creis@chromium.org>
Reviewed-by: Alex Moshchuk <alexmos@chromium.org>
Cr-Commit-Position: refs/heads/main@{#918961}
2021-09-07 21:51:40 +00:00
W. James MacLean
40d136c2e8 Split Worker ref-count from keep-alive ref count.
This CL implements tracking for workers separate from
fetch-keep-alive and delayed-subframe-unload tracking in RPHI.
In a follow-on CL we will add instrumentation to track the
time-remaining for fetch-keep-alive in order to better understand
when ChildProcessSecurityPolicy can safely clean up the
associated RenderProcess' information.

Bug: 1148542
Change-Id: I37e30a4e7533768135f3471297627fe16ab02a4f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2799937
Reviewed-by: Scott Violet <sky@chromium.org>
Reviewed-by: Charlie Reis <creis@chromium.org>
Commit-Queue: W. James MacLean <wjmaclean@chromium.org>
Cr-Commit-Position: refs/heads/main@{#913794}
2021-08-20 14:53:07 +00:00
Hans Wennborg
78b521894c Add includes in preparation for leaner mojom.h files (2/3)
In order to reduce build times, generated mojom.h files will use
forward declarations more aggressively after https://crrev.com/c/2932644

In particular, mojom.h files which define an interface may not provide
full definitions of method parameter types defined in other mojoms.
This reduces the size of those interfaces, but it means that
implementors and callers of such methods may have to include more
headers, as is done in this CL.

Bug: 242216
Change-Id: I1ce4ae3cd675888a172c35d9df6af5cfc29ccff8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2962433
Commit-Queue: Hans Wennborg <hans@chromium.org>
Auto-Submit: Hans Wennborg <hans@chromium.org>
Reviewed-by: Nico Weber <thakis@chromium.org>
Owners-Override: Nico Weber <thakis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#892550}
2021-06-15 13:42:15 +00:00
Daniel Cheng
bf5afa01d6 Fix / clean up crash key usage in //content
- Crash keys that are scope-limited have been migrated to the
  easier-to-use SCOPED_CRASH_KEY_* macros.
- Callers that leaked the result of AllocateCrashKeyString
  have been updated to cache the returned pointer in a variable
  with static storage duration.
- All static storage duration variables that point to crash keys
  have been marked with `const` to indicate the pointer should
  not be reassigned.

Change-Id: I62a889e863eb2f67011bb1a87b25d4c1a1e29de8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2915000
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Nasko Oskov <nasko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#886443}
2021-05-25 20:24:31 +00:00
Lukasz Anforowicz
b9a969a2ce Real instance methods for BrowserContext: StoragePartition methods.
This CL refactors non-overridable (i.e. implemented only within
//content) methods of `BrowserContext`, so that they are implemented as
instance methods (rather than as `static` methods taking a `self`
argument).  This particular CL refactors the following methods:
- GetStoragePartition
- GetStoragePartitionForUrl
- ForEachStoragePartition
- GetStoragePartitionCount
- AsyncObliterateStoragePartition
- GarbageCollectStoragePartitions
- GetDefaultStoragePartition

Using instance methods (e.g. modifying all the callsites to use
instance method invocation syntax) is a prerequisite for splitting
BrowserContext into BrowserContextImpl+BrowserContextDelegate.  In
particular, in the long-term, the refactored methods should be
pure-virtual methods of BrowserContext that are overriden/implemented by
BrowserContextImpl.  Such virtual methods would be *instance* methods -
this is what the current CL helps with.

Bug: 1179776
AX-Relnotes: n/a.
Change-Id: I6effd1da5c17f27579251d41051b6ea08f689faf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2725732
Reviewed-by: Łukasz Anforowicz <lukasza@chromium.org>
Reviewed-by: Charlie Reis <creis@chromium.org>
Auto-Submit: Łukasz Anforowicz <lukasza@chromium.org>
Commit-Queue: Charlie Reis <creis@chromium.org>
Owners-Override: Charlie Reis <creis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#877482}
2021-04-29 15:26:25 +00:00
Lukasz Anforowicz
287ec63cc5 Extract BrowserContext::CreateVideoDecodePerfHistory method.
Before this CL, the old BrowserContext::GetVideoDecodePerfHistory method
was mixing 2 responsibilities:

1. Lazily creating a VideoDecodePerfHistory object, storing
   and retrieving it.

2. Letting //content embedders override how VideoDecodePerfHistory
   is created.

In other words, the old GetVideoDecodePerfHistory method was partially
belonging to a (hypothetical/future) BrowserContextDelegate and
partially belonging to a BrowserContext::Impl.

After this CL, there are 2 separate methods:

- CreateVideoDecodePerfHistory controls how VideoDecodePerfHistory
  is created.  //content layer provides a default implementation, but
  //content embedders (e.g. OffTheRecordProfileImpl) may override the
  behavior.  In the long term, this method belongs in the
  (hypothetical/future) BrowserContextDelegate class.

- GetVideoDecodePerfHistory remains responsible for lazy creation,
  storing and retrieval of the VideoDecodePerfHistory object.  This
  method is not overridden by //content embedders (this CL removes some
  duplicate/no-longer-needed code from //content embeders) and no longer
  needs to be a virtual method.  In the long term, this method belongs
  in the (hypothetical/future) BrowserContextImpl class.

Bug: 1179776
Change-Id: I38ec9532dd2308df968f4979a13d6fbb7473d9fb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2720012
Reviewed-by: Chrome Cunningham <chcunningham@chromium.org>
Reviewed-by: Mihai Sardarescu <msarda@chromium.org>
Reviewed-by: Kevin Marshall <kmarshall@chromium.org>
Reviewed-by: Charlie Reis <creis@chromium.org>
Commit-Queue: Łukasz Anforowicz <lukasza@chromium.org>
Cr-Commit-Position: refs/heads/master@{#870232}
2021-04-07 22:07:39 +00:00
Lukasz Anforowicz
729a9e1c5f Avoid using UserData in //content/browser/browser_context.cc
Before this CL, //content/browser/browser_context.cc would rely on
base::SupportsUserData to simulate 10+ fields of BrowserContext.  The
motivation for this was to hide //content-internal details (e.g. the
fields and their types) from //content/public API (e.g. from the
declaration of the BrowserContext class).

After this CL, explicit fields are used while still being hidden from
//content/public API behind a private, fwd-declared Impl class.

Motivation:

- Removing the SupportsUserData dependency is a necessary step toward
  migration to separate BrowserContext, BrowserContextImpl and
  BrowserContextDelegate classes.

- Explicit fields are easier to read and use (when coding or when
  using a debugger).

Bug: 1179776
Change-Id: Ifdc3ff1d7b945678fa0a915af780c9631c998058
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2706279
Commit-Queue: Łukasz Anforowicz <lukasza@chromium.org>
Reviewed-by: Chrome Cunningham <chcunningham@chromium.org>
Reviewed-by: John Abd-El-Malek <jam@chromium.org>
Reviewed-by: danakj <danakj@chromium.org>
Cr-Commit-Position: refs/heads/master@{#868166}
2021-03-31 17:44:01 +00:00