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

Unified Diff: content/common/origin_trials/trial_token.h

Issue 1909633003: Collect UMA data for Origin Trials (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix/update unit tests 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: content/common/origin_trials/trial_token.h
diff --git a/content/common/origin_trials/trial_token.h b/content/common/origin_trials/trial_token.h
index fa05e3713b5b943cbd3f8fd774d09f1c5f8793cc..ff7941efbb37d72fa4e4e489f543819705cafda0 100644
--- a/content/common/origin_trials/trial_token.h
+++ b/content/common/origin_trials/trial_token.h
@@ -13,6 +13,10 @@
#include "content/common/content_export.h"
#include "url/origin.h"
+namespace blink {
+enum class WebOriginTrialTokenStatus;
+}
+
namespace content {
// The Experimental Framework (EF) provides limited access to experimental
@@ -32,19 +36,26 @@ class CONTENT_EXPORT TrialToken {
public:
~TrialToken();
- // Returns a token object if the string represents a signed well-formed token,
- // or nullptr otherwise. (This does not mean that the token is currently
- // valid, or appropriate for a given origin / feature, just that it is
+ // If the string represents a signed well-formed token, a token object is
+ // returned, and success is returned in the |out_status| parameter. Otherwise,
+ // the |out_status| parameter indicates what was wrong with the string, and
+ // nullptr is returned.
+ // Note that success does not mean that the token is currently valid, or
+ // appropriate for a given origin / feature. It only means that it is
// correctly formatted and signed by the supplied public key, and can be
- // parsed.)
- static std::unique_ptr<TrialToken> From(const std::string& token_text,
- base::StringPiece public_key);
-
- // Returns true if this token is appropriate for use by the given origin,
- // for the given feature name, and has not yet expired.
- bool IsValidForFeature(const url::Origin& origin,
- base::StringPiece feature_name,
- const base::Time& now) const;
+ // parsed.
+ static std::unique_ptr<TrialToken> From(
+ const std::string& token_text,
+ base::StringPiece public_key,
+ blink::WebOriginTrialTokenStatus* out_status);
+
+ // Returns success if this token is appropriate for use by the given origin
+ // and feature name, and has not yet expired. Otherwise, the return value
+ // indicates why the token is not valid.
+ blink::WebOriginTrialTokenStatus IsValidForFeature(
+ const url::Origin& origin,
+ base::StringPiece feature_name,
+ const base::Time& now) const;
url::Origin origin() { return origin_; }
std::string feature_name() { return feature_name_; }
@@ -53,10 +64,13 @@ class CONTENT_EXPORT TrialToken {
protected:
friend class TrialTokenTest;
- // Returns the payload of a signed token, or nullptr if the token is not
- // properly signed, or is not well-formed.
- static std::unique_ptr<std::string> Extract(const std::string& token_text,
- base::StringPiece public_key);
+ // If the string represents a properly signed and well-formed token, the JSON
iclelland 2016/04/28 17:00:58 Extract explicitly doesn't care whether the payloa
chasej 2016/05/02 15:53:11 To me, this comment doesn't guarantee that valid J
+ // payload is returned in the |out_token_json| parameter and success is
+ // returned. Otherwise,the return code indicates what was wrong with the
+ // string, and |out_token_json| is unchanged.
+ static blink::WebOriginTrialTokenStatus Extract(const std::string& token_text,
+ base::StringPiece public_key,
+ std::string* out_token_json);
// Returns a token object if the string represents a well-formed JSON token
// payload, or nullptr otherwise.

Powered by Google App Engine
This is Rietveld 408576698