| 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_RENDERER_ORIGIN_TRIALS_TRIAL_TOKEN_H_ | 5 #ifndef CONTENT_RENDERER_ORIGIN_TRIALS_TRIAL_TOKEN_H_ |
| 6 #define CONTENT_RENDERER_ORIGIN_TRIALS_TRIAL_TOKEN_H_ | 6 #define CONTENT_RENDERER_ORIGIN_TRIALS_TRIAL_TOKEN_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 // it can be parsed.) | 37 // it can be parsed.) |
| 38 static scoped_ptr<TrialToken> Parse(const std::string& token_text); | 38 static scoped_ptr<TrialToken> Parse(const std::string& token_text); |
| 39 | 39 |
| 40 // Returns true if this feature is appropriate for use by the given origin, | 40 // Returns true if this feature is appropriate for use by the given origin, |
| 41 // for the given feature name. This does not check whether the signature is | 41 // for the given feature name. This does not check whether the signature is |
| 42 // valid, or whether the token itself has expired. | 42 // valid, or whether the token itself has expired. |
| 43 bool IsAppropriate(const std::string& origin, | 43 bool IsAppropriate(const std::string& origin, |
| 44 const std::string& featureName) const; | 44 const std::string& featureName) const; |
| 45 | 45 |
| 46 // Returns true if this token has a valid signature, and has not expired. | 46 // Returns true if this token has a valid signature, and has not expired. |
| 47 bool IsValid(const base::Time& now) const; | 47 bool IsValid(const base::Time& now, |
| 48 const base::StringPiece& public_key) const; |
| 48 | 49 |
| 49 std::string signature() { return signature_; } | 50 std::string signature() { return signature_; } |
| 50 std::string data() { return data_; } | 51 std::string data() { return data_; } |
| 51 GURL origin() { return origin_; } | 52 GURL origin() { return origin_; } |
| 52 std::string feature_name() { return feature_name_; } | 53 std::string feature_name() { return feature_name_; } |
| 53 uint64_t expiry_timestamp() { return expiry_timestamp_; } | 54 uint64_t expiry_timestamp() { return expiry_timestamp_; } |
| 54 | 55 |
| 55 protected: | 56 protected: |
| 56 friend class TrialTokenTest; | 57 friend class TrialTokenTest; |
| 57 | 58 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 87 std::string feature_name_; | 88 std::string feature_name_; |
| 88 | 89 |
| 89 // The time until which this token should be considered valid, in UTC, as | 90 // The time until which this token should be considered valid, in UTC, as |
| 90 // seconds since the Unix epoch. | 91 // seconds since the Unix epoch. |
| 91 uint64_t expiry_timestamp_; | 92 uint64_t expiry_timestamp_; |
| 92 }; | 93 }; |
| 93 | 94 |
| 94 } // namespace content | 95 } // namespace content |
| 95 | 96 |
| 96 #endif // CONTENT_RENDERER_ORIGIN_TRIALS_TRIAL_TOKEN_H_ | 97 #endif // CONTENT_RENDERER_ORIGIN_TRIALS_TRIAL_TOKEN_H_ |
| OLD | NEW |