* Ran clang-tidy with -fix.
* Ran git cl format.
* Reverted any fixes which caused local problems (mostly because of
making constructors explicit and breaking unittests that depended
on them being implicit).
Other minor hand-edits applied during rebasing.
This does not make base/ fully clang-tidy clean, but it should greatly
reduce the number of existing errors.
Bug: none
Change-Id: I93a046f2838e6494812fa038b776b22b8dea93a7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6119194
Reviewed-by: Lei Zhang <thestig@chromium.org>
Owners-Override: Lei Zhang <thestig@chromium.org>
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1403975}
This is a no-op migration from base::ThreadPriority to base::ThreadType.
Except for the name changes of enum classes and functions, their
behavior should be kept unchanged. By using the new ThreadType API, the
caller declare the type of work a thread runs, and let the platform
implementation decide its behavior. Apart from the current priority
setting, the QoS API will further be used on some platforms.
Mappings in existing callers are as follows:
ThreadPriority::BACKGROUND => ThreadType::kBackground
ThreadPriority::NORMAL => ThreadType::kDefault
ThreadPriority::DISPLAY for compositing only on select
platforms (WIN, ANDROID, CrOS)
=> ThreadType::kCompositing
ThreadPriority::DISPLAY unconditionally on *all* platforms
=> ThreadType::kDisplayCritical
ThreadPriority::REALTIME_AUDIO => ThreadType::kRealtimeAudio
As this CL aims to make all platform-specific decisions in the
platform_thread_<platform>.cc impls, ifdef exceptions on main threads
(like on Mac) have moved to their respective impls.
The resulting callers should thus have no ifdefs left except for the odd
exception with a TODO we aim to unravel after this no-op CL.
ifdefs for render_message_filter()->SetThreadType() stay for now as this
call is already platform specific.
Bug: 1278628, 1324809
Change-Id: I36fbc4fc988c12e712da2e131595255a7b4fe4b7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3329026
Reviewed-by: Wez <wez@chromium.org>
Reviewed-by: Ken Rockot <rockot@google.com>
Reviewed-by: Alexander Timin <altimin@chromium.org>
Commit-Queue: Zhibo Wang <zhibo1.wang@intel.com>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Reviewed-by: Olga Sharonova <olka@chromium.org>
Reviewed-by: Bo Liu <boliu@chromium.org>
Reviewed-by: Peng Huang <penghuang@chromium.org>
Reviewed-by: Kentaro Hara <haraken@chromium.org>
Reviewed-by: Xiyuan Xia <xiyuan@chromium.org>
Reviewed-by: Xianzhu Wang <wangxianzhu@chromium.org>
Reviewed-by: Markus Handell <handellm@google.com>
Reviewed-by: Sergey Volk <servolk@chromium.org>
Reviewed-by: Ken Buchanan <kenrb@chromium.org>
Reviewed-by: Scott Violet <sky@chromium.org>
Reviewed-by: Etienne Pierre-Doray <etiennep@chromium.org>
Reviewed-by: Zhenyao Mo <zmo@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1021517}
Only fixing callsites that explicitly invoke operator= or the Callback
constructor (to avoid tweaking files that specify it in overrides/etc.)
outside of a comment.
i.e. matching this regex:
'\n *[^/\n][^/\n][^/\n]*base::(Once|Repeating)?(Callback|Closure)( =|\(\))'
and skipping any files that already has a fwd-decl as either:
- 'class (Once|Repeating)?(Callback|Closure);'
- 'base/callback_forward.h'
This is a prereq to remove unused base/task/post_task.h includes in
https://chromium-review.googlesource.com/c/chromium/src/+/3555247
Bug: 1026641
Change-Id: I20f661e4b388b83606359b7fcdebc8cd93095bf3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3554741
Commit-Queue: Gabriel Charette <gab@chromium.org>
Auto-Submit: Gabriel Charette <gab@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Owners-Override: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/main@{#986224}
This reverts commit ddb183db51.
Reason for revert: MSVC generates dynamic initializers for constexpr constructors with non-constexpr variables. It's not clear if the C++ spec allows for this.
Original change's description:
> Make LazyInstance's constructor constexpr.
>
> This allows hiding the buffer into private state, this will allow adding more POD
> members as a follow-up.
> Believe it or not, there was a user of this private state up until very recently..!
> https://chromium-review.googlesource.com/c/chromium/src/+/850294
>
> This also allows removing the need for the LAZY_INSTANCE_INITIALIZER
> construction hack (will follow-up with a mass removal CL).
>
> -Wglobal-constructors (https://chromium-review.googlesource.com/c/chromium/src/+/866738)
> in //base guarantees that this doesn't result in global constructors.
>
> Bug: 797129
> Change-Id: Id891d051180b18155f0e23c0ec55cb0f4d3018ac
> Reviewed-on: https://chromium-review.googlesource.com/861426
> Commit-Queue: Gabriel Charette <gab@chromium.org>
> Reviewed-by: Daniel Cheng <dcheng@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#530469}
TBR=dcheng@chromium.org,gab@chromium.org,fdoray@chromium.org
# Not skipping CQ checks because original CL landed > 1 day ago.
Bug: 797129, 807491
Change-Id: I3bac97268584295fdd39563428c7f7dbe9ae8560
Reviewed-on: https://chromium-review.googlesource.com/896603
Reviewed-by: Robert Liao <robliao@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Commit-Queue: Robert Liao <robliao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#533564}
This reverts commit 1b97e93c5a.
Reason for revert: Speculative revert due to Linux TSAN unittest errors:
https://uberchromegw.corp.google.com/i/chromium.memory/builders/Linux%20TSan%20Tests/builds/17057
Original change's description:
> Make DestructorAtExit LazyInstances leak.
>
> This means that tests may no longer rely on LazyInstance<T> to clean
> up global state between tests. Tests that depend on globals but need
> a clean test environment should use explicit test hooks to reset this
> state.
>
> Only one test depends on DestructorAtExit for correct functionality.
> cast_audio_backend_unittests creates several mocks that are owned by a
> base::LazyInstance. Since Gmock verifies expectations in destructors,
> switching all LazyInstances to leaky ones breaks this verification.
> The solution is to manually verify and check the expectations at the
> end of the test.
>
> Note that while the mock objects are annotated as leaked for Gmock,
> that does not mean the cast_audio_backend_unittests will leak
> arbitrary amounts of memory. The test fixture already configures
> StreamMixer for each test run; this setup will clear up any leftover
> objects from the previous test.
>
> DestructorAtExit will be removed in a followup.
>
> Bug: 698982
> Cq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;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: I822ce507dbb98067a788466e7c8fcc96c3a64ef9
> Reviewed-on: https://chromium-review.googlesource.com/874994
> Commit-Queue: Daniel Cheng <dcheng@chromium.org>
> Reviewed-by: Kenneth MacKay <kmackay@chromium.org>
> Reviewed-by: Gabriel Charette <gab@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#531385}
TBR=dcheng@chromium.org,gab@chromium.org,kmackay@chromium.org
Change-Id: Ief1f9169caa0ff81e2c095df0a0520a71d7640a1
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 698982
Cq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;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
Reviewed-on: https://chromium-review.googlesource.com/882506
Reviewed-by: Joe Downing <joedow@chromium.org>
Commit-Queue: Joe Downing <joedow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#531398}
This means that tests may no longer rely on LazyInstance<T> to clean
up global state between tests. Tests that depend on globals but need
a clean test environment should use explicit test hooks to reset this
state.
Only one test depends on DestructorAtExit for correct functionality.
cast_audio_backend_unittests creates several mocks that are owned by a
base::LazyInstance. Since Gmock verifies expectations in destructors,
switching all LazyInstances to leaky ones breaks this verification.
The solution is to manually verify and check the expectations at the
end of the test.
Note that while the mock objects are annotated as leaked for Gmock,
that does not mean the cast_audio_backend_unittests will leak
arbitrary amounts of memory. The test fixture already configures
StreamMixer for each test run; this setup will clear up any leftover
objects from the previous test.
DestructorAtExit will be removed in a followup.
Bug: 698982
Cq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;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: I822ce507dbb98067a788466e7c8fcc96c3a64ef9
Reviewed-on: https://chromium-review.googlesource.com/874994
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Kenneth MacKay <kmackay@chromium.org>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#531385}
This test ensures that LazyInstance initialization isn't blocked
by priority inversions when mixed-priority threads try to
initialize the same LazyInstance object. That is, test to make
sure r527445 works.
On my Z840, this test takes 5 to 10 seconds to complete without
r527445 but ~30ms with it :). An explicit 5s timeout was added to
this test to make the regression case indeed fail (instead of
relying on the longer test timeout under which it's mostly fine).
Bug: 799853, 797129
Change-Id: I3ff59b92f0b4c15574f091549b3cfe8eadd9ae6f
Reviewed-on: https://chromium-review.googlesource.com/866871
Reviewed-by: François Doray <fdoray@chromium.org>
Reviewed-by: Bruce Dawson <brucedawson@chromium.org>
Commit-Queue: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#529886}
The LazyInstance::operator== removed by this CL is undesirable, because
1) it didn't have a corresponding operator!=
2) it was only used to compare against nullptr
(i.e. to check if the lazy instance was created already or not)
This CL removes LazyInstance::operator== and replaces it with
LazyInstance::IsCreated() method.
Bug: 789738
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: Idfbb4a9f0699cb10f3f861860070b7f316a16ad6
Reviewed-on: https://chromium-review.googlesource.com/792124
Reviewed-by: Nick Carter <nick@chromium.org>
Reviewed-by: danakj <danakj@chromium.org>
Reviewed-by: Kurt Horimoto <kkhorimoto@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Łukasz Anforowicz <lukasza@chromium.org>
Cr-Commit-Position: refs/heads/master@{#522172}
after a refactoring at http://crrev.com/ad6d8a9bbf9bd5e2.
As a follow-up of the refactoring, this CL inlines the alias to its users
in //base and //cc.
base: :StaticAtomicSequenceNumber is an alias of base::AtomicSequenceNumber
Change-Id: I343885b85cce413148ccd6aa9e5fa94913d7fecc
Reviewed-on: https://chromium-review.googlesource.com/568063
Reviewed-by: danakj <danakj@chromium.org>
Commit-Queue: Taiju Tsuiki <tzik@chromium.org>
Cr-Commit-Position: refs/heads/master@{#488123}
Removes the compiler-specific base #define ALIGNOF and replace uses with alignof.
Replaces some uses of ALIGNAS with alignas. These are not all replaced,
and a note is added to the definition about the problems with alignas.
This came from https://codereview.chromium.org/2670873002/
Remove base::AlignedMemory and replace with alignas(type) char[size].
std::aligned_storage has some limitations. The style guide is updated to note these and mark it disallowed. It is also updated for alignas and alignof.
CQ_INCLUDE_TRYBOTS=master.tryserver.blink:linux_trusty_blink_rel
Review-Url: https://codereview.chromium.org/2932053002
Cr-Commit-Position: refs/heads/master@{#479169}
This change requires the user of LazyInstance to explicitly select
either ::DestructorAtExit or ::Leaky. It seems clear that many users of
LazyInstance have just gone with default and are either unaware or
didn't consider that the default requires running an AtExit at process
shutdown.
As a first step, make this choice explicit, and update current users
to be ::DestructorAtExit to maintain current behaviour. Follow ups can
then attempt to consider individual switches from DestructorAtExit to
Leaky including reviewers with domain-specific knowledge.
i.e. No intended behaviour change from this CL.
R=thakis@chromium.org
Lots of TBRs for mechanical changes:
boliu: android_webview/
danakj: cc/
dmurph: storage/
jam: content/ ipc/, mojo/
jbauman: gpu/
jochen: gin/
oshima: chromeos/
raymes: ppapi/
rdevlin.cronin: extensions/
rockot: device/, services/
rogerta: google_apis/
rsleevi: net/, crypto/
sdefresne: components/, ios/
sergeyu: jingle/
slan: chromecast/
thakis: base/, chrome/, third_party/, tools/, ui/
vitalybuka: printing/
wez: remoting/
TBR=above
BUG=698982
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.android:android_cronet_tester;master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_site_isolation;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel
Review-Url: https://codereview.chromium.org/2733283002
Cr-Commit-Position: refs/heads/master@{#455405}
This patch also replaces the global AtomicSequenceNumber variables with
StaticAtomicSequenceNumber in order to remove static initializers.
BUG=94925
Review URL: http://codereview.chromium.org/9415039
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@126376 0039d316-1c4b-4281-b951-d872f2087c98
Converted the first 20 or so hits for LeakyLazyInstanceTraits on codesearch to
demonstrate the benefit at callsites. The real change is base/lazy_instance.h;
everything else is example.
BUG=none
TEST=none
Review URL: https://chromiumcodereview.appspot.com/9192024
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@118754 0039d316-1c4b-4281-b951-d872f2087c98
stub and "using" declarations in the old location to avoid having to change the
entire project at once.
TEST=it compiles
BUG=none
Review URL: http://codereview.chromium.org/6001010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@70342 0039d316-1c4b-4281-b951-d872f2087c98
namespace. This does not move the "hard" thread stuff (thread.h).
TEST=it compiles
BUG=none
Review URL: http://codereview.chromium.org/6079009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@70315 0039d316-1c4b-4281-b951-d872f2087c98
LazyInstances are destroyed by the AtExitManager, but we have
threads that outlive the AtExitManager that could potentially
access this.
Review URL: http://codereview.chromium.org/3956003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@63410 0039d316-1c4b-4281-b951-d872f2087c98
For now, this is only for base_unittests. The plan is to enable
it for all unit tests. This should finally fix mysterious
problems cause by Singletons surviving after one test etc.
This change also adapts LazyInstance so that it can be reused
after being destroyed. It is used very frequently, for example
each time a MessageLoop is used. It is also worth noting that
we had some problems in the past related to the MessageLoop
being destroyed and re-instantiated in the same test executable.
This patch should also fix that.
TEST=none
BUG=12710
Review URL: http://codereview.chromium.org/372057
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@32507 0039d316-1c4b-4281-b951-d872f2087c98
Preliminary work to enforce new PRESUBMIT.py rules:
- <=80 cols
- no trailing whitespaces
- svn:eol-style=LF
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10791 0039d316-1c4b-4281-b951-d872f2087c98