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

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: Clean up unused headers Created 4 years, 10 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
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..901e7773ea2db3e45a9fb223f1508bc45a99f47f 100644
--- a/third_party/WebKit/Source/build/scripts/templates/OriginTrials.cpp.tmpl
+++ b/third_party/WebKit/Source/build/scripts/templates/OriginTrials.cpp.tmpl
@@ -3,21 +3,45 @@
#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) {}
jbroman 2016/03/04 15:23:48 nit: long line; consider breaking
iclelland 2016/03/07 15:38:37 Done.
+
+// 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}}Enabled(errorMessage);
}
-// static
-bool OriginTrials::{{feature.first_lowered_name}}Enabled(ExecutionContext* executionContext) {
- return {{feature.first_lowered_name}}EnabledImpl(executionContext, nullptr);
+bool OriginTrials::{{feature.first_lowered_name}}Enabled(String& errorMessage) {
+ return {{feature.first_lowered_name}}EnabledImpl(&errorMessage);
+}
+
+bool OriginTrials::{{feature.first_lowered_name}}Enabled() {
+ return {{feature.first_lowered_name}}EnabledImpl(nullptr);
}
{% endif %}
{% endfor %}
@@ -25,13 +49,18 @@ bool OriginTrials::{{feature.first_lowered_name}}Enabled(ExecutionContext* execu
{% 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

Powered by Google App Engine
This is Rietveld 408576698