1 // Copyright 2019 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef BASE_MEMORY_DISCARDABLE_MEMORY_INTERNAL_H_ 6 #define BASE_MEMORY_DISCARDABLE_MEMORY_INTERNAL_H_ 7 8 #include "base/base_export.h" 9 #include "base/feature_list.h" 10 #include "base/metrics/field_trial_params.h" 11 #include "build/build_config.h" 12 13 #if defined(OS_ANDROID) || defined(OS_LINUX) || defined(OS_BSD) 14 15 namespace base { 16 17 // Enumeration of the possible experiment groups in the discardable memory 18 // backing trial. Note that |kAshmem| and |kEmulatedSharedMemory| both map to 19 // discardable shared memory, except the former allows for the use of ashmem for 20 // unpinning memory. Ensure that the order of the enum values matches those in 21 // |kDiscardableMemoryBackingParamOptions|. 22 enum DiscardableMemoryTrialGroup : int { 23 kEmulatedSharedMemory = 0, 24 kMadvFree, 25 // Only Android devices will be assigned to the ashmem group. 26 kAshmem, 27 }; 28 29 namespace features { 30 // Feature flag enabling the discardable memory backing trial. 31 BASE_EXPORT extern const base::Feature kDiscardableMemoryBackingTrial; 32 33 BASE_EXPORT extern const base::FeatureParam<DiscardableMemoryTrialGroup>::Option 34 kDiscardableMemoryBackingParamOptions[]; 35 36 BASE_EXPORT extern const base::FeatureParam<DiscardableMemoryTrialGroup> 37 kDiscardableMemoryBackingParam; 38 } // namespace features 39 40 // Whether we should do the discardable memory backing trial for this session. 41 BASE_EXPORT bool DiscardableMemoryBackingFieldTrialIsEnabled(); 42 43 // If we should do the discardable memory backing trial, then get the trial 44 // group this session belongs in. 45 BASE_EXPORT DiscardableMemoryTrialGroup 46 GetDiscardableMemoryBackingFieldTrialGroup(); 47 48 } // namespace base 49 50 #endif // defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_BSD) 51 52 #endif // BASE_MEMORY_DISCARDABLE_MEMORY_INTERNAL_H_ 53