tree: 3a1cb778f1d6c70f12586e75a4bd113a8e3b21a1 [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. immediate_crash.h
  143. immediate_crash_unittest.cc
  144. lazy_instance.h
  145. lazy_instance_helpers.cc
  146. lazy_instance_helpers.h
  147. lazy_instance_unittest.cc
  148. linux_util.cc
  149. linux_util.h
  150. location.cc
  151. location.h
  152. logging.cc
  153. logging.h
  154. logging_unittest.cc
  155. logging_win.cc
  156. logging_win.h
  157. macros.h
  158. native_library.cc
  159. native_library.h
  160. native_library_fuchsia.cc
  161. native_library_ios.mm
  162. native_library_mac.mm
  163. native_library_posix.cc
  164. native_library_unittest.cc
  165. native_library_win.cc
  166. no_destructor.h
  167. no_destructor_unittest.cc
  168. observer_list.h
  169. observer_list_internal.cc
  170. observer_list_internal.h
  171. observer_list_perftest.cc
  172. observer_list_threadsafe.cc
  173. observer_list_threadsafe.h
  174. observer_list_threadsafe_unittest.cc
  175. observer_list_types.cc
  176. observer_list_types.h
  177. observer_list_unittest.cc
  178. observer_list_unittest.nc
  179. one_shot_event.cc
  180. one_shot_event.h
  181. one_shot_event_unittest.cc
  182. optional.h
  183. optional_unittest.cc
  184. optional_unittest.nc
  185. os_compat_android.cc
  186. os_compat_android.h
  187. os_compat_android_unittest.cc
  188. os_compat_nacl.cc
  189. os_compat_nacl.h
  190. OWNERS
  191. parameter_pack.h
  192. parameter_pack_unittest.cc
  193. path_service.cc
  194. path_service.h
  195. path_service_unittest.cc
  196. pending_task.cc
  197. pending_task.h
  198. pickle.cc
  199. pickle.h
  200. pickle_fuzzer.cc
  201. pickle_unittest.cc
  202. post_task_and_reply_with_result_internal.h
  203. PRESUBMIT.py
  204. rand_util.cc
  205. rand_util.h
  206. rand_util_fuchsia.cc
  207. rand_util_nacl.cc
  208. rand_util_posix.cc
  209. rand_util_unittest.cc
  210. rand_util_win.cc
  211. README.md
  212. run_loop.cc
  213. run_loop.h
  214. run_loop_unittest.cc
  215. safe_numerics_unittest.cc
  216. scoped_clear_last_error.h
  217. scoped_clear_last_error_unittest.cc
  218. scoped_clear_last_error_win.cc
  219. scoped_generic.h
  220. scoped_generic_unittest.cc
  221. scoped_native_library.cc
  222. scoped_native_library.h
  223. scoped_native_library_unittest.cc
  224. scoped_observer.h
  225. SECURITY_OWNERS
  226. security_unittest.cc
  227. sequence_checker.h
  228. sequence_checker_impl.cc
  229. sequence_checker_impl.h
  230. sequence_checker_unittest.cc
  231. sequence_token.cc
  232. sequence_token.h
  233. sequence_token_unittest.cc
  234. sequenced_task_runner.cc
  235. sequenced_task_runner.h
  236. sequenced_task_runner_helpers.h
  237. sequenced_task_runner_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.