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

Side by Side 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, 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 unified diff | Download patch
OLDNEW
1 {% from 'macros.tmpl' import license %} 1 {% from 'macros.tmpl' import license %}
2 {{license()}} 2 {{license()}}
3 3
4 #include "core/origin_trials/OriginTrials.h" 4 #include "core/origin_trials/OriginTrials.h"
5 5
6 #include "core/dom/ExecutionContext.h"
6 #include "core/origin_trials/OriginTrialContext.h" 7 #include "core/origin_trials/OriginTrialContext.h"
7 #include "platform/RuntimeEnabledFeatures.h" 8 #include "platform/RuntimeEnabledFeatures.h"
8 9
9 namespace blink { 10 namespace blink {
11
12 OriginTrials::OriginTrials(PassOwnPtrWillBeRawPtr<OriginTrialContext> originTria lContext) : m_originTrialContext(originTrialContext) {}
jbroman 2016/03/04 15:23:48 nit: long line; consider breaking
iclelland 2016/03/07 15:38:37 Done.
13
14 // static
15 const char* OriginTrials::supplementName()
16 {
17 return "OriginTrials";
18 }
19
20 // static
21 OriginTrials* OriginTrials::from(ExecutionContext* host)
22 {
23 OriginTrials* originTrials = reinterpret_cast<OriginTrials*>(WillBeHeapSuppl ement<ExecutionContext>::from(host, supplementName()));
24 if (!originTrials) {
25 originTrials = new OriginTrials(host->createOriginTrialContext());
26 WillBeHeapSupplement<ExecutionContext>::provideTo(*host, supplementName( ), adoptPtrWillBeNoop(originTrials));
27 }
28 return originTrials;
29 }
30
10 {% for feature in features %} 31 {% for feature in features %}
11 {% if feature.origin_trial_feature_name %} 32 {% if feature.origin_trial_feature_name %}
12 33
13 // static 34 // static
14 bool OriginTrials::{{feature.first_lowered_name}}Enabled(ExecutionContext* execu tionContext, String& errorMessage) { 35 bool OriginTrials::{{feature.first_lowered_name}}Enabled(ExecutionContext* execu tionContext, String& errorMessage) {
15 return {{feature.first_lowered_name}}EnabledImpl(executionContext, &errorMes sage); 36 return OriginTrials::from(executionContext)->{{feature.first_lowered_name}}E nabled(errorMessage);
16 } 37 }
17 38
18 // static 39 bool OriginTrials::{{feature.first_lowered_name}}Enabled(String& errorMessage) {
19 bool OriginTrials::{{feature.first_lowered_name}}Enabled(ExecutionContext* execu tionContext) { 40 return {{feature.first_lowered_name}}EnabledImpl(&errorMessage);
20 return {{feature.first_lowered_name}}EnabledImpl(executionContext, nullptr); 41 }
42
43 bool OriginTrials::{{feature.first_lowered_name}}Enabled() {
44 return {{feature.first_lowered_name}}EnabledImpl(nullptr);
21 } 45 }
22 {% endif %} 46 {% endif %}
23 {% endfor %} 47 {% endfor %}
24 48
25 {% for feature in features %} 49 {% for feature in features %}
26 {% if feature.origin_trial_feature_name %} 50 {% if feature.origin_trial_feature_name %}
27 51
28 // static 52 bool OriginTrials::{{feature.first_lowered_name}}EnabledImpl(String* errorMessag e) {
29 bool OriginTrials::{{feature.first_lowered_name}}EnabledImpl(ExecutionContext* e xecutionContext, String* errorMessage) {
30 if (RuntimeEnabledFeatures::{{feature.first_lowered_name}}Enabled()) 53 if (RuntimeEnabledFeatures::{{feature.first_lowered_name}}Enabled())
31 return true; 54 return true;
32 return OriginTrialContext::isFeatureEnabled(executionContext, "{{feature.ori gin_trial_feature_name}}", errorMessage); 55 if (!m_originTrialContext) return false;
56 return m_originTrialContext->isFeatureEnabled("{{feature.origin_trial_featur e_name}}", errorMessage);
33 } 57 }
34 {% endif %} 58 {% endif %}
35 {% endfor %} 59 {% endfor %}
36 60
61 DEFINE_TRACE(OriginTrials)
62 {
63 visitor->trace(m_originTrialContext);
64 WillBeHeapSupplement<ExecutionContext>::trace(visitor);
65 }
37 } // namespace blink 66 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698