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