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

Unified Diff: third_party/WebKit/Source/core/origin_trials/OriginTrialContext.h

Issue 1875593003: Revert of Store the list of trial tokens in OriginTrialContext (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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/core/origin_trials/OriginTrialContext.h
diff --git a/third_party/WebKit/Source/core/origin_trials/OriginTrialContext.h b/third_party/WebKit/Source/core/origin_trials/OriginTrialContext.h
index df27b813536f2808012b42264ad94cc89f5e91a8..d8e062915353e976ecd6de48406990dc3fde3933 100644
--- a/third_party/WebKit/Source/core/origin_trials/OriginTrialContext.h
+++ b/third_party/WebKit/Source/core/origin_trials/OriginTrialContext.h
@@ -6,7 +6,8 @@
#define OriginTrialContext_h
#include "core/CoreExport.h"
-#include "platform/Supplementable.h"
+#include "platform/heap/Handle.h"
+#include "wtf/Forward.h"
#include "wtf/HashSet.h"
#include "wtf/Vector.h"
#include "wtf/text/WTFString.h"
@@ -20,7 +21,7 @@
// features, on a per-origin basis (origin trials). This class provides the
// implementation to check if the experimental feature should be enabled for the
// current context. This class is not for direct use by feature implementers.
-// Instead, the OriginTrials generated namespace provides a method for each
+// Instead, the OriginTrials generated class provides a static method for each
// feature to check if it is enabled. Experimental features must be defined in
// RuntimeEnabledFeatures.in, which is used to generate OriginTrials.h/cpp.
//
@@ -29,16 +30,26 @@
// feature names. Instead, the EF validates the name provided by the feature
// implementation against any provided tokens.
//
+// This class is abstract, and should be subclassed for each execution context
+// which supports origin trials.
+//
// TODO(chasej): Link to documentation, or provide more detail on keys, .etc
-class CORE_EXPORT OriginTrialContext final : public GarbageCollectedFinalized<OriginTrialContext>, public Supplement<ExecutionContext> {
-USING_GARBAGE_COLLECTED_MIXIN(OriginTrialContext)
+class CORE_EXPORT OriginTrialContext : public GarbageCollectedFinalized<OriginTrialContext> {
public:
- explicit OriginTrialContext(ExecutionContext*);
+ static const char kTrialHeaderName[];
+ virtual ~OriginTrialContext() = default;
- static const char* supplementName();
- static OriginTrialContext* from(ExecutionContext*);
+ virtual ExecutionContext* getExecutionContext() = 0;
+ virtual Vector<String> getTokens() = 0;
- void addToken(const String& token);
+ DECLARE_VIRTUAL_TRACE();
+
+protected:
+ OriginTrialContext();
+
+private:
+ friend class OriginTrialContextTest;
+ friend class OriginTrials;
// Returns true if the feature should be considered enabled for the current
// execution context. This method usually makes use of the token validator
@@ -46,11 +57,7 @@
// is required (for testing, for instance).
bool isFeatureEnabled(const String& featureName, String* errorMessage, WebTrialTokenValidator* = nullptr);
- DECLARE_VIRTUAL_TRACE();
-
-private:
- Member<ExecutionContext> m_host;
- Vector<String> m_tokens;
+ bool hasValidToken(Vector<String> tokens, const String& featureName, String* errorMessage, WebTrialTokenValidator*);
// Records whether an error message has been generated, for each feature
// name. Since these messages are generally written to the console, this is

Powered by Google App Engine
This is Rietveld 408576698