Skip to content

Commit

Permalink
VPN-5854 - Implement infrastructure for experimental features (#8859)
Browse files Browse the repository at this point in the history
  • Loading branch information
brizental authored Dec 22, 2023
1 parent c34cc36 commit f3ac6c1
Show file tree
Hide file tree
Showing 52 changed files with 143 additions and 66 deletions.
2 changes: 1 addition & 1 deletion src/addons/addon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include "conditionwatchers/addonconditionwatchertranslationthreshold.h"
#include "conditionwatchers/addonconditionwatchertriggertimesecs.h"
#include "env.h"
#include "feature.h"
#include "feature/feature.h"
#include "glean/generated/metrics.h"
#include "leakdetector.h"
#include "localizer.h"
Expand Down
2 changes: 1 addition & 1 deletion src/addons/addonapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

#include "addon.h"
#include "env.h"
#include "feature/featuremodel.h"
#include "frontend/navigator.h"
#include "leakdetector.h"
#include "logger.h"
#include "models/featuremodel.h"
#include "qmlengineholder.h"
#include "settingsholder.h"
#include "urlopener.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include "addonconditionwatcherfeaturesenabled.h"

#include "feature.h"
#include "feature/feature.h"
#include "leakdetector.h"

// static
Expand Down
2 changes: 1 addition & 1 deletion src/addons/manager/addonmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include "addonindex.h"
#include "addons/addonmessage.h"
#include "constants.h"
#include "feature.h"
#include "feature/feature.h"
#include "leakdetector.h"
#include "logger.h"
#include "qmlengineholder.h"
Expand Down
2 changes: 1 addition & 1 deletion src/authenticationinapp/authenticationinappsession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "authenticationinapp.h"
#include "authenticationlistener.h"
#include "constants.h"
#include "feature.h"
#include "feature/feature.h"
#include "glean/generated/metrics.h"
#include "hawkauth.h"
#include "hkdf.h"
Expand Down
11 changes: 6 additions & 5 deletions src/cmake/shared-sources.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ target_sources(shared-sources INTERFACE
${CMAKE_SOURCE_DIR}/src/constants.h
${CMAKE_SOURCE_DIR}/src/constants.cpp
${CMAKE_SOURCE_DIR}/src/settingslist.h
${CMAKE_SOURCE_DIR}/src/featurelist.h
${CMAKE_SOURCE_DIR}/src/feature/featurelist.h
${CMAKE_SOURCE_DIR}/src/feature/experimentalfeaturelist.h
${CMAKE_SOURCE_DIR}/src/addons/addon.cpp
${CMAKE_SOURCE_DIR}/src/addons/addon.h
${CMAKE_SOURCE_DIR}/src/addons/addonapi.cpp
Expand Down Expand Up @@ -104,8 +105,8 @@ target_sources(shared-sources INTERFACE
${CMAKE_SOURCE_DIR}/src/env.h
${CMAKE_SOURCE_DIR}/src/errorhandler.cpp
${CMAKE_SOURCE_DIR}/src/errorhandler.h
${CMAKE_SOURCE_DIR}/src/feature.cpp
${CMAKE_SOURCE_DIR}/src/feature.h
${CMAKE_SOURCE_DIR}/src/feature/feature.cpp
${CMAKE_SOURCE_DIR}/src/feature/feature.h
${CMAKE_SOURCE_DIR}/src/filterproxymodel.cpp
${CMAKE_SOURCE_DIR}/src/filterproxymodel.h
${CMAKE_SOURCE_DIR}/src/fontloader.cpp
Expand Down Expand Up @@ -156,8 +157,8 @@ target_sources(shared-sources INTERFACE
${CMAKE_SOURCE_DIR}/src/logger.h
${CMAKE_SOURCE_DIR}/src/loghandler.cpp
${CMAKE_SOURCE_DIR}/src/loghandler.h
${CMAKE_SOURCE_DIR}/src/models/featuremodel.cpp
${CMAKE_SOURCE_DIR}/src/models/featuremodel.h
${CMAKE_SOURCE_DIR}/src/feature/featuremodel.cpp
${CMAKE_SOURCE_DIR}/src/feature/featuremodel.h
${CMAKE_SOURCE_DIR}/src/models/licensemodel.cpp
${CMAKE_SOURCE_DIR}/src/models/licensemodel.h
${CMAKE_SOURCE_DIR}/src/networkmanager.cpp
Expand Down
5 changes: 3 additions & 2 deletions src/cmake/sources.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ set_property(TARGET mozillavpn-sources PROPERTY INTERFACE_INCLUDE_DIRECTORIES
# VPN Client source files
target_sources(mozillavpn-sources INTERFACE
${CMAKE_CURRENT_SOURCE_DIR}/accessiblenotification.cpp
${CMAKE_CURRENT_SOURCE_DIR}/featurelistcallback.h
${CMAKE_CURRENT_SOURCE_DIR}/featurelist.h
${CMAKE_CURRENT_SOURCE_DIR}/feature/featurelistcallback.h
${CMAKE_CURRENT_SOURCE_DIR}/feature/featurelist.h
${CMAKE_CURRENT_SOURCE_DIR}/feature/experimentalfeaturelist.h
${CMAKE_CURRENT_SOURCE_DIR}/appimageprovider.h
${CMAKE_CURRENT_SOURCE_DIR}/applistprovider.h
${CMAKE_CURRENT_SOURCE_DIR}/apppermission.cpp
Expand Down
2 changes: 1 addition & 1 deletion src/commands/commandui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include "connectionhealth.h"
#include "constants.h"
#include "controller.h"
#include "feature.h"
#include "feature/feature.h"
#include "fontloader.h"
#include "glean/generated/metrics.h"
#include "glean/generated/pings.h"
Expand Down
2 changes: 1 addition & 1 deletion src/connectionbenchmark/connectionbenchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "connectionhealth.h"
#include "constants.h"
#include "controller.h"
#include "feature.h"
#include "feature/feature.h"
#include "glean/generated/metrics.h"
#include "leakdetector.h"
#include "logger.h"
Expand Down
2 changes: 1 addition & 1 deletion src/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include "constants.h"
#include "controllerimpl.h"
#include "dnshelper.h"
#include "feature.h"
#include "feature/feature.h"
#include "frontend/navigator.h"
#include "ipaddress.h"
#include "leakdetector.h"
Expand Down
2 changes: 1 addition & 1 deletion src/dnshelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include <QHostAddress>

#include "feature.h"
#include "feature/feature.h"
#include "ipaddress.h"
#include "logger.h"
#include "rfc/rfc1918.h"
Expand Down
14 changes: 14 additions & 0 deletions src/feature/experimentalfeaturelist.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#if defined(_MSVC_TRADITIONAL) && _MSVC_TRADITIONAL
# error Not supported
#endif

#ifdef UNIT_TEST
EXPERIMENTAL_FEATURE(myExperimentalFeature, // Feature ID
"myExperimentalFeature", // Feature name
QStringList({"one", "two", "three"}) // Feature settings
)
#endif
6 changes: 6 additions & 0 deletions src/feature.cpp → src/feature/feature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ void Feature::maybeInitialize() {
callback);
#include "featurelist.h"
#undef FEATURE

#define EXPERIMENTAL_FEATURE(id, name, ...) \
new Feature(#id, name, FeatureCallback_true, FeatureCallback_true, \
QStringList(), FeatureCallback_false);
#include "experimentalfeaturelist.h"
#undef EXPERIMENTAL_FEATURE
}
}

Expand Down
5 changes: 5 additions & 0 deletions src/feature.h → src/feature/feature.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ class Feature : public QObject {
#include "featurelist.h"
#undef FEATURE

#define EXPERIMENTAL_FEATURE(id, name, ...) \
static constexpr const char* ExperimentalFeature_##id = #id;
#include "experimentalfeaturelist.h"
#undef EXPERIMENTAL_FEATURE

Q_PROPERTY(QString id MEMBER m_id CONSTANT)
Q_PROPERTY(QString name MEMBER m_name CONSTANT)
Q_PROPERTY(bool isToggleable READ isToggleable CONSTANT)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/frontend/navigator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#include "app.h"
#include "errorhandler.h"
#include "feature.h"
#include "feature/feature.h"
#include "glean/generated/metrics.h"
#include "leakdetector.h"
#include "logger.h"
Expand Down
2 changes: 1 addition & 1 deletion src/glean/mzglean.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "mzglean.h"

#include "constants.h"
#include "feature.h"
#include "feature/feature.h"
#include "glean/generated/metrics.h"
#include "glean/generated/pings.h"
#include "leakdetector.h"
Expand Down
4 changes: 2 additions & 2 deletions src/inspector/inspectorhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
#include <functional>

#include "constants.h"
#include "feature.h"
#include "feature/feature.h"
#include "feature/featuremodel.h"
#include "frontend/navigator.h"
#include "glean/generated/metrics.h"
#include "inspectorhotreloader.h"
Expand All @@ -32,7 +33,6 @@
#include "localizer.h"
#include "logger.h"
#include "loghandler.h"
#include "models/featuremodel.h"
#include "models/subscriptiondata.h"
#include "mozillavpn.h"
#include "mzglean.h"
Expand Down
2 changes: 1 addition & 1 deletion src/keyregenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include "constants.h"
#include "controller.h"
#include "feature.h"
#include "feature/feature.h"
#include "leakdetector.h"
#include "logger.h"
#include "mfbt/checkedint.h"
Expand Down
2 changes: 1 addition & 1 deletion src/loghandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include <QUrl>

#include "constants.h"
#include "feature.h"
#include "feature/feature.h"
#include "logger.h"
#include "urlopener.h"

Expand Down
2 changes: 1 addition & 1 deletion src/models/servercity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <QJsonValue>

#include "constants.h"
#include "feature.h"
#include "feature/feature.h"
#include "leakdetector.h"
#include "location.h"
#include "mozillavpn.h"
Expand Down
2 changes: 1 addition & 1 deletion src/models/servercountrymodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

#include "collator.h"
#include "constants.h"
#include "feature.h"
#include "feature/feature.h"
#include "leakdetector.h"
#include "logger.h"
#include "mozillavpn.h"
Expand Down
2 changes: 1 addition & 1 deletion src/mozillavpn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "constants.h"
#include "controller.h"
#include "dnshelper.h"
#include "feature.h"
#include "feature/feature.h"
#include "frontend/navigationbarmodel.h"
#include "frontend/navigator.h"
#include "glean/generated/metrics.h"
Expand Down
2 changes: 1 addition & 1 deletion src/platforms/android/androidcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include "androidvpnactivity.h"
#include "controller.h"
#include "errorhandler.h"
#include "feature.h"
#include "feature/feature.h"
#include "glean/generated/metrics.h"
#include "i18nstrings.h"
#include "ipaddress.h"
Expand Down
18 changes: 9 additions & 9 deletions src/platforms/ios/ioscontroller.mm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "ioscontroller.h"
#include "Mozilla-Swift.h"
#include "controller.h"
#include "feature.h"
#include "feature/feature.h"
#include "glean/generated/metrics.h"
#include "ipaddress.h"
#include "leakdetector.h"
Expand Down Expand Up @@ -115,14 +115,14 @@

if (!impl) {
logger.error() << "Controller not correctly initialized";
#if TARGET_OS_SIMULATOR
if (MozillaVPN::instance()->state() == App::StateOnboarding) {
logger.debug() << "Cannot activate VPN on a simulator. Completing onboarding.";
MozillaVPN::instance()->onboardingCompleted();
}
#endif

#if TARGET_OS_SIMULATOR
if (MozillaVPN::instance()->state() == App::StateOnboarding) {
logger.debug() << "Cannot activate VPN on a simulator. Completing onboarding.";
MozillaVPN::instance()->onboardingCompleted();
}
#endif

emit disconnected();
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/productshandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <QScopeGuard>

#include "constants.h"
#include "feature.h"
#include "feature/feature.h"
#include "leakdetector.h"
#include "logger.h"
#include "mozillavpn.h"
Expand Down
2 changes: 1 addition & 1 deletion src/qmlengineholder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "authenticationinapp/authenticationinapp.h"
#include "env.h"
#include "errorhandler.h"
#include "feature/featuremodel.h"
#include "frontend/navigationbarmodel.h"
#include "frontend/navigator.h"
#include "glean/generated/metrics.h"
Expand All @@ -20,7 +21,6 @@
#include "leakdetector.h"
#include "localizer.h"
#include "loghandler.h"
#include "models/featuremodel.h"
#include "models/licensemodel.h"
#include "settingsholder.h"
#include "theme.h"
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/sentryadapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include <QStandardPaths>

#include "constants.h"
#include "feature.h"
#include "feature/feature.h"
#include "leakdetector.h"
#include "logger.h"
#include "loghandler.h"
Expand Down
2 changes: 1 addition & 1 deletion src/serverlatency.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <QDateTime>

#include "controller.h"
#include "feature.h"
#include "feature/feature.h"
#include "leakdetector.h"
#include "logger.h"
#include "mfbt/checkedint.h"
Expand Down
20 changes: 19 additions & 1 deletion src/settingsholder.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@
#include <QVariant>

#include "constants.h"
#include "feature.h"
#include "feature/feature.h"
#include "settings/setting.h"
#include "settings/settingsmanager.h"

constexpr const char* EXPERIMENTS_SETTING_GROUP = "experiments";

/**
* @brief The SettingsHolder class is a singleton that exposes the APIs to
* interact with build time declared static settings.
Expand Down Expand Up @@ -56,6 +58,12 @@ class SettingsHolder final : public QObject {
#include "settingslist.h"
#undef SETTING

#define EXPERIMENTAL_FEATURE(experimentId, ...) \
SettingGroup* experimentId() { return m_##experimentId; }

#include "feature/experimentalfeaturelist.h"
#undef EXPERIMENTAL_FEATURE

private:
#define SETTING(type, toType, getter, setter, remover, has, key, defaultValue, \
removeWhenReset, isSensitive) \
Expand All @@ -66,6 +74,16 @@ class SettingsHolder final : public QObject {
#include "settingslist.h"
#undef SETTING

#define EXPERIMENTAL_FEATURE(experimentId, experimentDescription, \
experimentSettings) \
SettingGroup* m_##experimentId = \
SettingsManager::instance()->createSettingGroup( \
QString("%1/%2").arg(EXPERIMENTS_SETTING_GROUP).arg(#experimentId), \
true, false, experimentSettings);

#include "feature/experimentalfeaturelist.h"
#undef EXPERIMENTAL_FEATURE

bool m_firstExecution = false;
};

Expand Down
2 changes: 1 addition & 1 deletion src/tasks/getfeaturelist/taskgetfeaturelist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
#include <QJsonObject>

#include "constants.h"
#include "feature/featuremodel.h"
#include "leakdetector.h"
#include "logger.h"
#include "models/featuremodel.h"
#include "networkrequest.h"

namespace {
Expand Down
2 changes: 1 addition & 1 deletion src/telemetry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "constants.h"
#include "controller.h"
#include "dnshelper.h"
#include "feature.h"
#include "feature/feature.h"
#include "glean/generated/metrics.h"
#include "glean/generated/pings.h"
#include "leakdetector.h"
Expand Down
Loading

0 comments on commit f3ac6c1

Please sign in to comment.