Commit 20bb13e1 authored by Yao Xiao's avatar Yao Xiao Committed by Commit Bot

Set the event_time_usec field in the FlocIdComputed event

The server is expecting this field, otherwise the event will be dropped.

Bug: 1119394
Change-Id: I7606ca2b8df2eff9c0ea3913e93694241e937ca5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2364516Reviewed-by: default avatarJosh Karlin <jkarlin@chromium.org>
Commit-Queue: Yao Xiao <yaoxia@chromium.org>
Cr-Commit-Position: refs/heads/master@{#799752}
parent 8430c4b9
...@@ -55,6 +55,8 @@ void FlocIdProviderImpl::NotifyFlocUpdated(ComputeFlocTrigger trigger) { ...@@ -55,6 +55,8 @@ void FlocIdProviderImpl::NotifyFlocUpdated(ComputeFlocTrigger trigger) {
return; return;
auto specifics = std::make_unique<sync_pb::UserEventSpecifics>(); auto specifics = std::make_unique<sync_pb::UserEventSpecifics>();
specifics->set_event_time_usec(
base::Time::Now().ToDeltaSinceWindowsEpoch().InMicroseconds());
sync_pb::UserEventSpecifics_FlocIdComputed* const floc_id_computed_event = sync_pb::UserEventSpecifics_FlocIdComputed* const floc_id_computed_event =
specifics->mutable_floc_id_computed_event(); specifics->mutable_floc_id_computed_event();
......
...@@ -380,6 +380,9 @@ TEST_F(FlocIdProviderUnitTest, EventLogging) { ...@@ -380,6 +380,9 @@ TEST_F(FlocIdProviderUnitTest, EventLogging) {
ASSERT_EQ(1u, fake_user_event_service_->GetRecordedUserEvents().size()); ASSERT_EQ(1u, fake_user_event_service_->GetRecordedUserEvents().size());
const sync_pb::UserEventSpecifics& specifics1 = const sync_pb::UserEventSpecifics& specifics1 =
fake_user_event_service_->GetRecordedUserEvents()[0]; fake_user_event_service_->GetRecordedUserEvents()[0];
EXPECT_EQ(specifics1.event_time_usec(),
base::Time::Now().ToDeltaSinceWindowsEpoch().InMicroseconds());
EXPECT_EQ(sync_pb::UserEventSpecifics::kFlocIdComputedEvent, EXPECT_EQ(sync_pb::UserEventSpecifics::kFlocIdComputedEvent,
specifics1.event_case()); specifics1.event_case());
...@@ -389,6 +392,8 @@ TEST_F(FlocIdProviderUnitTest, EventLogging) { ...@@ -389,6 +392,8 @@ TEST_F(FlocIdProviderUnitTest, EventLogging) {
event1.event_trigger()); event1.event_trigger());
EXPECT_EQ(12345ULL, event1.floc_id()); EXPECT_EQ(12345ULL, event1.floc_id());
task_environment_.FastForwardBy(base::TimeDelta::FromDays(3));
set_floc_id(FlocId(999ULL)); set_floc_id(FlocId(999ULL));
floc_id_provider_->NotifyFlocUpdated( floc_id_provider_->NotifyFlocUpdated(
FlocIdProviderImpl::ComputeFlocTrigger::kScheduledUpdate); FlocIdProviderImpl::ComputeFlocTrigger::kScheduledUpdate);
...@@ -396,6 +401,8 @@ TEST_F(FlocIdProviderUnitTest, EventLogging) { ...@@ -396,6 +401,8 @@ TEST_F(FlocIdProviderUnitTest, EventLogging) {
ASSERT_EQ(2u, fake_user_event_service_->GetRecordedUserEvents().size()); ASSERT_EQ(2u, fake_user_event_service_->GetRecordedUserEvents().size());
const sync_pb::UserEventSpecifics& specifics2 = const sync_pb::UserEventSpecifics& specifics2 =
fake_user_event_service_->GetRecordedUserEvents()[1]; fake_user_event_service_->GetRecordedUserEvents()[1];
EXPECT_EQ(specifics2.event_time_usec(),
base::Time::Now().ToDeltaSinceWindowsEpoch().InMicroseconds());
EXPECT_EQ(sync_pb::UserEventSpecifics::kFlocIdComputedEvent, EXPECT_EQ(sync_pb::UserEventSpecifics::kFlocIdComputedEvent,
specifics2.event_case()); specifics2.event_case());
...@@ -412,6 +419,8 @@ TEST_F(FlocIdProviderUnitTest, EventLogging) { ...@@ -412,6 +419,8 @@ TEST_F(FlocIdProviderUnitTest, EventLogging) {
ASSERT_EQ(3u, fake_user_event_service_->GetRecordedUserEvents().size()); ASSERT_EQ(3u, fake_user_event_service_->GetRecordedUserEvents().size());
const sync_pb::UserEventSpecifics& specifics3 = const sync_pb::UserEventSpecifics& specifics3 =
fake_user_event_service_->GetRecordedUserEvents()[2]; fake_user_event_service_->GetRecordedUserEvents()[2];
EXPECT_EQ(specifics3.event_time_usec(),
base::Time::Now().ToDeltaSinceWindowsEpoch().InMicroseconds());
EXPECT_EQ(sync_pb::UserEventSpecifics::kFlocIdComputedEvent, EXPECT_EQ(sync_pb::UserEventSpecifics::kFlocIdComputedEvent,
specifics3.event_case()); specifics3.event_case());
......
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