Remove DISALLOW_* macros from net/

This inlines all remaining DISALLOW_* macros in net/. This is done
manually (vim regex + manually finding insertion position).

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

Bug: 1010217
Change-Id: I7fade65cf1fd0f08e1c3baeff35dfbf3beb3ebce
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3202538
Commit-Queue: Peter Boström <[email protected]>
Reviewed-by: Lei Zhang <[email protected]>
Owners-Override: Lei Zhang <[email protected]>
Cr-Commit-Position: refs/heads/main@{#929037}
diff --git a/net/dns/address_info.h b/net/dns/address_info.h
index f5a0124..9db0917 100644
--- a/net/dns/address_info.h
+++ b/net/dns/address_info.h
@@ -56,8 +56,12 @@
       const addrinfo& hints,
       std::unique_ptr<AddrInfoGetter> getter = nullptr);
 
+  AddressInfo(const AddressInfo&) = delete;
+  AddressInfo& operator=(const AddressInfo&) = delete;
+
   AddressInfo(AddressInfo&& other);
   AddressInfo& operator=(AddressInfo&& other);
+
   ~AddressInfo();
 
   // Accessors
@@ -76,8 +80,6 @@
   // Data.
   addrinfo* ai_;  // Never null (except after move)
   std::unique_ptr<AddrInfoGetter> getter_;
-
-  DISALLOW_COPY_AND_ASSIGN(AddressInfo);
 };
 
 // Encapsulates calls to getaddrinfo and freeaddrinfo for tests.
diff --git a/net/dns/address_sorter_win.cc b/net/dns/address_sorter_win.cc
index 524ba713..1d7538c 100644
--- a/net/dns/address_sorter_win.cc
+++ b/net/dns/address_sorter_win.cc
@@ -55,6 +55,9 @@
           base::BindOnce(&Job::OnComplete, job));
     }
 
+    Job(const Job&) = delete;
+    Job& operator=(const Job&) = delete;
+
    private:
     friend class base::RefCountedThreadSafe<Job>;
 
@@ -137,8 +140,6 @@
     std::unique_ptr<SOCKET_ADDRESS_LIST, base::FreeDeleter> input_buffer_;
     std::unique_ptr<SOCKET_ADDRESS_LIST, base::FreeDeleter> output_buffer_;
     bool success_;
-
-    DISALLOW_COPY_AND_ASSIGN(Job);
   };
 };
 
diff --git a/net/dns/dns_config_service_posix.cc b/net/dns/dns_config_service_posix.cc
index a88fa461..1aef5a0 100644
--- a/net/dns/dns_config_service_posix.cc
+++ b/net/dns/dns_config_service_posix.cc
@@ -184,6 +184,9 @@
     DETACH_FROM_SEQUENCE(sequence_checker_);
   }
 
+  ConfigReader(const ConfigReader&) = delete;
+  ConfigReader& operator=(const ConfigReader&) = delete;
+
   void DoWork() override { dns_config_ = ReadDnsConfig(); }
 
   void OnWorkFinished() override {
@@ -204,8 +207,6 @@
   DnsConfigServicePosix* const service_;
   // Written in DoWork, read in OnWorkFinished, no locking necessary.
   absl::optional<DnsConfig> dns_config_;
-
-  DISALLOW_COPY_AND_ASSIGN(ConfigReader);
 };
 
 DnsConfigServicePosix::DnsConfigServicePosix()
diff --git a/net/dns/dns_hosts.cc b/net/dns/dns_hosts.cc
index b029a7b..3facc043 100644
--- a/net/dns/dns_hosts.cc
+++ b/net/dns/dns_hosts.cc
@@ -30,6 +30,9 @@
         token_is_ip_(false),
         comma_mode_(comma_mode) {}
 
+  HostsParser(const HostsParser&) = delete;
+  HostsParser& operator=(const HostsParser&) = delete;
+
   // Advances to the next token (IP or hostname).  Returns whether another
   // token was available.  |token_is_ip| and |token| can be used to find out
   // the type and text of the token.
@@ -126,8 +129,6 @@
   bool token_is_ip_;
 
   const ParseHostsCommaMode comma_mode_;
-
-  DISALLOW_COPY_AND_ASSIGN(HostsParser);
 };
 
 void ParseHostsWithCommaMode(const std::string& contents,
diff --git a/net/dns/dns_reloader.cc b/net/dns/dns_reloader.cc
index 0672e711..9ffff30 100644
--- a/net/dns/dns_reloader.cc
+++ b/net/dns/dns_reloader.cc
@@ -47,6 +47,9 @@
 
 class DnsReloader : public NetworkChangeNotifier::DNSObserver {
  public:
+  DnsReloader(const DnsReloader&) = delete;
+  DnsReloader& operator=(const DnsReloader&) = delete;
+
   // NetworkChangeNotifier::DNSObserver:
   void OnDNSChanged() override {
     base::AutoLock lock(lock_);
@@ -90,8 +93,6 @@
 
   // We use thread local storage to identify which ReloadState to interact with.
   base::ThreadLocalOwnedPointer<ReloadState> tls_reload_state_;
-
-  DISALLOW_COPY_AND_ASSIGN(DnsReloader);
 };
 
 base::LazyInstance<DnsReloader>::Leaky
diff --git a/net/dns/dns_session.h b/net/dns/dns_session.h
index 606d987..162309f4 100644
--- a/net/dns/dns_session.h
+++ b/net/dns/dns_session.h
@@ -40,6 +40,9 @@
              const RandIntCallback& rand_int_callback,
              NetLog* net_log);
 
+  DnsSession(const DnsSession&) = delete;
+  DnsSession& operator=(const DnsSession&) = delete;
+
   const DnsConfig& config() const { return config_; }
   DnsSocketAllocator* socket_allocator() { return socket_allocator_.get(); }
   DnsUdpTracker* udp_tracker() { return &udp_tracker_; }
@@ -70,8 +73,6 @@
   NetLog* net_log_;
 
   mutable base::WeakPtrFactory<DnsSession> weak_ptr_factory_{this};
-
-  DISALLOW_COPY_AND_ASSIGN(DnsSession);
 };
 
 }  // namespace net
diff --git a/net/dns/dns_transaction.cc b/net/dns/dns_transaction.cc
index 18d48034..feaa6bef 100644
--- a/net/dns/dns_transaction.cc
+++ b/net/dns/dns_transaction.cc
@@ -206,6 +206,9 @@
         query_(std::move(query)),
         udp_tracker_(udp_tracker) {}
 
+  DnsUDPAttempt(const DnsUDPAttempt&) = delete;
+  DnsUDPAttempt& operator=(const DnsUDPAttempt&) = delete;
+
   // DnsAttempt methods.
 
   int Start(CompletionOnceCallback callback) override {
@@ -352,8 +355,6 @@
   std::unique_ptr<DnsResponse> response_;
 
   CompletionOnceCallback callback_;
-
-  DISALLOW_COPY_AND_ASSIGN(DnsUDPAttempt);
 };
 
 class DnsHTTPAttempt : public DnsAttempt, public URLRequest::Delegate {
@@ -441,6 +442,9 @@
     request_->set_isolation_info(isolation_info);
   }
 
+  DnsHTTPAttempt(const DnsHTTPAttempt&) = delete;
+  DnsHTTPAttempt& operator=(const DnsHTTPAttempt&) = delete;
+
   // DnsAttempt overrides.
 
   int Start(CompletionOnceCallback callback) override {
@@ -590,8 +594,6 @@
   NetLogWithSource net_log_;
 
   base::WeakPtrFactory<DnsHTTPAttempt> weak_factory_{this};
-
-  DISALLOW_COPY_AND_ASSIGN(DnsHTTPAttempt);
 };
 
 void ConstructDnsHTTPAttempt(DnsSession* session,
@@ -638,6 +640,9 @@
             base::MakeRefCounted<IOBufferWithSize>(sizeof(uint16_t))),
         response_length_(0) {}
 
+  DnsTCPAttempt(const DnsTCPAttempt&) = delete;
+  DnsTCPAttempt& operator=(const DnsTCPAttempt&) = delete;
+
   // DnsAttempt:
   int Start(CompletionOnceCallback callback) override {
     DCHECK_EQ(STATE_NONE, next_state_);
@@ -867,8 +872,6 @@
   std::unique_ptr<DnsResponse> response_;
 
   CompletionOnceCallback callback_;
-
-  DISALLOW_COPY_AND_ASSIGN(DnsTCPAttempt);
 };
 
 // ----------------------------------------------------------------------------
diff --git a/net/dns/dns_transaction_unittest.cc b/net/dns/dns_transaction_unittest.cc
index 3d514c8..df6b1e4 100644
--- a/net/dns/dns_transaction_unittest.cc
+++ b/net/dns/dns_transaction_unittest.cc
@@ -2365,6 +2365,9 @@
     loop_to_quit_->Quit();
   }
 
+  CookieCallback(const CookieCallback&) = delete;
+  CookieCallback& operator=(const CookieCallback&) = delete;
+
   void GetCookieListCallback(
       const net::CookieAccessResultList& list,
       const net::CookieAccessResultList& excluded_cookies) {
@@ -2382,7 +2385,6 @@
   net::CookieList list_;
   bool result_;
   std::unique_ptr<base::RunLoop> loop_to_quit_;
-  DISALLOW_COPY_AND_ASSIGN(CookieCallback);
 };
 
 TEST_F(DnsTransactionTest, HttpsPostTestNoCookies) {
diff --git a/net/dns/fuzzed_host_resolver_util.cc b/net/dns/fuzzed_host_resolver_util.cc
index 43ab85d..27583b3d 100644
--- a/net/dns/fuzzed_host_resolver_util.cc
+++ b/net/dns/fuzzed_host_resolver_util.cc
@@ -157,6 +157,9 @@
         data_provider_(data_provider),
         network_task_runner_(base::ThreadTaskRunnerHandle::Get()) {}
 
+  FuzzedHostResolverProc(const FuzzedHostResolverProc&) = delete;
+  FuzzedHostResolverProc& operator=(const FuzzedHostResolverProc&) = delete;
+
   int Resolve(const std::string& host,
               AddressFamily address_family,
               HostResolverFlags host_resolver_flags,
@@ -215,8 +218,6 @@
 
   // Just used for thread-safety checks.
   scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_;
-
-  DISALLOW_COPY_AND_ASSIGN(FuzzedHostResolverProc);
 };
 
 const Error kMdnsErrors[] = {ERR_FAILED,
diff --git a/net/dns/host_resolver_manager.cc b/net/dns/host_resolver_manager.cc
index 368d72f..99db63e 100644
--- a/net/dns/host_resolver_manager.cc
+++ b/net/dns/host_resolver_manager.cc
@@ -1297,6 +1297,9 @@
     DCHECK(delegate_);
   }
 
+  DnsTask(const DnsTask&) = delete;
+  DnsTask& operator=(const DnsTask&) = delete;
+
   // The number of transactions required for the specified query type. Does not
   // change as transactions are completed.
   int num_needed_transactions() const { return num_needed_transactions_; }
@@ -1925,8 +1928,6 @@
   // task completes unsuccessfully. Used as a signal that underlying
   // transactions should timeout more quickly.
   bool fallback_available_;
-
-  DISALLOW_COPY_AND_ASSIGN(DnsTask);
 };
 
 //-----------------------------------------------------------------------------
diff --git a/net/dns/host_resolver_manager_unittest.cc b/net/dns/host_resolver_manager_unittest.cc
index 4e8fe8b..9d18d6c 100644
--- a/net/dns/host_resolver_manager_unittest.cc
+++ b/net/dns/host_resolver_manager_unittest.cc
@@ -141,6 +141,9 @@
         requests_waiting_(&lock_),
         slots_available_(&lock_) {}
 
+  MockHostResolverProc(const MockHostResolverProc&) = delete;
+  MockHostResolverProc& operator=(const MockHostResolverProc&) = delete;
+
   // Waits until |count| calls to |Resolve| are blocked. Returns false when
   // timed out.
   bool WaitFor(unsigned count) {
@@ -266,8 +269,6 @@
   unsigned num_slots_available_;
   base::ConditionVariable requests_waiting_;
   base::ConditionVariable slots_available_;
-
-  DISALLOW_COPY_AND_ASSIGN(MockHostResolverProc);
 };
 
 class ResolveHostResponseHelper {
@@ -295,6 +296,10 @@
                                       base::Unretained(this))));
   }
 
+  ResolveHostResponseHelper(const ResolveHostResponseHelper&) = delete;
+  ResolveHostResponseHelper& operator=(const ResolveHostResponseHelper&) =
+      delete;
+
   bool complete() const { return top_level_result_error_ != ERR_IO_PENDING; }
 
   int top_level_result_error() {
@@ -338,8 +343,6 @@
   std::unique_ptr<HostResolverManager::CancellableResolveHostRequest> request_;
   int top_level_result_error_ = ERR_IO_PENDING;
   base::RunLoop run_loop_;
-
-  DISALLOW_COPY_AND_ASSIGN(ResolveHostResponseHelper);
 };
 
 // Using LookupAttemptHostResolverProc simulate very long lookups, and control
diff --git a/net/dns/host_resolver_proc.h b/net/dns/host_resolver_proc.h
index b4c8fd02..ae3b363 100644
--- a/net/dns/host_resolver_proc.h
+++ b/net/dns/host_resolver_proc.h
@@ -33,6 +33,9 @@
   explicit HostResolverProc(HostResolverProc* previous,
                             bool allow_fallback_to_system_or_default = true);
 
+  HostResolverProc(const HostResolverProc&) = delete;
+  HostResolverProc& operator=(const HostResolverProc&) = delete;
+
   // Resolves |host| to an address list, restricting the results to addresses
   // in |address_family|. If successful returns OK and fills |addrlist| with
   // a list of socket addresses. Otherwise returns a network error code, and
@@ -82,8 +85,6 @@
   bool allow_fallback_to_system_;
   scoped_refptr<HostResolverProc> previous_proc_;
   static HostResolverProc* default_proc_;
-
-  DISALLOW_COPY_AND_ASSIGN(HostResolverProc);
 };
 
 // Resolves |host| to an address list, using the system's default host resolver.
@@ -102,6 +103,10 @@
 class NET_EXPORT_PRIVATE SystemHostResolverProc : public HostResolverProc {
  public:
   SystemHostResolverProc();
+
+  SystemHostResolverProc(const SystemHostResolverProc&) = delete;
+  SystemHostResolverProc& operator=(const SystemHostResolverProc&) = delete;
+
   int Resolve(const std::string& hostname,
               AddressFamily address_family,
               HostResolverFlags host_resolver_flags,
@@ -110,8 +115,6 @@
 
  protected:
   ~SystemHostResolverProc() override;
-
-  DISALLOW_COPY_AND_ASSIGN(SystemHostResolverProc);
 };
 
 // Parameters for customizing HostResolverProc behavior in HostResolvers.
diff --git a/net/dns/mdns_cache.h b/net/dns/mdns_cache.h
index 0dfaa16..c041e546 100644
--- a/net/dns/mdns_cache.h
+++ b/net/dns/mdns_cache.h
@@ -61,6 +61,10 @@
   };
 
   MDnsCache();
+
+  MDnsCache(const MDnsCache&) = delete;
+  MDnsCache& operator=(const MDnsCache&) = delete;
+
   ~MDnsCache();
 
   // Return value indicates whether the record was added, changed
@@ -116,8 +120,6 @@
 
   base::Time next_expiration_;
   size_t entry_limit_;
-
-  DISALLOW_COPY_AND_ASSIGN(MDnsCache);
 };
 
 }  // namespace net
diff --git a/net/dns/mdns_client_impl.h b/net/dns/mdns_client_impl.h
index 8fcec6fd..181a220 100644
--- a/net/dns/mdns_client_impl.h
+++ b/net/dns/mdns_client_impl.h
@@ -217,6 +217,9 @@
   MDnsClientImpl(base::Clock* clock,
                  std::unique_ptr<base::OneShotTimer> cleanup_timer);
 
+  MDnsClientImpl(const MDnsClientImpl&) = delete;
+  MDnsClientImpl& operator=(const MDnsClientImpl&) = delete;
+
   ~MDnsClientImpl() override;
 
   // MDnsClient implementation:
@@ -242,8 +245,6 @@
   std::unique_ptr<base::OneShotTimer> cleanup_timer_;
 
   std::unique_ptr<Core> core_;
-
-  DISALLOW_COPY_AND_ASSIGN(MDnsClientImpl);
 };
 
 class MDnsListenerImpl : public MDnsListener,
diff --git a/net/dns/record_rdata.h b/net/dns/record_rdata.h
index 8479857..835955b 100644
--- a/net/dns/record_rdata.h
+++ b/net/dns/record_rdata.h
@@ -250,7 +250,12 @@
   static const uint16_t kType = dns_protocol::kTypeOPT;
 
   OptRecordRdata();
+
+  OptRecordRdata(const OptRecordRdata&) = delete;
+  OptRecordRdata& operator=(const OptRecordRdata&) = delete;
+
   OptRecordRdata(OptRecordRdata&& other);
+
   ~OptRecordRdata() override;
 
   OptRecordRdata& operator=(OptRecordRdata&& other);
@@ -273,8 +278,6 @@
  private:
   std::vector<Opt> opts_;
   std::vector<char> buf_;
-
-  DISALLOW_COPY_AND_ASSIGN(OptRecordRdata);
 };
 
 // This class parses and serializes the INTEGRITY DNS record.
diff --git a/net/dns/serial_worker.h b/net/dns/serial_worker.h
index 3e4615a..11e4748 100644
--- a/net/dns/serial_worker.h
+++ b/net/dns/serial_worker.h
@@ -36,6 +36,9 @@
  public:
   SerialWorker();
 
+  SerialWorker(const SerialWorker&) = delete;
+  SerialWorker& operator=(const SerialWorker&) = delete;
+
   // Unless already scheduled, post |DoWork| to ThreadPool.
   // Made virtual to allow mocking.
   virtual void WorkNow();
@@ -75,8 +78,6 @@
   State state_;
 
   base::WeakPtrFactory<SerialWorker> weak_factory_{this};
-
-  DISALLOW_COPY_AND_ASSIGN(SerialWorker);
 };
 
 }  // namespace net
diff --git a/net/dns/serial_worker_unittest.cc b/net/dns/serial_worker_unittest.cc
index 061b54a0..270b3ec1 100644
--- a/net/dns/serial_worker_unittest.cc
+++ b/net/dns/serial_worker_unittest.cc
@@ -39,6 +39,9 @@
     SerialWorkerTest* test_;
   };
 
+  SerialWorkerTest(const SerialWorkerTest&) = delete;
+  SerialWorkerTest& operator=(const SerialWorkerTest&) = delete;
+
   // Mocks
 
   void OnWork() {
@@ -147,8 +150,6 @@
 
   std::string breakpoint_;
   base::RunLoop* run_loop_ = nullptr;
-
-  DISALLOW_COPY_AND_ASSIGN(SerialWorkerTest);
 };
 
 TEST_F(SerialWorkerTest, ExecuteAndSerializeReads) {