| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_COMMON_ORIGIN_TRIALS_TRIAL_TOKEN_H_ | 5 #ifndef CONTENT_COMMON_ORIGIN_TRIALS_TRIAL_TOKEN_H_ |
| 6 #define CONTENT_COMMON_ORIGIN_TRIALS_TRIAL_TOKEN_H_ | 6 #define CONTENT_COMMON_ORIGIN_TRIALS_TRIAL_TOKEN_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 // Note that success does not mean that the token is currently valid, or | 43 // Note that success does not mean that the token is currently valid, or |
| 44 // appropriate for a given origin / feature. It only means that it is | 44 // appropriate for a given origin / feature. It only means that it is |
| 45 // correctly formatted and signed by the supplied public key, and can be | 45 // correctly formatted and signed by the supplied public key, and can be |
| 46 // parsed. | 46 // parsed. |
| 47 static std::unique_ptr<TrialToken> From( | 47 static std::unique_ptr<TrialToken> From( |
| 48 const std::string& token_text, | 48 const std::string& token_text, |
| 49 base::StringPiece public_key, | 49 base::StringPiece public_key, |
| 50 blink::WebOriginTrialTokenStatus* out_status); | 50 blink::WebOriginTrialTokenStatus* out_status); |
| 51 | 51 |
| 52 // Returns success if this token is appropriate for use by the given origin | 52 // Returns success if this token is appropriate for use by the given origin |
| 53 // and feature name, and has not yet expired. Otherwise, the return value | 53 // and has not yet expired. Otherwise, the return value indicates why the |
| 54 // indicates why the token is not valid. | 54 // token is not valid. |
| 55 blink::WebOriginTrialTokenStatus IsValidForFeature( | 55 blink::WebOriginTrialTokenStatus IsValid(const url::Origin& origin, |
| 56 const url::Origin& origin, | 56 const base::Time& now) const; |
| 57 base::StringPiece feature_name, | |
| 58 const base::Time& now) const; | |
| 59 | 57 |
| 60 url::Origin origin() { return origin_; } | 58 url::Origin origin() { return origin_; } |
| 61 std::string feature_name() { return feature_name_; } | 59 std::string feature_name() { return feature_name_; } |
| 62 base::Time expiry_time() { return expiry_time_; } | 60 base::Time expiry_time() { return expiry_time_; } |
| 63 | 61 |
| 64 protected: | 62 protected: |
| 65 friend class TrialTokenTest; | 63 friend class TrialTokenTest; |
| 66 | 64 |
| 67 // If the string represents a properly signed and well-formed token, the token | 65 // If the string represents a properly signed and well-formed token, the token |
| 68 // payload is returned in the |out_token_payload| parameter and success is | 66 // payload is returned in the |out_token_payload| parameter and success is |
| (...skipping 27 matching lines...) Expand all Loading... |
| 96 // The name of the experimental feature which this token enables. | 94 // The name of the experimental feature which this token enables. |
| 97 std::string feature_name_; | 95 std::string feature_name_; |
| 98 | 96 |
| 99 // The time until which this token should be considered valid. | 97 // The time until which this token should be considered valid. |
| 100 base::Time expiry_time_; | 98 base::Time expiry_time_; |
| 101 }; | 99 }; |
| 102 | 100 |
| 103 } // namespace content | 101 } // namespace content |
| 104 | 102 |
| 105 #endif // CONTENT_COMMON_ORIGIN_TRIALS_TRIAL_TOKEN_H_ | 103 #endif // CONTENT_COMMON_ORIGIN_TRIALS_TRIAL_TOKEN_H_ |
| OLD | NEW |