Commit 9ee18c76 authored by Mason Freed's avatar Mason Freed Committed by Commit Bot

Add additional DVLOG output for origin trial token parsing

There is already some debug output available for origin trials,
which can be enabled with:

 % chrome --vmodule=origin_trial_context=1 --enable-logging=stderr

This CL adds a bit more human-readable debug output, plus it adds
the appropriate flags to the documentation, so it is easier to find.

TL/DR now:
 % chrome --vmodule=trial_token=2,origin_trial_context=1 --enable-logging=stderr

Change-Id: I27d08055f460287e02531886593c696e700bbe3b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2347385Reviewed-by: default avatarJason Chase <chasej@chromium.org>
Commit-Queue: Mason Freed <masonfreed@chromium.org>
Auto-Submit: Mason Freed <masonfreed@chromium.org>
Cr-Commit-Position: refs/heads/master@{#799308}
parent d485fe03
......@@ -204,6 +204,17 @@ It's also used by Origin Trials unit tests and web tests.
If you cannot set command-line switches (e.g., on Chrome OS), you can also
directly modify [chrome_origin_trial_policy.cc].
To see additional information about origin trial token parsing (including reasons
for failures, or token names for successful tokens), you can add these switches:
`--vmodule=trial_token=2,origin_trial_context=1`
If you are building with `is_debug=false`, then you will also need to add
`dcheck_always_on=true` to your build options, and add this to the command line:
`--enable-logging=stderr`
### Web Tests
When using the \[RuntimeEnabled\] IDL attribute, you should add web tests
to verify that the V8 bindings code is working as expected. Depending on how
......
......@@ -7,6 +7,7 @@
#include "base/base64.h"
#include "base/big_endian.h"
#include "base/json/json_reader.h"
#include "base/logging.h"
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "base/optional.h"
......@@ -74,6 +75,7 @@ std::unique_ptr<TrialToken> TrialToken::From(
*out_status = Extract(token_text, public_key, &token_payload,
&token_signature, &token_version);
if (*out_status != OriginTrialTokenStatus::kSuccess) {
DVLOG(2) << "Malformed origin trial token found (unable to extract)";
return nullptr;
}
std::unique_ptr<TrialToken> token = Parse(token_payload, token_version);
......@@ -81,8 +83,11 @@ std::unique_ptr<TrialToken> TrialToken::From(
token->signature_ = token_signature;
*out_status = OriginTrialTokenStatus::kSuccess;
} else {
DVLOG(2) << "Malformed origin trial token found (unable to parse)";
*out_status = OriginTrialTokenStatus::kMalformed;
}
DVLOG(2) << "Valid origin trial token found for feature "
<< token->feature_name();
return token;
}
......@@ -91,9 +96,11 @@ OriginTrialTokenStatus TrialToken::IsValid(const url::Origin& origin,
// The order of these checks is intentional. For example, will only report a
// token as expired if it is valid for the origin.
if (!ValidateOrigin(origin)) {
DVLOG(2) << "Origin trial token from different origin";
return OriginTrialTokenStatus::kWrongOrigin;
}
if (!ValidateDate(now)) {
DVLOG(2) << "Origin trial token expired";
return OriginTrialTokenStatus::kExpired;
}
return OriginTrialTokenStatus::kSuccess;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment