0
Commit Graph

41 Commits

Author SHA1 Message Date
Peter Kasting
811504a7aa Apply clang-tidy autofixes to base/.
* 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}
2025-01-08 19:18:50 -08:00
Peter Kasting
134ef9afca [cleanup] clang-format base.
Produced with:

find base -name \"*.cc\" -o -name \"*.h\" -o -name \"*.mm\" | xargs clang-format -i

base/third_party was then manually reset.

R=pbos@chromium.org

NO_IFTTT=Reformat only

Bug: none
Change-Id: Ie567eb767d41315fd60e8a17c6aee8a90ff6a3ec
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6117971
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Owners-Override: Peter Boström <pbos@chromium.org>
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Reviewed-by: Peter Boström <pbos@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1400624}
2024-12-27 18:30:09 -08:00
Benoît Lizé
aac37187e7 [base] Convert parts of base to std::atomic from atomicops
Change-Id: I6f6eecdc347a4787e9db197186d4c6032496a7da
Bug: 40175832
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6054733
Commit-Queue: Benoit Lize <lizeb@chromium.org>
Reviewed-by: Francois Pierre Doray <fdoray@chromium.org>
Reviewed-by: Colin Blundell <blundell@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1393602}
2024-12-09 12:42:24 +00:00
Avi Drissman
63e1f9974b Update header includes for /base/functional in /base
bind.h, callback.h, callback_forward.h, and callback_helpers.h
moved into /base/functional/. Update the include paths to
directly include them in their new location.

Bug: 1364441
Change-Id: I97ecfb8a36fddb64735c2e8393985d4c400d2f3a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4163303
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Owners-Override: Daniel Cheng <dcheng@chromium.org>
Owners-Override: Avi Drissman <avi@chromium.org>
Auto-Submit: Avi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1092528}
2023-01-13 18:54:43 +00:00
Avi Drissman
e4622aaecc Update copyright headers in base/
The methodology used to generate this CL is documented in
https://crbug.com/1098010#c34.

An earlier version of this CL, https://crrev.com/c/3879904,
was reverted due to an issue that was resolved with
https://crrev.com/c/3881211.

No-Try: true
Bug: 1098010
Change-Id: Ibd6ffb97e66835bc299fe7b85876c3e2927b2345
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3883841
Auto-Submit: Avi Drissman <avi@chromium.org>
Owners-Override: Avi Drissman <avi@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1044747}
2022-09-08 20:36:06 +00:00
Daniel Cheng
3d1108defc Revert "Update copyright headers in base/"
This reverts commit eccb7e8107.

Reason for revert: https://crbug.com/1361092

Original change's description:
> Update copyright headers in base/
>
> The methodology used to generate this CL is documented in
> https://crbug.com/1098010#c21.
>
> No-Try: true
> Bug: 1098010
> Change-Id: Icd01cc1648eab4b0550afcff2bee17076359a132
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3879904
> Owners-Override: Avi Drissman <avi@chromium.org>
> Commit-Queue: Avi Drissman <avi@chromium.org>
> Auto-Submit: Avi Drissman <avi@chromium.org>
> Reviewed-by: Mark Mentovai <mark@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#1044191}

Bug: 1098010
Change-Id: Iefdde85d3d44fabe09906cd725b39a4e0b359491
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3880811
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Owners-Override: Daniel Cheng <dcheng@chromium.org>
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1044252}
2022-09-07 23:42:04 +00:00
Avi Drissman
eccb7e8107 Update copyright headers in base/
The methodology used to generate this CL is documented in
https://crbug.com/1098010#c21.

No-Try: true
Bug: 1098010
Change-Id: Icd01cc1648eab4b0550afcff2bee17076359a132
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3879904
Owners-Override: Avi Drissman <avi@chromium.org>
Commit-Queue: Avi Drissman <avi@chromium.org>
Auto-Submit: Avi Drissman <avi@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1044191}
2022-09-07 21:26:21 +00:00
Zhibo Wang
d9e4a00a85 Create base::ThreadType to replace base::ThreadPriority
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}
2022-07-07 04:34:59 +00:00
Gabriel Charette
1dcf647b10 [base] IWYU for Callback
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}
2022-03-28 23:42:56 +00:00
Keishi Hattori
0e45c020c4 Rewrite most Foo* field_ pointer fields to raw_ptr<Foo> field_.
DO NOT REVERT (unless absolutely necessary)! Report build breaks to keishi@(APAC)/glazunov@(EMEA)/sebmarchand@(NA) as soon as you see them. Fixes are expected to be trivial.

This commit was generated automatically, by running the following script: tools/clang/rewrite_raw_ptr_fields/rewrite-multiple-platforms.sh on commit fe74bc434e

For more information, see MiraclePtr One Pager [1], the PSA at chromium-dev@ [2], and the raw_ptr documentation in //base/memory/raw_ptr.md.

FYI This CL does not enable MiraclePtr protection and we expect no behavior change from this.

[1] https://docs.google.com/document/d/1pnnOAIz_DMWDI4oIOFoMAqLnf_MZ2GsrJNb_dbQ3ZBg/edit?usp=sharing
[2] https://groups.google.com/a/chromium.org/g/chromium-dev/c/vAEeVifyf78/m/SkBUc6PhBAAJ

Binary-Size: Increase of around 500kb was approved for MiraclePtr
Include-Ci-Only-Tests: true
No-Tree-Checks: true
No-Presubmit: true
Bug: 1272324, 1073933
Change-Id: I05c86a83bbb4b3f4b017f361dd7f4e7437697f69
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3305132
Commit-Queue: Keishi Hattori <keishi@chromium.org>
Reviewed-by: Bartek Nowierski <bartekn@chromium.org>
Owners-Override: Bartek Nowierski <bartekn@chromium.org>
Cr-Commit-Position: refs/heads/main@{#945735}
2021-11-27 09:25:52 +00:00
Peter Kasting
e5a38eddbd Migrate "base::TimeDelta::FromX" to "base:X".
All changes were done automatically with git grep, sed, xargs, etc.

No-Presubmit: true
No-Try: true
Bug: 1243777
Change-Id: I7cc197e9027f7837cd36afc67a209079f85ec364
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3198824
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@{#927512}
2021-10-02 03:06:35 +00:00
David Bienvenu
b4b441e83a remove DISALLOW_COPY_AND_ASSIGN from files in base/*
Also fixes a few cpp lint errors. No functional changes.

Bug: 1010217
Change-Id: Ibdbac42980740d26392812b39f86859b238b7a64
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2422964
Commit-Queue: David Bienvenu <davidbienvenu@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#809700}
2020-09-23 05:49:57 +00:00
Lei Zhang
25c9ff6476 Use base::IsAligned() in more places.
Avoid manually doing bitwise operation, now that base::IsAligned()
exists. Also fix lint errors and some nits in modified files.

Change-Id: I6836367a9af03295c61b6273752fb51bef46bd33
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2245690
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Reviewed-by: James Darpinian <jdarpinian@chromium.org>
Reviewed-by: Peng Huang <penghuang@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#780133}
2020-06-19 02:30:43 +00:00
Sebastien Marchand
75a7cdfb81 Move the base/sys_info* files to base/system/
This is a part of my effort to cleanup our system-wide metric
measurement code.

TBR=wfh@chromium.org,bartfab@chromium.org,jochen@chromium.org,rsesek@chromium.org,kinuko@chromium.org

Bug: 891864
Change-Id: I896b8936d91789ba0e0423f0937cd54c973bfcda
Reviewed-on: https://chromium-review.googlesource.com/c/1327441
Commit-Queue: Sébastien Marchand <sebmarchand@chromium.org>
Reviewed-by: Sébastien Marchand <sebmarchand@chromium.org>
Reviewed-by: François Doray <fdoray@chromium.org>
Cr-Commit-Position: refs/heads/master@{#607813}
2018-11-13 23:47:03 +00:00
Robert Liao
6c58b870ad Revert "Make LazyInstance's constructor constexpr."
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}
2018-02-01 04:47:01 +00:00
Joe Downing
0d4683df86 Revert "Make DestructorAtExit LazyInstances leak."
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}
2018-01-24 01:32:38 +00:00
Daniel Cheng
1b97e93c5a 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}
2018-01-23 23:51:31 +00:00
Gabriel Charette
ddb183db51 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}
2018-01-19 10:19:52 +00:00
Gabriel Charette
70b37302be Add LazyInstanceTest.PriorityInversionAtInitializationResolves
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}
2018-01-17 21:00:18 +00:00
Lukasz Anforowicz
d3e1913b13 Replace LazyInstance::operator== with an explicit IsCreated() method.
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}
2017-12-06 19:44:27 +00:00
Chris Watkins
bb7211cd37 Run clang-tidy modernize-use-equals-{delete,default} on //base
See the bugs and cxx post for justification and details:
https://groups.google.com/a/chromium.org/forum/#!topic/cxx/RkOHzIK6Tq8

This change was done using clang-tidy as described here:
https://chromium.googlesource.com/chromium/src/+/lkcr/docs/clang_tidy.md

In some cases the the tool leaves behind a string of commas where it
replaced a member initializer list
(https://bugs.llvm.org/show_bug.cgi?id=35051). They were cleaned up with:
  git diff --name-only | \
    xargs sed -E -i 's/(^\s*|\)\s*):[ ,]*= default/\1 = default/'

BUG=778959,778957

Change-Id: I95a3f3dae4796e4a7beb77793a6101f433a2c649
Reviewed-on: https://chromium-review.googlesource.com/789718
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Commit-Queue: Chris Watkins <watk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#520033}
2017-11-29 07:16:38 +00:00
Ivan Kotenkov
a16212a56d Convert NULL and 0 to nullptr in base using clang-tidy.
Steps to replicate:
1. Build clang-tidy and clang-apply-replacements as described here: https://chromium.googlesource.com/chromium/src/+/lkcr/docs/clang_tidy.md
2. Build targets necessary for the change in out/gn.
3. Generate the compilation database:
  tools/clang/scripts/generate_compdb.py -p out/gn > compile_commands.json
4. Run clang-tidy and apply replacements:
  cd out/gn && PATH_TO_RUN_CLANG_TIDY/run-clang-tidy.py -p ../../ -clang-tidy-binary PATH_TO_CLANG_TIDY_BINARY -clang-apply-replacements-binary PATH_TO_CLANG_APPLY_REPLACEMENTS_BINARY -checks=-*,modernize-use-nullptr -fix -j 8 DIR_TO_CONVERT

Bug: 403854, 776257
Change-Id: I920f43d09b9fab758a3b8663fcf0c405d8519ad4
Reviewed-on: https://chromium-review.googlesource.com/732105
Commit-Queue: Ivan Kotenkov <kotenkov@yandex-team.ru>
Reviewed-by: danakj <danakj@chromium.org>
Cr-Commit-Position: refs/heads/master@{#514808}
2017-11-08 12:37:33 +00:00
tzik
455b325fa3 Replace base::StaticAtomicSequenceNumber with base::AtomicSequenceNumber in //base and //cc
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}
2017-07-20 03:24:57 +00:00
brettw
16289b3ef7 Use C++11 alignment primitives
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}
2017-06-13 21:58:40 +00:00
scottmg
5e65e3a4fb Require explicit selection of traits for LazyInstance
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}
2017-03-08 08:48:46 +00:00
avi
9b6f42934e Switch to standard integer types in base/.
BUG=138542
TBR=mark@chromium.org
NOPRESUBMIT=true

Review URL: https://codereview.chromium.org/1538743002

Cr-Commit-Position: refs/heads/master@{#366910}
2015-12-26 22:16:15 +00:00
dcheng
5648818ef9 Standardize usage of virtual/override/final in base/
BUG=417463
TBR=danakj@chromium.org

Review URL: https://codereview.chromium.org/668783004

Cr-Commit-Position: refs/heads/master@{#300447}
2014-10-21 10:55:12 +00:00
mostynb
9e096de10e replace OVERRIDE and FINAL with override and final in base/
BUG=417463

Review URL: https://codereview.chromium.org/611153004

Cr-Commit-Position: refs/heads/master@{#298520}
2014-10-07 17:59:25 +00:00
rsleevi@chromium.org
441061813c Add virtual and OVERRIDE to base/ implementation files
BUG=none
TEST=compiles


Review URL: http://codereview.chromium.org/10004001

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@131098 0039d316-1c4b-4281-b951-d872f2087c98
2012-04-06 03:53:02 +00:00
pliard@chromium.org
8a8443ffbb Add base::StaticAtomicSequenceNumber.
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
2012-03-13 12:07:19 +00:00
jbates@chromium.org
cd924d6e5e Add ALIGNAS and ALIGNOF macros to ensure proper alignment of StaticMemorySingletonTraits
BUG=95006

Review URL: https://chromiumcodereview.appspot.com/9186057

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@123270 0039d316-1c4b-4281-b951-d872f2087c98
2012-02-23 17:52:20 +00:00
fischman@chromium.org
9fc441643d Add a convenience typedef LazyInstance<T>::Leaky to avoid repeating T.
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
2012-01-23 22:56:41 +00:00
tedvessenes@gmail.com
a1b75b94f6 Change code in base (primarily unit tests) to use Sleep(TimeDelta).
BUG=108171
TEST=


Review URL: http://codereview.chromium.org/9055001

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@116065 0039d316-1c4b-4281-b951-d872f2087c98
2011-12-31 22:53:51 +00:00
joth@chromium.org
6de0fd1d93 Allow linker initialization of lazy instance
Using the initializer list construct = {0} allows the object to be linker initialized.
Modify the LazyInstance class design to make it a pod aggregate type that can be linker initialized this way. Also combines the instance and state members, in line with the Singleton<> class design.
Introduces a new LAZY_INSTANCE_INITIALIZER macro specifically for using to init all lazy instances + modify all existing callsites to use it. (Old code would no longer compile)

BUG=94925
TEST=existing tests pass. http://build.chromium.org/f/chromium/perf/linux-release/sizes/report.html?history=150&header=chrome-si&graph=chrome-si&rev=-1 should step downward.
TBR=jam@chromium.org,rvargas@chromium.org,darin@chromium.org,ben@chromium.org,apatrick@chromium.org,akalin@chromium.org

Review URL: http://codereview.chromium.org/8491043

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@110076 0039d316-1c4b-4281-b951-d872f2087c98
2011-11-15 13:31:49 +00:00
brettw@chromium.org
ce072a7181 Move platform_thread to base/threading and put in the base namespace. I left a
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
2010-12-31 20:02:16 +00:00
brettw@chromium.org
ac9ba8fe1d Move some misc thread-related stuff from base to base/thread and into the base
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
2010-12-30 18:08:36 +00:00
evan@chromium.org
dcc6933f48 ThreadRestrictions: leak the thread local variable
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
2010-10-21 20:41:47 +00:00
erg@google.com
2fdc86af64 Style cleanup in preparation for auto-linting base/.
BUG=none
TEST=none

Review URL: http://codereview.chromium.org/552004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@37164 0039d316-1c4b-4281-b951-d872f2087c98
2010-01-26 23:08:02 +00:00
phajdan.jr@chromium.org
4ea927b886 Isolate tests by running AtExit callbacks between them.
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
2009-11-19 09:11:39 +00:00
maruel@chromium.org
52a261f59b NO CODE CHANGE (except one global std::wstring changed to const wchar_t* const per style compliance).
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
2009-03-03 15:01:12 +00:00
deanm@google.com
30039e6ec6 Create a LazyInstance abstraction for avoiding static constructors by lazily creating an instance of an object on first access. This is like Singleton, but without the Singleton property of sharing instances. This also preallocates space for the object to avoid the heap to try to help fragmentation and creation performance.
Review URL: http://codereview.chromium.org/1608

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1837 0039d316-1c4b-4281-b951-d872f2087c98
2008-09-08 14:11:13 +00:00