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. |