tree: 54e107c707fa5d815d90a12fde17dcd5a127c25d [path history] [tgz]
  1. java/
  2. javatests/
  3. jni_generator/
  4. junit/
  5. library_loader/
  6. linker/
  7. orderfile/
  8. proguard/
  9. task_scheduler/
  10. android_hardware_buffer_compat.cc
  11. android_hardware_buffer_compat.h
  12. android_image_reader_abi.h
  13. android_image_reader_compat.cc
  14. android_image_reader_compat.h
  15. android_image_reader_compat_unittest.cc
  16. apk_assets.cc
  17. apk_assets.h
  18. application_status_listener.cc
  19. application_status_listener.h
  20. application_status_listener_unittest.cc
  21. base_feature_list.cc
  22. base_features.cc
  23. base_features.h
  24. base_jni_onload.cc
  25. base_jni_onload.h
  26. build_info.cc
  27. build_info.h
  28. bundle_utils.cc
  29. bundle_utils.h
  30. callback_android.cc
  31. callback_android.h
  32. child_process_binding_types.h
  33. child_process_service.cc
  34. child_process_unittest.cc
  35. command_line_android.cc
  36. COMMON_METADATA
  37. content_uri_utils.cc
  38. content_uri_utils.h
  39. content_uri_utils_unittest.cc
  40. cpu_features.cc
  41. DIR_METADATA
  42. early_trace_event_binding.cc
  43. early_trace_event_binding.h
  44. event_log.cc
  45. event_log.h
  46. feature_list_jni.cc
  47. features_jni.cc
  48. field_trial_list.cc
  49. important_file_writer_android.cc
  50. int_string_callback.cc
  51. int_string_callback.h
  52. jank_metric_uma_recorder.cc
  53. jank_metric_uma_recorder.h
  54. jank_metric_uma_recorder_unittest.cc
  55. java_exception_reporter.cc
  56. java_exception_reporter.h
  57. java_handler_thread.cc
  58. java_handler_thread.h
  59. java_handler_thread_unittest.cc
  60. java_heap_dump_generator.cc
  61. java_heap_dump_generator.h
  62. java_runtime.cc
  63. java_runtime.h
  64. jni_android.cc
  65. jni_android.h
  66. jni_android_unittest.cc
  67. jni_array.cc
  68. jni_array.h
  69. jni_array_unittest.cc
  70. jni_int_wrapper.h
  71. jni_registrar.cc
  72. jni_registrar.h
  73. jni_string.cc
  74. jni_string.h
  75. jni_string_unittest.cc
  76. jni_utils.cc
  77. jni_utils.h
  78. jni_weak_ref.cc
  79. jni_weak_ref.h
  80. locale_utils.cc
  81. locale_utils.h
  82. memory_pressure_listener_android.cc
  83. memory_pressure_listener_android.h
  84. native_uma_recorder.cc
  85. OWNERS
  86. path_service_android.cc
  87. path_utils.cc
  88. path_utils.h
  89. path_utils_unittest.cc
  90. radio_utils.cc
  91. radio_utils.h
  92. radio_utils_unittest.cc
  93. reached_addresses_bitset.cc
  94. reached_addresses_bitset.h
  95. reached_addresses_bitset_unittest.cc
  96. reached_code_profiler.cc
  97. reached_code_profiler.h
  98. reached_code_profiler_stub.cc
  99. README.md
  100. remove_stale_data.cc
  101. remove_stale_data.h
  102. resource_exclusions.gni
  103. scoped_hardware_buffer_fence_sync.cc
  104. scoped_hardware_buffer_fence_sync.h
  105. scoped_hardware_buffer_handle.cc
  106. scoped_hardware_buffer_handle.h
  107. scoped_java_ref.cc
  108. scoped_java_ref.h
  109. scoped_java_ref_unittest.cc
  110. statistics_recorder_android.cc
  111. sys_utils.cc
  112. sys_utils.h
  113. sys_utils_unittest.cc
  114. thread_instruction_count.cc
  115. thread_instruction_count.h
  116. timezone_utils.cc
  117. timezone_utils.h
  118. trace_event_binding.cc
  119. trace_event_binding.h
  120. unguessable_token_android.cc
  121. unguessable_token_android.h
  122. unguessable_token_android_unittest.cc
android/README.md

//base/android

This directory contains:

  • C++ APIs that are broadly useful and are unique to target_os="android", and
  • Java APIs that are broadly useful, along C++ bindings when necessary.

This directory does not contain Android-specific implementations / extensions to APIs declared directly in //base. Those live in //base/*_android.cc, or behind #ifdefs.

Adding New APIs

The advice laid out in //base/README.md applies to this directory as well. The bars for what APIs should exist and for code quality are generally higher than for other directories. If you find yourself wanting to add a new API, you should expect that code reviews take multiple revisions and that they be met with (respectful) scrutiny.

If you are not sure whether an API would make sense to add, you can ask via java@chromium.org. It is common to add APIs to //chrome (or elsewhere) first, and move them into //base after their usefulness has been proven.

What Uses //base/android?

The main two clients are Chrome and WebView, but it is also used by other Chromium-based apps, such as Chromecast and Chrome Remote desktop. Some //base/android classes are used by //build (this is a layering violation, tracked in crbug/1364192 and crbug/1377351).

Two considerations for WebView:

  1. The application Context is that of the host app's.
  2. The UI thread might be different from the main thread.

New API Checklist

Here is a list of checks you should go through when adding a new API:

  1. The functionality does not already exist in system libraries (Java APIs, Android SDK) or in already adopted third_party libraries, such as AndroidX.
  2. Reasonable effort has been made to ensure the new API is discoverable. E.g.: Coordinate refactorings of existing patterns to it, add a [presubmit check], to recommend it, etc.
  3. Tests (ideally Robolectric) are added.
  4. Thought has been put into API design.
    • E.g. adding @Nullable, or @DoNotMock
    • E.g. adding test helpers, such as ForTesting() methods or TestRules
    • E.g. adding asserts or comments about thread-safety
    • E.g. could usage of the API be made harder to get wrong?

Choosing a Reviewer

All members of //base/android/OWNERS will be CC'ed on reviews through a //WATCHLIST entry. For new APIs, feel free to pick a reviewer at random. For modifying existing files, it is best to use a reviewer from prior changes to the file.