ScopedNestableTaskAllower allows application tasks in native loops and
RunLoops that run within its scope. It is deprecated.
If the intent is to allow application tasks in a native loop, it
should be replaced with ScopedAllowApplicationTasksInNativeNestedLoop.
If the intent is to allow application tasks in a RunLoop, the RunLoop
should be constructed with Type::kNestableTasksAllowed.
If no loop (native or RunLoop) runs within the scope of the
ScopedNestableTaskAllower, it should just be removed.
We manually inspected the code to determine the appropriate replacement
for each remaining use.
Bug: 781352
Change-Id: I007bd0a0f9d6aa938f879f48864a9400808d486b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4035451
Reviewed-by: Gabriel Charette <gab@chromium.org>
Owners-Override: Gabriel Charette <gab@chromium.org>
Commit-Queue: Francois Pierre Doray <fdoray@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1075631}
To migrate to v3 task posting API, this CL moves moves
(Sequenced|Thread)TaskRunnerHandle::Get() to
(Sequenced|SingleThread)TaskRunner::GetCurrentDefault()
and related classes. For more detail on this migration, refer to
https://docs.google.com/document/d/1tssusPykvx3g0gvbvU4HxGyn3MjJlIylnsH13-Tv6s4/edit#bookmark=id.1umyn7v5a4p
The blink codebase's presubmits were substantially changed. This was
done because the presubmit did not parse in-class identifiers, and so
there was no way of banning inner classes/methods/identifiers of a
class which is allowed.
The reason this was needed for this CL is that
base::(Sequenced|SingleThread)TaskRunners are permitted in blink, but
we need to ban (Sequenced|SingleThread)TaskRunner::GetCurrentDefault()
and [...]::CurrentDefaultHandle to ensure that tasks in blink remain
properly labeled.
To this end, a new type of identifier (in-class identifiers, such as
nested::namespace::ClassName::EnumClassName) is parsed by the
presubmit, and a new kind of rule can be added to the _CONFIG file to
allow/deny them. They are parsed very similarly to the existing
identifiers, but crucially, they are allowed by default, whereas
ClassNames are denied by default.
In addition, the tests for the presubmit were mostly rewritten to
properly test whether the identifiers in the test are actually
allowed/disallowed. Instead of simply testing to see whether an
identifier is present in _CONFIG in the presubmit file, the
presubmit's functions are called in the same way as happens during the
presubmit to make sure the code being run actually works.
Finally, it also tests that the identifiers tested are fully parsed
(a handful of them weren't because they were either preceded by '::'
or in-class) by the presubmit.
The task runner handle classes still exist in the codebase, and no
existing Chromium code has been modified, as semantics have been
preserved despite the implementation change.
The implementation migration will then take place in future CLs.
Because the two APIs expose the same functionality, the codebase
can be incrementally migrated.
Bug: 1026641
Change-Id: I7ea7bb36f30ecd3cdefedcffd8bae16118b0f3d2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3804911
Reviewed-by: Francois Pierre Doray <fdoray@chromium.org>
Commit-Queue: Sean Maher <spvw@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1050813}
To aid conversions, first removed "using base::TimeDelta;" and converted
TimeDelta to base::TimeDelta in the affected files. Then converted all
TimeDelta::FromX() and TimeDelta().FromX() (!) into X().
The changes in this CL were all performed by tools; no manual
interventions occurred.
Bug: 1243777
Change-Id: Iddcb80d7883fd494d2209d01945a6553f316ff95
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3202380
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Owners-Override: Peter Kasting <pkasting@chromium.org>
Reviewed-by: Peter Boström <pbos@chromium.org>
Cr-Commit-Position: refs/heads/main@{#928323}
The browser process no longer does network requests on the IO thread.
Also expand on what "handles IPC" means as often Mojo interfaces are
not on the IO thread.
Change-Id: I7e449cda99b4527316c27bf8e1557fa030877ff0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3061781
Commit-Queue: Matt Falkenhagen <falken@chromium.org>
Reviewed-by: Ken Rockot <rockot@google.com>
Cr-Commit-Position: refs/heads/master@{#909087}
Add JobHandle::IsComplete and pass worker_count as argument to
max_concurrency_callback.
To make better use of worker_lock, and accommodate worklist use case by
exposing worker count:
- worker_count is used in max_concurrency_callback in cases where the
return value is inferred from it. In the worklist case, each active
worker keep a local segment not visible globally, so worker_count is
added to the global queue size.
- IsComplete is used to make sure that no work is pending. In the
worklist case, checking that we're done involves checking that the
global queue is empty AND that worker_count == 0 (atomically), which
is a lot easier when |worker_lock| is taken. This is used e.g. in
marking to switch phase (we don't want to cancel or join) where we
stop creating work.
Bug: 1114823
Change-Id: I5efc5622aa70e731981a958a066ab56567c603ed
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2304972
Reviewed-by: Omer Katz <omerkatz@chromium.org>
Reviewed-by: Jochen Eisinger <jochen@chromium.org>
Reviewed-by: François Doray <fdoray@chromium.org>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Commit-Queue: Etienne Pierre-Doray <etiennep@chromium.org>
Cr-Commit-Position: refs/heads/master@{#797359}
This is a reland of
https://chromium-review.googlesource.com/c/chromium/src/+/1932464 with
a missing #include added to assistant_test_mixin.cc.
The Run() timeouts set for tests now default to crashing the calling
process. This ensures that Run() timeouts cause visible failures
regardless of whether the calling suite uses GTest. Suites which do use
GTest can switch to having timeouts reported via GTEST_FAIL() by calling:
base::test::ScopedRunLoopTimeout::SetUseGTestFailOnTimeout();
Test suites derived from base::TestSuite will have this option set for
them as part of the TestSuite initialization.
The RunLoop::ScopedRunTimeoutForTest helper is moved to
base::test::ScopedRunLoopTimeout, to allow it to have GTest dependencies.
TBR=gab@chromium.org,kmarshall@chromium.org
Cq-Include-Trybots: luci.chrome.try:linux-chromeos-chrome
Bug: 1021777, 1014767
Change-Id: I1f6674913e06607b07c40020341a9e25ef75b72e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2044082
Auto-Submit: Wez <wez@chromium.org>
Commit-Queue: Scott Violet <sky@chromium.org>
Reviewed-by: Scott Violet <sky@chromium.org>
Reviewed-by: Wez <wez@chromium.org>
Cr-Commit-Position: refs/heads/master@{#739911}
This reverts commit e7f522eeb9.
Reason for revert: suspect causing compile failure on linux-chromeos-chrome.
Sample build: https://ci.chromium.org/p/chrome/builders/ci/linux-chromeos-chrome/2923
Sample log: https://logs.chromium.org/logs/chrome/buildbucket/cr-buildbucket.appspot.com/8888898680396285712/+/steps/compile/0/stdout?format=raw
E.g.
../../chrome/browser/ui/ash/assistant/assistant_test_mixin.cc:323:42: error: variable has incomplete type 'const base::test::ScopedRunLoopTimeout'
const base::test::ScopedRunLoopTimeout run_timeout(wait_timeout);
^
../../base/run_loop.h:28:7: note: forward declaration of 'base::test::ScopedRunLoopTimeout'
class ScopedRunLoopTimeout;
^
../../chrome/browser/ui/ash/assistant/assistant_test_mixin.cc:356:42: error: variable has incomplete type 'const base::test::ScopedRunLoopTimeout'
const base::test::ScopedRunLoopTimeout run_timeout(wait_timeout);
^
../../base/run_loop.h:28:7: note: forward declaration of 'base::test::ScopedRunLoopTimeout'
class ScopedRunLoopTimeout;
^
../../chrome/browser/ui/ash/assistant/assistant_test_mixin.cc:371:42: error: variable has incomplete type 'const base::test::ScopedRunLoopTimeout'
const base::test::ScopedRunLoopTimeout run_timeout(wait_timeout);
^
../../base/run_loop.h:28:7: note: forward declaration of 'base::test::ScopedRunLoopTimeout'
class ScopedRunLoopTimeout;
^
3 errors generated.
Original change's description:
> [base] Make test Run() timeouts fatal unless using GTest.
>
> The Run() timeouts set for tests now default to crashing the calling
> process. This ensures that Run() timeouts cause visible failures
> regardless of whether the calling suite uses GTest. Suites which do use
> GTest can switch to having timeouts reported via GTEST_FAIL() by calling:
>
> base::test::ScopedRunLoopTimeout::SetUseGTestFailOnTimeout();
>
> Test suites derived from base::TestSuite will have this option set for
> them as part of the TestSuite initialization.
>
> The RunLoop::ScopedRunTimeoutForTest helper is moved to
> base::test::ScopedRunLoopTimeout, to allow it to have GTest dependencies.
>
> Bug: 1021777, 1014767
> Change-Id: Id372c666c6455e56e52034ae528b417a0c23143c
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1932464
> Commit-Queue: Wez <wez@chromium.org>
> Auto-Submit: Wez <wez@chromium.org>
> Reviewed-by: Scott Violet <sky@chromium.org>
> Reviewed-by: Gabriel Charette <gab@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#739760}
TBR=sky@chromium.org,wez@chromium.org,gab@chromium.org,kmarshall@chromium.org
Change-Id: Ib0927699042f216971448da8b1d70619c0545367
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 1021777, 1014767
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2045697
Reviewed-by: Takashi Sakamoto <tasak@google.com>
Commit-Queue: Takashi Sakamoto <tasak@google.com>
Cr-Commit-Position: refs/heads/master@{#739790}
The Run() timeouts set for tests now default to crashing the calling
process. This ensures that Run() timeouts cause visible failures
regardless of whether the calling suite uses GTest. Suites which do use
GTest can switch to having timeouts reported via GTEST_FAIL() by calling:
base::test::ScopedRunLoopTimeout::SetUseGTestFailOnTimeout();
Test suites derived from base::TestSuite will have this option set for
them as part of the TestSuite initialization.
The RunLoop::ScopedRunTimeoutForTest helper is moved to
base::test::ScopedRunLoopTimeout, to allow it to have GTest dependencies.
Bug: 1021777, 1014767
Change-Id: Id372c666c6455e56e52034ae528b417a0c23143c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1932464
Commit-Queue: Wez <wez@chromium.org>
Auto-Submit: Wez <wez@chromium.org>
Reviewed-by: Scott Violet <sky@chromium.org>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#739760}
This returns to the current task's task runner. Note there are some
situations where this is not valid:
* When we're not running a task (it will DCHECK).
* When we're in a one-off base::ThreadPool task (it will DCHECK).
* In non-scheduler backed threads (it will DCHECK).
Bug: 835323
Change-Id: I3a789557247240e0c36a47339574350d79746144
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1834094
Commit-Queue: Gabriel Charette <gab@chromium.org>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Reviewed-by: Rohit Rao <rohitrao@chromium.org>
Reviewed-by: François Doray <fdoray@chromium.org>
Cr-Commit-Position: refs/heads/master@{#707484}
This is
1) s/TestBrowserThreadBundle/BrowserTaskEnvironment/ on src/
2) s/([^/])\b\w*thread_bundle(_)?/\1task_environment\2/ on files modified in (1)
3) git cl format
4) Manually fix up remainder "ThreadBundle" and "thread_bundle" found via
string search on the whole of src/.
For ease of review:
* Step #3 is the diff between patch sets 1..2
* Step #4 is the diff between patch sets 2..3
TBR=dcheng@chromium.org
(for post-review owners bypass per mechanical change)
Bug: 992483
Change-Id: I4945141f6d78bdc6c98444198e5012ddc8e5bff0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1758440
Reviewed-by: Gabriel Charette <gab@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Commit-Queue: Gabriel Charette <gab@chromium.org>
Auto-Submit: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#688755}
(well half of them because git cl upload wouldn't let me do
them all at once...)
This is step #1 of the mass migration. Some of these will be
backported to SingleThreadTaskEnvironment in a later phase.
scoped_task_environment.h will also only move in a follow-up CL.
TBR=dcheng@chromium.org
Bug: 992483
Change-Id: I44bc376deee9b6c95bafac8d54165174d86a5001
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1756247
Reviewed-by: Gabriel Charette <gab@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Commit-Queue: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#688086}
This CL makes a SingleThreadTaskRunner example more explicit by using
the SingleThreadTaskRunner type instead of using the
SequencedTaskRunner base class.
Bug: N/A
Change-Id: I77fa2affacbda0f4847e4b808eab267f0977fb49
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1636668
Reviewed-by: Marijn Kruisselbrink <mek@chromium.org>
Commit-Queue: Dominic Farolino <domfarolino@gmail.com>
Cr-Commit-Position: refs/heads/master@{#665049}
In order to leave the base::ThreadPool symbol available for
an upcoming "destination" task trait.
Also moved ThreadPoolImpl to be the implementation of TaskExecutor,
not ThreadPoolInstance. It was a mistake that base::ThreadPool was
implementing TaskExecutor, its users shouldn't have access to
PostTask*() and Create*TaskRunner*().
TBR=fdoray@chromium.org
(bypass owners for side-effects beyond //base)
Bug: 968047
Change-Id: I0607fba6d7f30d202bf7f61a9f461b1256e87467
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1634851
Reviewed-by: Gabriel Charette <gab@chromium.org>
Reviewed-by: François Doray <fdoray@chromium.org>
Commit-Queue: Gabriel Charette <gab@chromium.org>
Auto-Submit: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#664300}
Mainly:
* Add a smoother introduction to the Core Concepts
(the previous nomenclature section assumed knowledged of some types
from the get-go).
* Try to avoid using yet-to-be-defined types everywhere (or make
references explicit).
* Stop referring to the old-vs-new codebase as the "new" paradigms
have been in place for a few years and the distinction is merely
confusing newcomers.
We will also look into adding a codelab to have a storylike approach
for newcomers which will be better suited than the point-by-point
how-to.
R=fdoray@chromium.org
Change-Id: I30fb7960796164496dab77b33bc33b39692b709e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1535489
Commit-Queue: Gabriel Charette <gab@chromium.org>
Reviewed-by: François Doray <fdoray@chromium.org>
Cr-Commit-Position: refs/heads/master@{#654986}
Reason: with the advent of other scheduling primitives in //base
(i.e. SequenceManager), TaskScheduler was no longer the only component
responsible for scheduling tasks. We will from now on refer to the
whole of //base/task as the "task scheduling infrastructure".
There are other types named "TaskScheduler" outside of base:: so
s/TaskScheduler/ThreadPool/ across the codebase wasn't possible.
Instead, this CL did:
1) base/task/task_scheduler => base/task/thread_pool
(catches all files with includes)
1.1) Careful manual search to add files without includes
(e.g. missing IWYU, docs, etc.)
2) TaskScheduler => ThreadPool in all files affected by (1)
3) task_scheduler => thread_pool in all files affected by (1)
4) "task scheduler" => "thread pool" in all files affected by (1)
4) Move task_scheduler_util like headers in
//content //components and //ios
Also:
* Renamed UMA metrics from TaskScheduler.* to ThreadPool.*
and dropped "Pool" from worker pool name suffixes.
* Renamed TaskScheduler*Worker thread names to ThreadPool*Worker
* In base/android: NativeTaskScheduler => NativeScheduler as it
was referring to the whole of base/task.
TaskSchedulerTest.java => NativePostTaskTest.java (former DNE)
* Intentionally ignoring IWYU violations in this already too large
CL.
In follow-up:
* Rename other types as well:
SchedulerWorker => WorkerThread
SchedulerWorkerPool* => WorkerThreadGroup*
Bug: 951388
Change-Id: I5bc2688b593c7682ef7e56d6b228539970ba107e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1561552
Commit-Queue: Gabriel Charette <gab@chromium.org>
Auto-Submit: Gabriel Charette <gab@chromium.org>
Reviewed-by: John Abd-El-Malek <jam@chromium.org>
Reviewed-by: François Doray <fdoray@chromium.org>
Reviewed-by: Ilya Sherman <isherman@chromium.org>
Reviewed-by: Richard Coles <torne@chromium.org>
Reviewed-by: Joe Mason <joenotcharles@google.com>
Reviewed-by: Etienne Pierre-Doray <etiennep@chromium.org>
Cr-Commit-Position: refs/heads/master@{#650997}