discardable_memory_internal.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. #ifndef BASE_MEMORY_DISCARDABLE_MEMORY_INTERNAL_H_
  5. #define BASE_MEMORY_DISCARDABLE_MEMORY_INTERNAL_H_
  6. #include "base/base_export.h"
  7. #include "base/feature_list.h"
  8. #include "base/metrics/field_trial_params.h"
  9. #include "build/build_config.h"
  10. #if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
  11. namespace base {
  12. // Enumeration of the possible experiment groups in the discardable memory
  13. // backing trial. Note that |kAshmem| and |kEmulatedSharedMemory| both map to
  14. // discardable shared memory, except the former allows for the use of ashmem for
  15. // unpinning memory. Ensure that the order of the enum values matches those in
  16. // |kDiscardableMemoryBackingParamOptions|.
  17. enum DiscardableMemoryTrialGroup : int {
  18. kEmulatedSharedMemory = 0,
  19. kMadvFree,
  20. // Only Android devices will be assigned to the ashmem group.
  21. kAshmem,
  22. };
  23. namespace features {
  24. // Feature flag enabling the discardable memory backing trial.
  25. BASE_EXPORT extern const base::Feature kDiscardableMemoryBackingTrial;
  26. BASE_EXPORT extern const base::FeatureParam<DiscardableMemoryTrialGroup>::Option
  27. kDiscardableMemoryBackingParamOptions[];
  28. BASE_EXPORT extern const base::FeatureParam<DiscardableMemoryTrialGroup>
  29. kDiscardableMemoryBackingParam;
  30. } // namespace features
  31. // Whether we should do the discardable memory backing trial for this session.
  32. BASE_EXPORT bool DiscardableMemoryBackingFieldTrialIsEnabled();
  33. // If we should do the discardable memory backing trial, then get the trial
  34. // group this session belongs in.
  35. BASE_EXPORT DiscardableMemoryTrialGroup
  36. GetDiscardableMemoryBackingFieldTrialGroup();
  37. } // namespace base
  38. #endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) ||
  39. // BUILDFLAG(IS_ANDROID)
  40. #endif // BASE_MEMORY_DISCARDABLE_MEMORY_INTERNAL_H_