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

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

Issue 1635593004: Rename Experimental Framework classes and concepts (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rename RuntimeEnabledFeatures flag to experimental_feature_name Created 4 years, 11 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
new file mode 100644
index 0000000000000000000000000000000000000000..4c089f1458800e61ba5fd8e5381f91d22424bd01
--- /dev/null
+++ b/third_party/WebKit/Source/core/origin_trials/OriginTrialContext.h
@@ -0,0 +1,58 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef OriginTrialContext_h
+#define OriginTrialContext_h
+
+#include "core/CoreExport.h"
+#include "core/dom/DOMException.h"
+#include "core/dom/ExecutionContext.h"
+#include "wtf/text/WTFString.h"
+
+namespace blink {
+
+class WebTrialTokenValidator;
+
+// The Experimental Framework (EF) provides limited access to experimental,
chasej 2016/01/26 16:56:53 Nit, I think the comma after experimental should b
iclelland 2016/01/26 19:05:48 Done.
+// 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 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.
+//
+// Experimental features are defined by string names, provided by the
+// implementers. The EF code does not maintain an enum or constant list for
+// feature names. Instead, the EF validates the name provided by the API
chasej 2016/01/26 16:56:53 Should be "feature", instead of "API".
iclelland 2016/01/26 19:05:48 Done.
+// implementation against any provided tokens.
+//
+// This class is not intended to be instantiated. Any required state is kept
+// with a WebApiKeyValidator object held in the Platform object.
+// The static methods in this class may be called either from the main thread
+// or from a worker thread.
+//
+// TODO(chasej): Link to documentation, or provide more detail on keys, .etc
+class CORE_EXPORT OriginTrialContext {
+public:
+ // Creates a NotSupportedError exception with a message explaining to
+ // external developers why the API is disabled and how to join origin
chasej 2016/01/26 16:56:53 Should be "feature", instead of "API".
+ // trials.
+ static DOMException* createApiDisabledException(const String& apiName);
chasej 2016/01/26 16:56:53 Should be renamed to createFeatureDisabledExceptio
iclelland 2016/01/26 19:05:48 Happy to delete it, and avoid creating an awkward
+
+private:
+ friend class OriginTrialContextTest;
+ friend class OriginTrials;
+
+ OriginTrialContext();
+
+ // Returns true if the feature should be considered enabled for the current
+ // execution context. This method usually makes use of the token validator
+ // object in the platform, but this may be overridden if a custom validator
+ // is required (for testing, for instance).
+ static bool isFeatureEnabled(ExecutionContext*, const String& featureName, String* errorMessage, WebTrialTokenValidator* = nullptr);
+};
+
+} // namespace blink
+
+#endif // OriginTrialContext_h

Powered by Google App Engine
This is Rietveld 408576698