Commit 6a12339e authored by Dylan Cutler's avatar Dylan Cutler Committed by Commit Bot

Use IdentifiabilitySensitiveStringToken in dactyloscoper.cc.

We can reuse this function to convert WTF::String to an
IdentifiableToken instead of casting it to a sequence of bytes.

Bug: 973801
Change-Id: I5dacf615f06ca777eaae7dbd5884dfa21a4a867a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2323311Reviewed-by: default avatarNate Chapin <japhet@chromium.org>
Reviewed-by: default avatarCaleb Raitto <caraitto@chromium.org>
Commit-Queue: Dylan Cutler <dylancutler@google.com>
Cr-Commit-Position: refs/heads/master@{#792861}
parent 7362c644
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "third_party/blink/renderer/core/frame/local_dom_window.h" #include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/frame/local_frame.h" #include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/loader/document_loader.h" #include "third_party/blink/renderer/core/loader/document_loader.h"
#include "third_party/blink/renderer/platform/privacy_budget/identifiability_digest_helpers.h"
namespace blink { namespace blink {
...@@ -44,22 +45,13 @@ void Dactyloscoper::RecordDirectSurface(ExecutionContext* context, ...@@ -44,22 +45,13 @@ void Dactyloscoper::RecordDirectSurface(ExecutionContext* context,
.Record(document->UkmRecorder()); .Record(document->UkmRecorder());
} }
// The anonymous namespace ensures this StringToBytes has internal linkage,
// in case someone defines another blink::StringToBytes elsewhere.
namespace {
base::span<const uint8_t> StringToBytes(String str) {
return str.Is8Bit() ? str.Span8() : as_bytes(str.Span16());
}
} // namespace
void Dactyloscoper::RecordDirectSurface(ExecutionContext* context, void Dactyloscoper::RecordDirectSurface(ExecutionContext* context,
WebFeature feature, WebFeature feature,
String str) { String str) {
if (str.IsEmpty()) if (str.IsEmpty())
return; return;
Dactyloscoper::RecordDirectSurface(context, feature, StringToBytes(str)); Dactyloscoper::RecordDirectSurface(context, feature,
IdentifiabilitySensitiveStringToken(str));
} }
void Dactyloscoper::RecordDirectSurface(ExecutionContext* context, void Dactyloscoper::RecordDirectSurface(ExecutionContext* context,
...@@ -69,7 +61,7 @@ void Dactyloscoper::RecordDirectSurface(ExecutionContext* context, ...@@ -69,7 +61,7 @@ void Dactyloscoper::RecordDirectSurface(ExecutionContext* context,
return; return;
IdentifiableTokenBuilder builder; IdentifiableTokenBuilder builder;
for (const auto& str : strs) { for (const auto& str : strs) {
builder.AddAtomic(StringToBytes(str)); builder.AddToken(IdentifiabilitySensitiveStringToken(str));
} }
Dactyloscoper::RecordDirectSurface(context, feature, builder.GetToken()); Dactyloscoper::RecordDirectSurface(context, feature, builder.GetToken());
} }
......
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