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

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: Fix/update unit tests 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..f9261fe19a30804e5711e6f5dc971ec3870666cb 100644
--- a/content/common/origin_trials/trial_token_validator.cc
+++ b/content/common/origin_trials/trial_token_validator.cc
@@ -7,23 +7,30 @@
#include "base/time/time.h"
#include "content/common/origin_trials/trial_token.h"
#include "content/public/common/content_client.h"
+#include "third_party/WebKit/public/platform/WebOriginTrialTokenStatus.h"
namespace content {
-bool TrialTokenValidator::ValidateToken(const std::string& token,
- const url::Origin& origin,
- base::StringPiece feature_name) {
+blink::WebOriginTrialTokenStatus 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 blink::WebOriginTrialTokenStatus::NotSupported;
}
- std::unique_ptr<TrialToken> trial_token = TrialToken::From(token, public_key);
- return trial_token &&
- trial_token->IsValidForFeature(origin, feature_name,
+ blink::WebOriginTrialTokenStatus status;
+ std::unique_ptr<TrialToken> trial_token =
+ TrialToken::From(token, public_key, &status);
+ if (status != blink::WebOriginTrialTokenStatus::Success) {
+ return status;
+ }
+
+ return trial_token->IsValidForFeature(origin, feature_name,
iclelland 2016/04/28 17:00:58 I'd be happier with a DCHECK(trial_token) here bef
chasej 2016/05/02 15:53:11 Does a DCHECK buy you much here? The pointer is pr
iclelland 2016/05/02 16:17:55 Fair enough; a crash is a crash :) Documentation-
base::Time::Now());
}

Powered by Google App Engine
This is Rietveld 408576698