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 uint8_t version() { return version_; } | 50 uint8_t version() { return version_; } |
50 std::string signature() { return signature_; } | 51 std::string signature() { return signature_; } |
51 std::string data() { return data_; } | 52 std::string data() { return data_; } |
52 GURL origin() { return origin_; } | 53 GURL origin() { return origin_; } |
53 std::string feature_name() { return feature_name_; } | 54 std::string feature_name() { return feature_name_; } |
54 uint64_t expiry_timestamp() { return expiry_timestamp_; } | 55 uint64_t expiry_timestamp() { return expiry_timestamp_; } |
55 | 56 |
56 protected: | 57 protected: |
57 friend class TrialTokenTest; | 58 friend class TrialTokenTest; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 std::string feature_name_; | 102 std::string feature_name_; |
102 | 103 |
103 // The time until which this token should be considered valid, in UTC, as | 104 // The time until which this token should be considered valid, in UTC, as |
104 // seconds since the Unix epoch. | 105 // seconds since the Unix epoch. |
105 uint64_t expiry_timestamp_; | 106 uint64_t expiry_timestamp_; |
106 }; | 107 }; |
107 | 108 |
108 } // namespace content | 109 } // namespace content |
109 | 110 |
110 #endif // CONTENT_RENDERER_ORIGIN_TRIALS_TRIAL_TOKEN_H_ | 111 #endif // CONTENT_RENDERER_ORIGIN_TRIALS_TRIAL_TOKEN_H_ |
OLD | NEW |