Remove all DISALLOW_COPY_AND_ASSIGNs

This replaces all remaining DISALLOW_COPY_AND_ASSIGN() instances with
their expanded counterparts.

The macro definitions and IWYU are left as a separate change. The former
to prevent unintended large reverts and the latter is easier once all
DISALLOW_ macros are gone.

Bug: 1010217
Change-Id: I0e2fd43f4060628c09420709010aab2c84b87148
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3259964
Commit-Queue: Peter Boström <pbos@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Owners-Override: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#938612}
NOKEYCHECK=True
GitOrigin-RevId: 896f13791f32e90dc08379498e17a181d4afcf5f
diff --git a/bus.h b/bus.h
index 1ea70f4..6121f20 100644
--- a/bus.h
+++ b/bus.h
@@ -222,6 +222,9 @@
   // Connect() is called.
   explicit Bus(const Options& options);
 
+  Bus(const Bus&) = delete;
+  Bus& operator=(const Bus&) = delete;
+
   // Called when an ownership request is complete.
   // Parameters:
   // - the requested service name.
@@ -783,8 +786,6 @@
   int num_pending_timeouts_;
 
   std::string address_;
-
-  DISALLOW_COPY_AND_ASSIGN(Bus);
 };
 
 }  // namespace dbus
diff --git a/dbus_statistics_unittest.cc b/dbus_statistics_unittest.cc
index 164d0b3..c14b076 100644
--- a/dbus_statistics_unittest.cc
+++ b/dbus_statistics_unittest.cc
@@ -14,6 +14,9 @@
  public:
   DBusStatisticsTest() = default;
 
+  DBusStatisticsTest(const DBusStatisticsTest&) = delete;
+  DBusStatisticsTest& operator=(const DBusStatisticsTest&) = delete;
+
   void SetUp() override { statistics::Initialize(); }
 
   void TearDown() override { statistics::Shutdown(); }
@@ -50,9 +53,6 @@
     statistics::AddSentMethodCall(
         "service2", "service2.interface1", "method1");
   }
-
- private:
-  DISALLOW_COPY_AND_ASSIGN(DBusStatisticsTest);
 };
 
 TEST_F(DBusStatisticsTest, TestDBusStatsBasic) {
diff --git a/message.h b/message.h
index d8649ca..1632b3f 100644
--- a/message.h
+++ b/message.h
@@ -84,6 +84,9 @@
     UNIX_FD = DBUS_TYPE_UNIX_FD,
   };
 
+  Message(const Message&) = delete;
+  Message& operator=(const Message&) = delete;
+
   // Returns the type of the message. Returns MESSAGE_INVALID if
   // raw_message_ is NULL.
   MessageType GetMessageType();
@@ -137,7 +140,6 @@
                                MessageReader* reader);
 
   DBusMessage* raw_message_;
-  DISALLOW_COPY_AND_ASSIGN(Message);
 };
 
 // MessageCall is a type of message used for calling a method via D-Bus.
@@ -155,6 +157,9 @@
   // The constructor creates the internal raw message.
   MethodCall(const std::string& interface_name, const std::string& method_name);
 
+  MethodCall(const MethodCall&) = delete;
+  MethodCall& operator=(const MethodCall&) = delete;
+
   // Returns a newly created MethodCall from the given raw message of the
   // type DBUS_MESSAGE_TYPE_METHOD_CALL. Takes the ownership of |raw_message|.
   static std::unique_ptr<MethodCall> FromRawMessage(DBusMessage* raw_message);
@@ -163,8 +168,6 @@
   // Creates a method call message. The internal raw message is NULL.
   // Only used internally.
   MethodCall();
-
-  DISALLOW_COPY_AND_ASSIGN(MethodCall);
 };
 
 // Signal is a type of message used to send a signal.
@@ -182,6 +185,9 @@
   // The constructor creates the internal raw_message_.
   Signal(const std::string& interface_name, const std::string& method_name);
 
+  Signal(const Signal&) = delete;
+  Signal& operator=(const Signal&) = delete;
+
   // Returns a newly created SIGNAL from the given raw message of the type
   // DBUS_MESSAGE_TYPE_SIGNAL. Takes the ownership of |raw_message|.
   static std::unique_ptr<Signal> FromRawMessage(DBusMessage* raw_message);
@@ -190,8 +196,6 @@
   // Creates a signal message. The internal raw message is NULL.
   // Only used internally.
   Signal();
-
-  DISALLOW_COPY_AND_ASSIGN(Signal);
 };
 
 // Response is a type of message used for receiving a response from a
@@ -211,12 +215,12 @@
   // Useful for testing.
   static std::unique_ptr<Response> CreateEmpty();
 
+  Response(const Response&) = delete;
+  Response& operator=(const Response&) = delete;
+
  protected:
   // Creates a Response message. The internal raw message is NULL.
   Response();
-
- private:
-  DISALLOW_COPY_AND_ASSIGN(Response);
 };
 
 // ErrorResponse is a type of message used to return an error to the
@@ -237,11 +241,12 @@
       const std::string& error_name,
       const std::string& error_message);
 
+  ErrorResponse(const ErrorResponse&) = delete;
+  ErrorResponse& operator=(const ErrorResponse&) = delete;
+
  private:
   // Creates an ErrorResponse message. The internal raw message is NULL.
   ErrorResponse();
-
-  DISALLOW_COPY_AND_ASSIGN(ErrorResponse);
 };
 
 // MessageWriter is used to write outgoing messages for calling methods
diff --git a/object_manager.h b/object_manager.h
index ada1fd0..e70c7e7 100644
--- a/object_manager.h
+++ b/object_manager.h
@@ -188,6 +188,9 @@
                                              const std::string& service_name,
                                              const ObjectPath& object_path);
 
+  ObjectManager(const ObjectManager&) = delete;
+  ObjectManager& operator=(const ObjectManager&) = delete;
+
   // Register a client implementation class |interface| for the given D-Bus
   // interface named in |interface_name|. That object's CreateProperties()
   // method will be used to create instances of dbus::PropertySet* when
@@ -363,8 +366,6 @@
   // Note: This should remain the last member so it'll be destroyed and
   // invalidate its weak pointers before any other members are destroyed.
   base::WeakPtrFactory<ObjectManager> weak_ptr_factory_{this};
-
-  DISALLOW_COPY_AND_ASSIGN(ObjectManager);
 };
 
 }  // namespace dbus
diff --git a/object_proxy.h b/object_proxy.h
index ecbbe87..6cb0c07 100644
--- a/object_proxy.h
+++ b/object_proxy.h
@@ -48,6 +48,9 @@
               const ObjectPath& object_path,
               int options);
 
+  ObjectProxy(const ObjectProxy&) = delete;
+  ObjectProxy& operator=(const ObjectProxy&) = delete;
+
   // Options to be OR-ed together when calling Bus::GetObjectProxyWithOptions().
   // Set the IGNORE_SERVICE_UNKNOWN_ERRORS option to silence logging of
   // org.freedesktop.DBus.Error.ServiceUnknown errors and
@@ -365,8 +368,6 @@
   std::string service_name_owner_;
 
   std::set<DBusPendingCall*> pending_calls_;
-
-  DISALLOW_COPY_AND_ASSIGN(ObjectProxy);
 };
 
 }  // namespace dbus