1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4  * License, v. 2.0. If a copy of the MPL was not distributed with this
5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 
7 // This is a cut down version of base/feature_list.h.
8 // This just returns the default state for a feature.
9 
10 #ifndef BASE_FEATURE_LIST_H_
11 #define BASE_FEATURE_LIST_H_
12 
13 #include "base/macros.h"
14 
15 namespace base {
16 
17 // Specifies whether a given feature is enabled or disabled by default.
18 enum FeatureState {
19   FEATURE_DISABLED_BY_DEFAULT,
20   FEATURE_ENABLED_BY_DEFAULT,
21 };
22 
23 // The Feature struct is used to define the default state for a feature. See
24 // comment below for more details. There must only ever be one struct instance
25 // for a given feature name - generally defined as a constant global variable or
26 // file static. It should never be used as a constexpr as it breaks
27 // pointer-based identity lookup.
28 struct BASE_EXPORT Feature {
29   // The name of the feature. This should be unique to each feature and is used
30   // for enabling/disabling features via command line flags and experiments.
31   // It is strongly recommended to use CamelCase style for feature names, e.g.
32   // "MyGreatFeature".
33   const char* const name;
34 
35   // The default state (i.e. enabled or disabled) for this feature.
36   const FeatureState default_state;
37 };
38 
39 class BASE_EXPORT FeatureList {
40  public:
IsEnabled(const Feature & feature)41   static bool IsEnabled(const Feature& feature) {
42     return feature.default_state == FEATURE_ENABLED_BY_DEFAULT;
43   }
44 
GetInstance()45   static FeatureList* GetInstance() { return nullptr; }
46 
47   DISALLOW_COPY_AND_ASSIGN(FeatureList);
48 };
49 
50 }  // namespace base
51 
52 #endif  // BASE_FEATURE_LIST_H_
53