Remove `RecordUserEvent(const UserEventSpecifics&)` overload.

This change removes the `RecordUserEvent` method that accepts a const reference to `UserEventSpecifics` from the `UserEventService` interface and its implementations. All call sites have been updated to use the `RecordUserEvent` method that takes a `std::unique_ptr<UserEventSpecifics>` instead.

Change-Id: I2b450f1f45dd5c34c93ae3bc8a02cb1f0dcd7e0f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6950415
Commit-Queue: Maksim Moskvitin <mmoskvitin@google.com>
Auto-Submit: Michael Tatarski <mtatarski@google.com>
Reviewed-by: Maksim Moskvitin <mmoskvitin@google.com>
Cr-Commit-Position: refs/heads/main@{#1516023}
diff --git a/chrome/browser/sync/test/integration/single_client_user_events_sync_test.cc b/chrome/browser/sync/test/integration/single_client_user_events_sync_test.cc
index 78d1030..aa878f1 100644
--- a/chrome/browser/sync/test/integration/single_client_user_events_sync_test.cc
+++ b/chrome/browser/sync/test/integration/single_client_user_events_sync_test.cc
@@ -59,7 +59,8 @@
   syncer::UserEventService* event_service =
       browser_sync::UserEventServiceFactory::GetForProfile(GetProfile(0));
   const UserEventSpecifics specifics = CreateTestEvent(base::Time());
-  event_service->RecordUserEvent(specifics);
+  event_service->RecordUserEvent(
+      std::make_unique<UserEventSpecifics>(specifics));
   EXPECT_TRUE(ExpectUserEvents({specifics}));
 }
 
@@ -74,7 +75,8 @@
 
   GetFakeServer()->OverrideResponseType(
       base::BindRepeating(&BounceType, CommitResponse::TRANSIENT_ERROR));
-  event_service->RecordUserEvent(specifics1);
+  event_service->RecordUserEvent(
+      std::make_unique<UserEventSpecifics>(specifics1));
 
   // This will block until we hit a TRANSIENT_ERROR, at which point we will
   // regain control and can switch back to SUCCESS. Note that the fake server
@@ -97,7 +99,8 @@
 
   // Only record |specifics2| after |specifics1| was successful to avoid race
   // conditions.
-  event_service->RecordUserEvent(specifics2);
+  event_service->RecordUserEvent(
+      std::make_unique<UserEventSpecifics>(specifics2));
   EXPECT_TRUE(ExpectUserEvents({specifics1, specifics2}));
 }
 
@@ -134,8 +137,10 @@
         return CommitResponse::SUCCESS;
       }));
 
-  event_service->RecordUserEvent(specifics2);
-  event_service->RecordUserEvent(specifics1);
+  event_service->RecordUserEvent(
+      std::make_unique<UserEventSpecifics>(specifics2));
+  event_service->RecordUserEvent(
+      std::make_unique<UserEventSpecifics>(specifics1));
 
   // We can't use only ExpectUserEvents() here because the entity that got the
   // transient error is still considered committed by the fake server.
@@ -157,7 +162,8 @@
   syncer::UserEventService* event_service =
       browser_sync::UserEventServiceFactory::GetForProfile(GetProfile(0));
 
-  event_service->RecordUserEvent(test_event1);
+  event_service->RecordUserEvent(
+      std::make_unique<UserEventSpecifics>(test_event1));
 
   // Wait until the first events is committed before disabling sync,
   // because disabled kHistory also disables user event sync, dropping all
@@ -166,10 +172,12 @@
   ASSERT_TRUE(
       GetClient(0)->DisableSyncForType(syncer::UserSelectableType::kHistory));
 
-  event_service->RecordUserEvent(test_event2);
+  event_service->RecordUserEvent(
+      std::make_unique<UserEventSpecifics>(test_event2));
   ASSERT_TRUE(
       GetClient(0)->EnableSyncForType(syncer::UserSelectableType::kHistory));
-  event_service->RecordUserEvent(test_event3);
+  event_service->RecordUserEvent(
+      std::make_unique<UserEventSpecifics>(test_event3));
 
   // No |test_event2| because it was recorded while history was disabled.
   EXPECT_TRUE(ExpectUserEvents({test_event1, test_event3}));
@@ -184,7 +192,8 @@
   syncer::UserEventService* event_service =
       browser_sync::UserEventServiceFactory::GetForProfile(GetProfile(0));
 
-  event_service->RecordUserEvent(specifics);
+  event_service->RecordUserEvent(
+      std::make_unique<UserEventSpecifics>(specifics));
 
   // UserSelectableType::kTabs shouldn't affect UserEvents in any way.
   EXPECT_TRUE(ExpectUserEvents({specifics}));
@@ -199,11 +208,13 @@
   ASSERT_TRUE(SetupSync());
   syncer::UserEventService* event_service =
       browser_sync::UserEventServiceFactory::GetForProfile(GetProfile(0));
-  event_service->RecordUserEvent(test_event1);
+  event_service->RecordUserEvent(
+      std::make_unique<UserEventSpecifics>(test_event1));
   EXPECT_TRUE(ExpectUserEvents({test_event1}));
   GetSyncService(0)->GetUserSettings()->SetEncryptionPassphrase("passphrase");
   ASSERT_TRUE(PassphraseAcceptedChecker(GetSyncService(0)).Wait());
-  event_service->RecordUserEvent(test_event2);
+  event_service->RecordUserEvent(
+      std::make_unique<UserEventSpecifics>(test_event2));
 
   // Just checking that we don't see test_event2 isn't very convincing yet,
   // because it may simply not have reached the server yet. So let's send
@@ -229,7 +240,8 @@
 
   syncer::UserEventService* event_service =
       browser_sync::UserEventServiceFactory::GetForProfile(GetProfile(0));
-  event_service->RecordUserEvent(test_event);
+  event_service->RecordUserEvent(
+      std::make_unique<UserEventSpecifics>(test_event));
 
   // Clear the "Sync paused" state again.
   GetClient(0)->ExitSyncPausedStateForPrimaryAccount();
@@ -262,7 +274,8 @@
   for (int i = 0; i < 2525; i++) {
     const UserEventSpecifics specifics =
         CreateTestEvent(zero + base::Milliseconds(i));
-    event_service->RecordUserEvent(specifics);
+    event_service->RecordUserEvent(
+        std::make_unique<UserEventSpecifics>(specifics));
     expected_specifics.push_back(specifics);
   }
   EXPECT_TRUE(ExpectUserEvents(expected_specifics));
@@ -272,7 +285,8 @@
   // Adding another entity again triggers sync immediately (as there's no
   // quota).
   const UserEventSpecifics specifics = CreateTestEvent(zero + base::Seconds(3));
-  event_service->RecordUserEvent(specifics);
+  event_service->RecordUserEvent(
+      std::make_unique<UserEventSpecifics>(specifics));
   expected_specifics.push_back(specifics);
   EXPECT_TRUE(ExpectUserEvents(expected_specifics));
 
diff --git a/chrome/browser/sync/test/integration/sync_errors_test.cc b/chrome/browser/sync/test/integration/sync_errors_test.cc
index 1d0867a..0b0a3b0b 100644
--- a/chrome/browser/sync/test/integration/sync_errors_test.cc
+++ b/chrome/browser/sync/test/integration/sync_errors_test.cc
@@ -352,7 +352,8 @@
   const sync_pb::UserEventSpecifics specifics =
       CreateTestEvent(base::Time::FromDeltaSinceWindowsEpoch(
           base::Microseconds(kUserEventTimeUsec)));
-  event_service->RecordUserEvent(specifics);
+  event_service->RecordUserEvent(
+      std::make_unique<sync_pb::UserEventSpecifics>(specifics));
 
   // Wait for a commit message containing the user event. However the commit
   // request will fail.
diff --git a/chrome/browser/sync/test/integration/two_client_user_events_sync_test.cc b/chrome/browser/sync/test/integration/two_client_user_events_sync_test.cc
index e81be18..5cfd431d 100644
--- a/chrome/browser/sync/test/integration/two_client_user_events_sync_test.cc
+++ b/chrome/browser/sync/test/integration/two_client_user_events_sync_test.cc
@@ -66,8 +66,10 @@
   // starting up sync because the user has custom passphrase setup.
   syncer::UserEventService* event_service =
       browser_sync::UserEventServiceFactory::GetForProfile(GetProfile(0));
-  event_service->RecordUserEvent(user_events_helper::CreateTestEvent(
-      base::Time() + base::Microseconds(1)));
+  event_service->RecordUserEvent(
+      std::make_unique<sync_pb::UserEventSpecifics>(
+          user_events_helper::CreateTestEvent(
+              base::Time() + base::Microseconds(1))));
 
   // Set up sync on the second client.
   ASSERT_TRUE(GetClient(kDecryptingClientId)->SetupSyncNoWaitForCompletion());
diff --git a/components/browser_sync/sync_internals_message_handler.cc b/components/browser_sync/sync_internals_message_handler.cc
index 1f7b6b0a..66dec0f 100644
--- a/components/browser_sync/sync_internals_message_handler.cc
+++ b/components/browser_sync/sync_internals_message_handler.cc
@@ -236,7 +236,8 @@
     event_specifics.set_navigation_id(StringAtIndexToInt64(args, 1u));
   }
 
-  user_event_service_->RecordUserEvent(event_specifics);
+  user_event_service_->RecordUserEvent(
+      std::make_unique<sync_pb::UserEventSpecifics>(event_specifics));
 }
 
 void SyncInternalsMessageHandler::HandleRequestStart(
diff --git a/components/sync_user_events/fake_user_event_service.cc b/components/sync_user_events/fake_user_event_service.cc
index 68f77f0..b6d43d4b 100644
--- a/components/sync_user_events/fake_user_event_service.cc
+++ b/components/sync_user_events/fake_user_event_service.cc
@@ -16,12 +16,7 @@
 void FakeUserEventService::RecordUserEvent(
     std::unique_ptr<UserEventSpecifics> specifics) {
   DCHECK(specifics);
-  RecordUserEvent(*specifics);
-}
-
-void FakeUserEventService::RecordUserEvent(
-    const UserEventSpecifics& specifics) {
-  recorded_user_events_.push_back(specifics);
+  recorded_user_events_.push_back(*specifics);
 }
 
 base::WeakPtr<syncer::DataTypeControllerDelegate>
diff --git a/components/sync_user_events/fake_user_event_service.h b/components/sync_user_events/fake_user_event_service.h
index 2b275797..d4a5e65a 100644
--- a/components/sync_user_events/fake_user_event_service.h
+++ b/components/sync_user_events/fake_user_event_service.h
@@ -28,7 +28,6 @@
   // UserEventService implementation.
   void RecordUserEvent(
       std::unique_ptr<sync_pb::UserEventSpecifics> specifics) override;
-  void RecordUserEvent(const sync_pb::UserEventSpecifics& specifics) override;
   base::WeakPtr<syncer::DataTypeControllerDelegate> GetControllerDelegate()
       override;
 
diff --git a/components/sync_user_events/no_op_user_event_service.cc b/components/sync_user_events/no_op_user_event_service.cc
index e3fc698..85d7efcf 100644
--- a/components/sync_user_events/no_op_user_event_service.cc
+++ b/components/sync_user_events/no_op_user_event_service.cc
@@ -17,9 +17,6 @@
 void NoOpUserEventService::RecordUserEvent(
     std::unique_ptr<UserEventSpecifics> specifics) {}
 
-void NoOpUserEventService::RecordUserEvent(
-    const UserEventSpecifics& specifics) {}
-
 base::WeakPtr<syncer::DataTypeControllerDelegate>
 NoOpUserEventService::GetControllerDelegate() {
   return nullptr;
diff --git a/components/sync_user_events/no_op_user_event_service.h b/components/sync_user_events/no_op_user_event_service.h
index dd1d4e24..d2d42c43 100644
--- a/components/sync_user_events/no_op_user_event_service.h
+++ b/components/sync_user_events/no_op_user_event_service.h
@@ -25,7 +25,6 @@
   // UserEventService implementation.
   void RecordUserEvent(
       std::unique_ptr<sync_pb::UserEventSpecifics> specifics) override;
-  void RecordUserEvent(const sync_pb::UserEventSpecifics& specifics) override;
   base::WeakPtr<syncer::DataTypeControllerDelegate> GetControllerDelegate()
       override;
 };
diff --git a/components/sync_user_events/user_event_service.h b/components/sync_user_events/user_event_service.h
index 76c2671..746fe95 100644
--- a/components/sync_user_events/user_event_service.h
+++ b/components/sync_user_events/user_event_service.h
@@ -29,8 +29,6 @@
   // requisite permissions are not present.
   virtual void RecordUserEvent(
       std::unique_ptr<sync_pb::UserEventSpecifics> specifics) = 0;
-  virtual void RecordUserEvent(
-      const sync_pb::UserEventSpecifics& specifics) = 0;
 
   // Returns the underlying Sync integration point.
   virtual base::WeakPtr<syncer::DataTypeControllerDelegate>
diff --git a/components/sync_user_events/user_event_service_impl.cc b/components/sync_user_events/user_event_service_impl.cc
index 1a6bc7f2..4fe6af09 100644
--- a/components/sync_user_events/user_event_service_impl.cc
+++ b/components/sync_user_events/user_event_service_impl.cc
@@ -114,11 +114,6 @@
   bridge_->RecordUserEvent(std::move(specifics));
 }
 
-void UserEventServiceImpl::RecordUserEvent(
-    const UserEventSpecifics& specifics) {
-  RecordUserEvent(std::make_unique<UserEventSpecifics>(specifics));
-}
-
 base::WeakPtr<syncer::DataTypeControllerDelegate>
 UserEventServiceImpl::GetControllerDelegate() {
   return bridge_->change_processor()->GetControllerDelegate();
diff --git a/components/sync_user_events/user_event_service_impl.h b/components/sync_user_events/user_event_service_impl.h
index 286c468..a9e8fee 100644
--- a/components/sync_user_events/user_event_service_impl.h
+++ b/components/sync_user_events/user_event_service_impl.h
@@ -31,7 +31,6 @@
   // UserEventService implementation.
   void RecordUserEvent(
       std::unique_ptr<sync_pb::UserEventSpecifics> specifics) override;
-  void RecordUserEvent(const sync_pb::UserEventSpecifics& specifics) override;
   base::WeakPtr<syncer::DataTypeControllerDelegate> GetControllerDelegate()
       override;