0
Commit Graph

81 Commits

Author SHA1 Message Date
Carlos Caballero
b25fe847c7 Rename MessageLoopCurrent to CurrentThread
Get rid of all references to MessageLoopCurrent(ForIO|ForUI)

This is a mechanical change. Just ran the following commands

mffr.py base/message_loop/message_loop_current base/task/current_thread
mffr.py -f MessageLoopCurrentForUI CurrentUIThread
mffr.py -f MessageLoopCurrentForIO CurrentIOThread
mffr.py -f MessageLoopCurrent CurrentThread
rm base/message_loop/message_loop_current.h

This patch will be reviewed according to
https://chromium.googlesource.com/chromium/src/+/master/docs/code_reviews.md#mechanical-changes

TBR=gab@chromium.org

Bug: 891670
Change-Id: If3892558ad71333f93a4698ac5411f141ccd5657
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2279990
Commit-Queue: Carlos Caballero <carlscab@google.com>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#789421}
2020-07-17 10:27:17 +00:00
Carlos Caballero
4a05092f8e Deprecate MessageLoopCurrent in favor of CurrentThread
Followup patches will migrate code to the new names and header files.

Bug: 891670
Change-Id: I35c3aa51236f8d0934d87d699e6298494ded14b8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2270327
Commit-Queue: Carlos Caballero <carlscab@google.com>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#784774}
2020-07-02 11:43:38 +00:00
Gabriel Charette
e7cdc5cd07 [BrowserThread] Migration callers without full content:: namespace
Note to QA: This CL is purely mechanical and shouldn't be blamed
for future regressions on touched files.

This is a follow-up to https://chromium-review.googlesource.com/c/chromium/src/+/2211138
which already removed all usage using content::BrowserThread.

Hence this script now matches unqualified BrowserThread:: without
risking having "content::" be selected as "traits_before" by the regex
(ran on same revision as step ).

content:: is now always added if outside namespace content {}
(deleting unused using content::BrowserThread; decls)

Script @ https://crbug.com/1026641#c92

(will TBR fdoray@ post-review for mechanical change)
TBR=fdoray@hchromium.org

AX-Relnotes: n/a.
Bug: 1026641
Change-Id: I51ae2f83eb17d19b54563fd9b4fc040d2aa0c948
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2212469
Commit-Queue: Gabriel Charette <gab@chromium.org>
Reviewed-by: François Doray <fdoray@chromium.org>
Cr-Commit-Position: refs/heads/master@{#772458}
2020-05-27 23:35:05 +00:00
Gabriel Charette
49e3cd0996 Introduce content::GetUIThreadTaskRunner() and its IO counterpart
As agreed upon in design doc @
https://docs.google.com/document/d/1tssusPykvx3g0gvbvU4HxGyn3MjJlIylnsH13-Tv6s4/edit?ts=5e1c66d5&pli=1#bookmark=id.ll79iqi5rlpp

base::ThreadPool counterpart to move away from post_task.h is @
https://chromium-review.googlesource.com/c/chromium/src/+/1977964

API usage migration will be done in a follow-up mega CL.
This CL at least uses it in its own tests.

See https://chromium-review.googlesource.com/c/chromium/src/+/2015655
for how this will look in practice for a few callsites.

Bug: 1026641
Change-Id: I98771fd68a513bf0a4776672a8d75fcbbb200bea
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2014055
Commit-Queue: Gabriel Charette <gab@chromium.org>
Reviewed-by: Alexander Timin <altimin@chromium.org>
Reviewed-by: François Doray <fdoray@chromium.org>
Reviewed-by: Darin Fisher <darin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#735734}
2020-01-28 03:45:27 +00:00
Gabriel Charette
b8c60e8497 [content test] Move TestBrowserThread as an impl detail!
No less than 6.5 years after TestBrowserThread was deprecated!

Moved as-is to browser_task_environment.cc % deletion on an unused constructor.

Only actual change in this CL is in
chrome/browser/android/digital_asset_links/digital_asset_links_handler_unittest.cc
to use BrowserTaskEnvironment instead (doesn't alter any logic, just
semantics).

// For minor tweaks to chrome/browser/android/digital_asset_links/digital_asset_links_handler_unittest.cc
TBR=lizeb@chromium.org
// To bypass owners on mechanical removal of unused headers.
TBR=avi@chromium.org

Bug: 272091
Change-Id: I174c23ae436c330b32f14bd12ff5f9dc4e23bab2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1978162
Commit-Queue: Gabriel Charette <gab@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Auto-Submit: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#726871}
2019-12-20 18:50:15 +00:00
danakj
151f8fdd0c Convert Callbacks to {Once,Repeating}Callback in content/browser/
Use OnceCallback where possible because the callback is only used once
and RepeatingCallback and BindRepeating otherwise.

Pass RepeatingCallback ownership by value instead of const ref.

R=avi@chromium.org

Bug: 1007760
Change-Id: I18ea04793d877ab91733dc3ecba363c2509ea68a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1961134
Commit-Queue: danakj <danakj@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Auto-Submit: danakj <danakj@chromium.org>
Cr-Commit-Position: refs/heads/master@{#723678}
2019-12-11 03:11:14 +00:00
Alex Clarke
bbf891dc8b Introduce base::CurrentThread trait.
This trait will allow tasks to be posted on the current thread, optionally
overriding other traits such as the base::TaskPriority or
content::BrowserTaskType. A refactor of BrowserTaskExecutor was necessary
to support ase::CurrentThread in a BrowserTaskEnvironment with a fake IO
thread.

BUG: 
Change-Id: If4627c8cec6efd404b483c5a9b789a579c00936b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1835494
Commit-Queue: Alex Clarke <alexclarke@chromium.org>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Reviewed-by: Alex Moshchuk <alexmos@chromium.org>
Reviewed-by: François Doray <fdoray@chromium.org>
Reviewed-by: Sami Kyöstilä <skyostil@chromium.org>
Cr-Commit-Position: refs/heads/master@{#704181}
2019-10-09 14:18:02 +00:00
Karolina Soltys
b083f9364d [scheduler] Registering the BrowserTaskExecutor in TLS.
This is a reland of a689aa50b6

Bug: 872236
Change-Id: I6ab54fe95459c294358913bf6a78a6a73e8cb449
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1787606
Commit-Queue: Karolina Soltys <ksolt@chromium.org>
Reviewed-by: Ted Choc <tedchoc@chromium.org>
Reviewed-by: Alex Clarke <alexclarke@chromium.org>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Auto-Submit: Karolina Soltys <ksolt@chromium.org>
Cr-Commit-Position: refs/heads/master@{#699818}
2019-09-25 16:18:06 +00:00
Yutaka Hirano
a025aa6c96 Revert "[scheduler] Relanding registering the task executor in TLS."
This reverts commit a689aa50b6.

Reason for revert: suspected to break content_unittests. See https://ci.chromium.org/p/chromium/builders/ci/Linux%20CFI/14863.

Original change's description:
> [scheduler] Relanding registering the task executor in TLS.
> 
> I am attempting to reland
> https://chromium-review.googlesource.com/c/chromium/src/+/1751251
> with a fix. The race condition which triggered the revert is test-only,
> I have now marked it as benign and it shouldn't fail TSAN anymore.
> 
> TBR=alexclarke@chromium.org,tedchoc@chromium.org
> 
> Bug: 968047
> Change-Id: Iafbc31a80144371b22c0cd4ef6547c2ef2adfd62
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1781596
> Reviewed-by: Karolina Soltys <ksolt@chromium.org>
> Reviewed-by: Alex Clarke <alexclarke@chromium.org>
> Commit-Queue: Karolina Soltys <ksolt@chromium.org>
> Auto-Submit: Karolina Soltys <ksolt@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#692708}

TBR=tedchoc@chromium.org,alexclarke@chromium.org,ksolt@chromium.org

Change-Id: I3c65ae5ae5ff3e8ecf3f990bb4464d3c6cab34ea
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 968047
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1784017
Reviewed-by: Yutaka Hirano <yhirano@chromium.org>
Commit-Queue: Yutaka Hirano <yhirano@chromium.org>
Cr-Commit-Position: refs/heads/master@{#692975}
2019-09-04 02:09:18 +00:00
Karolina Soltys
a689aa50b6 [scheduler] Relanding registering the task executor in TLS.
I am attempting to reland
https://chromium-review.googlesource.com/c/chromium/src/+/1751251
with a fix. The race condition which triggered the revert is test-only,
I have now marked it as benign and it shouldn't fail TSAN anymore.

TBR=alexclarke@chromium.org,tedchoc@chromium.org

Bug: 968047
Change-Id: Iafbc31a80144371b22c0cd4ef6547c2ef2adfd62
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1781596
Reviewed-by: Karolina Soltys <ksolt@chromium.org>
Reviewed-by: Alex Clarke <alexclarke@chromium.org>
Commit-Queue: Karolina Soltys <ksolt@chromium.org>
Auto-Submit: Karolina Soltys <ksolt@chromium.org>
Cr-Commit-Position: refs/heads/master@{#692708}
2019-09-03 17:28:49 +00:00
Gabriel Charette
c710874894 Reland "[TaskEnvironment] Complete migration with header rename"
This is a reland of 18947083c7

The move_source_file.py script's formatting rules incorrectly
formatted services/device/generic_sensor/platform_sensor_and_provider_unittest_win.cc
after all. But we also can't rely 100% on git cl format (crbug.com/997063)
so I ended up performing a git cl format && git add -up
(+interactive addition of missing blank line after foo.h when included
from top of foo.cc)

Also added
$ tools/git/move_source_file.py net/test/test_with_scoped_task_environment.h net/test/test_with_task_environment.h

Original change's description:
> [TaskEnvironment] Complete migration with header rename
>
> This is merely:
>
> $ tools/git/move_source_file.py base/test/scoped_task_environment.h base/test/task_environment.h
> $ tools/git/move_source_file.py base/test/scoped_task_environment.cc base/test/task_environment.cc
> $ tools/git/move_source_file.py base/test/scoped_task_environment_unittest.cc base/test/task_environment_unittest.cc
> $ tools/git/move_source_file.py content/public/test/test_browser_thread_bundle.h content/public/test/browser_task_environment.h
> $ tools/git/move_source_file.py content/public/test/test_browser_thread_bundle.cc content/public/test/browser_task_environment.cc
> $ tools/git/move_source_file.py content/public/test/test_browser_thread_bundle_unittest.cc content/public/test/browser_task_environment_unittest.cc
> $ tools/git/move_source_file.py ios/web/public/test/test_web_thread_bundle.h ios/web/public/test/web_task_environment.h
> $ tools/git/move_source_file.py ios/web/test/test_web_thread_bundle.cc ios/web/test/web_task_environment.cc
>
> and a few manual renames in DEPS files missed by the script
>
> This CL uses --bypass-hooks to avoid having to git cl format because
> many headers are being reordered by git cl format and it's too many to
> figure out in a no-op CL which ones are okay with it.
> windows.h for one should typically be first and another one of the
> reorderings in PS3 even caused a compile failure:
> https://chromium-review.googlesource.com/c/chromium/src/+/1764962/3/components/services/font/font_loader_unittest.cc
>
> TBR=dcheng@chromium.org
>
> Bug: 992483
> Change-Id: I32a4afd43ef779393c95d9873c157be2d3da1dd1
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1764962
> 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@{#689778}

TBR=dcheng@chromium.org

Bug: 992483
Change-Id: I6179dd1329a4d30bf5c65450ea893537f31e6f85
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1767658
Reviewed-by: Gabriel Charette <gab@chromium.org>
Commit-Queue: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#689794}
2019-08-23 03:31:40 +00:00
Gabriel Charette
b69fcd4f6e Revert "[TaskEnvironment] Complete migration with header rename"
This reverts commit 18947083c7.

Reason for revert: broke Win

Original change's description:
> [TaskEnvironment] Complete migration with header rename
> 
> This is merely:
> 
> $ tools/git/move_source_file.py base/test/scoped_task_environment.h base/test/task_environment.h
> $ tools/git/move_source_file.py base/test/scoped_task_environment.cc base/test/task_environment.cc
> $ tools/git/move_source_file.py base/test/scoped_task_environment_unittest.cc base/test/task_environment_unittest.cc
> $ tools/git/move_source_file.py content/public/test/test_browser_thread_bundle.h content/public/test/browser_task_environment.h
> $ tools/git/move_source_file.py content/public/test/test_browser_thread_bundle.cc content/public/test/browser_task_environment.cc
> $ tools/git/move_source_file.py content/public/test/test_browser_thread_bundle_unittest.cc content/public/test/browser_task_environment_unittest.cc
> $ tools/git/move_source_file.py ios/web/public/test/test_web_thread_bundle.h ios/web/public/test/web_task_environment.h
> $ tools/git/move_source_file.py ios/web/test/test_web_thread_bundle.cc ios/web/test/web_task_environment.cc
> 
> and a few manual renames in DEPS files missed by the script
> 
> This CL uses --bypass-hooks to avoid having to git cl format because
> many headers are being reordered by git cl format and it's too many to
> figure out in a no-op CL which ones are okay with it.
> windows.h for one should typically be first and another one of the
> reorderings in PS3 even caused a compile failure:
> https://chromium-review.googlesource.com/c/chromium/src/+/1764962/3/components/services/font/font_loader_unittest.cc
> 
> TBR=dcheng@chromium.org
> 
> Bug: 992483
> Change-Id: I32a4afd43ef779393c95d9873c157be2d3da1dd1
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1764962
> 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@{#689778}

TBR=dcheng@chromium.org,gab@chromium.org

Change-Id: I9aa8ff558d1ff78cebe0c25e559c017578ad4f53
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 992483
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1767657
Reviewed-by: Gabriel Charette <gab@chromium.org>
Commit-Queue: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#689780}
2019-08-23 02:13:29 +00:00
Gabriel Charette
18947083c7 [TaskEnvironment] Complete migration with header rename
This is merely:

$ tools/git/move_source_file.py base/test/scoped_task_environment.h base/test/task_environment.h
$ tools/git/move_source_file.py base/test/scoped_task_environment.cc base/test/task_environment.cc
$ tools/git/move_source_file.py base/test/scoped_task_environment_unittest.cc base/test/task_environment_unittest.cc
$ tools/git/move_source_file.py content/public/test/test_browser_thread_bundle.h content/public/test/browser_task_environment.h
$ tools/git/move_source_file.py content/public/test/test_browser_thread_bundle.cc content/public/test/browser_task_environment.cc
$ tools/git/move_source_file.py content/public/test/test_browser_thread_bundle_unittest.cc content/public/test/browser_task_environment_unittest.cc
$ tools/git/move_source_file.py ios/web/public/test/test_web_thread_bundle.h ios/web/public/test/web_task_environment.h
$ tools/git/move_source_file.py ios/web/test/test_web_thread_bundle.cc ios/web/test/web_task_environment.cc

and a few manual renames in DEPS files missed by the script

This CL uses --bypass-hooks to avoid having to git cl format because
many headers are being reordered by git cl format and it's too many to
figure out in a no-op CL which ones are okay with it.
windows.h for one should typically be first and another one of the
reorderings in PS3 even caused a compile failure:
https://chromium-review.googlesource.com/c/chromium/src/+/1764962/3/components/services/font/font_loader_unittest.cc

TBR=dcheng@chromium.org

Bug: 992483
Change-Id: I32a4afd43ef779393c95d9873c157be2d3da1dd1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1764962
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@{#689778}
2019-08-23 02:05:33 +00:00
Findit
30f71a78e8 Revert "[scheduler] Registering the executor in TLS."
This reverts commit 1e76b45fba.

Reason for revert:

Findit (https://goo.gl/kROfz5) identified CL at revision 689646 as the
culprit for failures in the build cycles as shown on:
https://analysis.chromium.org/waterfall/culprit?key=ag9zfmZpbmRpdC1mb3ItbWVyRAsSDVdmU3VzcGVjdGVkQ0wiMWNocm9taXVtLzFlNzZiNDVmYmE0MWZmMTQ5MDRiZjVkZmM5OWEyODk1YTBiZmQ0YjAM

Sample Failed Build: https://ci.chromium.org/buildbot/chromium.memory/Linux%20TSan%20Tests/43203

Sample Failed Step: content_unittests

Original change's description:
> [scheduler] Registering the executor in TLS.
> 
> Bug: 968047
> Change-Id: Idaf9c72f13419ac29804a91e54be86d71ff9b7f7
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1751251
> Commit-Queue: Karolina Soltys <ksolt@chromium.org>
> Reviewed-by: Karolina Soltys <ksolt@chromium.org>
> Reviewed-by: Ted Choc <tedchoc@chromium.org>
> Reviewed-by: Alex Clarke <alexclarke@chromium.org>
> Auto-Submit: Karolina Soltys <ksolt@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#689646}


Change-Id: I80b73e5cb9b57e3ffa6d766497a7fdaa89d4d1a4
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 968047
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1766782
Cr-Commit-Position: refs/heads/master@{#689690}
2019-08-22 22:02:01 +00:00
Karolina Soltys
1e76b45fba [scheduler] Registering the executor in TLS.
Bug: 968047
Change-Id: Idaf9c72f13419ac29804a91e54be86d71ff9b7f7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1751251
Commit-Queue: Karolina Soltys <ksolt@chromium.org>
Reviewed-by: Karolina Soltys <ksolt@chromium.org>
Reviewed-by: Ted Choc <tedchoc@chromium.org>
Reviewed-by: Alex Clarke <alexclarke@chromium.org>
Auto-Submit: Karolina Soltys <ksolt@chromium.org>
Cr-Commit-Position: refs/heads/master@{#689646}
2019-08-22 20:35:07 +00:00
Gabriel Charette
694c3c33ca [TaskEnvironment] Mass-migrate away from ScopedTaskEnvironment (1/2)
(well half of them because git cl upload wouldn't let me do
 them all at once...)

This is step  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}
2019-08-19 14:53:05 +00:00
Gabriel Charette
748577aa7e [test::TaskEnvironment] Rename Thread::TaskEnvironment to avoid confusion
Precursor to https://chromium-review.googlesource.com/c/chromium/src/+/1747171

R=dcheng@chromium.org

Bug: 992483
Change-Id: I0bd990acbfc97ae95b9faaba1ecab682f85150c3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1747190
Auto-Submit: Gabriel Charette <gab@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Sami Kyöstilä <skyostil@chromium.org>
Commit-Queue: Sami Kyöstilä <skyostil@chromium.org>
Cr-Commit-Position: refs/heads/master@{#685964}
2019-08-12 12:53:55 +00:00
Chris Sharp
7840c58097 Reland "Reland "Remove references to MessagePump::Type""
This reverts commit 8f5f3e89a5.

Reason for revert: Revert wasn't needed

Original change's description:
> Revert "Reland "Remove references to MessagePump::Type""
> 
> This reverts commit 1c1d61e5d9.
> 
> Reason for revert: I suspect this is causing a compile failure on the Linux ChromiumOS Full Bot.
> 
> Output:
> FAILED: obj/chromeos/services/assistant/tests/service_unittest.o
> /b/s/w/ir/cache/goma/client/gomacc ../../third_par...
> ../../chromeos/services/assistant/service_unittest.cc:12:10: fatal error: 'ash/public/interfaces/constants.mojom-forward.h' file not found
> #include "ash/public/interfaces/constants.mojom-forward.h"
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> 
> Original change's description:
> > Reland "Remove references to MessagePump::Type"
> > 
> > This is a reland of bfca9d675c
> > 
> > Was reverted because an optional trybot failed due to a missing include in an unrelated file.
> > That was fixed in https://crrev.com/c/1729634 and https://crrev.com/c/1730894
> > 
> > Original change's description:
> > > Remove references to MessagePump::Type
> > >
> > > It is going away soon, replace with the real thing: MessagePumpType
> > >
> > > Had to fix a lot of includes (MessagePumpType is defined in message_pump_type.h).
> > >
> > > This is a mechanical change that will be reviewed according to
> > > https://chromium.googlesource.com/chromium/src/+/master/docs/code_reviews.md#mechanical-changes
> > >
> > > Bug: 891670
> > > TBR=gab@chromium.org
> > >
> > > Change-Id: I1c85fce3cc11f7a283153ccaf2596e6e92a638d7
> > > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1726058
> > > Commit-Queue: Carlos Caballero <carlscab@google.com>
> > > Reviewed-by: Gabriel Charette <gab@chromium.org>
> > > Cr-Commit-Position: refs/heads/master@{#682731}
> > 
> > TBR=gab@chromium.org
> > 
> > Bug: 891670
> > Change-Id: I7654fb4ff3a5e8c0505aafb33939d2035f28f88b
> > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1730416
> > Commit-Queue: Carlos Caballero <carlscab@google.com>
> > Reviewed-by: Gabriel Charette <gab@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#683592}
> 
> TBR=gab@chromium.org,carlscab@google.com
> 
> Change-Id: Ie479741cf8092d9110a9ee6c5fa81e7e084c6788
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: 891670
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1733432
> Reviewed-by: Chris Sharp <csharp@chromium.org>
> Commit-Queue: Chris Sharp <csharp@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#683602}

TBR=gab@chromium.org,csharp@chromium.org,carlscab@google.com

Change-Id: Ieb323e7afaf248384c05b8cb0c13d6ec50856c75
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 891670
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1733434
Reviewed-by: Chris Sharp <csharp@chromium.org>
Commit-Queue: Chris Sharp <csharp@chromium.org>
Cr-Commit-Position: refs/heads/master@{#683603}
2019-08-02 15:45:32 +00:00
Chris Sharp
8f5f3e89a5 Revert "Reland "Remove references to MessagePump::Type""
This reverts commit 1c1d61e5d9.

Reason for revert: I suspect this is causing a compile failure on the Linux ChromiumOS Full Bot.

Output:
FAILED: obj/chromeos/services/assistant/tests/service_unittest.o
/b/s/w/ir/cache/goma/client/gomacc ../../third_par...
../../chromeos/services/assistant/service_unittest.cc:12:10: fatal error: 'ash/public/interfaces/constants.mojom-forward.h' file not found
#include "ash/public/interfaces/constants.mojom-forward.h"
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Original change's description:
> Reland "Remove references to MessagePump::Type"
> 
> This is a reland of bfca9d675c
> 
> Was reverted because an optional trybot failed due to a missing include in an unrelated file.
> That was fixed in https://crrev.com/c/1729634 and https://crrev.com/c/1730894
> 
> Original change's description:
> > Remove references to MessagePump::Type
> >
> > It is going away soon, replace with the real thing: MessagePumpType
> >
> > Had to fix a lot of includes (MessagePumpType is defined in message_pump_type.h).
> >
> > This is a mechanical change that will be reviewed according to
> > https://chromium.googlesource.com/chromium/src/+/master/docs/code_reviews.md#mechanical-changes
> >
> > Bug: 891670
> > TBR=gab@chromium.org
> >
> > Change-Id: I1c85fce3cc11f7a283153ccaf2596e6e92a638d7
> > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1726058
> > Commit-Queue: Carlos Caballero <carlscab@google.com>
> > Reviewed-by: Gabriel Charette <gab@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#682731}
> 
> TBR=gab@chromium.org
> 
> Bug: 891670
> Change-Id: I7654fb4ff3a5e8c0505aafb33939d2035f28f88b
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1730416
> Commit-Queue: Carlos Caballero <carlscab@google.com>
> Reviewed-by: Gabriel Charette <gab@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#683592}

TBR=gab@chromium.org,carlscab@google.com

Change-Id: Ie479741cf8092d9110a9ee6c5fa81e7e084c6788
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 891670
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1733432
Reviewed-by: Chris Sharp <csharp@chromium.org>
Commit-Queue: Chris Sharp <csharp@chromium.org>
Cr-Commit-Position: refs/heads/master@{#683602}
2019-08-02 15:37:08 +00:00
Carlos Caballero
1c1d61e5d9 Reland "Remove references to MessagePump::Type"
This is a reland of bfca9d675c

Was reverted because an optional trybot failed due to a missing include in an unrelated file.
That was fixed in https://crrev.com/c/1729634 and https://crrev.com/c/1730894

Original change's description:
> Remove references to MessagePump::Type
>
> It is going away soon, replace with the real thing: MessagePumpType
>
> Had to fix a lot of includes (MessagePumpType is defined in message_pump_type.h).
>
> This is a mechanical change that will be reviewed according to
> https://chromium.googlesource.com/chromium/src/+/master/docs/code_reviews.md#mechanical-changes
>
> Bug: 891670
> TBR=gab@chromium.org
>
> Change-Id: I1c85fce3cc11f7a283153ccaf2596e6e92a638d7
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1726058
> Commit-Queue: Carlos Caballero <carlscab@google.com>
> Reviewed-by: Gabriel Charette <gab@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#682731}

TBR=gab@chromium.org

Bug: 891670
Change-Id: I7654fb4ff3a5e8c0505aafb33939d2035f28f88b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1730416
Commit-Queue: Carlos Caballero <carlscab@google.com>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#683592}
2019-08-02 15:10:39 +00:00
Sami Kyostila
8e4d5a915e content/browser: Always specify thread affinity when posting tasks
*** Note: There is no behavior change from this patch. ***

The PostTask APIs will shortly be changed to require all tasks to explicitly
specify their thread affinity, i.e., whether the task should run on the thread
pool or a specific named thread such as a BrowserThread. This patch updates all
call sites with thread affinity annotation. We also remove the "WithTraits"
suffix to make the call sites more readable.

Before:

    // Thread pool task.
    base::PostTaskWithTraits(FROM_HERE, {...}, ...);

    // UI thread task.
    base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI, ...}, ...);

After:

    // Thread pool task.
    base::PostTask(FROM_HERE, {base::ThreadPool(), ...}, ...);

    // UI thread task.
    base::PostTask(FROM_HERE, {BrowserThread::UI, ...}, ...);

This patch was semi-automatically prepared with these steps:

    1. Patch in https://chromium-review.googlesource.com/c/chromium/src/+/1635827
       to make thread affinity a build-time requirement.
    2. Run an initial pass with a clang rewriter:
       https://chromium-review.googlesource.com/c/chromium/src/+/1635623
    3. ninja -C out/Debug | grep 'requested here' | cut -d: -f1-3 | sort | \
           uniq > errors.txt
    4. while read line; do
         f=$(echo $line | cut -d: -f 1)
         r=$(echo $line | cut -d: -f 2)
         c=$(echo $line | cut -d: -f 3)
         sed -i "${r}s/./&base::ThreadPool(),/$c" $f
       done < errors.txt
    5. GOTO 3 until build succeeds.
    6. Remove the "WithTraits" suffix from task API call sites:

       $ tools/git/mffr.py -i <(cat <<EOF
       [
         ["PostTaskWithTraits",                            "PostTask"],
         ["PostDelayedTaskWithTraits",                     "PostDelayedTask"],
         ["PostTaskWithTraitsAndReply",                    "PostTaskAndReply"],
         ["CreateTaskRunnerWithTraits",                    "CreateTaskRunner"],
         ["CreateSequencedTaskRunnerWithTraits",           "CreateSequencedTaskRunner"],
         ["CreateUpdateableSequencedTaskRunnerWithTraits", "CreateUpdateableSequencedTaskRunner"],
         ["CreateSingleThreadTaskRunnerWithTraits",        "CreateSingleThreadTaskRunner"],
         ["CreateCOMSTATaskRunnerWithTraits",              "CreateCOMSTATaskRunner"]
       ]
       EOF
       )

This CL was uploaded by git cl split.

R=boliu@chromium.org, tsepez@chromium.org

Bug: 968047
Change-Id: I346372d16a3856186ea74d14e0dd8a12f7cacae5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1729589
Commit-Queue: Sami Kyöstilä <skyostil@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Bo <boliu@chromium.org>
Auto-Submit: Sami Kyöstilä <skyostil@chromium.org>
Cr-Commit-Position: refs/heads/master@{#683554}
2019-08-02 12:45:05 +00:00
Findit
b0504e9d67 Revert "Remove references to MessagePump::Type"
This reverts commit bfca9d675c.

Reason for revert:

Findit (https://goo.gl/kROfz5) identified CL at revision 682731 as the
culprit for failures in the build cycles as shown on:
https://analysis.chromium.org/waterfall/culprit?key=ag9zfmZpbmRpdC1mb3ItbWVyRAsSDVdmU3VzcGVjdGVkQ0wiMWNocm9taXVtL2JmY2E5ZDY3NWM1MjQ4NDNiOGJiNmEwZDAxNGUyOWQ0ZDY4NTkwNTYM

Sample Failed Build: https://ci.chromium.org/buildbot/chromium/win-archive-rel/3468

Sample Failed Step: compile

Original change's description:
> Remove references to MessagePump::Type
> 
> It is going away soon, replace with the real thing: MessagePumpType
> 
> Had to fix a lot of includes (MessagePumpType is defined in message_pump_type.h).
> 
> This is a mechanical change that will be reviewed according to
> https://chromium.googlesource.com/chromium/src/+/master/docs/code_reviews.md#mechanical-changes
> 
> Bug: 891670
> TBR=gab@chromium.org
> 
> Change-Id: I1c85fce3cc11f7a283153ccaf2596e6e92a638d7
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1726058
> Commit-Queue: Carlos Caballero <carlscab@google.com>
> Reviewed-by: Gabriel Charette <gab@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#682731}


Change-Id: Idf6e0f69a07267d3a322c700882d2b3f65dcf021
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 891670
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1729553
Cr-Commit-Position: refs/heads/master@{#682762}
2019-07-31 16:42:20 +00:00
Carlos Caballero
bfca9d675c Remove references to MessagePump::Type
It is going away soon, replace with the real thing: MessagePumpType

Had to fix a lot of includes (MessagePumpType is defined in message_pump_type.h).

This is a mechanical change that will be reviewed according to
https://chromium.googlesource.com/chromium/src/+/master/docs/code_reviews.md#mechanical-changes

Bug: 891670
TBR=gab@chromium.org

Change-Id: I1c85fce3cc11f7a283153ccaf2596e6e92a638d7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1726058
Commit-Queue: Carlos Caballero <carlscab@google.com>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#682731}
2019-07-31 15:49:24 +00:00
Alex Clarke
49854cc84a Add ScopedDoNotUseUIDefaultQueueFromIO
In some circumstanecs you need to specify a BrowserTaskType or a priority when
posting a task from the IO theread to the UI thread or you risk inadvertant
task reordering. This patch introduces ScopedDoNotUseUIDefaultQueueFromIO an
RAII helper which causes PostTask on the UI thread's default task queue from
the IO thread to DCHECK.

The idea is to place ScopedDoNotUseUIDefaultQueueFromIO in contexts where
you're explicitly prioritizing certain tasks and it will guard against future
PostTasks which might otherwise get flakily reordered.

Bug: 863341
Change-Id: I67a56b2747b8bdd1ef35ec3652b55f1dc7ea830c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1660340
Reviewed-by: Nasko Oskov <nasko@chromium.org>
Reviewed-by: Alexander Timin <altimin@chromium.org>
Reviewed-by: Sami Kyöstilä <skyostil@chromium.org>
Commit-Queue: Alex Clarke <alexclarke@chromium.org>
Cr-Commit-Position: refs/heads/master@{#672823}
2019-06-27 08:25:49 +00:00
Alex Clarke
636e705be4 Introduce SingleThreadTaskExecutor the replacement for base::MessageLoop
A large but mostly trivial patch in preparation for removing
base::MessageLoop. We introduce SingleThreadTaskExecutor a simple FIFO
scheduler, which is intended for non-test code that needs a simple
single threaded task environment. Tests should use ScopedTaskEnvironment
or TestBrowserThreadBundle instead.

This patch also moves MessageLoop::Type to MessagePump::Type and
moves the factory method to MessagePump::Create.

TBR=gab@chromium.org

Change-Id: I9850c4657bb90b62490f4313c420cae025101371
BUG: 891670
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1632216
Reviewed-by: Alex Clarke <alexclarke@chromium.org>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Commit-Queue: Alex Clarke <alexclarke@chromium.org>
Cr-Commit-Position: refs/heads/master@{#664709}
2019-05-30 10:49:37 +00:00
Carlos Caballero
4118f7eb06 Add helper to post best effort tasks
This helper will be useful when migrating code away from
PostAfterStartupTask. Some callsites would otherwise need a trampoline
as they need to post to a given task runner. This helper is only needed
until we have sequence-funneling in place.

This patch is a split of https://crrev.com/c/1571661. Refer to this if
you need more context for this change.

Bug: 887407
Change-Id: I122f837e6a7b509903055798deb0f2b6eb215bed
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1628725
Commit-Queue: Carlos Caballero <carlscab@google.com>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#663717}
2019-05-28 13:54:00 +00:00
Carlos Caballero
e840fc3ea0 Add multiple task queues for the IO thread
This will enable the same scheduling capabilities as we already have on
the UI thread.

Bug: 863341
Change-Id: Ice34f614d78321caabf0fac3c6b1d6a621abb712
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1598813
Reviewed-by: Jochen Eisinger <jochen@chromium.org>
Reviewed-by: Alex Clarke <alexclarke@chromium.org>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Commit-Queue: Carlos Caballero <carlscab@google.com>
Cr-Commit-Position: refs/heads/master@{#663539}
2019-05-27 14:16:37 +00:00
Carlos Caballero
72e8a209b5 Add BrowserTaskQueues::EnableAllQueues
After this patch all queues in BrowserTaskQueues will be disabled on
creation and users must explicitly enable them via a call to either
BrowserTaskQueues::EnableAllQueues or
BrowserTaskQueues::EnableAllExceptBestEffortQueues

This will help us ensure the invariant that no tasks will run before
BrowserMainLoop::CreateThreads still holds after we add an IO
scheduler.

Bug: 863341
Change-Id: I07d34ec84e166b12b9ab50448acde7f943f9cbbb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1611979
Reviewed-by: Scott Violet <sky@chromium.org>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Reviewed-by: Alex Clarke <alexclarke@chromium.org>
Commit-Queue: Carlos Caballero <carlscab@google.com>
Cr-Commit-Position: refs/heads/master@{#661772}
2019-05-21 16:51:17 +00:00
Carlos Caballero
5f6212babf Create a dedicated class to hold all browser TaskQueues
Also provide a Handle class that is safe to use from any thread.
This class can then be reused by the IO thread.

Bug: 863341
Change-Id: I129c6481e79bf87b95bcf641a91258a878ec5cf5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1598811
Commit-Queue: Carlos Caballero <carlscab@google.com>
Reviewed-by: Alex Clarke <alexclarke@chromium.org>
Reviewed-by: Alexander Timin <altimin@chromium.org>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#659023}
2019-05-13 13:45:16 +00:00
Carlos Caballero
12a834ad60 Refactor browser_thread_unittest.cc
No need for the complicated constructor params if all can be done in the
constructor itself.

Change-Id: I75db0a61665923706f7b4b2b0f3f9ee792db1123
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1569906
Auto-Submit: Carlos Caballero <carlscab@google.com>
Commit-Queue: Gabriel Charette <gab@chromium.org>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#653160}
2019-04-23 13:48:28 +00:00
Carlos Caballero
1209b3115d Fix BrowserThreadTest
BrowserUIThreadScheduler must be destroyed on the UI thread which in
these tests runs on a dedicated thread.

Bug: 863341
Change-Id: I130f2fcdac7c6ba8a4654c1813ade962af6fef02
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1543395
Auto-Submit: Carlos Caballero <carlscab@google.com>
Reviewed-by: Alex Clarke <alexclarke@chromium.org>
Reviewed-by: Bo <boliu@chromium.org>
Commit-Queue: Bo <boliu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#646283}
2019-04-01 13:30:41 +00:00
Alex Clarke
636d6b60c7 Fix leak of MessageLoop in base::Thread
This leak was introduced by https://crrev.com/c/1462801/ where
there was a confusion between MessageLoop and MessageLoopBase
(surprisingly the former owns the latter).

This patch fixes the leak and generally clarifies ownership.
We still need to change base::Thread::Options::task_environment to be a
std::unique_ptr but that's a larger refactor.

Change-Id: Ic5380df2fb9dca5cb0818ce8e8b90e05192c6e9d
BUG: 933925, 934088, 933014, 932857
Reviewed-on: https://chromium-review.googlesource.com/c/1480462
Commit-Queue: Alex Clarke <alexclarke@chromium.org>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#634462}
2019-02-22 01:39:04 +00:00
Alex Clarke
831ed1e633 Add a BrowserUIThreadScheduler
This 'scheduler' currently is a strict FIFO and task execution order will not change.

Design doc: https://docs.google.com/document/d/1z1BDq9vzcEpkhN9LSPF5XMnZ0kLJ8mWWkNAi4OI7cos/edit#

Bug: 863341, 872372, 932857
Change-Id: Ifcf17d6438ec97adc721053b446de48d59935726
Reviewed-on: https://chromium-review.googlesource.com/c/1429120
Commit-Queue: Alex Clarke <alexclarke@chromium.org>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Reviewed-by: Sami Kyöstilä <skyostil@chromium.org>
Cr-Commit-Position: refs/heads/master@{#633145}
2019-02-18 21:10:08 +00:00
Alex Clarke
4779e4bdc7 Move MessageLoopForUI creation to BrowserTaskExecutor::Create
This is in preparation for the BrowserUIThreadScheduler where we
hope to have only one location where it's set up.

Bug: 863341, 872372
Change-Id: Ia7c07adc1d60280f2aed25f5226bfce80c6aba4b
Reviewed-on: https://chromium-review.googlesource.com/c/1461393
Commit-Queue: Alex Clarke <alexclarke@chromium.org>
Reviewed-by: Jochen Eisinger <jochen@chromium.org>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#632797}
2019-02-15 22:32:03 +00:00
CJ DiMeglio
638cf54d0d Removes rawptr uses of ReleaseSoon.
This CL removes the deprecated overload of ReleaseSoon that takes in a
rawptr, and replaces it with the safer overload that takes in a
scoped_refptr.

Bug: 900010
Change-Id: Ica88ec1151bc71f1f4bb107bbfeb71288031c02c
Reviewed-on: https://chromium-review.googlesource.com/c/1346999
Reviewed-by: Reilly Grant <reillyg@chromium.org>
Reviewed-by: Dmitry Gozman <dgozman@chromium.org>
Reviewed-by: Yuwei Huang <yuweih@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Cait Phillips <caitkp@chromium.org>
Reviewed-by: Marijn Kruisselbrink <mek@chromium.org>
Reviewed-by: Nico Weber <thakis@chromium.org>
Commit-Queue: CJ DiMeglio <lethalantidote@chromium.org>
Cr-Commit-Position: refs/heads/master@{#614918}
2018-12-08 02:22:14 +00:00
Alexander Timin
4f9c35c363 [message_loop] Remove message_loop_forward.h
As a final step, replace all includes back:
- mv message_loop_current.h message_loop.h
- s/message_loop_forward.h/message_loop.h/ in all includes.
- s/message_loop_forward.h/message_loop.h/ in base/BUILD.gn
- Remove message_loop_forward.h from third_party/DEPS.

TBR=gab@chromium.org
R=gab@chromium.org
BUG=891670

Change-Id: I623077025701459ddb7045cbcfdad138aa90a9e4
Reviewed-on: https://chromium-review.googlesource.com/c/1313110
Reviewed-by: Alexander Timin <altimin@chromium.org>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#604690}
2018-11-01 20:15:20 +00:00
Alexander Timin
c643d0e146 [message_loop] Temporary introduce message_loop_forward.h.
To facilitate splitting MessageLoop into MessageLoop and MessageLoopImpl
introduce message_loop_forward.h and use it everywhere.

- s/message_loop.h/message_loop_forward.h/ in all includes.
- Add message_loop_forward.h to base/BUILD.gn.
- Add message_loop_forward.h to third_party/DEPS.

TBR=gab@chromium.org
BUG=891670

Change-Id: Ibac3a24f5bd4291c9d57dd32c627477e4e6ef324
Reviewed-on: https://chromium-review.googlesource.com/c/1313108
Reviewed-by: Gabriel Charette <gab@chromium.org>
Commit-Queue: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#604672}
2018-11-01 19:43:28 +00:00
Eric Seckler
4d89f64d9c content: Remove BrowserThread::Post*Task / GetTaskRunnerForThread.
This removes BrowserThread::Post(NonNestable|)(Delayed|)Task and moves
GetTaskRunnerForThread into the impl (it's still used to vend
TaskRunners in BrowserTaskExecutor).

These methods have been replaced by base/post_task.h in conjunction
with content/public/browser/browser_task_traits.h

Bug: 878356
Change-Id: Ia122dc0921769f43da9271ddd6e1ce2f402df779
Reviewed-on: https://chromium-review.googlesource.com/1235728
Commit-Queue: Eric Seckler <eseckler@chromium.org>
Reviewed-by: Dmitry Gozman <dgozman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#592879}
2018-09-20 18:16:16 +00:00
Alex Clarke
7dc412de2b Introduce content::BrowserTaskExecutor
This class's job is to map base::TaskTraits to actual task queues
for the browser process.  This was split off from
https://chromium-review.googlesource.com/c/chromium/src/+/1214223
and is a pre-requisite for the BrowserUIThreadScheduler.

Design doc: https://docs.google.com/document/d/1z1BDq9vzcEpkhN9LSPF5XMnZ0kLJ8mWWkNAi4OI7cos/edit#

BUG=863341, 872372

Change-Id: Ic80e8f66cf245cca136c29387031d111e57fa713
Reviewed-on: https://chromium-review.googlesource.com/1224115
Commit-Queue: Alex Clarke <alexclarke@chromium.org>
Reviewed-by: Jochen Eisinger <jochen@chromium.org>
Reviewed-by: Eric Seckler <eseckler@chromium.org>
Cr-Commit-Position: refs/heads/master@{#591316}
2018-09-14 10:02:31 +00:00
Eric Seckler
e329cb9df7 content: Add a TaskTraits extension and TaskExecutor for BrowserThreads.
This allows using //base/task/post_task.h for posting tasks to a
BrowserThread by specifying a BrowserThread::ID as a task trait.

Also adds a content::NonNestable task trait to support non-nestable
tasks in base::PostTaskWithTraits.

In the future, we will add further traits to facilitate scheduling
tasks onto different SequenceManager queues on the UI thread, see:
https://docs.google.com/document/d/1z1BDq9vzcEpkhN9LSPF5XMnZ0kLJ8mWWkNAi4OI7cos/edit?usp=sharing

Bug: 867421, 863341, 878356
Change-Id: Id8b7bc2e374917ceb421c7f6139790e6f1457511
Reviewed-on: https://chromium-review.googlesource.com/1181364
Commit-Queue: Eric Seckler <eseckler@chromium.org>
Reviewed-by: Sami Kyöstilä <skyostil@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Reviewed-by: François Doray <fdoray@chromium.org>
Reviewed-by: Alex Clarke <alexclarke@chromium.org>
Cr-Commit-Position: refs/heads/master@{#586728}
2018-08-28 16:09:40 +00:00
Gabriel Charette
697593400d Remove MessageLoop::current() usage in /content/browser/browser_thread_unittest.cc
(and modernize usage of RunLoop)

Bug: 825327
Change-Id: I4a453384ea9f9735824c1259bd82c590571ff038
Reviewed-on: https://chromium-review.googlesource.com/1024798
Reviewed-by: John Abd-El-Malek <jam@chromium.org>
Commit-Queue: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#554880}
2018-04-30 21:23:40 +00:00
Gabriel Charette
8eb4dff991 Reland "Refactor BrowserThreadImpl, BrowserProcessSubThread, and BrowserMainLoop"
This is a reland of d260e9cf66

It was reverted because of crbug.com/824716, these weren't new crashes
but known crashes mislabeled as a fallout of this change.
http://cl/190471699 fixes the crash backend to not rely on
"content::BrowserThreadImpl::IOThreadRun" being in the signature.

Only diff in this CL is to use base::debug::Alias() in methods that we
don't want optimized (i.e. IOThreadRun) out as CHECK_GT was seen as
optimized out in some of the reported crashes (even though the same
pattern as before was used by this CL..?)

Original change's description:
> Refactor BrowserThreadImpl, BrowserProcessSubThread, and BrowserMainLoop
>
> This brings back the invariant that BrowserThread::IO isn't available
> before BrowserMainLoop::CreateThreads(). This was broken to fix issue
> 729596 to bring up the thread earlier for ServiceManager but it is
> important that code that posts to BrowserThread::IO statically have an
> happens-after relationship to BrowserMainLoop::CreateThreads(). Exposing
> it statically earlier put that invariant at risk.
>
> Thankfully fixing issue 815225 resulted in finally reaching the long
> sought goal of only having BrowserThread::UI/IO. Now that the IO thread
> is also kicked off before it's named statically, BrowserThreadImpl no
> longer needs to be a base::Thread, hence this refactoring.
>
> Before this CL:
>  * BrowserThreadImpl was a base::Thread
>    (could be a fake thread if SetMessageLoop was used)
>  * BrowserProcessSubThread was a BrowserThreadImpl
>    (performed a bit more initialization)
>  * BrowserProcessSubThread was only used in production (in
>    BrowserMainLoop)
>  * BrowserThreadImpl was used for fake threads (BrowserMainLoop for
>    BrowserThread::UI) and for testing (TestBrowserThread(Impl)).
>  * BrowserThreadImpl overrode Init/Run/CleanUp() from base::Thread to
>    perform some sanity checks as well as drive IOThread's Delegate (ref.
>    BrowserThread::SetIOThreadDelegate())
>  * BrowserProcessSubThread re-overrode Init/Run/CleanUp() to perform
>    per-thread //content initialization (tests missed out on that per
>    TestBrowserThread bypassing BrowserProcessSubThread by directly
>    subclassing BrowserThreadImpl).
>
> With this CL:
>  * BrowserThreadImpl is merely a scoped object that binds a provided
>    SingleThreadTaskRunner to a BrowserThread::ID.
>  * BrowserProcessSubThread is a base::Thread and performs all of the
>    initialization and cleanup specific to //content (this means it now
>    also manages BrowserThread::SetIOThreadDelegate())
>  * BrowserProcessSubThread can be brought up early before being bound to
>    a BrowserThread::ID (BrowserMainLoop handles that through
>    BrowserProcessSubThread ::RegisterAsBrowserThread())
>
> Unfortunate exceptions required for this CL:
>  * IOThread::Init() (invoked through BrowserThreadDelegate) perfoms
>    blocking operations this was previously performed before installed
>    the ThreadRestrictions on BrowserThread::IO. But now that //content
>    is initialized after bringing up the thread, a
>    base::ScopedAllowBlocking is required in scope of IOThread::Init().
>  * TestBrowserThread previously bypassing BrowserProcessSubThread by
>    directly subclassing BrowserThreadImpl meant it wasn't subject to
>    ThreadRestrictions (unfortunate becomes it denies allowance
>    verification to product code running in unit tests). Adding it back
>    causes DCHECKs, as such
>    BrowserProcessSubThread::AllowBlockingForTesting was added to allow
>    this CL to pass CQ.
>
> Of note:
>  * BrowserProcessSubThread is still written as though it supports many
>    BrowserThread::IDs but in practice it's mostly always
>    BrowserThread::IO (except in ThreadWatcherTest I think). This change
>    was big enough that I didn't bother also breaking that
>    generalization.
>  * BrowserThreadImpl's constructor was made private to ensure only
>    BrowserProcessSubThread and a few select callers get to drive it (to
>    avoid previous missed initialization issues)
>  * Atomics to manage BrowserThread::SetIOThreadDelegate were removed.
>    Restriction was instead added that this only be called before
>    initialization and after shutdown (this was already the case).
>
> Follow-ups to this CL:
>  * //ios duplicates this logic and will need to undergo the same change
>    as a follow-up
>  * Fixing ios will allow removal of base::Thread::SetMessageLoop hack :)
>  * Removing BrowserThreadGlobals::lock_ to address crbug.com/821034 will
>    be much easier
>  * BrowserThread post APIs should DCHECK rather than no-op if using a
>    BrowserThread::ID before it's registered.
>
> Bug: 815225, 821034, 729596
> Change-Id: If1038f23079df72203b1e95c7d26647f8824a726
> Reviewed-on: https://chromium-review.googlesource.com/969104
> Reviewed-by: John Abd-El-Malek <jam@chromium.org>
> Commit-Queue: Gabriel Charette <gab@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#544440}

TBR=jam@chromium.org

Bug: 815225, 821034, 729596, 824716
Change-Id: I9a180975c69a008f8519d1d3d44663aa58a74a92
Reviewed-on: https://chromium-review.googlesource.com/980793
Reviewed-by: John Abd-El-Malek <jam@chromium.org>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Commit-Queue: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#546104}
2018-03-27 14:22:54 +00:00
Matt Falkenhagen
fa239c8c41 Revert "Refactor BrowserThreadImpl, BrowserProcessSubThread, and BrowserMainLoop"
This reverts commit d260e9cf66.

Reason for revert: In Windows Canary versions since 67.0.3377.0, where this commit landed, IO thread hang reports have spiked dramatically. It is now the  browser crash report on Windows Canary at 33% of reports. I'm speculatively reverting this to see if the crash rate heals.

Original change's description:
> Refactor BrowserThreadImpl, BrowserProcessSubThread, and BrowserMainLoop
>
> This brings back the invariant that BrowserThread::IO isn't available
> before BrowserMainLoop::CreateThreads(). This was broken to fix issue
> 729596 to bring up the thread earlier for ServiceManager but it is
> important that code that posts to BrowserThread::IO statically have an
> happens-after relationship to BrowserMainLoop::CreateThreads(). Exposing
> it statically earlier put that invariant at risk.
>
> Thankfully fixing issue 815225 resulted in finally reaching the long
> sought goal of only having BrowserThread::UI/IO. Now that the IO thread
> is also kicked off before it's named statically, BrowserThreadImpl no
> longer needs to be a base::Thread, hence this refactoring.
>
> Before this CL:
>  * BrowserThreadImpl was a base::Thread
>    (could be a fake thread if SetMessageLoop was used)
>  * BrowserProcessSubThread was a BrowserThreadImpl
>    (performed a bit more initialization)
>  * BrowserProcessSubThread was only used in production (in
>    BrowserMainLoop)
>  * BrowserThreadImpl was used for fake threads (BrowserMainLoop for
>    BrowserThread::UI) and for testing (TestBrowserThread(Impl)).
>  * BrowserThreadImpl overrode Init/Run/CleanUp() from base::Thread to
>    perform some sanity checks as well as drive IOThread's Delegate (ref.
>    BrowserThread::SetIOThreadDelegate())
>  * BrowserProcessSubThread re-overrode Init/Run/CleanUp() to perform
>    per-thread //content initialization (tests missed out on that per
>    TestBrowserThread bypassing BrowserProcessSubThread by directly
>    subclassing BrowserThreadImpl).
>
> With this CL:
>  * BrowserThreadImpl is merely a scoped object that binds a provided
>    SingleThreadTaskRunner to a BrowserThread::ID.
>  * BrowserProcessSubThread is a base::Thread and performs all of the
>    initialization and cleanup specific to //content (this means it now
>    also manages BrowserThread::SetIOThreadDelegate())
>  * BrowserProcessSubThread can be brought up early before being bound to
>    a BrowserThread::ID (BrowserMainLoop handles that through
>    BrowserProcessSubThread ::RegisterAsBrowserThread())
>
> Unfortunate exceptions required for this CL:
>  * IOThread::Init() (invoked through BrowserThreadDelegate) perfoms
>    blocking operations this was previously performed before installed
>    the ThreadRestrictions on BrowserThread::IO. But now that //content
>    is initialized after bringing up the thread, a
>    base::ScopedAllowBlocking is required in scope of IOThread::Init().
>  * TestBrowserThread previously bypassing BrowserProcessSubThread by
>    directly subclassing BrowserThreadImpl meant it wasn't subject to
>    ThreadRestrictions (unfortunate becomes it denies allowance
>    verification to product code running in unit tests). Adding it back
>    causes DCHECKs, as such
>    BrowserProcessSubThread::AllowBlockingForTesting was added to allow
>    this CL to pass CQ.
>
> Of note:
>  * BrowserProcessSubThread is still written as though it supports many
>    BrowserThread::IDs but in practice it's mostly always
>    BrowserThread::IO (except in ThreadWatcherTest I think). This change
>    was big enough that I didn't bother also breaking that
>    generalization.
>  * BrowserThreadImpl's constructor was made private to ensure only
>    BrowserProcessSubThread and a few select callers get to drive it (to
>    avoid previous missed initialization issues)
>  * Atomics to manage BrowserThread::SetIOThreadDelegate were removed.
>    Restriction was instead added that this only be called before
>    initialization and after shutdown (this was already the case).
>
> Follow-ups to this CL:
>  * //ios duplicates this logic and will need to undergo the same change
>    as a follow-up
>  * Fixing ios will allow removal of base::Thread::SetMessageLoop hack :)
>  * Removing BrowserThreadGlobals::lock_ to address crbug.com/821034 will
>    be much easier
>  * BrowserThread post APIs should DCHECK rather than no-op if using a
>    BrowserThread::ID before it's registered.
>
> Bug: 815225, 821034, 729596
> Change-Id: If1038f23079df72203b1e95c7d26647f8824a726
> Reviewed-on: https://chromium-review.googlesource.com/969104
> Reviewed-by: John Abd-El-Malek <jam@chromium.org>
> Commit-Queue: Gabriel Charette <gab@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#544440}

TBR=gab@chromium.org,jam@chromium.org
NOPRESUBMIT=true

# Not skipping CQ checks because original CL landed > 1 day ago.
# falken: Skipping presubmit to use deprecated ThreadResrictions::DisallowWaiting().

Bug: 815225, 821034, 729596
Change-Id: I2be97c5d8183497c005ab397c871f625b034d850
Reviewed-on: https://chromium-review.googlesource.com/979752
Commit-Queue: Matt Falkenhagen <falken@chromium.org>
Reviewed-by: Matt Falkenhagen <falken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#545725}
2018-03-26 04:21:19 +00:00
Gabriel Charette
d260e9cf66 Refactor BrowserThreadImpl, BrowserProcessSubThread, and BrowserMainLoop
This brings back the invariant that BrowserThread::IO isn't available
before BrowserMainLoop::CreateThreads(). This was broken to fix issue
729596 to bring up the thread earlier for ServiceManager but it is
important that code that posts to BrowserThread::IO statically have an
happens-after relationship to BrowserMainLoop::CreateThreads(). Exposing
it statically earlier put that invariant at risk.

Thankfully fixing issue 815225 resulted in finally reaching the long
sought goal of only having BrowserThread::UI/IO. Now that the IO thread
is also kicked off before it's named statically, BrowserThreadImpl no
longer needs to be a base::Thread, hence this refactoring.

Before this CL:
 * BrowserThreadImpl was a base::Thread
   (could be a fake thread if SetMessageLoop was used)
 * BrowserProcessSubThread was a BrowserThreadImpl
   (performed a bit more initialization)
 * BrowserProcessSubThread was only used in production (in
   BrowserMainLoop)
 * BrowserThreadImpl was used for fake threads (BrowserMainLoop for
   BrowserThread::UI) and for testing (TestBrowserThread(Impl)).
 * BrowserThreadImpl overrode Init/Run/CleanUp() from base::Thread to
   perform some sanity checks as well as drive IOThread's Delegate (ref.
   BrowserThread::SetIOThreadDelegate())
 * BrowserProcessSubThread re-overrode Init/Run/CleanUp() to perform
   per-thread //content initialization (tests missed out on that per
   TestBrowserThread bypassing BrowserProcessSubThread by directly
   subclassing BrowserThreadImpl).

With this CL:
 * BrowserThreadImpl is merely a scoped object that binds a provided
   SingleThreadTaskRunner to a BrowserThread::ID.
 * BrowserProcessSubThread is a base::Thread and performs all of the
   initialization and cleanup specific to //content (this means it now
   also manages BrowserThread::SetIOThreadDelegate())
 * BrowserProcessSubThread can be brought up early before being bound to
   a BrowserThread::ID (BrowserMainLoop handles that through
   BrowserProcessSubThread ::RegisterAsBrowserThread())

Unfortunate exceptions required for this CL:
 * IOThread::Init() (invoked through BrowserThreadDelegate) perfoms
   blocking operations this was previously performed before installed
   the ThreadRestrictions on BrowserThread::IO. But now that //content
   is initialized after bringing up the thread, a
   base::ScopedAllowBlocking is required in scope of IOThread::Init().
 * TestBrowserThread previously bypassing BrowserProcessSubThread by
   directly subclassing BrowserThreadImpl meant it wasn't subject to
   ThreadRestrictions (unfortunate becomes it denies allowance
   verification to product code running in unit tests). Adding it back
   causes DCHECKs, as such
   BrowserProcessSubThread::AllowBlockingForTesting was added to allow
   this CL to pass CQ.

Of note:
 * BrowserProcessSubThread is still written as though it supports many
   BrowserThread::IDs but in practice it's mostly always
   BrowserThread::IO (except in ThreadWatcherTest I think). This change
   was big enough that I didn't bother also breaking that
   generalization.
 * BrowserThreadImpl's constructor was made private to ensure only
   BrowserProcessSubThread and a few select callers get to drive it (to
   avoid previous missed initialization issues)
 * Atomics to manage BrowserThread::SetIOThreadDelegate were removed.
   Restriction was instead added that this only be called before
   initialization and after shutdown (this was already the case).

Follow-ups to this CL:
 * //ios duplicates this logic and will need to undergo the same change
   as a follow-up
 * Fixing ios will allow removal of base::Thread::SetMessageLoop hack :)
 * Removing BrowserThreadGlobals::lock_ to address crbug.com/821034 will
   be much easier
 * BrowserThread post APIs should DCHECK rather than no-op if using a
   BrowserThread::ID before it's registered.

Bug: 815225, 821034, 729596
Change-Id: If1038f23079df72203b1e95c7d26647f8824a726
Reviewed-on: https://chromium-review.googlesource.com/969104
Reviewed-by: John Abd-El-Malek <jam@chromium.org>
Commit-Queue: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#544440}
2018-03-20 18:10:45 +00:00
Peter Kasting
341e1fbe2d Allow base::DoNothing() to handle any argument list.
This changes the form of DoNothing() from a simple no-arg function to a class
that produces callbacks via templated operator().  This allows callers to
replace base::Bind(&base::DoNothing) with base::DoNothing() for a small
boilerplate reduction; more importantly, it allows using DoNothing() to replace
existing no-op functions/lambdas that took more than zero args, and thus had to
be manually declared.  This removes dozens of such functions and around 600 LOC
total.

In a few places, DoNothing() can't be used directly, and this change also adds
explicit callback-generating Once<>() and Repeatedly<>() members that will
produce a callback with a specific signature.

BUG=811554
TEST=none

Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_mojo;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_vr;master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel
Change-Id: I37f87b35c6c079a6a8c03ff18ec3a54e1237f126
Reviewed-on: https://chromium-review.googlesource.com/903416
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Reviewed-by: Jochen Eisinger <jochen@chromium.org>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#538953}
2018-02-24 00:03:01 +00:00
Gabriel Charette
e9748f27c3 Uncontroversial and easy to carve out bits of deprecated BrowserThreads cleanup.
Overall reland is at https://chromium-review.googlesource.com/c/chromium/src/+/705775,
these are the easy bits that can land first (and wrap up contributions to issues
365909 and 752144 as well as to the ios/ side of 689520).

NOPRESUBMIT=TRUE (for BrowserThread presubmit triggered by touching related code)
TBR=jam@chromium.org, jsbell@chromium.org, sdefresne@chromium.org, asvitkine@chromium.org

Bug: 689520, 365909, 752144
Change-Id: I9b2b5326a12de5f7ffa22f8ac3332c8e57a6e14f
Reviewed-on: https://chromium-review.googlesource.com/738469
Commit-Queue: Gabriel Charette <gab@chromium.org>
Reviewed-by: Sylvain Defresne <sdefresne@chromium.org>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#511551}
2017-10-25 19:31:15 +00:00
tzik
4fea24afdc Apply base_bind_rewriters to //content/browser/{a,b,c,d,f,g}*
This CL applies //tools/clang/base_bind_rewriters to //content/browser/{a,b,c,d,f,g}*
It rewrites base::Bind to base::BindOnce where the resulting base::Callback
is immediately converted to base::OnceCallback, which is considered safe
to use base::BindOnce.

E.g.:
  base::PostTask(FROM_HERE, base::Bind([]{}));
  base::OnceClosure cb = base::Bind([]{});
are converted to:
  base::PostTask(FROM_HERE, base::BindOnce([]{}));
  base::OnceClosure cb = base::BindOnce([]{});
Change-Id: I11ae9ac169c8e0ff9d9b95452fec22a8b7c91df7

NOPRESUBMIT=true

Change-Id: I11ae9ac169c8e0ff9d9b95452fec22a8b7c91df7
Reviewed-on: https://chromium-review.googlesource.com/628003
Commit-Queue: Taiju Tsuiki <tzik@chromium.org>
Reviewed-by: Kinuko Yasuda <kinuko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#496656}
2017-08-23 11:41:47 +00:00
Gabriel Charette
53a9ef8107 Mass replace MessageLoop::Quit*() with RunLoop::QuitCurrent*Deprecated().
And added runloop.h alongside message_loop.h in allowed //base dependencies
in Blink platform code as RunLoop is effectively an extension of
MessageLoop and I don't see a reason not to allow it.

TBR: danakj@chromium.org (for the scripted change)
TBR: kinuko@chromium.org (for third_party\Webkit\Source\platform\DEPS tweak)
Bug: 748715
Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel
Change-Id: I36c934a0f22e3ee7ff44d3efb80c6a1fe710b7b5
Reviewed-on: https://chromium-review.googlesource.com/585732
Reviewed-by: Kinuko Yasuda <kinuko@chromium.org>
Commit-Queue: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#489617}
2017-07-26 12:36:23 +00:00
Yeol
0349534f91 Rename TaskRunner::RunsTasksOnCurrentThread() in //chrome, //content
Renamed TaskRunner::RunsTasksOnCurrentThread() to

TaskRunner: :RunsTasksInCurrentSequence() in //chrome, //content
Bug: 665062
Change-Id: I2d6a309bb5f116e521da91a7f66b4fe8b756a386
Reviewed-on: https://chromium-review.googlesource.com/558326
Commit-Queue: Avi Drissman <avi@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Reviewed-by: Jochen Eisinger <jochen@chromium.org>
Reviewed-by: Ken Rockot <rockot@chromium.org>
Cr-Commit-Position: refs/heads/master@{#488670}
2017-07-21 16:03:50 +00:00
dimaa
61c9b8f29a Most of BrowserThreadTest tests always fail (crash) the first time, and need to be retried separately (each test isolated).
BrowserThreadImpl states need to be cleaned up between tests,
otherwise the subsequent tests will crash trying to reinitialize BrowserThreadImpl.

This CL make sure that this is done correctly.
BUG=697560

Review-Url: https://codereview.chromium.org/2721223004
Cr-Commit-Position: refs/heads/master@{#454321}
2017-03-02 18:51:50 +00:00