[Code Health] Remove a use of base::SupportsWeakPtr.

Bug: 647430
Change-Id: Iec3a778fc74a3e67695ef6370cf9e8cafaf6d302
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5247707
Auto-Submit: David Bertoni <dbertoni@chromium.org>
Reviewed-by: Charlie Harrison <csharrison@chromium.org>
Commit-Queue: Charlie Harrison <csharrison@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1253889}
diff --git a/content/browser/attribution_reporting/attribution_data_host_manager.h b/content/browser/attribution_reporting/attribution_data_host_manager.h
index e7fd343..1f051eb8 100644
--- a/content/browser/attribution_reporting/attribution_data_host_manager.h
+++ b/content/browser/attribution_reporting/attribution_data_host_manager.h
@@ -42,8 +42,7 @@
 
 // Interface responsible for coordinating `AttributionDataHost`s received from
 // the renderer.
-class AttributionDataHostManager
-    : public base::SupportsWeakPtr<AttributionDataHostManager> {
+class AttributionDataHostManager {
  public:
   virtual ~AttributionDataHostManager() = default;
 
@@ -182,6 +181,9 @@
       GURL reporting_url,
       const net::HttpResponseHeaders* headers,
       bool is_final_response) = 0;
+
+  // Get a WeakPtr to the implementation instance.
+  virtual base::WeakPtr<AttributionDataHostManager> AsWeakPtr() = 0;
 };
 
 }  // namespace content
diff --git a/content/browser/attribution_reporting/attribution_data_host_manager_impl.cc b/content/browser/attribution_reporting/attribution_data_host_manager_impl.cc
index 2dac871..d3146f1 100644
--- a/content/browser/attribution_reporting/attribution_data_host_manager_impl.cc
+++ b/content/browser/attribution_reporting/attribution_data_host_manager_impl.cc
@@ -1593,6 +1593,11 @@
               header->registrar);
 }
 
+base::WeakPtr<AttributionDataHostManager>
+AttributionDataHostManagerImpl::AsWeakPtr() {
+  return weak_factory_.GetWeakPtr();
+}
+
 void AttributionDataHostManagerImpl::BackgroundRegistrationsTied(
     const blink::AttributionSrcToken& token,
     size_t count,
diff --git a/content/browser/attribution_reporting/attribution_data_host_manager_impl.h b/content/browser/attribution_reporting/attribution_data_host_manager_impl.h
index 7bb7187..dca94e4 100644
--- a/content/browser/attribution_reporting/attribution_data_host_manager_impl.h
+++ b/content/browser/attribution_reporting/attribution_data_host_manager_impl.h
@@ -62,7 +62,7 @@
 // requests may continue until after we have detached a frame, all browser
 // process data needed to validate sources/triggers is stored alongside each
 // receiver.
-class CONTENT_EXPORT AttributionDataHostManagerImpl
+class CONTENT_EXPORT AttributionDataHostManagerImpl final
     : public AttributionDataHostManager,
       public blink::mojom::AttributionDataHost {
  public:
@@ -139,6 +139,7 @@
       GURL reporting_url,
       const net::HttpResponseHeaders* headers,
       bool is_final_response) override;
+  base::WeakPtr<AttributionDataHostManager> AsWeakPtr() override;
 
  private:
   class RegistrationContext;
diff --git a/content/browser/attribution_reporting/test/mock_attribution_data_host_manager.cc b/content/browser/attribution_reporting/test/mock_attribution_data_host_manager.cc
index 32dc30d8..af44578 100644
--- a/content/browser/attribution_reporting/test/mock_attribution_data_host_manager.cc
+++ b/content/browser/attribution_reporting/test/mock_attribution_data_host_manager.cc
@@ -10,4 +10,9 @@
 
 MockAttributionDataHostManager::~MockAttributionDataHostManager() = default;
 
+base::WeakPtr<AttributionDataHostManager>
+MockAttributionDataHostManager::AsWeakPtr() {
+  return weak_factory_.GetWeakPtr();
+}
+
 }  // namespace content
diff --git a/content/browser/attribution_reporting/test/mock_attribution_data_host_manager.h b/content/browser/attribution_reporting/test/mock_attribution_data_host_manager.h
index 8d45f558..56485b36 100644
--- a/content/browser/attribution_reporting/test/mock_attribution_data_host_manager.h
+++ b/content/browser/attribution_reporting/test/mock_attribution_data_host_manager.h
@@ -11,6 +11,7 @@
 #include <string>
 #include <vector>
 
+#include "base/memory/weak_ptr.h"
 #include "components/attribution_reporting/registration_eligibility.mojom-forward.h"
 #include "components/attribution_reporting/suitable_origin.h"
 #include "content/browser/attribution_reporting/attribution_beacon_id.h"
@@ -31,7 +32,7 @@
 
 namespace content {
 
-class MockAttributionDataHostManager : public AttributionDataHostManager {
+class MockAttributionDataHostManager final : public AttributionDataHostManager {
  public:
   MockAttributionDataHostManager();
   ~MockAttributionDataHostManager() override;
@@ -129,6 +130,11 @@
                const net::HttpResponseHeaders* headers,
                bool is_final_response),
               (override));
+
+  base::WeakPtr<AttributionDataHostManager> AsWeakPtr() override;
+
+ private:
+  base::WeakPtrFactory<MockAttributionDataHostManager> weak_factory_{this};
 };
 
 }  // namespace content