Chromium Code Reviews| 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..37785312475918465e8084e2063ce579de61d47c 100644 |
| --- a/content/common/origin_trials/trial_token.h |
| +++ b/content/common/origin_trials/trial_token.h |
| @@ -11,6 +11,7 @@ |
| #include "base/strings/string_piece.h" |
| #include "base/time/time.h" |
| #include "content/common/content_export.h" |
| +#include "content/common/origin_trials/trial_token_status.h" |
| #include "url/origin.h" |
| namespace content { |
| @@ -32,19 +33,24 @@ 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 in the |out_token| parameter and success is returned. Otherwise, |
| + // the return code indicates what was wrong with the string, and |out_token| |
| + // is set to NULL. |
| + // 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 TrialTokenStatus From(const std::string& token_text, |
| + base::StringPiece public_key, |
| + std::unique_ptr<TrialToken>& out_token); |
|
Marijn Kruisselbrink
2016/04/21 18:18:42
Pass-by-(non-const)-reference is against the style
chasej
2016/04/22 18:50:06
TL;DR - I made the result enum be the out paramete
Marijn Kruisselbrink
2016/04/22 21:51:06
Never mind, you're right. I think I was thinking t
|
| + |
| + // 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. |
| + TrialTokenStatus 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 +59,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 |
| + // 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 TrialTokenStatus Extract(const std::string& token_text, |
| + base::StringPiece public_key, |
| + std::unique_ptr<std::string>& out_token_json); |
|
Marijn Kruisselbrink
2016/04/21 18:18:42
Here too, don't use non-const reference arguments.
chasej
2016/04/22 18:50:06
Done.
|
| // Returns a token object if the string represents a well-formed JSON token |
| // payload, or nullptr otherwise. |