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