tree: 33eb0dbb3d6a9246c09b9ab090c9a9d1ad04ca62 [path history] [tgz]
  1. allocator/
  2. android/
  3. apple/
  4. containers/
  5. debug/
  6. files/
  7. functional/
  8. hash/
  9. i18n/
  10. json/
  11. macros/
  12. memory/
  13. message_loop/
  14. metrics/
  15. nix/
  16. numerics/
  17. posix/
  18. power_monitor/
  19. process/
  20. profiler/
  21. ranges/
  22. sampling_heap_profiler/
  23. strings/
  24. substring_set_matcher/
  25. synchronization/
  26. system/
  27. task/
  28. test/
  29. third_party/
  30. threading/
  31. time/
  32. timer/
  33. trace_event/
  34. tracing/
  35. types/
  36. at_exit.cc
  37. at_exit.h
  38. at_exit_unittest.cc
  39. atomic_ref_count.h
  40. atomic_sequence_num.h
  41. atomicops.h
  42. atomicops_internals_atomicword_compat.h
  43. atomicops_internals_portable.h
  44. atomicops_unittest.cc
  45. auto_reset.h
  46. auto_reset_unittest.cc
  47. barrier_callback.h
  48. barrier_callback_unittest.cc
  49. barrier_closure.cc
  50. barrier_closure.h
  51. barrier_closure_unittest.cc
  52. base64.cc
  53. base64.h
  54. base64_decode_fuzzer.cc
  55. base64_encode_fuzzer.cc
  56. base64_unittest.cc
  57. base64url.cc
  58. base64url.h
  59. base64url_fuzzer.cc
  60. base64url_unittest.cc
  61. base_export.h
  62. base_paths.cc
  63. base_paths.h
  64. base_paths_android.cc
  65. base_paths_android.h
  66. base_paths_apple.cc
  67. base_paths_apple.h
  68. base_paths_posix.cc
  69. base_paths_posix.h
  70. base_switches.cc
  71. base_switches.h
  72. big_endian.cc
  73. big_endian.h
  74. big_endian_unittest.cc
  75. bit_cast.h
  76. bit_cast_unittest.cc
  77. bits.h
  78. bits_unittest.cc
  79. build_time.h
  80. build_time_unittest.cc
  81. callback_list.cc
  82. callback_list.h
  83. callback_list_unittest.cc
  84. callback_list_unittest.nc
  85. cancelable_callback.h
  86. cancelable_callback_unittest.cc
  87. check.cc
  88. check.h
  89. check_deref.h
  90. check_example.cc
  91. check_is_test.cc
  92. check_is_test.h
  93. check_is_test_unittest.cc
  94. check_op.cc
  95. check_op.h
  96. check_unittest.cc
  97. command_line.cc
  98. command_line.h
  99. command_line_fuzzer.cc
  100. command_line_unittest.cc
  101. compiler_specific.h
  102. component_export.h
  103. component_export_unittest.cc
  104. cpu.cc
  105. cpu.h
  106. cpu_reduction_experiment.cc
  107. cpu_reduction_experiment.h
  108. cpu_unittest.cc
  109. critical_closure.h
  110. cxx20_is_constant_evaluated.h
  111. cxx20_is_constant_evaluated_unittest.cc
  112. cxx20_to_address.h
  113. dcheck_is_on.h
  114. enterprise_util.cc
  115. enterprise_util.h
  116. environment.cc
  117. environment.h
  118. environment_unittest.cc
  119. export_template.h
  120. feature_list.cc
  121. feature_list.h
  122. feature_list_unittest.cc
  123. features.cc
  124. features.h
  125. file_descriptor_posix.cc
  126. file_descriptor_posix.h
  127. file_descriptor_store.cc
  128. file_descriptor_store.h
  129. file_version_info.h
  130. format_macros.h
  131. generated_build_date.h
  132. gmock_unittest.cc
  133. gtest_prod_util.h
  134. immediate_crash.h
  135. immediate_crash_unittest.cc
  136. lazy_instance.h
  137. lazy_instance_helpers.cc
  138. lazy_instance_helpers.h
  139. lazy_instance_unittest.cc
  140. libcpp_hardening_test.cc
  141. linux_util.cc
  142. linux_util.h
  143. linux_util_unittest.cc
  144. location.cc
  145. location.h
  146. location_unittest.cc
  147. logging.cc
  148. logging.h
  149. logging_buildflags.h
  150. logging_chromeos.cc
  151. logging_unittest.cc
  152. native_library.cc
  153. native_library.h
  154. native_library_posix.cc
  155. native_library_unittest.cc
  156. no_destructor.h
  157. no_destructor_unittest.cc
  158. no_destructor_unittest.nc
  159. nodebug_assertion.cc
  160. notreached.h
  161. observer_list.h
  162. observer_list_internal.cc
  163. observer_list_internal.h
  164. observer_list_perftest.cc
  165. observer_list_threadsafe.cc
  166. observer_list_threadsafe.h
  167. observer_list_threadsafe_unittest.cc
  168. observer_list_types.cc
  169. observer_list_types.h
  170. observer_list_unittest.cc
  171. observer_list_unittest.nc
  172. one_shot_event.cc
  173. one_shot_event.h
  174. one_shot_event_unittest.cc
  175. os_compat_android.cc
  176. os_compat_android.h
  177. os_compat_android_unittest.cc
  178. parameter_pack.h
  179. parameter_pack_unittest.cc
  180. path_service.cc
  181. path_service.h
  182. path_service_unittest.cc
  183. pending_task.cc
  184. pending_task.h
  185. pickle.cc
  186. pickle.h
  187. pickle_fuzzer.cc
  188. pickle_unittest.cc
  189. rand_util.cc
  190. rand_util.h
  191. rand_util_perftest.cc
  192. rand_util_posix.cc
  193. rand_util_unittest.cc
  194. README.md
  195. run_loop.cc
  196. run_loop.h
  197. run_loop_unittest.cc
  198. safe_numerics_unittest.cc
  199. scoped_add_feature_flags.cc
  200. scoped_add_feature_flags.h
  201. scoped_add_feature_flags_unittest.cc
  202. scoped_clear_last_error.h
  203. scoped_clear_last_error_unittest.cc
  204. scoped_environment_variable_override.cc
  205. scoped_environment_variable_override.h
  206. scoped_generic.h
  207. scoped_generic_unittest.cc
  208. scoped_multi_source_observation.h
  209. scoped_multi_source_observation_unittest.cc
  210. scoped_native_library.cc
  211. scoped_native_library.h
  212. scoped_native_library_unittest.cc
  213. scoped_observation.h
  214. scoped_observation_traits.h
  215. scoped_observation_traits_internal.h
  216. scoped_observation_unittest.cc
  217. security_unittest.cc
  218. sequence_checker.cc
  219. sequence_checker.h
  220. sequence_checker_impl.cc
  221. sequence_checker_impl.h
  222. sequence_checker_unittest.cc
  223. sequence_checker_unittest.nc
  224. sequence_token.cc
  225. sequence_token.h
  226. sequence_token_unittest.cc
  227. stack_canary_linux.cc
  228. stack_canary_linux.h
  229. stack_canary_linux_unittest.cc
  230. state_transitions.h
  231. state_transitions_unittest.cc
  232. std_clamp_unittest.cc
  233. stl_util.h
  234. stl_util_unittest.cc
  235. supports_user_data.cc
  236. supports_user_data.h
  237. supports_user_data_unittest.cc
  238. sync_socket.cc
  239. sync_socket.h
  240. sync_socket_posix.cc
  241. sync_socket_unittest.cc
  242. sys_byteorder.h
  243. sys_byteorder_unittest.cc
  244. syslog_logging.cc
  245. syslog_logging.h
  246. template_util.h
  247. template_util_unittest.cc
  248. thread_annotations.h
  249. thread_annotations_unittest.cc
  250. thread_annotations_unittest.nc
  251. token.cc
  252. token.h
  253. token_unittest.cc
  254. tools_sanity_unittest.cc
  255. traits_bag.h
  256. traits_bag_unittest.cc
  257. traits_bag_unittest.nc
  258. tuple.h
  259. tuple_unittest.cc
  260. unguessable_token.cc
  261. unguessable_token.h
  262. unguessable_token_unittest.cc
  263. uuid.cc
  264. uuid.h
  265. uuid_unittest.cc
  266. value_iterators.cc
  267. value_iterators.h
  268. value_iterators_unittest.cc
  269. values.cc
  270. values.h
  271. values_unittest.cc
  272. values_unittest.nc
  273. version.cc
  274. version.h
  275. version_unittest.cc
  276. vlog.cc
  277. vlog.h
  278. vlog_unittest.cc
  279. write_build_date_header.py
base/README.md

What is this

Contains a written down set of principles and other information on //base. Please add to it!

About //base:

Chromium is a very mature project. Most things that are generally useful are already here and things not here aren't generally useful.

The bar for adding stuff to base is that it must have demonstrated wide applicability. Prefer to add things closer to where they're used (i.e. “not base”), and pull into base only when needed. In a project our size, sometimes even duplication is OK and inevitable.

Adding a new logging macro DPVELOG_NE is not more clear than just writing the stuff you want to log in a regular logging statement, even if it makes your calling code longer. Just add it to your own code.

If the code in question does not need to be used inside base, but will have multiple consumers across the codebase, consider placing it in a new directory under components/ instead.

base is written for the Chromium project and is not intended to be used outside it. Using base outside of src.git is explicitly not supported, and base makes no guarantees about API (or even ABI) stability (like all other code in Chromium). New code that depends on base/ must be in src.git. Code that's not in src.git but pulled in through DEPS (for example, v8) cannot use base.

Qualifications for being in //base OWNERS

  • interest and ability to learn low level/high detail/complex c++ stuff
  • inclination to always ask why and understand everything (including external interactions like win32) rather than just hoping the author did it right
  • mentorship/experience
  • demonstrated good judgement (esp with regards to public APIs) over a length of time

Owners are added when a contributor has shown the above qualifications and when they express interest. There isn't an upper bound on the number of OWNERS.

Design and naming

  • Be sure to use the base namespace.
  • STL-like constructs should adhere as closely to STL as possible. Functions and behaviors not present in STL should only be added when they are related to the specific data structure implemented by the container.
  • For STL-like constructs our policy is that they should use STL-like naming even when it may conflict with the style guide. So functions and class names should be lower case with underscores. Non-STL-like classes and functions should use Google naming.

Performance testing

Since the primitives provided by //base are used very widely, it is important to ensure they scale to the necessary workloads and perform well under all supported platforms. The base_perftests target is a suite of synthetic microbenchmarks that measure performance in various scenarios:

  • BasicPostTaskPerfTest: Exercises MessageLoopTaskRunner's multi-threaded queue in isolation.
  • ConditionVariablePerfTest: Measures thread switching cost of condition variables.
  • IntegratedPostTaskPerfTest: Exercises the full MessageLoop/RunLoop machinery.
  • JSONPerfTest: Tests JSONWriter and JSONReader performance.
  • MessageLoopPerfTest: Measures the speed of task posting in various configurations.
  • ObserverListPerfTest: Exercises adding, removing and signalling observers.
  • PartitionLockPerfTest: Tests the implementation of Lock used in PartitionAlloc
  • PthreadEventPerfTest: Establishes the baseline thread switching cost using pthreads.
  • RandUtilPerfTest: Measures the time it takes to generate random numbers.
  • ScheduleWorkTest: Measures the overhead of MessagePump::ScheduleWork.
  • SequenceManagerPerfTest: Benchmarks SequenceManager scheduling with various underlying task runners.
  • TaskObserverPerfTest: Measures the incremental cost of adding task observers.
  • TaskPerfTest: Checks the cost of posting tasks between threads.
  • ThreadLocalStoragePerfTest: Exercises different mechanisms for accessing data associated with the current thread (C++ thread_local, the implementation in //base, the POSIX/WinAPI directly)
  • WaitableEvent{Thread,}PerfTest: Measures waitable events in single and multithreaded scenarios.

Regressions in these benchmarks can generally by caused by 1) operating system changes, 2) compiler version or flag changes or 3) changes in //base code itself.