Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(178)

Unified Diff: third_party/WebKit/Source/build/scripts/templates/OriginTrials.cpp.tmpl

Issue 1743623002: [Experimental Framework] Make the OriginTrialContext a member of ExecutionContext (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/build/scripts/templates/OriginTrials.h.tmpl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/build/scripts/templates/OriginTrials.cpp.tmpl
diff --git a/third_party/WebKit/Source/build/scripts/templates/OriginTrials.cpp.tmpl b/third_party/WebKit/Source/build/scripts/templates/OriginTrials.cpp.tmpl
index 37c260202720e13c49461aae64b4ca2d6012fc3d..c95d7fbad9c5a1795703f366aa3913056988a916 100644
--- a/third_party/WebKit/Source/build/scripts/templates/OriginTrials.cpp.tmpl
+++ b/third_party/WebKit/Source/build/scripts/templates/OriginTrials.cpp.tmpl
@@ -3,35 +3,63 @@
#include "core/origin_trials/OriginTrials.h"
+#include "core/dom/ExecutionContext.h"
#include "core/origin_trials/OriginTrialContext.h"
#include "platform/RuntimeEnabledFeatures.h"
namespace blink {
+
+OriginTrials::OriginTrials(PassOwnPtrWillBeRawPtr<OriginTrialContext> originTrialContext)
+ : m_originTrialContext(originTrialContext) {}
+
+// static
+const char* OriginTrials::supplementName()
+{
+ return "OriginTrials";
+}
+
+// static
+OriginTrials* OriginTrials::from(ExecutionContext* host)
+{
+ OriginTrials* originTrials = reinterpret_cast<OriginTrials*>(WillBeHeapSupplement<ExecutionContext>::from(host, supplementName()));
+ if (!originTrials) {
+ originTrials = new OriginTrials(host->createOriginTrialContext());
+ WillBeHeapSupplement<ExecutionContext>::provideTo(*host, supplementName(), adoptPtrWillBeNoop(originTrials));
+ }
+ return originTrials;
+}
+
{% for feature in features %}
{% if feature.origin_trial_feature_name %}
// static
bool OriginTrials::{{feature.first_lowered_name}}Enabled(ExecutionContext* executionContext, String& errorMessage) {
- return {{feature.first_lowered_name}}EnabledImpl(executionContext, &errorMessage);
+ return OriginTrials::from(executionContext)->{{feature.first_lowered_name}}EnabledImpl(&errorMessage);
}
// static
bool OriginTrials::{{feature.first_lowered_name}}Enabled(ExecutionContext* executionContext) {
- return {{feature.first_lowered_name}}EnabledImpl(executionContext, nullptr);
+ return OriginTrials::from(executionContext)->{{feature.first_lowered_name}}EnabledImpl(nullptr);
}
+
{% endif %}
{% endfor %}
{% for feature in features %}
{% if feature.origin_trial_feature_name %}
-// static
-bool OriginTrials::{{feature.first_lowered_name}}EnabledImpl(ExecutionContext* executionContext, String* errorMessage) {
+bool OriginTrials::{{feature.first_lowered_name}}EnabledImpl(String* errorMessage) {
if (RuntimeEnabledFeatures::{{feature.first_lowered_name}}Enabled())
return true;
- return OriginTrialContext::isFeatureEnabled(executionContext, "{{feature.origin_trial_feature_name}}", errorMessage);
+ if (!m_originTrialContext) return false;
+ return m_originTrialContext->isFeatureEnabled("{{feature.origin_trial_feature_name}}", errorMessage);
}
{% endif %}
{% endfor %}
+DEFINE_TRACE(OriginTrials)
+{
+ visitor->trace(m_originTrialContext);
+ WillBeHeapSupplement<ExecutionContext>::trace(visitor);
+}
} // namespace blink
« no previous file with comments | « no previous file | third_party/WebKit/Source/build/scripts/templates/OriginTrials.h.tmpl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698