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

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

Issue 1828063002: Add support for origin trials in workers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@trial-token-in-header-blink-document
Patch Set: fix test flakyness Created 4 years, 7 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 4e376cdba2e9784b1dc6fa53a486ad01be697594..8f13dbfab087cabe3f5d57b94b0eba37cb5de64c 100644
--- a/third_party/WebKit/Source/core/origin_trials/OriginTrialContext.h
+++ b/third_party/WebKit/Source/core/origin_trials/OriginTrialContext.h
@@ -35,10 +35,19 @@ class WebTrialTokenValidator;
class CORE_EXPORT OriginTrialContext final : public GarbageCollectedFinalized<OriginTrialContext>, public Supplement<ExecutionContext> {
USING_GARBAGE_COLLECTED_MIXIN(OriginTrialContext)
public:
+ enum CreateMode {
+ CreateIfNotExists,
+ DontCreateIfNotExists
+ };
+
explicit OriginTrialContext(ExecutionContext*);
static const char* supplementName();
- static OriginTrialContext* from(ExecutionContext*);
+
+ // Returns the OriginTrialContext for a specific ExecutionContext. If
+ // |create| is false, this returns null if no OriginTrialContext exists
+ // yet for the ExecutionContext.
+ static OriginTrialContext* from(ExecutionContext*, CreateMode = CreateIfNotExists);
// Parses an Origin-Trial header as specified in
// https://jpchase.github.io/OriginTrials/#header into individual tokens.
@@ -47,8 +56,14 @@ public:
static std::unique_ptr<Vector<String>> parseHeaderValue(const String& headerValue);
static void addTokensFromHeader(ExecutionContext*, const String& headerValue);
+ static void addTokens(ExecutionContext*, const Vector<String>* tokens);
+
+ // Returns the trial tokens that are active in a specific ExecutionContext.
+ // Returns null if no tokens were added to the ExecutionContext.
+ static std::unique_ptr<Vector<String>> getTokens(ExecutionContext*);
void addToken(const String& token);
+ void addTokens(const Vector<String>& tokens);
// Returns true if the feature should be considered enabled for the current
// execution context. If non-null, the |errorMessage| parameter will be used
« no previous file with comments | « third_party/WebKit/Source/core/core.gypi ('k') | third_party/WebKit/Source/core/origin_trials/OriginTrialContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698