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

Base is pulled into many projects. For example, various ChromeOS daemons. So the bar for adding stuff 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.

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.
  • PthreadEventPerfTest: Establishes the baseline thread switching cost using pthreads.
  • 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.
  • 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.