Replace DISALLOW_COPY_AND_ASSIGN in net/

This replaces DISALLOW_COPY_AND_ASSIGN with explicit constructor deletes
where a local script is able to detect its insertion place (~Foo() is
public => insert before this line).

This is incomplete as not all classes have a public ~Foo() declared, so
not all DISALLOW_COPY_AND_ASSIGN occurrences are replaced.

IWYU cleanup is left as a separate pass that is easier when these macros
go away.

Bug: 1010217
Change-Id: Ie30b152cdd5d493c5b2ecd96d13d789c18123f2b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3174408
Auto-Submit: Peter Boström <[email protected]>
Commit-Queue: Daniel Cheng <[email protected]>
Reviewed-by: Daniel Cheng <[email protected]>
Owners-Override: Daniel Cheng <[email protected]>
Cr-Commit-Position: refs/heads/main@{#923926}
diff --git a/net/cert/internal/trust_store_mac.cc b/net/cert/internal/trust_store_mac.cc
index 8236c4a..50f94d875 100644
--- a/net/cert/internal/trust_store_mac.cc
+++ b/net/cert/internal/trust_store_mac.cc
@@ -509,6 +509,9 @@
             base::Unretained(this)));
   }
 
+  KeychainTrustObserver(const KeychainTrustObserver&) = delete;
+  KeychainTrustObserver& operator=(const KeychainTrustObserver&) = delete;
+
   // Destroying the observer unregisters the callback. Must be destroyed on the
   // notification thread in order to safely release |subscription_|.
   ~KeychainTrustObserver() {
@@ -533,8 +536,6 @@
   base::CallbackListSubscription subscription_;
 
   base::subtle::Atomic64 iteration_ = 0;
-
-  DISALLOW_COPY_AND_ASSIGN(KeychainTrustObserver);
 };
 
 }  // namespace
@@ -598,6 +599,9 @@
     keychain_observer_ = std::make_unique<KeychainTrustObserver>();
   }
 
+  TrustImplDomainCache(const TrustImplDomainCache&) = delete;
+  TrustImplDomainCache& operator=(const TrustImplDomainCache&) = delete;
+
   ~TrustImplDomainCache() override {
     GetNetworkNotificationThreadMac()->DeleteSoon(
         FROM_HERE, std::move(keychain_observer_));
@@ -671,8 +675,6 @@
   TrustDomainCache system_domain_cache_;
   TrustDomainCache admin_domain_cache_;
   TrustDomainCache user_domain_cache_;
-
-  DISALLOW_COPY_AND_ASSIGN(TrustImplDomainCache);
 };
 
 // TrustImplNoCache is the simplest approach which calls
@@ -681,6 +683,9 @@
  public:
   explicit TrustImplNoCache(CFStringRef policy_oid) : policy_oid_(policy_oid) {}
 
+  TrustImplNoCache(const TrustImplNoCache&) = delete;
+  TrustImplNoCache& operator=(const TrustImplNoCache&) = delete;
+
   ~TrustImplNoCache() override = default;
 
   // Returns true if |cert| is present in kSecTrustSettingsDomainSystem.
@@ -707,8 +712,6 @@
 
  private:
   const CFStringRef policy_oid_;
-
-  DISALLOW_COPY_AND_ASSIGN(TrustImplNoCache);
 };
 
 // TrustImplMRUCache is calls SecTrustSettingsCopyTrustSettings on every cert
@@ -721,6 +724,9 @@
     keychain_observer_ = std::make_unique<KeychainTrustObserver>();
   }
 
+  TrustImplMRUCache(const TrustImplMRUCache&) = delete;
+  TrustImplMRUCache& operator=(const TrustImplMRUCache&) = delete;
+
   ~TrustImplMRUCache() override {
     GetNetworkNotificationThreadMac()->DeleteSoon(
         FROM_HERE, std::move(keychain_observer_));
@@ -843,8 +849,6 @@
   // not cache their results, as it isn't clear whether the calculated result
   // applies to the new or old trust settings.
   int64_t iteration_ = -1;
-
-  DISALLOW_COPY_AND_ASSIGN(TrustImplMRUCache);
 };
 
 TrustStoreMac::TrustStoreMac(CFStringRef policy_oid,