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