• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2024 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include <string>
6 
7 #include "base/android/feature_map.h"
8 #include "base/base_jni/BaseFeatureMap_jni.h"
9 #include "base/feature_list.h"
10 #include "base/features.h"
11 #include "base/no_destructor.h"
12 
13 namespace base::android {
14 
15 namespace {
16 // Array of features exposed through the Java BaseFeatureMap API. Entries in
17 // this array may either refer to features defined in //base features.
18 const base::Feature* const kFeaturesExposedToJava[] = {
19     &features::kPostPowerMonitorBroadcastReceiverInitToBackground,
20     &features::kPostGetMyMemoryStateToBackground,
21 };
22 
23 // static
GetFeatureMap()24 base::android::FeatureMap* GetFeatureMap() {
25   static base::NoDestructor<base::android::FeatureMap> kFeatureMap(std::vector(
26       std::begin(kFeaturesExposedToJava), std::end(kFeaturesExposedToJava)));
27   return kFeatureMap.get();
28 }
29 
30 }  // namespace
31 
JNI_BaseFeatureMap_GetNativeMap(JNIEnv * env)32 static jlong JNI_BaseFeatureMap_GetNativeMap(JNIEnv* env) {
33   return reinterpret_cast<jlong>(GetFeatureMap());
34 }
35 
36 }  // namespace base::android
37