blob: 9487a8cc86ea168d3880c282e95db5077a30b9a6 [file] [log] [blame]
Gordon Guanf2f7a8402019-11-27 18:26:441// 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)
14
15namespace 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|.
22enum DiscardableMemoryTrialGroup : int {
23 kEmulatedSharedMemory = 0,
24 kMadvFree,
25 // Only Android devices will be assigned to the ashmem group.
26 kAshmem,
27};
28
29namespace features {
30// Feature flag enabling the discardable memory backing trial.
31BASE_EXPORT extern const base::Feature kDiscardableMemoryBackingTrial;
32
33BASE_EXPORT extern const base::FeatureParam<DiscardableMemoryTrialGroup>::Option
34 kDiscardableMemoryBackingParamOptions[];
35
36BASE_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.
41BASE_EXPORT bool DiscardableMemoryBackingFieldTrialIsEnabled();
42
43// If we should do the discardable memory backing trial, then get the trial
44// group this session belongs in.
45BASE_EXPORT DiscardableMemoryTrialGroup
46GetDiscardableMemoryBackingFieldTrialGroup();
47
48} // namespace base
49
50#endif // defined(OS_LINUX) || defined(OS_ANDROID)
51
52#endif // BASE_MEMORY_DISCARDABLE_MEMORY_INTERNAL_H_