tree: dc5acde040ec17ce15324289c51f47c21308a723 [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. input_hint_checker.cc
  49. input_hint_checker.h
  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_bytebuffer.cc
  71. jni_bytebuffer.h
  72. jni_bytebuffer_unittest.cc
  73. jni_conversions.cc
  74. jni_registrar.cc
  75. jni_registrar.h
  76. jni_string.cc
  77. jni_string.h
  78. jni_string_unittest.cc
  79. jni_utils.cc
  80. jni_utils.h
  81. jni_weak_ref.cc
  82. jni_weak_ref.h
  83. locale_utils.cc
  84. locale_utils.h
  85. meminfo_dump_provider.cc
  86. meminfo_dump_provider.h
  87. meminfo_dump_provider_unittest.cc
  88. memory_pressure_listener_android.cc
  89. memory_pressure_listener_android.h
  90. memory_purge_manager_android.cc
  91. memory_purge_manager_android.h
  92. native_uma_recorder.cc
  93. OWNERS
  94. path_service_android.cc
  95. path_utils.cc
  96. path_utils.h
  97. path_utils_unittest.cc
  98. pmf_utils.cc
  99. pmf_utils.h
  100. pmf_utils_unittest.cc
  101. pre_freeze_background_memory_trimmer.cc
  102. pre_freeze_background_memory_trimmer.h
  103. pre_freeze_background_memory_trimmer_unittest.cc
  104. radio_utils.cc
  105. radio_utils.h
  106. radio_utils_unittest.cc
  107. README.md
  108. requires_api.h
  109. resource_exclusions.gni
  110. robolectric_jni_onload.cc
  111. scoped_hardware_buffer_fence_sync.cc
  112. scoped_hardware_buffer_fence_sync.h
  113. scoped_hardware_buffer_handle.cc
  114. scoped_hardware_buffer_handle.h
  115. scoped_java_ref.h
  116. scoped_java_ref_unittest.cc
  117. statistics_recorder_android.cc
  118. sys_utils.cc
  119. sys_utils.h
  120. sys_utils_unittest.cc
  121. thread_instruction_count.cc
  122. thread_instruction_count.h
  123. timezone_utils.cc
  124. timezone_utils.h
  125. token_android.cc
  126. token_android.h
  127. token_android_unittest.cc
  128. trace_event_binding.cc
  129. trace_event_binding.h
  130. unguessable_token_android.cc
  131. unguessable_token_android.h
  132. 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.