Change GCMDriver::GetEncryptionInfo to take a OnceCallback

Also modernize some of the surrounding code, and pass ownership of
strings rather than just a reference, removing some copies.

Change-Id: Ib53ba2c6acab5a6196ef58dd6067daea1d4d9edd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1695298
Reviewed-by: Richard Knoll <[email protected]>
Commit-Queue: Peter Beverloo <[email protected]>
Cr-Commit-Position: refs/heads/master@{#676071}
diff --git a/components/gcm_driver/gcm_driver_unittest.cc b/components/gcm_driver/gcm_driver_unittest.cc
index 93ec392..b9735a04 100644
--- a/components/gcm_driver/gcm_driver_unittest.cc
+++ b/components/gcm_driver/gcm_driver_unittest.cc
@@ -95,8 +95,7 @@
                       WaitToFinish wait_to_finish);
 
   void SendWebPushMessageCompleted(base::Optional<std::string> message_id);
-  void GetEncryptionInfoCompleted(const std::string& p256dh,
-                                  const std::string& auth_secret);
+  void GetEncryptionInfoCompleted(std::string p256dh, std::string auth_secret);
   void DecryptMessageCompleted(GCMDecryptionResult result,
                                const IncomingMessage& message);
   void UnregisterCompleted(GCMClient::Result result);
@@ -226,8 +225,8 @@
   base::RunLoop run_loop;
   async_operation_completed_callback_ = run_loop.QuitClosure();
   driver_->GetEncryptionInfo(
-      app_id, base::Bind(&GCMDriverBaseTest::GetEncryptionInfoCompleted,
-                         base::Unretained(this)));
+      app_id, base::BindOnce(&GCMDriverBaseTest::GetEncryptionInfoCompleted,
+                             base::Unretained(this)));
   if (wait_to_finish == WAIT)
     run_loop.Run();
 }
@@ -254,11 +253,10 @@
     async_operation_completed_callback_.Run();
 }
 
-void GCMDriverBaseTest::GetEncryptionInfoCompleted(
-    const std::string& p256dh,
-    const std::string& auth_secret) {
-  p256dh_ = p256dh;
-  auth_secret_ = auth_secret;
+void GCMDriverBaseTest::GetEncryptionInfoCompleted(std::string p256dh,
+                                                   std::string auth_secret) {
+  p256dh_ = std::move(p256dh);
+  auth_secret_ = std::move(auth_secret);
   if (!async_operation_completed_callback_.is_null())
     async_operation_completed_callback_.Run();
 }