Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(779)

Unified Diff: content/common/origin_trials/trial_token_validator.cc

Issue 1909633003: Collect UMA data for Origin Trials (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/common/origin_trials/trial_token_validator.cc
diff --git a/content/common/origin_trials/trial_token_validator.cc b/content/common/origin_trials/trial_token_validator.cc
index 6eef75a5e9a40be7f7cf5b3a3d594dc8e789f1b7..c85c774e3199e9dbaa2904a61c80e177ebb603e8 100644
--- a/content/common/origin_trials/trial_token_validator.cc
+++ b/content/common/origin_trials/trial_token_validator.cc
@@ -10,20 +10,25 @@
namespace content {
-bool TrialTokenValidator::ValidateToken(const std::string& token,
- const url::Origin& origin,
- base::StringPiece feature_name) {
+TrialTokenStatus TrialTokenValidator::ValidateToken(
+ const std::string& token,
+ const url::Origin& origin,
+ base::StringPiece feature_name) {
// TODO(iclelland): Allow for multiple signing keys, and iterate over all
// active keys here. https://crbug.com/543220
ContentClient* content_client = GetContentClient();
base::StringPiece public_key = content_client->GetOriginTrialPublicKey();
if (public_key.empty()) {
- return false;
+ return TRIAL_TOKEN_STATUS_NOT_SUPPORTED;
}
- std::unique_ptr<TrialToken> trial_token = TrialToken::From(token, public_key);
- return trial_token &&
- trial_token->IsValidForFeature(origin, feature_name,
+ std::unique_ptr<TrialToken> trial_token;
+ TrialTokenStatus status = TrialToken::From(token, public_key, trial_token);
+ if (status != TRIAL_TOKEN_STATUS_SUCCESS) {
+ return status;
+ }
+
+ return trial_token->IsValidForFeature(origin, feature_name,
base::Time::Now());
}

Powered by Google App Engine
This is Rietveld 408576698